Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / usb2 / hcd / ohci / 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: OHCI USB Controller interrupt pipes transaction processing
44\ See license at end of file
45
46hex
47headers
48
49d# 500 constant intr-in-timeout
50
510 value #intr-in \ Count of outstanding begin-intr-in
52
530 instance value intr-in-pipe
540 instance value intr-in-interval
55
560 instance value intr-in-ed \ Instance variables for begin-intr-in, intr-in?,
570 instance value intr-in-td \ restart-intr-in and end-intr-in
58
59: #intr-in++ ( -- ) #intr-in 1+ to #intr-in ;
60: #intr-in-- ( -- ) #intr-in 1- to #intr-in ;
61
62: disable-periodic ( -- ) 4 hc-cntl-clr next-frame ;
63: enable-periodic ( -- ) 4 hc-cntl-set ;
64
65: insert-in-intr ( ed -- )
66 ( ed ) intr-in-interval insert-intr-ed
67 enable-periodic
68;
69: remove-intr ( ed -- )
70 disable-periodic
71 ( ed ) remove-intr-ed
72 #intr-in if enable-periodic then
73;
74
75: intr-in-data@ ( -- n ) intr-in-pipe target di-in-data@ di-data>ed-data ;
76: intr-in-data! ( n -- ) ed-data>di-data intr-in-pipe target di-in-data! ;
77: fixup-intr-in-data ( ed -- )
78 usb-error USB_ERR_STALL and if
79 drop intr-in-pipe h# 80 or unstall-pipe
80 ED_TOGGLE_DATA0
81 else
82 >hced-tdhead le-l@
83 then
84 intr-in-data!
85;
86
87: process-intr-args ( buf len pipe timeout -- ) process-bulk-args ;
88: alloc-intr-edtds ( -- ed td ) alloc-bulk-edtds ;
89: fill-intr-io-tds ( td -- ) fill-bulk-io-tds ;
90: fill-intr-in-ed ( ed -- )
91 my-dev/pipe my-speed or ED_DIR_IN or ED_SKIP_OFF or ED_FORMAT_G or
92 my-maxpayload d# 16 << or
93 over >hced-control le-l!
94 ( ed ) dup >hced-tdhead le-l@ ( ed head )
95 intr-in-data@ or ( ed head' )
96 over >hced-tdhead le-l! ( ed )
97 ( ed ) sync-edtds ( )
98;
99: remove-my-intr ( ed -- ) dup remove-intr free-edtds ;
100
101external
102
103: begin-intr-in ( buf len pipe interval -- )
104 debug? if ." begin-intr-in" cr then
105 intr-in-ed if 4drop exit then \ Already started
106 #intr-in++
107
108 to intr-in-interval
109 dup to intr-in-pipe
110 intr-in-timeout process-intr-args
111 alloc-intr-edtds to intr-in-td to intr-in-ed
112
113 \ IN TD
114 intr-in-td fill-intr-io-tds
115
116 \ Start intr transaction
117 intr-in-ed dup fill-intr-in-ed
118 insert-in-intr
119;
120
121: intr-in? ( -- actual usberr )
122 intr-in-ed 0= if 0 USB_ERR_INV_OP exit then
123 clear-usb-error ( )
124 process-hc-status ( )
125 intr-in-ed dup sync-edtds ( ed )
126 ed-done? if ( )
127 intr-in-td error? if
128 0 ( actual )
129 else ( )
130 intr-in-td dup get-actual ( td actual )
131 over >td-cbp l@ rot >td-pcbp l@ 2 pick dma-sync ( actual )
132 then
133 usb-error ( actual usberr )
134 intr-in-ed fixup-intr-in-data ( actual usberr )
135 else
136 0 usb-error ( actual usberr )
137 then
138;
139
140headers
141: restart-intr-in-td ( td -- )
142 begin ?dup while
143 dup >td-next l@ if
144 TD_CC_NOTACCESSED TD_DIR_IN or TD_INTR_OFF or TD_ROUND_ON or
145 over >hctd-control le-l!
146 dup >td-pcbp l@ over >hctd-cbp le-l!
147 dup >td-next l@ >td-phys l@ over >hctd-next le-l!
148 then
149 >td-next l@
150 repeat
151;
152
153external
154: restart-intr-in ( -- )
155 intr-in-ed 0= if exit then
156 intr-in-ed ed-set-skip
157
158 \ Setup TD again
159 intr-in-td restart-intr-in-td
160
161 \ Setup ED again
162 intr-in-td >td-phys l@ intr-in-data@ or intr-in-ed >hced-tdhead le-l!
163 intr-in-ed dup sync-edtds
164 ed-unset-skip
165;
166
167: end-intr-in ( -- )
168 debug? if ." end-intr-in" cr then
169 intr-in-ed 0= if exit then
170 #intr-in--
171 intr-in-td map-out-cbp
172 intr-in-ed remove-my-intr
173 0 to intr-in-ed 0 to intr-in-td
174;
175
176headers
177
178: (end-extra) ( -- ) (end-extra) end-intr-in ;
179' (end-extra) to end-extra
180
181
182\ LICENSE_BEGIN
183\ Copyright (c) 2006 FirmWorks
184\
185\ Permission is hereby granted, free of charge, to any person obtaining
186\ a copy of this software and associated documentation files (the
187\ "Software"), to deal in the Software without restriction, including
188\ without limitation the rights to use, copy, modify, merge, publish,
189\ distribute, sublicense, and/or sell copies of the Software, and to
190\ permit persons to whom the Software is furnished to do so, subject to
191\ the following conditions:
192\
193\ The above copyright notice and this permission notice shall be
194\ included in all copies or substantial portions of the Software.
195\
196\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
197\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
198\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
199\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
200\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
201\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
202\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
203\
204\ LICENSE_END