Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: nodes.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: @(#)nodes.fth 1.15 03/05/12 | |
43 | purpose: | |
44 | copyright: Copyright 1998-2003 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | : find-fcode ( adr1 len1 -- adr2 len2 true | false ) | |
48 | " sunw,find-fcode" get-inherited-property drop | |
49 | decode-int nip nip | |
50 | execute | |
51 | ; | |
52 | ||
53 | : find-interface-fcode ( -- addr len ) " interface" find-fcode drop ; | |
54 | ||
55 | : disabled-prop ( -- ) " disabled" encode-string " status" property ; | |
56 | ||
57 | : create-reg ( -- ) my-space encode-int " reg" property ; | |
58 | ||
59 | : ?create-speed ( lo-speed? -- ) if 0 0 " low-speed" property then ; | |
60 | ||
61 | : create-config ( config -- ) encode-int " configuration#" property ; | |
62 | ||
63 | : create-interface# ( i# -- ) encode-int " interface#" property ; | |
64 | ||
65 | : my-speed ( -- lo-speed? ) | |
66 | " low-speed" get-my-property if | |
67 | false | |
68 | else 2drop true | |
69 | then | |
70 | ; | |
71 | ||
72 | : my-usb-adr ( -- usb-address ) \ must be there | |
73 | " assigned-address" get-my-property drop | |
74 | decode-int nip nip | |
75 | ; | |
76 | ||
77 | : my-0max-packet ( -- ) \ must be there | |
78 | " 0max-packet" get-my-property drop | |
79 | decode-int nip nip | |
80 | to 0max-packet | |
81 | ; | |
82 | ||
83 | \ i# is from the interface descriptor. This is to be more tolerant of | |
84 | \ (non-USB compliant) devices that don't start the descriptors at 0. | |
85 | : create-interface ( speed i# -- ) | |
86 | " device interface " diag-crtype | |
87 | diagnostic-mode? if dup . then \ XXX debug | |
88 | 100 dma-alloc >r \ to hold unit address string | |
89 | tuck | |
90 | 1 swap encode-unit \ always config 1 | |
91 | r@ swap dup >r move ( i# speed ) ( R: uadr ucnt ) | |
92 | >r >r find-interface-fcode over r> r> | |
93 | new-device | |
94 | ?create-speed \ publish low-speed for child interface node | |
95 | create-interface# | |
96 | " " r> r@ swap set-args \ XXX can we use the u#s area? | |
97 | 1 byte-load | |
98 | finish-device | |
99 | dma-free \ dump fcode | |
100 | r> 100 dma-free \ dump unit address | |
101 | " device interface done" diag-crtype \ XXX debug | |
102 | ; | |
103 | ||
104 | ||
105 | \ publish low-speed in child interface nodes. otherwise get-inherited-property | |
106 | \ could pick up some low-speed ancestor. not a problem for usb-adr. | |
107 | : make-interfaces ( -- ) | |
108 | " device get-ints" diag-crtype \ XXX debug | |
109 | my-speed my-usb-adr | |
110 | get-int-descriptors | |
111 | ?dup if \ XXX data-over benign here? | |
112 | drop | |
113 | dma-free | |
114 | disabled-prop \ XXX not quite. For the device; no interfaces | |
115 | exit | |
116 | else stall-or-nak? if | |
117 | dma-free | |
118 | disabled-prop \ XXX not quite. For the device; no interfaces | |
119 | exit | |
120 | then | |
121 | then ( int-adr icnt ) | |
122 | 2dup >r >r | |
123 | begin ( iadr' icnt' ) | |
124 | over i-descript-interface-id c@ | |
125 | my-speed swap create-interface | |
126 | no-more-interfaces? | |
127 | until | |
128 | 2drop | |
129 | r> r> dma-free | |
130 | ; | |
131 | ||
132 | : finish-node ( config-desc dev-desc -- ) | |
133 | create-reg | |
134 | over c-descript-config-id c@ | |
135 | create-config \ use bconfigvalue | |
136 | dup create-device-name | |
137 | create-device-compat | |
138 | make-interfaces | |
139 | ; | |
140 | ||
141 | : create-usb-device ( -- ) | |
142 | my-0max-packet | |
143 | my-speed my-usb-adr get-dev-descrip ( d-adr dcnt hw-err? | stat 0 ) | |
144 | ?dup if | |
145 | data-overrun-error <> if \ data-over benign here | |
146 | dma-free | |
147 | device-name | |
148 | disabled-prop \ XXX not really | |
149 | exit | |
150 | then | |
151 | else stall-or-nak? if | |
152 | dma-free | |
153 | device-name | |
154 | disabled-prop \ XXX not really | |
155 | exit | |
156 | then | |
157 | then | |
158 | over d-descript-maxpkt c@ to 0max-packet | |
159 | dma-free | |
160 | \ 0max-packet needed for interfaces to inherit: | |
161 | 0max-packet encode-int " 0max-packet" property | |
162 | my-speed my-usb-adr | |
163 | 2dup get-config1-descrip | |
164 | ( spd uadr cnfg1-adr ccnt hw-err? | stat 0 ) | |
165 | ?dup if \ hw-err; already printed | |
166 | drop | |
167 | dma-free | |
168 | device-name | |
169 | disabled-prop \ XXX not quite; hub still enables | |
170 | 2drop | |
171 | exit | |
172 | else stall-or-nak? if | |
173 | dma-free | |
174 | device-name | |
175 | disabled-prop \ XXX not quite; hub still enables | |
176 | 2drop | |
177 | exit | |
178 | then | |
179 | then | |
180 | 2swap get-dev-descrip | |
181 | ( cnfg-adr ccnt dev-adr dcnt hw-err? | stat 0 ) | |
182 | ?dup if \ hw-err; already printed | |
183 | drop | |
184 | dma-free dma-free | |
185 | device-name | |
186 | disabled-prop \ XXX not quite; hub still enables | |
187 | exit | |
188 | else stall-or-nak? if | |
189 | dma-free dma-free | |
190 | device-name | |
191 | disabled-prop \ XXX not quite; hub still enables | |
192 | exit | |
193 | then | |
194 | then ( cnfg-adr ccnt dev-adr dcnt ) | |
195 | 2dup >r >r 2over >r >r | |
196 | drop nip | |
197 | finish-node | |
198 | r> r> r> r> dma-free dma-free | |
199 | ; | |
200 | ||
201 | create-usb-device |