Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: install.fth | |
4 | \ | |
5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | \ | |
7 | \ - Do no alter or remove copyright notices | |
8 | \ | |
9 | \ - Redistribution and use of this software in source and binary forms, with | |
10 | \ or without modification, are permitted provided that the following | |
11 | \ conditions are met: | |
12 | \ | |
13 | \ - Redistribution of source code must retain the above copyright notice, | |
14 | \ this list of conditions and the following disclaimer. | |
15 | \ | |
16 | \ - Redistribution in binary form must reproduce the above copyright notice, | |
17 | \ this list of conditions and the following disclaimer in the | |
18 | \ documentation and/or other materials provided with the distribution. | |
19 | \ | |
20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors | |
21 | \ may be used to endorse or promote products derived from this software | |
22 | \ without specific prior written permission. | |
23 | \ | |
24 | \ This software is provided "AS IS," without a warranty of any kind. | |
25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
36 | \ | |
37 | \ You acknowledge that this software is not designed, licensed or | |
38 | \ intended for use in the design, construction, operation or maintenance of | |
39 | \ any nuclear facility. | |
40 | \ | |
41 | \ ========== Copyright Header End ============================================ | |
42 | id: @(#)install.fth 1.5 03/04/16 | |
43 | purpose: Converts V1 display interface to V2 package interface | |
44 | copyright: Copyright 1990-2003 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | headers | |
48 | \ Compatibility package to present a package-style interface for | |
49 | \ old-style display drivers. | |
50 | ||
51 | : $makealias ( xt adr len -- ) | |
52 | 2dup my-voc find-method if ( xt adr len acf' ) | |
53 | 2drop 2drop | |
54 | else ( xt adr len ) | |
55 | $create -1 setalias | |
56 | then | |
57 | ; | |
58 | ||
59 | headerless | |
60 | : disp-selftest ( -- failed? ) | |
61 | my-self >r | |
62 | initial-addr my-termemu @ ( first-ihandle ) | |
63 | ?dup if is my-self then ( ) | |
64 | " disp-test" $call-self ( failed? ) | |
65 | r> is my-self ( failed? ) | |
66 | ; | |
67 | ||
68 | : disp-close ( -- ) | |
69 | current-device >r my-voc push-device | |
70 | \ Reset the my-termemu value in the instance record | |
71 | my-termemu if | |
72 | initial-addr my-termemu off | |
73 | initial-addr frame-buffer-adr off | |
74 | my-termemu " remove" $call-self close-package | |
75 | then | |
76 | r> push-device | |
77 | ; | |
78 | : disp-open ( -- flag ) | |
79 | \ If this device is already open | |
80 | \ then my-termemu will be initialized | |
81 | \ with the ihandle from the prev. open | |
82 | my-termemu ?dup if ( first-ihandle ) | |
83 | close-chain is my-self | |
84 | else | |
85 | \ Open an instance of the terminal emulator | |
86 | 0 0 " terminal-emulator" $open-package to my-termemu | |
87 | ||
88 | " install" $call-self | |
89 | install-terminal-emulator | |
90 | \ Save the ihandle in the instance record | |
91 | my-self initial-addr my-termemu ! | |
92 | frame-buffer-adr initial-addr frame-buffer-adr ! | |
93 | then true | |
94 | ; | |
95 | : disp-write ( adr len -- len ) tuck ansi-type ; | |
96 | ||
97 | \ This relies upon the next 4 routines being headered, which is currently | |
98 | \ the case. | |
99 | ||
100 | : stdout: \ name ( xt-function xt-default -- ) | |
101 | create swap token, token, | |
102 | does> | |
103 | stdout @ ?dup if ( tptr ) | |
104 | package( dup token@ >name name>string ( tptr name$ ) | |
105 | my-voc (search-wordlist) if ( tptr acf ) | |
106 | nip ( acf ) | |
107 | else ( tptr ) | |
108 | my-termemu 0= if 1 ta+ then ( acf ) | |
109 | token@ ( acf ) | |
110 | then ( acf ) | |
111 | execute )package ( ??result?? ) | |
112 | else ( tptr ) | |
113 | 1 ta+ token@ execute ( ??result?? ) | |
114 | then ( ??result?? ) | |
115 | ; | |
116 | ||
117 | \ How this works: If the console has not been opened yet and stdout @ | |
118 | \ returns 0, fallback to the default case acf value that was supplied | |
119 | \ when the word was compiled; otherwise try to turn | |
120 | \ the function back into a string and search the output device for | |
121 | \ a matching routine. If it exists then execute it; if that | |
122 | \ fails then we try the termemu; if that fails call the default case acf | |
123 | \ that was supplied when the word was compiled. This approach permits | |
124 | \ routines that return differing values to use the same control code. | |
125 | ||
126 | ' line# ' false stdout: stdout-line# ( -- line# ) | |
127 | ' column# ' false stdout: stdout-column# ( -- column# ) | |
128 | ' char-width ' false stdout: stdout-char-width ( -- pixels ) | |
129 | ' draw-logo ' noop stdout: stdout-draw-logo ( -- ) | |
130 | ||
131 | headers | |
132 | ||
133 | : is-install ( xt -- ) | |
134 | ( xt ) " install" $makealias | |
135 | ['] disp-open " open" $makealias | |
136 | ['] disp-write " write" $makealias | |
137 | ['] draw-logo " draw-logo" $makealias | |
138 | ['] reset-screen " restore" $makealias | |
139 | ; | |
140 | : is-remove ( xt -- ) | |
141 | ( xt ) " remove" $makealias | |
142 | ['] disp-close " close" $makealias | |
143 | ; | |
144 | : is-selftest ( xt -- ) | |
145 | ( xt ) " disp-test" $makealias | |
146 | ['] disp-selftest " selftest" $makealias | |
147 | ; |