Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / usb / dq.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: dq.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: @(#)dq.fth 1.2 98/03/24
43purpose:
44copyright: Copyright 1997 Sun Microsystems, Inc. All Rights Reserved
45
46: dump-copy ( transfer-d -- )
47 dup my-data @ swap caller-count @ give-chunk
48;
49
50: transfer-bits>copy-out? ( transfer-d endp-bits -- copy-out? dummy )
51 swap transfer-control le-l@
52 d# 19 rshift 3 and \ dp bits
53 2 = \ in
54 swap
55;
56
57: copy-out? ( transfer-d -- copy-out? ) \ look at bits
58 dup my-endpoint @ endpoint-control le-l@
59 d# 11 rshift 3 and \ d bits
60 case 1 of drop false endof
61 2 of drop true endof
62 transfer-bits>copy-out?
63 endcase
64;
65
66: copy-out ( transfer-d -- ) \ look at addresses/cnts
67 dup my-data @ 0<> over caller-data @ 0<> and
68 over caller-count @ 0<> and if
69 dup my-data @
70 over caller-data @
71 rot caller-count @
72 move
73 else drop
74 then
75;
76
77: copy-for-client ( transfer-d -- )
78 dup copy-out? if
79 copy-out
80 else drop
81 then
82;
83
84\ Dump the transfer-d.
85: dump-transfer ( transfer-d -- )
86 dup my-endpoint @
87 -1 swap transfer-count +!
88 dup copy-for-client
89 dup caller-count @ if dup dump-copy then
90 /transfer give-chunk
91;
92
93\ XXX need special to dump all the copy-buffers??
94: dump-isoc-transfer ( transfer-d -- )
95;
96
97: ts-q> ( endpoint-addr -- )
98 dup td-tail@
99 over td-head@ dev>virt ( endpt-addr tail-dev t-addr )
100 begin
101 2dup next-transfer le-l@ <>
102 while ( endpt-addr tail-dev t-addr )
103 dup next-transfer le-l@ dev>virt
104 swap dump-transfer
105 repeat drop ( endpoint-addr tail-dev )
106 over td-head!
107 sync-endpoint
108;
109
110\ Need to remove subsequent associated transfer d's when one has an error
111\ or when removing an endpoint.
112\ Assumes endpoint has been turned off. Dump them all, except a dummy.
113: clear-endpoint ( endpoint-addr -- )
114 dup td-tail@ over td-head@ = if \ already empty
115 drop
116 else ( endpt-addr )
117 ts-q>
118 then
119;
120
121: wipe-endpoint ( endpoint-addr -- )
122 dup skip-endp
123 next-frame
124 clear-endpoint
125;
126
127\ Dump endpoint and dummy transfer
128: toss-endpoint ( addr -- )
129 dup td-head@ dev>virt /transfer give-chunk
130 /endpoint give-chunk
131;
132
133\ Assumes no transfer descriptors, except the dummy one at the end:
134: eq> ( addr -- ) \ Remove endpoint descriptor at addr from q
135
136 dup next-endpoint@ \ Stuff pointer to next into previous one
137 over prev-endpoint @ next-endpoint!
138 dup prev-endpoint @ sync-endpoint
139
140 \ stuff pointer to prev into next:
141 dup next-endpoint@ ?dup if ( addr next-dev )
142 over prev-endpoint @
143 swap dev>virt prev-endpoint !
144 dup next-endpoint@ dev>virt sync-endpoint
145 then ( addr )
146
147 toss-endpoint
148;
149
150\ Don't dump the one at transfer-d, just the ones behind it.
151: dump-following-transfer-d's ( transfer-d endpoint -- )
152 0 swap code-done-q ! \ this done-q can be reused now.
153 next-transfer le-l@ ( dev-transfer )
154 begin
155 ?dup
156 while
157 dev>virt dup next-transfer le-l@
158 swap dump-transfer
159 repeat
160;