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 s" obp-tftp" device-name
15 INSTANCE VARIABLE ciregs-buffer
18 ciregs-size alloc-mem ciregs-buffer !
22 : load ( addr -- size )
24 \ Save old client interface register
25 ciregs ciregs-buffer @ ciregs-size move
27 s" bootargs" get-chosen 0= IF 0 0 THEN >r >r
28 s" bootpath" get-chosen 0= IF 0 0 THEN >r >r
30 \ Set bootpath to current device
31 my-parent ihandle>phandle node>path encode-string
32 s" bootpath" set-chosen
34 \ Generate arg string for snk like
35 \ "netboot load-addr length filename"
36 (u.) s" netboot " 2swap $cat s" 60000000 " $cat
38 \ Allocate 1720 bytes to store the BOOTP-REPLY packet
39 6B8 alloc-mem dup >r (u.) $cat s" " $cat
40 huge-tftp-load @ IF s" 1 " ELSE s" 0 " THEN $cat
41 \ Add desired TFTP-Blocksize as additional argument
43 \ Add OBP-TFTP Bootstring argument, e.g. "10.128.0.1,bootrom.bin,10.128.40.1"
46 \ Call SNK netboot loadr
47 (client-exec) dup 0< IF drop 0 THEN
49 \ Restore to old client interface register
50 ciregs-buffer @ ciregs ciregs-size move
52 \ Recover buffer address of BOOTP-REPLY packet
55 r> r> over IF s" bootpath" set-chosen ELSE 2drop THEN
56 r> r> over IF s" bootargs" set-chosen ELSE 2drop THEN
58 \ Store BOOTP-REPLY packet as property
59 dup 6B8 encode-bytes s" bootp-response" s" /chosen" find-node set-property
66 ciregs-buffer @ ciregs-size free-mem
70 s" ping " my-args $cat (client-exec)