Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: chipmap.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 ============================================ | |
42 | id: @(#)chipmap.fth 1.4 02/11/07 | |
43 | purpose: | |
44 | copyright: Copyright 1997, 2002 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | d# 15 constant max-ports \ ohci has max 15 downstream ports | |
48 | ||
49 | \ ohci registers | |
50 | ||
51 | struct | |
52 | 4 field hc-rev | |
53 | 4 field hc-control | |
54 | 4 field hc-cmd-status | |
55 | 4 field hc-int-status | |
56 | 4 field hc-int-enable | |
57 | 4 field hc-int-disable | |
58 | 4 field hc-hcca | |
59 | 4 field hc-period-current | |
60 | 4 field hc-control-head | |
61 | 4 field hc-control-current | |
62 | 4 field hc-bulk-head | |
63 | 4 field hc-bulk-current | |
64 | 4 field hc-done-head | |
65 | 4 field hc-fm-interval | |
66 | 4 field hc-fm-remaining | |
67 | 4 field hc-fm# | |
68 | 4 field hc-period-start | |
69 | 4 field hc-ls-threshold | |
70 | 4 field hc-roota | |
71 | 4 field hc-rootb | |
72 | 4 field hc-root-status | |
73 | max-ports 4 * field hc-port-status | |
74 | ||
75 | ( chip reg. size ) constant /controller | |
76 | ||
77 | 0 value chip-base | |
78 | ||
79 | : map-regs ( -- ) | |
80 | my-address my-space h# 200.0010 + /controller " map-in" $call-parent | |
81 | to chip-base | |
82 | my-space 4 + " config-w@" $call-parent | |
83 | h# 146 or | |
84 | my-space 4 + " config-w!" $call-parent | |
85 | ; | |
86 | ||
87 | : unmap-regs ( -- ) | |
88 | 0 my-space 4 + " config-w!" $call-parent | |
89 | chip-base /controller " map-out" $call-parent | |
90 | -1 to chip-base | |
91 | ; | |
92 | ||
93 | : show-reg ( addr -- ) | |
94 | rl@ | |
95 | <# u# u# u# u# ascii . hold u# u# u# u# u#> | |
96 | type | |
97 | ; | |
98 | ||
99 | \ XXX this is really crude | |
100 | : show-rio ( -- ) \ display current values in chip | |
101 | cr | |
102 | chip-base 4 + h# 10 bounds do \ skip hc-rev | |
103 | i show-reg 4 spaces | |
104 | 4 +loop | |
105 | cr | |
106 | chip-base h# 14 + h# 10 bounds do | |
107 | i show-reg 4 spaces | |
108 | 4 +loop | |
109 | cr | |
110 | chip-base h# 24 + h# 10 bounds do | |
111 | i show-reg 4 spaces | |
112 | 4 +loop | |
113 | cr | |
114 | chip-base h# 34 + h# 10 bounds do | |
115 | i show-reg 4 spaces | |
116 | 4 +loop | |
117 | cr | |
118 | chip-base h# 44 + h# 10 bounds do | |
119 | i show-reg 4 spaces | |
120 | 4 +loop | |
121 | cr | |
122 | chip-base h# 54 + h# 10 bounds do | |
123 | i show-reg 4 spaces | |
124 | 4 +loop | |
125 | \ cr | |
126 | \ chip-base h# 60 + show-reg | |
127 | cr | |
128 | ; | |
129 | ||
130 | \ host controller communications area | |
131 | ||
132 | struct | |
133 | h# 80 field interrupt-table | |
134 | 2 field frame# | |
135 | 2 field pad1 | |
136 | 4 field done-head | |
137 | d# 120 field reserved1 | |
138 | ||
139 | ( hcca size ) constant /hcca | |
140 | ||
141 | 0 value hcca | |
142 | 0 value dev-hcca | |
143 | ||
144 | \ hcca must also be synced before getting the done-q pointer. | |
145 | \ XXX what happens if the controller is writing the frame# while syncing? | |
146 | : sync-hcca ( -- ) | |
147 | sync-mem | |
148 | ; | |
149 | ||
150 | \ XXX must be aligned on 256 byte bdry. ohci 7.2.1 | |
151 | : map-hcca ( -- ) | |
152 | /hcca get-chunk to hcca | |
153 | hcca virt>dev to dev-hcca | |
154 | ; | |
155 | ||
156 | : unmap-hcca ( -- ) | |
157 | -1 to dev-hcca | |
158 | hcca /hcca give-chunk | |
159 | -1 to hcca | |
160 | ; | |
161 | ||
162 | : setup-hcca ( -- ) | |
163 | dev-dummy-endpoints \ setup interrupt table | |
164 | hcca interrupt-table d# 32 la+ | |
165 | hcca interrupt-table do | |
166 | dup i le-l! /endpoint + | |
167 | /l +loop drop | |
168 | sync-hcca | |
169 | ; | |
170 | ||
171 | : dump-hcca ( -- ) ; \ XXX may not be needed | |
172 | ||
173 | : make-structs ( -- ) | |
174 | map-hcca | |
175 | make-dummies | |
176 | setup-hcca | |
177 | ; | |
178 | ||
179 | : dump-structs ( -- ) | |
180 | dump-hcca | |
181 | dump-dummies | |
182 | unmap-hcca | |
183 | ; | |
184 | ||
185 | \ XXX is there a way to force dma-map-in to give aligned addresses? need | |
186 | \ 16 byte alignment and 32 byte alignment. Can over allocate and then | |
187 | \ use an aligned part of the total allocation. |