Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / board-qemu / slof / qemu-bootlist.fs
1 \ *****************************************************************************
2 \ * Copyright (c) 2011 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 defer set-boot-device
14 defer add-boot-device
15
16 8 CONSTANT MAX-ALIAS
17 : add-boot-aliases ( str -- )
18     2dup add-boot-device               ( $str )
19     MAX-ALIAS 1 DO
20         2dup i $cathex 2dup              ( $str $strN $strN )
21         find-alias 0 > IF                ( $str $strN false | $result )
22             drop strdup add-boot-device  ( $str )
23         ELSE 2drop THEN
24     LOOP
25     2drop
26 ;
27
28 : qemu-read-bootlist ( -- )
29    \ See if QEMU has set exact boot device list
30    " qemu,boot-list" get-chosen IF
31         s" boot-device" $setenv
32         EXIT
33    THEN
34
35    0 0 set-boot-device
36
37    " qemu,boot-device" get-chosen not IF
38       \ No boot list set from qemu, so check nvram
39       " boot-device" evaluate swap drop 0= IF
40          \ Not set in nvram too, set default disk/cdrom alias
41          " disk" add-boot-aliases
42          " cdrom" add-boot-aliases
43          " net" add-boot-aliases
44       THEN
45       EXIT
46    THEN
47
48    0 ?DO
49        dup i + c@ CASE
50            0        OF ENDOF
51            [char] a OF ENDOF
52            [char] b OF ENDOF
53            [char] c OF " disk"  add-boot-aliases ENDOF
54            [char] d OF " cdrom" add-boot-aliases ENDOF
55            [char] n OF " net"   add-boot-aliases ENDOF
56        ENDCASE cr
57    LOOP
58    drop
59 ;
60
61 ' qemu-read-bootlist to read-bootlist