Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / usb2 / hcd / dev-info.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: dev-info.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: @(#)dev-info.fth 1.1 07/01/24
43purpose: Data structures and manuipulation routines for all USB Controllers
44\ See license at end of file
45
46hex
47headers
48
49\ ---------------------------------------------------------------------------
50\ device-info (DI): data structure internal to the OHCI driver.
51\ It keeps track of assigned USB addresses. For each USB device, its speed.
52\ And for each endpoint in a device, its max packet size and data toggle bit.
53\
54\ This data structure, once created, stays around at all time.
55\ ---------------------------------------------------------------------------
56
57struct
58 2 field >di-ep-maxpayload \ Max packet size for the endpoint
59 1 field >di-ep-in-toggle \ Data toggle state
60 1 field >di-ep-out-toggle \ Data toggle state
61constant /di-ep-struct
62
63struct
64 1 field >di-speed \ Device speed
65 1 field >di-hub \ Hub address (EHCI only)
66 1 field >di-port \ Port number (EHCI only)
67 1+ \ Padding for word alignment
68 /di-ep-struct #max-endpoint * field >di-ep
69 \ Endpoint structure
70dup constant /di-entry
71
72#max-dev * constant /di
730 value di \ device-info
74
750 value cur-dev \ Value of the last assigned usb address
76
77: 'di ( idx -- adr ) /di-entry * di + ;
78: 'di-ep ( pipe idx -- adr ) 'di >di-ep swap /di-ep-struct * + ;
79
80: di-speed! ( speed idx -- ) 'di >di-speed c! ;
81: di-speed@ ( idx -- speed ) 'di >di-speed c@ ;
82: di-hub! ( hub idx -- ) 'di >di-hub c! ;
83: di-hub@ ( idx -- hub ) 'di >di-hub c@ ;
84: di-port! ( port idx -- ) 'di >di-port c! ;
85: di-port@ ( idx -- port ) 'di >di-port c@ ;
86
87: 'di-maxpayload ( pipe idx -- adr ) 'di-ep >di-ep-maxpayload ;
88: di-maxpayload! ( len pipe idx -- ) 'di-maxpayload w! ;
89: di-maxpayload@ ( pipe idx -- len ) 'di-maxpayload w@ ;
90
91: di-in-data! ( n pipe id -- ) 'di-ep >di-ep-in-toggle c! ;
92: di-in-data@ ( pipe id -- n ) 'di-ep >di-ep-in-toggle c@ ;
93: di-out-data! ( n pipe id -- ) 'di-ep >di-ep-out-toggle c! ;
94: di-out-data@ ( pipe id -- n ) 'di-ep >di-ep-out-toggle c@ ;
95: di-in-data-toggle ( pipe idx -- ) 2dup di-in-data@ 1 xor -rot di-in-data! ;
96: di-out-data-toggle ( pipe idx -- ) 2dup di-out-data@ 1 xor -rot di-out-data! ;
97
98: ok-to-add-device? ( -- flag ) cur-dev 1+ #max-dev < ;
99: new-address ( -- dev )
100 cur-dev 1+ dup to cur-dev
101 /pipe0 0 cur-dev di-maxpayload!
102;
103
104: init-di ( -- )
105 \ allocate and initialize the device descriptors
106 /di alloc-mem to di
107 di /di erase
108 /pipe0 0 0 di-maxpayload! \ Default max payload
109;
110
111: init-struct ( -- )
112 init-di
113;
114
115headers
116
117\ LICENSE_BEGIN
118\ Copyright (c) 2006 FirmWorks
119\
120\ Permission is hereby granted, free of charge, to any person obtaining
121\ a copy of this software and associated documentation files (the
122\ "Software"), to deal in the Software without restriction, including
123\ without limitation the rights to use, copy, modify, merge, publish,
124\ distribute, sublicense, and/or sell copies of the Software, and to
125\ permit persons to whom the Software is furnished to do so, subject to
126\ the following conditions:
127\
128\ The above copyright notice and this permission notice shall be
129\ included in all copies or substantial portions of the Software.
130\
131\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
132\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
133\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
134\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
135\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
136\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
137\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
138\
139\ LICENSE_END