Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / slof / fs / vpd-bootlist.fs
1 \ *****************************************************************************
2 \ * Copyright (c) 2004, 2008 IBM Corporation
3 \ * All rights reserved.
4 \ * This program and the accompanying materials
5 \ * are made available under the terms of the BSD License
6 \ * which accompanies this distribution, and is available at
7 \ * http://www.opensource.org/licenses/bsd-license.php
8 \ *
9 \ * Contributors:
10 \ *     IBM Corporation - initial implementation
11 \ ****************************************************************************/
12
13 4 CONSTANT vpd-bootlist-size
14
15 \ Bootable devices
16 00 CONSTANT FLOPPY
17 01 CONSTANT USB
18 02 CONSTANT SAS
19 03 CONSTANT SATA
20 04 CONSTANT ISCSI
21 05 CONSTANT ISCSICRITICAL
22 06 CONSTANT NET
23 07 CONSTANT NOTSPECIFIED
24 08 CONSTANT HDD0
25 09 CONSTANT HDD1
26 0a CONSTANT HDD2
27 0b CONSTANT HDD3
28 0c CONSTANT CDROM
29 0e CONSTANT HDD4
30 10 CONSTANT SCSI
31
32 : check-bootlist ( -- true | false )
33    vpd-bootlist l@
34    dup 0= IF
35       ( bootlist == 0 means that probably nothing from vpd has been received )
36       s" Boot list could not be read from VPD" log-string cr
37       s" Boot watchdog has been rearmed" log-string cr
38       2 set-watchdog
39       EXIT
40    THEN
41
42    FFFFFFFF = IF
43       ( bootlist all FFs means that the vpd has no useful information )
44       .banner
45       -6b boot-exception-handler
46       \ The next message is duplicate, but sent w. log-string
47       s" Boot list successfully read from VPD but no useful information received" log-string cr
48       s" Please specify the boot device in the management module" log-string cr
49       s" Specified Boot Sequence not valid" mm-log-warning
50       false
51       EXIT
52    THEN
53
54    true
55 ;
56
57 \ the following words are necessary for vpd-boot-import
58 defer set-boot-device
59 defer add-boot-device
60
61 \ select-install? is a flag which is used in the SMS panel #20
62 \ "Select/Install Boot Devices".
63 \ This panel can be used to temporarily override the boot device.
64 false VALUE select-install?
65
66 \ select/install-path stores string address and string length of the
67 \ device node chosen in the SMS panel #20 "Select/Install Boot Devices"
68 \ This device node is prepended to the boot path if select-install? is
69 \ true.
70 CREATE select/install-path 2 cells allot
71
72 \ Import boot device list from VPD
73 \ If none, keep the existing list in NVRAM
74 \ This word can be used to overwrite read-bootlist if wanted
75
76 : vpd-boot-import  ( -- )
77    0 0 set-boot-device
78
79    select-install? IF
80       select/install-path 2@ add-boot-device
81    THEN
82
83    vpd-read-bootlist
84    check-bootlist  IF
85       4 0  DO  vpd-bootlist i + c@
86          CASE
87             6  OF  \ cr s" 2B Booting from Network" log-string cr
88                furnish-boot-file strdup add-boot-device
89             ENDOF
90
91             HDD0  OF  \ cr s" 2B Booting from hdd0" log-string cr
92                s" disk hdd0" add-boot-device ENDOF
93
94             HDD1  OF  \ cr s" 2B Booting from hdd1" log-string cr
95                s" hdd1" add-boot-device ENDOF
96
97             HDD2  OF  \ cr s" 2B Booting from hdd2" log-string cr
98                s" hdd2" add-boot-device ENDOF
99
100             HDD3  OF  \ cr s" 2B Booting from hdd3" log-string cr
101                s" hdd3" add-boot-device ENDOF
102
103             CDROM OF  \ cr s" 2B Booting from CDROM" log-string cr
104                s" cdrom" add-boot-device ENDOF
105
106             HDD4  OF  \ cr s" 2B Booting from hdd4" log-string cr
107                s" hdd4" add-boot-device ENDOF
108
109             F  OF  \ cr s" 2B Booting from SAS - w. Timeout" log-string cr
110                 s" sas" add-boot-device ENDOF
111
112             SCSI  OF  \ cr s" 2B Booting from SAS - Continuous Retry" log-string cr
113                 s" sas" add-boot-device ENDOF
114
115          ENDCASE
116       LOOP
117       bootdevice 2@ nip
118       IF 0
119       ELSE
120          \ Check for all no device -> use boot-device  
121          vpd-bootlist l@ 07070707 = IF 0 ELSE -6b THEN 
122       THEN
123    ELSE -6a THEN
124    boot-exception-handler
125 ;
126
127 : vpd-bootlist-restore-default  ( -- )
128    NOTSPECIFIED vpd-bootlist 0 + c!
129    NOTSPECIFIED vpd-bootlist 1 + c!
130    NOTSPECIFIED vpd-bootlist 2 + c!
131    HDD0 vpd-bootlist 3 + c!
132    vpd-write-bootlist
133 ;
134