C H A P T E R 5

Loading and Executing Programs

The User Interface provides several methods for loading and executing a program. 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.

lists commands for loading files from various sources.

TABLE 5-1 File Loading Commands

Command

Stack Diagram

Description

?go

( -- )

Execute Forth, FCode or binary programs.

boot [specifiers] -h

( -- )

Load file from specified source.

byte-load

( addr span -- )

Interpret loaded FCode binary file. span is usually 1.

dl

( -- )

Load a Forth file over a serial line with a terminal emulator and interpret. Using tip as an example, type::
~C cat filename
^-D

dlbin

( -- )

Load a binary file over a serial line with a terminal emulator. Using tip as an example, type:

~C cat filename

dload filename

( addr -- )

Load the specified file over Ethernet at the given address.

eval

( addr len -- )

Interpret loaded Forth text file.

go

( -- )

Begin executing a previously-loaded binary program, or resume executing an interrupted program.

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

( -- addr )

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 example above, 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 OpenBoot 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 User Interface's symbolic debugging capability. (See Chapter 6 '' 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 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 ", 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, OpenBoot 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 a Serial Port

Forth programs loaded with dl must be ASCII files.

To load the file over the serial line, connect the system-under-test's serial port to a machine that is able to transfer a file on request, and start a terminal emulator on that system. The terminal emulator is then used to download the file using dl .

The following example assumes the use of the Unix terminal emulator tip . (See Appendix A ", for information on this procedure.)

1. At the ok prompt, type:

 ok dl 

2. 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 file is automatically interpreted after it is loaded, and the ok prompt re-appears on the screen of the system to which the file was loaded.


Using dlbin to Load FCode or Binary Over a Serial Port

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 ", for information on this procedure.)

1. At the ok prompt, type:

ok dlbin 

2. 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 

Copyright © 2001, Sun Microsystems, Inc. All rights reserved.