Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / slof / fs / sms / sms-load.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 false VALUE (sms-loaded?)
14
15 false value (sms-available?)
16
17 s" sms.fs" romfs-lookup IF true to (sms-available?) drop THEN
18
19 (sms-available?) [IF]
20
21 #include "packages/sms.fs"
22
23 \ Initialize SMS NVRAM handling.
24 #include "sms-nvram.fs"
25
26 \ Dynamically load sms code from the romfs file
27 \ Assumption is that skeleton sms package already exists
28 \ but aside of open & close, all other methods are in a romfs file (sms.fs)
29 \ Here we open the package and load the rest of the functionality
30
31 \ After that, one needs to find-device and execute sms-start method
32 \ The shorthand for that is given as (global) sms-start word
33
34 : $sms-node s" /packages/sms" ;
35
36 : (sms-init-package) ( -- true|false )
37    (sms-loaded?) ?dup IF EXIT THEN
38    $sms-node ['] find-device catch IF 2drop false EXIT THEN
39    s" sms.fs" [COMPILE] included
40    device-end
41    true dup to (sms-loaded?)
42 ;
43
44 \ External wrapper for sms package method
45 : (sms-evaluate) ( addr len -- )
46    (sms-init-package) not IF
47       cr ." SMS is not available." cr 2drop exit
48    THEN
49
50    s" Entering SMS ..." type
51    disable-watchdog
52    reset-dual-emit
53
54    \ if we only had execute-device-method...
55    2>r $sms-node find-device
56    2r> evaluate
57    device-end
58    vpd-boot-import
59 ;
60
61 : sms-start ( -- ) s" sms-start" (sms-evaluate) ;
62 : sms-fru-replacement ( -- ) s" sms-fru-replacement" (sms-evaluate) ;
63
64 [ELSE]
65
66 : sms-start ( -- ) cr ." SMS is not available." cr ;
67 : sms-fru-replacement ( -- ) cr ." SMS FRU replacement is not available." cr ;
68
69 [THEN]
70