Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: requests.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: @(#)requests.fth 1.6 00/05/09 | |
43 | purpose: | |
44 | copyright: Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved | |
45 | ||
46 | : request-blank ( -- addr ) /request dma-alloc ; | |
47 | ||
48 | : descript-form ( len -- addr ) | |
49 | request-blank | |
50 | get-descript-req over request-type w! | |
51 | swap over req-len le-w! | |
52 | ; | |
53 | ||
54 | : get-dev-descript-form ( len -- addr ) | |
55 | descript-form | |
56 | device-descript over req-value 1+ c! | |
57 | ; | |
58 | ||
59 | : get-config-descript-form ( len -- addr ) | |
60 | descript-form | |
61 | config-descript over req-value 1+ c! \ need index as well | |
62 | ; | |
63 | ||
64 | : get-dev-descrip ( speed usb-adr -- dev-descrip-addr dcnt hw-err? | stat 0 ) | |
65 | 0 swap 0max-packet swap | |
66 | /dev-descriptor dma-alloc | |
67 | dup >r swap | |
68 | /dev-descriptor swap | |
69 | /dev-descriptor get-dev-descript-form | |
70 | dup >r swap | |
71 | /request swap | |
72 | 0 swap execute-control | |
73 | r> /request dma-free | |
74 | ?dup | |
75 | r> /dev-descriptor | |
76 | 2swap | |
77 | 0= if 0 then | |
78 | ; | |
79 | ||
80 | : get-config-descrip ( speed usb-adr n cnt | |
81 | -- config-n-descrip-addr cnt hw-err? | stat 0 ) | |
82 | swap rot >r >r >r ( R: usb-addr n cnt ) | |
83 | 0 0max-packet | |
84 | r@ dma-alloc ( speed in max c-d-addr ) | |
85 | r> r> r> ( speed in max c-d-addr cnt n u-addr ) | |
86 | 2over >r >r >r >r ( R: cnt c-addr u-addr n ) | |
87 | dup get-config-descript-form | |
88 | r> over req-value c! ( speed in max c-addr cnt pak-adr ) | |
89 | r> over >r >r ( R: cnt config-desc packet-addr usb-addr ) | |
90 | /request 0 r> execute-control | |
91 | r> /request dma-free | |
92 | ?dup | |
93 | r> r> | |
94 | 2swap | |
95 | 0= if 0 then | |
96 | ; | |
97 | ||
98 | \ XXX keyboard/mouse respond with expected stuff at 1 | |
99 | : get-config1-descrip ( speed usb-adr | |
100 | -- config1-descrip-addr ccnt hw-err? | stat 0 ) | |
101 | 0 /config-descriptor get-config-descrip | |
102 | ; | |
103 | ||
104 | : .usb ( stat -- ) | |
105 | case 2 of noop endof | |
106 | 6 of cr ." usb-nak" endof | |
107 | e of cr ." usb-stall" endof | |
108 | cr ." usb-unknown: " dup . | |
109 | endcase | |
110 | ; | |
111 | ||
112 | : stall-or-nak? ( stat -- stall-or-nak? ) | |
113 | dup .usb | |
114 | dup e = swap 6 = or | |
115 | ; | |
116 | ||
117 | : idump ( adr cnt -- ) \ XXX debug | |
118 | " dump" $find drop execute | |
119 | ; | |
120 | ||
121 | \ get config1 descriptor for total count | |
122 | \ get the entire config1 descriptor. copy interface descriptor to buffer | |
123 | : get-int-descrip ( speed usb-adr -- int-descrip-addr icnt hw-err? | stat 0 ) | |
124 | 2dup get-config1-descrip ( spd usb-adr c1-adr ccnt hw-err? | stat 0 ) | |
125 | dup if \ hw-err found; already printed | |
126 | >r 2swap 2drop r> | |
127 | exit | |
128 | else | |
129 | over stall-or-nak? if \ stall or nak found | |
130 | 2rot 2drop | |
131 | exit | |
132 | else 2drop \ ok so far | |
133 | then | |
134 | then | |
135 | over c-descript-total le-w@ \ count of total descriptor | |
136 | -rot dma-free ( speed u-adr c-total ) | |
137 | \ XXX keyboard/mouse respond with expected stuff at 1 | |
138 | 0 swap get-config-descrip \ get entire config1 descriptor | |
139 | ( c1adr c1cnt hw-err? | stat 0 ) | |
140 | dup if \ hw-err; already printed | |
141 | exit | |
142 | else | |
143 | over stall-or-nak? if \ stall or nak found | |
144 | exit | |
145 | else 2drop \ went ok; Note A, see below | |
146 | then | |
147 | then ( c1adr c1cnt ) ( R: i# ) | |
148 | " combined int-start" diag-crtype \ XXX debug | |
149 | \ cr 2dup idump cr \ XXX debug | |
150 | 2dup find-int-descrips ( c-addr ccnt i-addr ccnt2 ) | |
151 | dup dma-alloc over >r dup >r ( R: icnt int-descrip-addr ) | |
152 | swap move ( c-addr ccnt ) | |
153 | dma-free | |
154 | r> r> | |
155 | 2 0 \ dummy usb status; actually the | |
156 | \ same as just above at note A | |
157 | ; | |
158 | ||
159 | \ XXX only for me, not for child (if I should be a hub, won't work for child) | |
160 | : clear-stall ( speed endpoint usb-adr -- hw-err? | stall 0 ) | |
161 | >r | |
162 | request-blank >r | |
163 | clear-feature-req h# 200 or r@ request-type w! | |
164 | endpoint-stall r@ req-value le-w! | |
165 | r@ req-index le-w! | |
166 | 1 0max-packet 0 0 | |
167 | r> /request | |
168 | 0 r> 2over >r >r | |
169 | execute-control | |
170 | r> r> dma-free | |
171 | ; |