Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / usb-devices / device / requests.fth
CommitLineData
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 ============================================
42id: @(#)requests.fth 1.7 00/05/09
43purpose:
44copyright: 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: get-config1-descrip ( speed usb-adr
99 -- config1-descrip-addr ccnt hw-err? | stat 0 )
100 0 /config-descriptor get-config-descrip
101;
102
103: stall-or-nak? ( stat -- stall-or-nak? )
104 dup e = swap 6 = or
105;
106
107\ get config1 for total count.
108\ get entire config1 descriptor. copy out interface descriptors.
109: get-int-descriptors ( speed usb-adr -- int-descrip-addr icnt hw-err? | stat 0 )
110 2dup get-config1-descrip ( spd u-adr c1-adr ccnt hw-err? | stat 0 )
111 dup if \ XXX data over benign here?
112 >r 2swap 2drop r>
113 exit
114 else
115 over stall-or-nak? if
116 2rot 2drop
117 exit
118 else
119 2drop
120 then
121 then
122 over c-descript-total le-w@
123 -rot dma-free ( speed u-adr c-total )
124 0 swap get-config-descrip ( cadr ccnt hw-err? | stat 0 ) \ whole descriptor
125 dup if \ XXX data over benign here?
126 exit
127 else
128 over stall-or-nak? if
129 exit
130 else
131 2drop
132 then
133 then ( cadr ccnt )
134 2dup find-int-descrips ( cadr ccnt iadr icnt )
135 dup dma-alloc
136 2dup >r >r ( cadr ccnt iadr icnt buf-adr ) ( R: buf-adr icnt )
137 swap move
138 dma-free
139 r> r> swap
140 2 0 \ dummy good status reply
141;
142
143: clear-stall ( speed endpoint usb-adr -- hw-err? | stat 0 )
144 >r
145 request-blank >r
146 clear-feature-req h# 200 or r@ request-type w!
147 endpoint-stall r@ req-value le-w!
148 r@ req-index le-w!
149 1 0max-packet 0 0 \ XXX won't work if interface is a hub. Other stuff
150 \ won't work either, since the hub code is for combined.
151 r> /request
152 0 r> 2over >r >r
153 execute-control
154 r> r> dma-free
155;