OpenBoot Command Reference Manual
  Search only this book
Download this book in PDF

Loading and Executing Programs

5

The Forth Monitor provides several methods for loading and executing a program on the machine. These methods load a file into memory from Ethernet, a hard disk, a floppy disk, and serial port A, and support the execution of Forth, FCode, and binary executable programs.
Commands for loading files from various sources are listed in Table 5-1.
Table 5-1
CommandStack DiagramDescription
?go( -- )Execute Forth, FCode or binary programs.
boot [specifiers] -h( -- )Load file from specified source.
byte-load( adr span -- )Interpret loaded FCode binary file. span is usually 1.
dl( -- )Load a Forth file over a serial line with TIP and interpret. Type: ~C cat filename

^-D

dlbin( -- )Load a binary file over a serial line with TIP.
Type: ~C cat filename
dload filename( adr -- )Load the specified file over Ethernet at the given address.
eval( adr len -- )Interpret loaded Forth text file.
go( -- )Begin executing a previously-loaded binary program, or resume executing an interrupted program.
Table 5-1
CommandStack DiagramDescription
init-program( -- )Initialize to execute a binary file.
load device-specifier argument( -- )Load data from specified device into memory at the address given by load-base.
load-base( -- adr )Address at which load places the data it reads from a device.

Using dload to Load from Ethernet

dload loads files over Ethernet at a specified address, as shown below.

  ok 4000 dload filename  

In the above example, filename must be relative to the server's root. Use 4000 (hex) as the address for dload input. dload uses the trivial file transfer protocol (TFTP), so the server may need to have its permissions adjusted for this to work.
Forth Programs Forth programs loaded with dload must be ASCII files beginning with the two characters "\ " (backslash and blank). To execute the loaded Forth program, type:

  ok 4000 file-size @ eval  

In the above example, file-size contains the size of the loaded image.
FCode Programs FCode programs loaded with dload must be a.out files. To execute the loaded FCode program, type:

  ok 4000 1 byte-load  

byte-load is used by the OpenBoot firmware to interpret FCode programs on expansion boards such as SBus. The 1 in the example is a specific value of a parameter that specifies the separation between FCode bytes in the general case. Since dload loads into system memory, 1 is the correct spacing.
Binary Executables Executable binary programs loaded with dload are a.out files and must be linked to run dload's input address (4000) or be position independent. To execute the binary program, type:

  ok go  

To run the program again, type:

  ok init-program go  

dload does not use intermediate booters (unlike the boot command). Thus, any symbol information included in the a.out file is available to the Forth Monitor's symbolic debugging capability. (See Chapter 6, "Debugging," for more information on symbolic debugging.)

Using boot to Load from Hard Disk, Floppy Disk, or Ethernet

You can also load and execute a program with boot, the command normally used to boot the operating system. boot has the following format:

  ok boot [device-specifier] [filename] -h  

device-specifier is either a full device path name or a device alias. (See Chapter 1, "Overview," for information on device path names and aliases.)
For a hard disk or floppy partition, filename is relative to the resident file system. (See Appendix B, "Building A Bootable Floppy Disk," for information on creating a bootable floppy disk.) For Ethernet, filename is relative to the system's root partition on its root server. In both cases, the leading / must be omitted from the file path.
The -h flag specifies that the program should be loaded, but not executed.
boot uses intermediate booters to accomplish its task. When loading from a hard disk or floppy disk, the OpenBoot firmware first loads the disk's boot block, which in turn loads a second-level booter. When loading over Ethernet, the firmware uses TFTP to load the second-level booter. filename and -h are passed to these intermediate booters.
Forth Programs Forth programs are ASCII source files that must be converted to the file format required by the secondary boot program. A utility called fakeboot is available from the SBus Support Group at Sun to perform this conversion. After the file is loaded into memory, it can be executed using the command eval.
For instance, if the file is loaded to address 0x4010, and runs for 934 bytes, type:

  ok 4010 d# 934 eval  

FCode Programs FCode programs produced by a Tokenizer (which creates FCode programs) may need to be converted to the file format of the secondary boot program. fakeboot may be useful in this process. Once the file is in memory, execute it using the byte-load command.
For example, assuming the file is loaded to address 0x4030, type:

  ok 4030 1 byte-load  

Binary Executables A binary program other than the operating system can also be loaded and executed as follows:

  ok go  

go is needed since the boot command includes -h.

Using dl to Load Forth Over Serial Port A

Forth programs loaded with dl must be ASCII files.
To load the file over the serial line, connect the system's serial port A to a machine that is able to transfer a file on request. One method is to set up a TIP window on another Sun system. (See Appendix A, "Setting Up a TIP Connection," for information on this procedure.) The following example assumes a TIP window setup.
  1. At the ok prompt, type:


   ok dl  

  1. In the TIP window of the other system, send the file, and follow it with a Control-D to signal the end of the file.


  ~C (local command) cat filename  
  (Away two seconds)  
  ^-D  

The ok prompt appears on the screen of the system to which the file is loaded.
dl normally loads the file at 4000 (hex). The file is automatically interpreted after it is loaded.

Using dlbin to Load FCode or Binary Over Serial Port A

FCode and binary programs loaded with dlbin must be a.out files. dlbin loads the files at the entry point indicated in the a.out header. Link binary files for 4000 (hex). Recent versions of the FCode Tokenizer create an a.out file with entry point 4000.
To load the file over the serial line, connect the system's serial port A to a machine that is able to transfer a file on request. The following example assumes a TIP window setup. (See Appendix A, "Setting Up a TIP Connection," for information on this procedure.)
  1. At the ok prompt, type:


  ok dlbin  

  1. In the TIP window of the other system, send the file:


  ~C (local command) cat filename  
  (Away two seconds)  

The ok prompt appears on the screen of the system to which the file is loaded.
To execute an FCode program, type:

  ok 4000 1 byte-load  
  ok  

To execute a binary program, type:

  ok go