|
|
1.1 ! root 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: s" obp-tftp" device-name ! 14: ! 15: INSTANCE VARIABLE ciregs-buffer ! 16: ! 17: : open ( -- okay? ) ! 18: ciregs-size alloc-mem ciregs-buffer ! ! 19: true ! 20: ; ! 21: ! 22: : load ( addr -- size ) ! 23: ! 24: \ Save old client interface register ! 25: ciregs ciregs-buffer @ ciregs-size move ! 26: ! 27: s" bootargs" get-chosen 0= IF 0 0 THEN >r >r ! 28: s" bootpath" get-chosen 0= IF 0 0 THEN >r >r ! 29: ! 30: \ Set bootpath to current device ! 31: my-parent ihandle>phandle node>path encode-string ! 32: s" bootpath" set-chosen ! 33: ! 34: \ Generate arg string for snk like ! 35: \ "netboot load-addr length filename" ! 36: (u.) s" netboot " 2swap $cat s" 60000000 " $cat ! 37: ! 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 ! 42: s" 1432 " $cat ! 43: \ Add OBP-TFTP Bootstring argument, e.g. "10.128.0.1,bootrom.bin,10.128.40.1" ! 44: my-args $cat ! 45: ! 46: \ Call SNK netboot loadr ! 47: (client-exec) dup 0< IF drop 0 THEN ! 48: ! 49: \ Restore to old client interface register ! 50: ciregs-buffer @ ciregs ciregs-size move ! 51: ! 52: \ Recover buffer address of BOOTP-REPLY packet ! 53: r> ! 54: ! 55: r> r> over IF s" bootpath" set-chosen ELSE 2drop THEN ! 56: r> r> over IF s" bootargs" set-chosen ELSE 2drop THEN ! 57: ! 58: \ Store BOOTP-REPLY packet as property ! 59: s" /chosen" select-dev ! 60: dup 6B8 encode-bytes s" bootp-response" property ! 61: device-end ! 62: ! 63: \ free buffer ! 64: 6B8 free-mem ! 65: ; ! 66: ! 67: : close ( -- ) ! 68: ciregs-buffer @ ciregs-size free-mem ! 69: ; ! 70: ! 71: : ping ( -- ) ! 72: s" ping " my-args $cat (client-exec) ! 73: ;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.