Branch
Hash :
1a08f436
Author :
Date :
2010-08-25T09:23:17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
\ ========== Copyright Header Begin ==========================================
\
\ Hypervisor Software File: transfermap.fth
\
\ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
\
\ - Do no alter or remove copyright notices
\
\ - Redistribution and use of this software in source and binary forms, with
\ or without modification, are permitted provided that the following
\ conditions are met:
\
\ - Redistribution of source code must retain the above copyright notice,
\ this list of conditions and the following disclaimer.
\
\ - Redistribution in binary form must reproduce the above copyright notice,
\ this list of conditions and the following disclaimer in the
\ documentation and/or other materials provided with the distribution.
\
\ Neither the name of Sun Microsystems, Inc. or the names of contributors
\ may be used to endorse or promote products derived from this software
\ without specific prior written permission.
\
\ This software is provided "AS IS," without a warranty of any kind.
\ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
\ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
\ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
\ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
\ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
\ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
\ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
\ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
\ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
\ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
\ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
\
\ You acknowledge that this software is not designed, licensed or
\ intended for use in the design, construction, operation or maintenance of
\ any nuclear facility.
\
\ ========== Copyright Header End ============================================
id: @(#)transfermap.fth 1.8 04/05/25
purpose:
copyright: Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved
copyright: Use is subject to license terms.
struct
4 field transfer-control
4 field curr-buffer
4 field next-transfer
h# 14 field buffer-end \ followed by pad to make general and isoc
\ transfer sizes the same
/n field my-endpoint \ used only by software, virt
/n field caller-data \ ditto, for caller's buffer
/n field caller-count
/n field my-data
h# 20 over h# 20 mod - \ pad to next 32 byte boundary
field endpad2
( general transfer descrip. size ) constant /transfer
\ We can't use curr-buffer and reverse index it to get back to the virt addr
\ of the data buffer because the controller will use that field and set it to
\ 0 to indicate a full transfer. So we use my-data to hold the virt addr of
\ the associated buffer. my-data can be used as a copy buffer that is
\ dma-able from the static pool. 0 in caller-data means no associated buffer.
\ caller-count is 0 if no data to transfer.
\ XXX will waste memory up to 32 bytes per descriptor if it is evenly
\ aligned before the calculation. can save the dict entry by pushing the
\ calculation into the size of my-data
\ isochronous transfer descriptor structure
struct
4 field isoc-control
h# c field buff-page \ followed by next-transfer & buffer-end, as above
4 field offset0 \ and offset1; reused for psw0 and psw1
4 field offset2 \ and offset3; reused for psw2 and psw3
4 field offset4 \ and offset5; reused for psw4 and psw5
4 field offset6 \ and offset7; reused for psw6 and psw7;
\ followed by my-endpoint, as above
drop
: condition-code ( transfer-d -- cc )
le-l@ d# 28 rshift
;
\ For isochronous packets:
: packet-condition-code ( n transfer-d -- cc )
offset0 swap 4 * + le-w@
h# f000 and d# 12 rshift
;
\ completion codes for transfers ( cc field of transfer descriptor):
0 constant no-error
1 constant crc-error
2 constant bit-error
3 constant toggle-error
4 constant stall-error
5 constant no-response-error
6 constant pid-error
7 constant unexpected-pid-error
8 constant data-overrun-error
9 constant data-underrun-error
\ a constant reserved1
\ b constant reserved2
c constant buf-overrun-error \ isoc only
d constant buf-underrun-error \ isoc only
e constant eno-access-error \ XXX isoc only?
f constant fno-access-error \ XXX isoc only?
\ These are generated by the code:
11 constant time-out-error
12 constant no-more-addresses
: .error ( hw-err? -- hw-err? )
cmn-error[ " USB " cmn-append
dup
case 1 of " crc" endof
2 of " bit" endof
3 of " toggle" endof
4 of " stall" endof
5 of " no response" endof
6 of " pid" endof
7 of " unexpected pid" endof
8 of " data overrun" endof
9 of " data underrun" endof
c of " buffer overrun" endof
d of " buffer underrun" endof
e of " eno" endof
f of " fno" endof
11 of " time out" endof
12 of " no address" endof
" unknown %x" 2 pick
endcase
]cmn-end
;
\ Maybe show hardware errors
: ?.error ( hw-err? | stat 0 -- hw-err? | stat 0 )
dup if
.error
then
;
\ Some next-transfer bits must be 0
\ XXX should be done when next transfer is allocated
: next-transfer! ( n e-addr -- )
\ swap h# f invert and swap
next-transfer le-l!
;
\ XXX to retire the endpoint, use my-endpoint to look at transfer head and
\ tail. if equal, the endpoint has no transfer q left, and can be retired.
\ not quite. there could be transfer descriptors still on the done q's, or
\ maybe in process in the chip.
\ direction bits for transfer descriptors:
00 constant setup-bits
01 constant out-bits
02 constant in-bits