Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: dropin.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: @(#)dropin.fth 1.29 01/04/06 | |
43 | purpose: | |
44 | copyright: Copyright 1992-2001 Sun Microsystems, Inc. All Rights Reserved | |
45 | ||
46 | \ Drop-in driver support. | |
47 | \ | |
48 | \ Drop-in drivers are stored in otherwise-unused PROM, usually near the | |
49 | \ end of the CPU PROM, after the main firmware image. | |
50 | ||
51 | \ The layout is as follows: | |
52 | \ | |
53 | \ End of PROM: | |
54 | \ | |
55 | \ <free space> | |
56 | \ Module n | |
57 | \ ... | |
58 | \ Module 1 | |
59 | \ Startup checksum | |
60 | \ Startup Code | |
61 | \ | |
62 | \ Beginning of PROM: | |
63 | \ | |
64 | \ Each module contains: | |
65 | \ | |
66 | \ High address: | |
67 | \ | |
68 | \ Module image (n bytes) The module itself | |
69 | \ Module name (16 bytes) Null-terminated string | |
70 | \ Reserved (4 bytes) reserved for future extension - must be 0 | |
71 | \ Checksum (4 bytes) 32-bit sum of image bytes | |
72 | \ Image size (4 bytes) size in bytes of image | |
73 | \ Magic Number (4 bytes) "OBMD" | |
74 | \ Sync bytes (1-3 bytes) Enough 0x01 bytes to align the Magic Number | |
75 | \ on a 4-byte boundary. | |
76 | \ | |
77 | \ Low address: | |
78 | \ | |
79 | \ Currently The "Module name" must be one of : | |
80 | \ | |
81 | \ cpu-devices- cpu-devices+ | |
82 | \ nvramrc- nvramrc+ | |
83 | \ probe- probe+ | |
84 | \ banner- banner+ | |
85 | \ test- test+ | |
86 | \ boot- boot+ | |
87 | \ | |
88 | \ Search and execution order can be either one of : | |
89 | \ (A) (B) | |
90 | \ 1. cpu-devices- 1. cpu-devices- | |
91 | \ 2. cpu-devices+ 2. cpu-devices+ | |
92 | \ 3. nvramrc- 3. nvramrc- | |
93 | \ 4. nvramrc+ 4. probe- | |
94 | \ 5. probe- 5. probe+ | |
95 | \ 6. probe+ 6. banner- | |
96 | \ 7. banner- 7. banner+ | |
97 | \ 8. banner+ 8. nvramrc+ | |
98 | \ 9. test- 9. test- | |
99 | \ 10. test+ 10. test+ | |
100 | \ 11. boot- 11. boot- | |
101 | \ 12. boot+ 12. boot+ | |
102 | \ | |
103 | \ | |
104 | \ (A). The search and execution order will be as specified in (A) | |
105 | \ If at least one of the following two statements is true. | |
106 | \ | |
107 | \ a) NVRAMRC is empty or use-nvramrc? NVRAM parameter is false | |
108 | \ | |
109 | \ b) NVRAMRC does not contain the sequence: | |
110 | \ probe-all | |
111 | \ install-console | |
112 | \ banner | |
113 | \ | |
114 | \ | |
115 | \ (B). The search and execution order will be as specified in (B) | |
116 | \ If both of the following two statements are true | |
117 | \ | |
118 | \ a) NVRAMRC contains the following sequence: | |
119 | \ probe-all | |
120 | \ install-console | |
121 | \ banner | |
122 | \ | |
123 | \ b) NVRAM parameter use-nvramrc? is true | |
124 | \ | |
125 | \ | |
126 | ||
127 | headerless | |
128 | 0 value di-header | |
129 | 0 value di-level | |
130 | 0 value header-page | |
131 | ||
132 | : difield \ name ( offset -- offset' ) | |
133 | create over c, + does> c@ di-header + | |
134 | ; | |
135 | ||
136 | struct | |
137 | /l difield di-magic | |
138 | /l difield di-size | |
139 | /l difield di-sum | |
140 | /l difield di-exp \ Reserved | |
141 | d# 16 difield di-name | |
142 | 0 difield di-image | |
143 | constant /di-header | |
144 | ||
145 | 0 value di-base | |
146 | ||
147 | : direct-open-drop-in ( -- 0 ) | |
148 | di-level 0= if map-drop-in is di-base then | |
149 | di-level 1+ to di-level | |
150 | 0 | |
151 | ; | |
152 | ||
153 | : direct-close-drop-in ( -- ) | |
154 | di-level 1- dup 0= if ( level ) | |
155 | di-base unmap-drop-in 0 to di-base | |
156 | then ( level ) | |
157 | 0 max is di-level ( level ) | |
158 | ; | |
159 | ||
160 | : check-di-magic ( addr -- header flag? ) | |
161 | 4 round-up is di-header | |
162 | di-magic l@ h# 4f424d44 = | |
163 | di-header swap | |
164 | ; | |
165 | ||
166 | : another-dropin? ( header -- false | header' true ) | |
167 | is di-header | |
168 | di-base -1 = if false exit then | |
169 | di-header if di-image di-size l@ + else di-base then ( adr ) | |
170 | check-di-magic dup 0= if nip then | |
171 | ; | |
172 | ||
173 | tail-chain: execute-buffer ( adr len -- ) \ Try machine code | |
174 | 2dup 4 min " CODE" $= if ( adr len ) | |
175 | drop 4 + 0 swap call 2drop exit | |
176 | then ( adr len ) | |
177 | tail; | |
178 | ||
179 | : (dropin>data) ( -- data,len ) di-image di-size l@ ; | |
180 | ||
181 | defer dropin>data ' (dropin>data) is dropin>data | |
182 | defer release-di-data ' 2drop is release-di-data | |
183 | ||
184 | \ Executes all drop-in packages whose names match the argument | |
185 | ||
186 | : direct-do-drop-in ( name-adr,len -- ) | |
187 | 2>r ( ) ( r: name-adr,len ) | |
188 | direct-open-drop-in ( header ) | |
189 | begin another-dropin? while ( header ) | |
190 | ||
191 | \ We go to a fair amount of extra trouble to keep the name | |
192 | \ and the current header address on the return stack, in | |
193 | \ case a drop-in messes up the data stack. | |
194 | ||
195 | 2r@ rot >r ( name-adr,len ) ( r: name-adr,len header) | |
196 | ||
197 | di-name cscount $= if ( ) ( r: name-adr,len header) | |
198 | dropin>data 2dup 2>r | |
199 | 'execute-buffer catch if 2drop then ( ) | |
200 | 2r> release-di-data ( ) | |
201 | then ( ) ( r: name-adr,len header) | |
202 | r> ( header ) ( r: name-adr,len ) | |
203 | repeat ( ) ( r: name-adr,len ) | |
204 | direct-close-drop-in ( ) ( r: name-adr,len ) | |
205 | 2r> 2drop ( ) | |
206 | ; ' direct-do-drop-in is do-drop-in | |
207 | ||
208 | \ After calling this routine, it is the responsibility of the | |
209 | \ caller to execute "free-drop-in" after it is finished using | |
210 | \ the located drop-in package. Failing to do so can result in | |
211 | \ wasted virtual memory. | |
212 | ||
213 | : direct-find-drop-in ( name-adr,len -- false | drop-in-adr,len true ) | |
214 | direct-open-drop-in ( name-adr,len header ) | |
215 | begin another-dropin? while ( name-adr,len header ) | |
216 | 2 pick 2 pick ( name-adr,len header name-adr,len ) | |
217 | di-name cscount $= if ( name-adr,len header ) | |
218 | drop 2drop ( ) | |
219 | dropin>data true ( virtual size true ) | |
220 | exit | |
221 | then | |
222 | repeat | |
223 | direct-close-drop-in | |
224 | 2drop false | |
225 | ; ' direct-find-drop-in is find-drop-in | |
226 | ||
227 | : direct-free-drop-in ( adr len -- ) | |
228 | release-di-data | |
229 | direct-close-drop-in | |
230 | ; ' direct-free-drop-in is free-drop-in | |
231 | ||
232 | headerless | |
233 | : (.dropin) ( -- ) | |
234 | push-decimal | |
235 | di-name cscount tuck type d# 17 swap - spaces | |
236 | di-size l@ d# 11 u.r di-exp l@ d# 11 push-hex .r pop-base | |
237 | di-sum l@ d# 11 u.r cr | |
238 | pop-base | |
239 | ; | |
240 | headers | |
241 | : .dropins ( -- ) | |
242 | ." Name Length Expansion Checksum" cr | |
243 | direct-open-drop-in ( header ) | |
244 | begin another-dropin? while ( header ) | |
245 | (.dropin) ( header ) | |
246 | repeat ( header ) | |
247 | direct-close-drop-in ( ) | |
248 | ; |