| 1 | \ ========== Copyright Header Begin ========================================== |
| 2 | \ |
| 3 | \ Hypervisor Software File: dload.fth |
| 4 | \ |
| 5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. |
| 6 | \ |
| 7 | \ - Do no alter or remove copyright notices |
| 8 | \ |
| 9 | \ - Redistribution and use of this software in source and binary forms, with |
| 10 | \ or without modification, are permitted provided that the following |
| 11 | \ conditions are met: |
| 12 | \ |
| 13 | \ - Redistribution of source code must retain the above copyright notice, |
| 14 | \ this list of conditions and the following disclaimer. |
| 15 | \ |
| 16 | \ - Redistribution in binary form must reproduce the above copyright notice, |
| 17 | \ this list of conditions and the following disclaimer in the |
| 18 | \ documentation and/or other materials provided with the distribution. |
| 19 | \ |
| 20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors |
| 21 | \ may be used to endorse or promote products derived from this software |
| 22 | \ without specific prior written permission. |
| 23 | \ |
| 24 | \ This software is provided "AS IS," without a warranty of any kind. |
| 25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, |
| 26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A |
| 27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN |
| 28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR |
| 29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR |
| 30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN |
| 31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR |
| 32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE |
| 33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, |
| 34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF |
| 35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
| 36 | \ |
| 37 | \ You acknowledge that this software is not designed, licensed or |
| 38 | \ intended for use in the design, construction, operation or maintenance of |
| 39 | \ any nuclear facility. |
| 40 | \ |
| 41 | \ ========== Copyright Header End ============================================ |
| 42 | id: @(#)dload.fth 1.14 01/05/29 |
| 43 | purpose: |
| 44 | copyright: Copyright 1990-2001 Sun Microsystems, Inc. All Rights Reserved |
| 45 | |
| 46 | \ Diagnostic loading feature. Directly loads a named file using TFTP, |
| 47 | \ instead of first loading the boot file that the server provides. |
| 48 | \ Also reads the symbol table if it is present. |
| 49 | \ The server must be configured for "non-secure" tftp; i.e. the tftp |
| 50 | \ daemon must be started without the "-s" flag. See /etc/inetd.conf |
| 51 | |
| 52 | headerless |
| 53 | : $strcat ( src$ dest$ -- dest+src$ ) |
| 54 | rot ( src dest dlen slen ) |
| 55 | 2dup + >r ( src dest dlen slen ) ( r: tlen ) |
| 56 | -rot ( src slen dest dlen ) ( r: tlen ) |
| 57 | over >r ( src slen dest dlen ) ( r: tlen dest ) |
| 58 | ca+ ( src slen dest+dlen ) ( r: tlen dest ) |
| 59 | swap cmove ( ) ( r: tlen dest ) |
| 60 | r> r> ( dest tlen ) |
| 61 | 2dup ca+ 0 swap c! ( dest+src$ ) |
| 62 | ; |
| 63 | d# 256 buffer: dload-buf |
| 64 | : (dload$) \ filename ( load-adr -- name$ ) |
| 65 | cleanup |
| 66 | is load-base optional-arg$ ( name$ ) |
| 67 | strip-blanks ( name$ ) |
| 68 | ?dup 0= if ( adr ) |
| 69 | p" "r"nUsage: <load-address> dload <filename> [ <args> ] "r"n" |
| 70 | throw |
| 71 | then ( name$ ) |
| 72 | ; |
| 73 | |
| 74 | headers |
| 75 | : $dload-read ( name$ dev$ -- ) |
| 76 | 2swap ( dev$ name$ ) |
| 77 | \ Replace every '/' with '|' |
| 78 | \ because arguments cannot include '/'s. |
| 79 | 2dup bounds ?do |
| 80 | i c@ ascii / = if ascii | i c! then |
| 81 | i c@ bl = ?leave |
| 82 | loop 2swap ( name$ dev$ ) |
| 83 | |
| 84 | \ Expand the device alias and stash it away |
| 85 | ?expand-alias dload-buf pack count ( name$ alias$ ) |
| 86 | |
| 87 | \ Get arguments to the network device (the last component of the |
| 88 | \ the device path) and format the argument list as follows: |
| 89 | \ - Add a ':' to the path if it isnt specified in the devalias |
| 90 | \ - If device arguments are present, and if the last argument |
| 91 | \ is "dhcp" or "bootp" without a trailing comma, add one. |
| 92 | \ - Append ',<filename>' at the end |
| 93 | |
| 94 | ascii / split-after 2drop ( name$ node$ ) |
| 95 | ascii : split-before 2drop ( name$ devargs$ ) |
| 96 | dup 0= if |
| 97 | 2drop " :" dload-buf $cat |
| 98 | else |
| 99 | + 4 - 4 2dup " dhcp" $= -rot " bootp" $= or if |
| 100 | " ," dload-buf $cat |
| 101 | then |
| 102 | then |
| 103 | " ," dload-buf $cat dload-buf $cat |
| 104 | |
| 105 | dload-buf count ( dev+name$ ) |
| 106 | |
| 107 | state-valid off ( dev+name$ ) |
| 108 | restartable? off ( dev+name$ ) |
| 109 | |
| 110 | $boot-read ( ) |
| 111 | ; |
| 112 | |
| 113 | : $dload ( name$ -- ) " net" $dload-read ; |
| 114 | |
| 115 | : dload \ filename ( load-addr -- ) |
| 116 | (dload$) " net" $dload-read |
| 117 | ; |
| 118 | headers |
| 119 | |