In legion build config, updated path to GNU tools and updated deprecated Sun CC flag...
[OpenSPARC-T2-SAM] / obp / obp / dev / usb-devices / device / compatible.fth
CommitLineData
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 ============================================
42id: @(#)compatible.fth 1.3 99/01/29
43purpose:
44copyright: Copyright 1998 Sun Microsystems, Inc. All Rights Reserved
45
46\ XXX can use dma-alloc, since this is only for probe time.
47h# 1000 buffer: string1 \ XXX prototype size
48
49-1 value d-addr
50-1 value c-addr
51
52: dev-class ( -- dev-class ) d-addr d-descript-class c@ ;
53
54: multi-config? ( -- multi-config? ) d-addr d-descript-#configs c@ 1 <> ;
55
56\ : #>$ ( n -- str len ) base @ >r hex (u.) r> base ! ;
57\ XXX hack for bad tokenizer that thinks (u.) is <# #s #>
58: #>$ ( n -- str len ) base @ >r hex <# u#s u#> r> base ! ;
59
60: $save ( str len addr -- addr len ) \ move string to addr
61 swap 2dup >r >r
62 move
63 r> r>
64;
65
66: append ( addr1 len1 addr2 len2 -- addr1 len1+len2) \ append to string1
67 2over 2over 2swap + swap move
68 nip +
69;
70
71: ,append ( addr len1 -- addr len2 ) \ append ,
72 " ," append
73;
74
75: #append ( n addr len1 -- addr len2 ) \ append a number str.
76 rot #>$ append
77;
78
79: .#append ( n addr len1 -- addr len2 ) \ append . and number
80 " ." append #append
81;
82
83: string+ ( prop-adr,len string-adr,len -- prop-adr,len' )
84 encode-string encode+
85;
86
87: $usb ( -- addr len ) " usb" ;
88
89: $.config ( -- addr len ) " .config" ;
90
91: $,class ( -- addr len ) " ,class" ;
92
93: dev4-#s ( -- pid vid )
94 d-addr d-descript-product le-w@
95 d-addr d-descript-vendor le-w@
96;
97
98: #s>dev-compat4 ( pid vid -- addr len ) \ text string
99 $usb string1 $save
100 #append
101 ,append
102 #append
103;
104
105: dev2-#s ( -- rev pid vid )
106 d-addr d-descript-device le-w@
107 dev4-#s
108;
109
110: #s>dev-compat2 ( rev pid vid -- addr len )
111 #s>dev-compat4
112 .#append
113;
114
115: dev1-#s ( -- config-id rev pid vid )
116 c-addr c-descript-config-id c@
117 dev2-#s
118;
119
120: #s>dev-compat1 ( config-id rev pid vid -- addr len )
121 #s>dev-compat2
122 $.config append
123 #append
124;
125
126: dev3-#s ( -- config-id pid vid )
127 c-addr c-descript-config-id c@
128 dev4-#s
129;
130
131: #s>dev-compat3 ( config-id pid vid -- addr len )
132 #s>dev-compat4
133 $.config append
134 #append
135;
136
137: dev7-#s ( -- dev-class vid )
138 dev-class
139 d-addr d-descript-vendor le-w@
140;
141
142: #s>dev-compat7 ( dev-class vid -- addr len )
143 $usb string1 $save
144 #append
145 $,class append
146 #append
147;
148
149: dev6-#s ( -- dev-sub dev-class vid )
150 d-addr d-descript-sub c@
151 dev7-#s
152;
153
154: #s>dev-compat6 ( dev-sub dev-class vid -- addr len )
155 #s>dev-compat7
156 .#append
157;
158
159: dev5-#s ( -- dev-prot dev-sub dev-class vid )
160 d-addr d-descript-protocol c@
161 dev6-#s
162;
163
164: #s>dev-compat5 ( dev-prot dev-sub dev-class vid -- addr len )
165 #s>dev-compat6
166 .#append
167;
168
169: dev10-#s ( -- dev-class )
170 dev-class
171;
172
173: #s>dev-compat10 ( dev-class -- addr len )
174 $usb string1 $save
175 $,class append
176 #append
177;
178
179: dev9-#s ( -- dev-sub dev-class )
180 d-addr d-descript-sub c@
181 dev10-#s
182;
183
184: #s>dev-compat9 ( dev-sub dev-class -- addr len )
185 #s>dev-compat10
186 .#append
187;
188
189: dev8-#s ( -- dev-prot dev-sub dev-class )
190 d-addr d-descript-protocol c@
191 dev9-#s
192;
193
194: #s>dev-compat8 ( dev-prot dev-sub dev-class -- addr len )
195 #s>dev-compat9
196 .#append
197;
198
199: dev-compat11 ( -- addr len )
200 " usb,device"
201;
202
203\ For non-zero dev-class
204: encode-dev-class ( prop-addr1 prop-len1 -- prop-addr2 prop-len2 )
205 dev5-#s #s>dev-compat5 string+
206 dev6-#s #s>dev-compat6 string+
207 dev7-#s #s>dev-compat7 string+
208 dev8-#s #s>dev-compat8 string+
209 dev9-#s #s>dev-compat9 string+
210 dev10-#s #s>dev-compat10 string+
211;
212
213: create-device-compat ( config-descrip-addr dev-descrip-addr -- )
214 is d-addr is c-addr
215 multi-config? if
216 dev1-#s #s>dev-compat1 encode-string
217 dev2-#s #s>dev-compat2 string+
218 else
219 dev2-#s #s>dev-compat2 encode-string
220 then
221 multi-config? if
222 dev3-#s #s>dev-compat3 string+
223 then
224 dev4-#s #s>dev-compat4 string+
225 dev-class if encode-dev-class then
226 dev-compat11 string+
227 " compatible" property
228;