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
10 \ * IBM Corporation - initial implementation
11 \ ****************************************************************************/
13 \ \\\\\\\\\\\\\\ Global Data
14 CREATE bootdevice 2 cells allot bootdevice 2 cells erase
15 CREATE bootargs 2 cells allot bootargs 2 cells erase
16 CREATE load-list 2 cells allot load-list 2 cells erase
18 : start-elf ( arg len entry -- )
19 msr@ 7fffffffffffffff and 2000 or ciregs >srr1 ! call-client
22 : start-elf64 ( arg len entry r2 -- )
23 msr@ 2000 or ciregs >srr1 !
25 call-client \ entry point is pointer to .opd
30 dup IF ELSE drop s" boot-device" evaluate find-alias THEN
31 dup IF strdup ELSE 0 THEN
32 encode-string s" bootpath" set-chosen
37 ?dup IF strdup encode-string s" bootpath" set-chosen THEN
41 skipws 0 parse dup 0= IF
42 2drop s" boot-file" evaluate
44 encode-string s" bootargs" set-chosen
47 : .(client-exec) ( arg len -- rc )
48 s" snk" romfs-lookup 0<> IF
49 \ Load SNK client 15 MiB after Paflof... FIXME: Hard-coded offset is ugly!
51 elf-load-file-to-addr drop \ FIXME - check this for LE, currently its BE only
52 dup @ swap 8 + @ \ populate entry r2
53 start-elf64 client-data
58 ' .(client-exec) to (client-exec)
60 : .client-exec ( arg len -- rc ) set-bootargs (client-exec) ;
61 ' .client-exec to client-exec
63 : netflash ( -- rc ) s" netflash 2000000 " (parse-line) $cat set-netbootpath
67 : netsave ( "addr len {filename}[,params]" -- rc )
68 (parse-line) dup 0> IF
69 s" netsave " 2swap $cat set-netbootpath client-exec
72 ." Usage: netsave addr len [bootp|dhcp,]filename[,siaddr][,ciaddr][,giaddr][,bootp-retries][,tftp-retries][,use_ci]"
77 : ping ( "{device-path:[device-args,]server-ip,[client-ip],[gateway-ip][,timeout]}" -- )
78 my-self >r current-node @ >r \ Save my-self
79 (parse-line) open-dev dup IF
80 dup to my-self dup ihandle>phandle set-node
82 s" ping" rot ['] $call-method CATCH IF
84 ." Not a pingable device"
90 ." Usage: ping device-path:[device-args,]server-ip,[client-ip],[gateway-ip][,timeout]"
93 r> set-node r> to my-self \ Restore my-self