Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / arch / sun4ju / columbus2 / multipath-boot.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: multipath-boot.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: @(#)multipath-boot.fth 1.5 07/02/27
43purpose:
44copyright: Copyright 2007 Sun Microsystems, Inc. All rights reserved.
45copyright: Copyright 2007 Fujitsu Limited. All Rights Reserved.
46copyright: Use is subject to license terms.
47
48\ Multipath boot controlling methods
49\
50\ Boot failure cases:
51\
52\ OS --+---> cif: boot --> $reboot-hook : mpb-$reboot-hook
53\ | Increment boot-device-index when called due to
54\ | unsuccessful boot. Abort rebooting if all devices
55\ | have failed in boot-device configuration.
56\ |
57\ +---> cif: exit --> client-fail-exited-chain : mpb-fail-exited-chain
58\ | Increment boot-device-index when called due to
59\ | unsuccessful boot. Reboot if alternative available
60\ | devices are left in boot-device configuration.
61\ |
62\ +---> XIR --> (arch/sun4ju/error-reset.fth)
63\ |
64\ +---> error trap --> Degrade and reset
65\ |
66\ +---> FATAL --> Clear Reset. SCF might degrade the fault unit.
67\ |
68\ +---> POFF/PON --> Clear Reset
69\ |
70\ +---> hangup --> SCF might issue XIR
71\ +---> XIR --> (arch/sun4ju/error-reset.fth)
72
73
74headerless
75false value boot-path-specified?
76
77\ Create multipath-boot property in chosen node.
78\ This property is created at run time by obp to indicate that
79\ boot device was picked up from "boot-device" config variable
80\ and "multipath-boot?" configuration-variable is currently
81\ set to TRUE.
82: make-multipath-boot-property ( -- )
83 " /chosen" find-device
84 0 0 encode-bytes " multipath-boot" property
85 device-end
86;
87
88: no-available-device-error ( -- )
89 cmn-error[ " All device paths in boot-device have failed." ]cmn-end
90;
91
92: all-devices-failed? ( -- flag )
93 boot-device ( adr len )
94 count-words boot-device-index < ( flag )
95;
96
97\ Indicate if multipath-boot (mpb) is enabled or not.
98: mpb-enable? ( -- enable? )
99 multipath-boot? ( enable? )
100 diagnostic-mode? 0= and ( enable?' )
101 boot-path-specified? 0= and ( enabled? )
102;
103
104: increment-boot-device-index ( -- )
105 boot-device-index 1+ to boot-device-index
106;
107
108: multipath-default-device ( -- $devname )
109 false to boot-path-specified? ( )
110 mpb-enable? ( enable? )
111 0= if ( )
112 (default-device) ( devname$ )
113 exit ( devname$ )
114 then
115
116 boot-device ( devnames$ )
117 boot-device-index 0 ( devnames$ index 0 )
118 ?do ( devnames$ )
119 -leading bl left-parse-string ( right$ left$ )
120[ifdef] multipath-debug
121 ??cr ." skip boot device '" 2dup type ." '" cr
122[then]
123 2drop ( right$ )
124 loop ( devnames$' )
125
126 begin ( devnames$ )
127 strip-blanks dup ( devnames$ len )
128 while ( devnames$ )
129 bl left-parse-string ( right$ left$ )
130[ifdef] multipath-debug
131 ??cr ." current boot index : " boot-device-index .d
132 ." current boot device '" 2dup type ." '" cr
133[then]
134 2dup locate-device 0= if ( right$ left$ phandle )
135 device-status-ok? if ( right$ left$ )
136 2dup open-dev ?dup if ( right$ left$ ihandle )
137 close-dev 2swap 2drop ( left$ )
138 \ Create multipath-boot property
139 make-multipath-boot-property
140 exit ( left$ )
141 else
142 default-device-hook ( right$ left$ )
143 then ( right$ left$ )
144 then ( right$ left$ )
145 then ( right$ left$ )
146 2drop ( right$ )
147 increment-boot-device-index ( right$ )
148 repeat ( adr 0 )
149 2drop ( )
150 no-available-device-error ( )
151 abort
152;
153' multipath-default-device to default-device
154
155\ Check and detect the multipath boot failure.
156\ Called at:
157\ - rebooting,
158\ - cif "exit",
159\ - error-reset-recovery, and
160\ - the failure case of opening boot-device, and
161\ - and case where OBP detects some error but could not identify the
162\ faulty device
163\
164\ The multipath boot failure is determined if
165\ - OBP has not relinquished its trap handling to the client program
166\ although we are in process of those methods
167\ AND
168\ if multipath-boot feature is enabled.
169\
170\ Case caused by command line operation is excluded.
171: multipath-boot-failed? ( -- failed? )
172 mpb-enable? ( enable? )
173 already-go? and ( failed? ) \ open-dev succeed?
174 obp-control-relinquished? 0= and ( failed?' ) \ boot-failed or shutdowned
175 \ or not-booted?
176 ok-prompt? 0= and ( failed?'') \ not commandline operation?
177;
178
179\ Hook $boot
180\ Set boot-path-specified? to default value.
181defer old-mpb-$boot-load-hook
182' $boot-load-hook behavior is old-mpb-$boot-load-hook
183: mpb-$boot-load-hook ( -- )
184 true to boot-path-specified? \ default setting
185 old-mpb-$boot-load-hook
186;
187' mpb-$boot-load-hook is $boot-load-hook
188
189\ Reboot for multipath-boot feature. Ignore path-buf to continue autoboot.
190: multipath-force-reboot
191 args-buf cscount " " " boot" $restart ( )
192;
193
194\ Common code to detect and recover the multipath boot failure.
195\ This code is supposed to be called in
196\ - rebooting via "$reboot", CIF "exit"
197\ - error-reset-recovery
198\ - the case where load of boot-device fail in "boot-read" or "$boot"
199\ - the case where OBP detects some error but could not identify
200\ the faulty device.
201\
202\ This code checks if those methods are called due to multipath boot failure.
203\ If so, increment boot-device-index. Then, if any other alternative
204\ boot-device is present, take the specified action: force the system to
205\ reboot so that we can try the next possible boot-device, or to do nothing
206\ but exit. If all boot-devices fail, abort to drop at OBP prompt with an
207\ error message.
208\
209: boot-failure-recovery ( force-reboot? -- )
210 multipath-boot-failed? 0= if
211 drop exit ( )
212 then ( )
213 increment-boot-device-index ( reboot? )
214 all-devices-failed? if ( reboot? )
215 \ Drop at OBP prompt if all boot-devices fail.
216 drop ( )
217 no-available-device-error ( )
218 abort ( )
219 else ( reboot? )
220 \ Force reboot if specified.
221 \ path-buf will be ignored to continue autoboot.
222 if ( )
223 multipath-force-reboot
224 then ( )
225 then
226;
227
228\ Hook "$reboot", which is called by CIF "boot' and "$load", to check
229\ and recover the multipath-boot failure. Even if OBP detects a boot
230\ failure and can select alternate device from "boot-device"
231\ configuration, this method does nothing but exit. Subsequent
232\ "$reboot" code is expected to reboot the system.
233defer old-mpb-$reboot-hook
234' $reboot-hook behavior is old-mpb-$reboot-hook
235: mpb-$reboot-hook
236 old-mpb-$reboot-hook
237 false boot-failure-recovery
238;
239' mpb-$reboot-hook is $reboot-hook
240
241\ Called to hook the methods except "$reboot". If OBP detects
242\ multipath boot failure and can select alternate device from
243\ "boot-device" configuration, force to reboot the system.
244: mpb-recovery-with-reboot ( -- )
245 true boot-failure-recovery
246;
247' mpb-recovery-with-reboot is cmn-end-mpb-recovery
248
249
250\ Hook CIF "exit" to check and recover the multipath-boot failure
251\
252defer old-mpb-fail-exited-chain
253: mpb-fail-exited-chain ( -- )
254 old-mpb-fail-exited-chain
255 mpb-recovery-with-reboot
256;
257
258\ Hook CIF "SUNW,set-trap-table" to initialize boot-device-index
259\ on a successful boot.
260defer old-mpb-starting-chain
261: mpb-starting-chain ( -- )
262 old-mpb-starting-chain
263
264 \ reset the index value at SUNW,set-trap-table only if it is non-zero
265 boot-device-index if
266 0 to boot-device-index
267 then
268;
269
270\ Following hooks must be installed at stand-init, because
271\ these chains are initialized to noop at cleanup on make.
272stand-init: Install multipath boot hooks
273 ['] client-fail-exited-chain behavior is old-mpb-fail-exited-chain
274 ['] mpb-fail-exited-chain is client-fail-exited-chain
275
276 ['] client-starting-chain behavior is old-mpb-starting-chain
277 ['] mpb-starting-chain is client-starting-chain
278;