Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: compatible.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: @(#)compatible.fth 1.3 99/09/16 | |
43 | purpose: | |
44 | copyright: Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved | |
45 | ||
46 | \ XXX can dma-alloc, since only used at probe time: | |
47 | h# 1000 instance buffer: string1 \ XXX prototype size; | |
48 | \ not required to be instance | |
49 | ||
50 | -1 instance value d-addr \ not required to be instance | |
51 | -1 instance value c-addr \ " | |
52 | -1 instance value i-addr \ " | |
53 | ||
54 | : dev-class ( -- dev-class ) d-addr d-descript-class c@ ; | |
55 | ||
56 | : int-class ( -- int-class ) i-addr i-descript-class c@ ; | |
57 | ||
58 | \ : #>$ ( n -- str len ) base @ >r hex (u.) r> base ! ; | |
59 | \ XXX hack for bad tokenizer that thinks (u.) is <# #s #> | |
60 | : #>$ ( n -- str len ) base @ >r hex <# u#s u#> r> base ! ; | |
61 | ||
62 | : $save ( str len addr -- addr len ) \ move string to addr | |
63 | swap 2dup >r >r | |
64 | move | |
65 | r> r> | |
66 | ; | |
67 | ||
68 | : append ( addr1 len1 addr2 len2 -- addr1 len1+len2) \ append to string1 | |
69 | 2over 2over 2swap + swap move | |
70 | nip + | |
71 | ; | |
72 | ||
73 | : ,append ( addr len1 -- addr len2 ) \ append , | |
74 | " ," append | |
75 | ; | |
76 | ||
77 | : #append ( n addr len1 -- addr len2 ) \ append a number str. | |
78 | rot #>$ append | |
79 | ; | |
80 | ||
81 | : .#append ( n addr len1 -- addr len2 ) \ append . and number | |
82 | " ." append #append | |
83 | ; | |
84 | ||
85 | : string+ ( prop-adr,len string-adr,len -- prop-adr,len' ) | |
86 | encode-string encode+ | |
87 | ; | |
88 | ||
89 | : $usb ( -- addr len ) " usb" ; | |
90 | ||
91 | : $,class ( -- addr len ) " ,class" ; | |
92 | ||
93 | : $usbif ( -- addr len ) " usbif" ; | |
94 | ||
95 | : dev4-#s ( -- pid vid ) | |
96 | d-addr d-descript-product le-w@ | |
97 | d-addr d-descript-vendor le-w@ | |
98 | ; | |
99 | ||
100 | : #s>dev-compat4 ( pid vid -- addr len ) \ text string | |
101 | $usb string1 $save | |
102 | #append | |
103 | ,append | |
104 | #append | |
105 | ; | |
106 | ||
107 | : dev2-#s ( -- rev pid vid ) | |
108 | d-addr d-descript-device le-w@ | |
109 | dev4-#s | |
110 | ; | |
111 | ||
112 | : #s>dev-compat2 ( rev pid vid -- addr len ) | |
113 | #s>dev-compat4 | |
114 | .#append | |
115 | ; | |
116 | ||
117 | : dev7-#s ( -- dev-class vid ) | |
118 | dev-class | |
119 | d-addr d-descript-vendor le-w@ | |
120 | ; | |
121 | ||
122 | : #s>dev-compat7 ( dev-class vid -- addr len ) | |
123 | $usb string1 $save | |
124 | #append | |
125 | $,class append | |
126 | #append | |
127 | ; | |
128 | ||
129 | : dev6-#s ( -- dev-sub dev-class vid ) | |
130 | d-addr d-descript-sub c@ | |
131 | dev7-#s | |
132 | ; | |
133 | ||
134 | : #s>dev-compat6 ( dev-sub dev-class vid -- addr len ) | |
135 | #s>dev-compat7 | |
136 | .#append | |
137 | ; | |
138 | ||
139 | : dev5-#s ( -- dev-prot dev-sub dev-class vid ) | |
140 | d-addr d-descript-protocol c@ | |
141 | dev6-#s | |
142 | ; | |
143 | ||
144 | : #s>dev-compat5 ( dev-prot dev-sub dev-class vid -- addr len ) | |
145 | #s>dev-compat6 | |
146 | .#append | |
147 | ; | |
148 | ||
149 | : dev10-#s ( -- dev-class ) | |
150 | dev-class | |
151 | ; | |
152 | ||
153 | : #s>dev-compat10 ( dev-class -- addr len ) | |
154 | $usb string1 $save | |
155 | $,class append | |
156 | #append | |
157 | ; | |
158 | ||
159 | : dev9-#s ( -- dev-sub dev-class ) | |
160 | d-addr d-descript-sub c@ | |
161 | dev10-#s | |
162 | ; | |
163 | ||
164 | : #s>dev-compat9 ( dev-sub dev-class -- addr len ) | |
165 | #s>dev-compat10 | |
166 | .#append | |
167 | ; | |
168 | ||
169 | : dev8-#s ( -- dev-prot dev-sub dev-class ) | |
170 | d-addr d-descript-protocol c@ | |
171 | dev9-#s | |
172 | ; | |
173 | ||
174 | : #s>dev-compat8 ( dev-prot dev-sub dev-class -- addr len ) | |
175 | #s>dev-compat9 | |
176 | .#append | |
177 | ; | |
178 | ||
179 | \ For non-zero dev-class | |
180 | : encode-dev-class ( prop-addr1 prop-len1 -- prop-addr2 prop-len2 ) | |
181 | dev5-#s #s>dev-compat5 string+ | |
182 | dev6-#s #s>dev-compat6 string+ | |
183 | dev7-#s #s>dev-compat7 string+ | |
184 | dev8-#s #s>dev-compat8 string+ | |
185 | dev9-#s #s>dev-compat9 string+ | |
186 | dev10-#s #s>dev-compat10 string+ | |
187 | ; | |
188 | ||
189 | : int5-#s ( -- int-class vid ) | |
190 | int-class | |
191 | d-addr d-descript-vendor le-w@ | |
192 | ; | |
193 | ||
194 | : #s>int-compat5 ( int-class vid -- addr len ) | |
195 | $usbif string1 $save | |
196 | #append | |
197 | $,class append | |
198 | #append | |
199 | ; | |
200 | ||
201 | : int4-#s ( -- i-sub int-class vid ) | |
202 | i-addr i-descript-sub c@ | |
203 | int5-#s | |
204 | ; | |
205 | ||
206 | : #s>int-compat4 ( i-sub int-class vid -- addr len ) | |
207 | #s>int-compat5 | |
208 | .#append | |
209 | ; | |
210 | ||
211 | : int3-#s ( -- i-prot i-sub int-class vid ) | |
212 | i-addr i-descript-protocol c@ | |
213 | int4-#s | |
214 | ; | |
215 | ||
216 | : #s>int-compat3 ( i-prot i-sub int-class vid -- addr len ) | |
217 | #s>int-compat4 | |
218 | .#append | |
219 | ; | |
220 | ||
221 | : int8-#s ( -- int-class ) | |
222 | int-class | |
223 | ; | |
224 | ||
225 | : #s>int-compat8 ( int-class -- addr len ) | |
226 | $usbif string1 $save | |
227 | $,class append | |
228 | #append | |
229 | ; | |
230 | ||
231 | : int7-#s ( -- i-sub int-class ) | |
232 | i-addr i-descript-sub c@ | |
233 | int8-#s | |
234 | ; | |
235 | ||
236 | : #s>int-compat7 ( i-sub int-class -- addr len ) | |
237 | #s>int-compat8 | |
238 | .#append | |
239 | ; | |
240 | ||
241 | : int6-#s ( -- i-prot i-sub int-class ) | |
242 | i-addr i-descript-protocol c@ | |
243 | int7-#s | |
244 | ; | |
245 | ||
246 | : #s>int-compat6 ( i-prot i-sub int-class -- addr len ) | |
247 | #s>int-compat7 | |
248 | .#append | |
249 | ; | |
250 | ||
251 | \ For non-zero int-class: | |
252 | : encode-int-class ( prop-addr1 prop-len1 -- prop-addr2 prop-len2 ) | |
253 | int3-#s #s>int-compat3 string+ | |
254 | int4-#s #s>int-compat4 string+ | |
255 | int5-#s #s>int-compat5 string+ | |
256 | int6-#s #s>int-compat6 string+ | |
257 | int7-#s #s>int-compat7 string+ | |
258 | int8-#s #s>int-compat8 string+ | |
259 | ; | |
260 | ||
261 | : create-combined-compat ( int-descrip-addr dev-descrip-addr -- ) | |
262 | is d-addr is i-addr | |
263 | dev2-#s #s>dev-compat2 encode-string | |
264 | dev4-#s #s>dev-compat4 string+ | |
265 | dev-class if encode-dev-class then | |
266 | int-class if encode-int-class then | |
267 | " compatible" property | |
268 | ; |