Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: bge-ipmifw.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: @(#)bge-ipmifw.fth 1.1 06/05/11 | |
43 | purpose: | |
44 | copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | \ BCM57xx IPMI/ASF firmware support | |
48 | \ | |
49 | \ BCM57xx support the ASF and IPMI features through the optional firmware | |
50 | \ running on the on-chip RISC processors. When enabled, the IPMI/ASF | |
51 | \ firmware expects the fcode driver to handshake with the firmware of | |
52 | \ various driver events like load, unload, reset, and suspend operations | |
53 | \ of the driver. The fcode driver and the IPMI/ASF Firmware use SW Event | |
54 | \ (bit 14, SW Event 7) within the RX CPU Event Register (h# 6810) and a | |
55 | \ portion of the device internal memory, for communications between the | |
56 | \ two entities. | |
57 | \ | |
58 | \ Following support is needed in the load & unload operations of the | |
59 | \ fcode driver: | |
60 | \ | |
61 | \ Fcode driver Load operation: | |
62 | \ o Pause IPMI/ASF firmware and wait for ACK | |
63 | \ o Write bootcode magic (h# 4B657654) to memory address h# B50 | |
64 | \ o Reset core clocks (exists in current code) | |
65 | \ o Write Fcode driver state 'Start' (h# 1) to h# C04 | |
66 | \ o Wait for complement of bootcode magic (h# 4B657654) [or timeout] | |
67 | \ o Continue with MAC initialization | |
68 | \ | |
69 | \ Fcode driver Unload/Shutdown operation: | |
70 | \ o Pause IPMI/ASF firmware and wait for ACK | |
71 | \ o Write bootcode magic (h# 4B657654) to memory address h# B50 | |
72 | \ o Disable state machines (exists in current code) | |
73 | \ o Reset core clocks (to restart the IPMI/ASF firmware) | |
74 | \ o Wait for complement of bootcode magic (h# 4B657654) [or timeout] | |
75 | \ o Write Fcode driver state 'Unload' (h# 2) to h# C04 | |
76 | \ | |
77 | ||
78 | headers | |
79 | ||
80 | \ BCM57xx bootcode fw mailbox | |
81 | h# b50 constant bootcode-mbox \ Bootcode magic addr | |
82 | h# 4b657654 constant bootcode-magic \ Magic "KevT" written to h# B50 | |
83 | \ by bootcode | |
84 | ||
85 | \ IPMI/ASF firmware status mailbox and states | |
86 | h# c00 constant ipmifw-status-mbox | |
87 | 1 constant ipmifw-running | |
88 | 2 constant ipmifw-paused | |
89 | ||
90 | \ Pause command to IPMI/ASF fw | |
91 | 2 constant fcode-pause-fw | |
92 | ||
93 | \ Fcode driver state mailbox and states | |
94 | h# c04 constant fcode-state-mbox | |
95 | 1 constant fcode-state-start | |
96 | 2 constant fcode-state-unload | |
97 | ||
98 | \ Used before actual reset/init code executes | |
99 | : enable-mem-access ( -- ) | |
100 | h# c h# 68 my-lset \ Ensure expected endianness | |
101 | 6 4 my-w! \ Enable Memory Space Decode | |
102 | 2 h# 4000 breg-bset \ Enable MAC Memory Arbitrator | |
103 | ; | |
104 | ||
105 | \ Check for BCM57xx bootcode fw magic "KevT" | |
106 | : valid-bootcode-magic? ( -- true | false ) | |
107 | h# b54 nicmem@ bootcode-magic = | |
108 | ; | |
109 | ||
110 | \ Check if IPMI/ASF fw has been enabled | |
111 | : ipmifw-enabled? ( -- true | false ) | |
112 | valid-bootcode-magic? if | |
113 | h# b58 nicmem@ 1 h# 7 << and 0<> ( true | false ) | |
114 | else | |
115 | false | |
116 | then | |
117 | ; | |
118 | ||
119 | \ Get IPMI/ASF fw state | |
120 | : ipmifw-state@ ( -- state ) ipmifw-status-mbox nicmem@ ; | |
121 | ||
122 | \ Display current status of IPMI/ASF fw | |
123 | : ipmifw-status ( -- ) | |
124 | cr ." IPMI/ASF firmware status: " | |
125 | ipmifw-enabled? if ." Enabled - " else ." Disabled - " then | |
126 | ipmifw-state@ case | |
127 | ipmifw-running of ." Running" endof | |
128 | ipmifw-paused of ." Paused" endof | |
129 | ." (state) " dup .d | |
130 | endcase cr | |
131 | ; | |
132 | ||
133 | \ Enable the SW Event 7 - bit[14] - of RX CPU Event register (h# 6810) | |
134 | \ to notify IPMI/ASF fw about the command sent to it via mailbox | |
135 | : set-sw-event ( -- ) | |
136 | h# 6810 breg@ 1 d# 14 << or ( bits ) | |
137 | h# 6810 breg! | |
138 | ; | |
139 | ||
140 | \ Read the SW Event 7 - bit[14] - from RX CPU Event register (h# 6810) | |
141 | : get-sw-event ( -- bit ) h# 6810 breg@ d# 14 >> 1 and ; | |
142 | ||
143 | \ Write cmd to IPMI/ASF fw mailbox and set the SW event notice | |
144 | : ipmifw-mbox! ( cmd -- ) h# b78 nicmem! set-sw-event ; | |
145 | ||
146 | \ Write the magic value "KevT" to bootcode mailbox | |
147 | : bootcode-sig! ( -- ) bootcode-magic bootcode-mbox nicmem! ; | |
148 | ||
149 | \ Wait for complement of bootcode-magic as response | |
150 | : check-bootcode-compl ( -- ) | |
151 | d# 100 0 do | |
152 | bootcode-mbox nicmem@ ( magic ) | |
153 | bootcode-magic h# ffff.ffff xor = if | |
154 | unloop exit | |
155 | then | |
156 | d# 5 ms | |
157 | loop | |
158 | ; | |
159 | ||
160 | \ Inform IPMI/ASF fw about fcode driver state | |
161 | : state-sig! ( state -- ) | |
162 | ipmifw-enabled? if | |
163 | fcode-state-mbox nicmem! | |
164 | else | |
165 | drop | |
166 | then | |
167 | ; | |
168 | ||
169 | \ Send pause cmd to IPMI/ASF fw only when it is in 'running' state. Used | |
170 | \ during reset, open, close calls. | |
171 | : pause-ipmifw ( -- ) | |
172 | ipmifw-state@ ipmifw-running = if | |
173 | fcode-pause-fw ipmifw-mbox! \ send pause cmd | |
174 | d# 100 0 do | |
175 | get-sw-event 0= if unloop exit then | |
176 | d# 5 ms | |
177 | loop | |
178 | then | |
179 | ; |