Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / usb2 / hcd / ehci / intr.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: intr.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: @(#)intr.fth 1.1 07/01/24
43purpose: EHCI USB Controller intr pipes transaction processing
44\ See license at end of file
45
46hex
47headers
48
49\ XXX Need to implement periodic interrupt transactions
50
51d# 500 constant intr-in-timeout
52
530 instance value intr-in-pipe
540 instance value intr-in-interval
55
560 instance value intr-in-qh
570 instance value intr-in-qtd
58
59: intr-in-data@ ( -- n ) intr-in-pipe target di-in-data@ di-data>td-data ;
60: intr-in-data! ( n -- ) td-data>di-data intr-in-pipe target di-in-data! ;
61: toggle-intr-in-data ( -- ) intr-in-pipe target di-in-data-toggle ;
62: fixup-intr-in-data ( qh -- n )
63 usb-error USB_ERR_STALL and if
64 drop intr-in-pipe h# 80 or unstall-pipe
65 TD_TOGGLE_DATA0
66 else
67 >hcqh-overlay >hcqtd-token le-l@
68 then
69 intr-in-data!
70;
71
72: process-intr-args ( buf len pipe timeout -- ) process-bulk-args ;
73: alloc-intr-qhqtds ( -- qh qtd ) alloc-bulk-qhqtds ;
74: fill-intr-io-qtds ( dir qtd -- )
75 my-#qtds 0 do ( dir qtd )
76 my-buf my-buf-phys /my-buf 3 pick fill-qtd-bptrs
77 ( dir qtd /bptr )
78 2 pick over d# 16 << or ( dir qtd /bptr token )
79 TD_C_ERR3 or TD_STAT_ACTIVE or ( dir qtd /bptr token' )
80 intr-in-data@ toggle-intr-in-data or ( dir qtd /bptr token' )
81 2 pick >hcqtd-token le-l! ( dir qtd /bptr )
82 my-buf++ ( dir qtd )
83 dup fixup-last-qtd ( dir qtd )
84 >qtd-next l@ ( dir qtd' )
85 loop 2drop ( )
86;
87
88external
89
90: begin-intr-in ( buf len pipe interval -- )
91 debug? if ." begin-intr-in" cr then
92 intr-in-qh if 4drop exit then \ Already started
93
94 to intr-in-interval
95 dup to intr-in-pipe
96 intr-in-timeout process-intr-args
97 alloc-intr-qhqtds to intr-in-qtd to intr-in-qh
98
99 \ IN qTDs
100 TD_PID_IN intr-in-qtd fill-intr-io-qtds
101
102 \ Start intr in transaction
103 intr-in-qh pt-intr fill-qh
104 intr-in-qh my-speed intr-in-interval insert-intr-qh
105;
106
107: intr-in? ( -- actual usberr )
108 intr-in-qh 0= if 0 USB_ERR_INV_OP exit then
109 clear-usb-error
110 process-hc-status
111 intr-in-qh dup sync-qhqtds
112 qh-done? if
113 intr-in-qh error? if
114 0
115 else
116 intr-in-qtd dup intr-in-qh >qh-#qtds l@ get-actual
117 over >qtd-buf rot >qtd-pbuf l@ 2 pick dma-sync
118 then
119 usb-error
120 intr-in-qh fixup-intr-in-data
121 else
122 0 usb-error
123 then
124;
125
126headers
127: restart-intr-in-qtd ( qtd -- )
128 begin ?dup while
129 dup >hcqtd-bptr0 dup le-l@ h# ffff.f000 and swap le-l!
130 dup >qtd-/buf l@ d# 16 <<
131 TD_STAT_ACTIVE or TD_C_ERR3 or TD_PID_IN or
132 intr-in-data@ or
133 over >hcqtd-token le-l!
134 >qtd-next l@
135 repeat
136;
137
138external
139: restart-intr-in ( -- )
140 intr-in-qh 0= if exit then
141
142 \ Setup qTD again
143 intr-in-qtd restart-intr-in-qtd
144
145 \ Setup QH again
146 intr-in-qh >hcqh-endp-char dup le-l@ QH_TD_TOGGLE invert and swap le-l!
147 intr-in-qtd >qtd-phys l@ intr-in-qh >hcqh-overlay >hcqtd-next le-l!
148 intr-in-qh sync-qhqtds
149;
150
151: end-intr-in ( -- )
152 debug? if ." end-intr-in" cr then
153 intr-in-qh 0= if exit then
154 intr-in-qh dup fixup-intr-in-data
155 intr-in-qtd map-out-bptrs
156 dup remove-intr-qh free-qhqtds
157 0 to intr-in-qh 0 to intr-in-qtd
158;
159
160headers
161
162: (end-extra) ( -- ) (end-extra) end-intr-in ;
163' (end-extra) to end-extra
164
165
166\ LICENSE_BEGIN
167\ Copyright (c) 2006 FirmWorks
168\
169\ Permission is hereby granted, free of charge, to any person obtaining
170\ a copy of this software and associated documentation files (the
171\ "Software"), to deal in the Software without restriction, including
172\ without limitation the rights to use, copy, modify, merge, publish,
173\ distribute, sublicense, and/or sell copies of the Software, and to
174\ permit persons to whom the Software is furnished to do so, subject to
175\ the following conditions:
176\
177\ The above copyright notice and this permission notice shall be
178\ included in all copies or substantial portions of the Software.
179\
180\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
181\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
182\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
183\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
184\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
185\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
186\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
187\
188\ LICENSE_END