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