intro − introduction to the standalone library The standalone library provides a set of the routines for use by standalone programs. These routines mimic many of the functions available under UNIX. Library routines are provided to perform i/o to consoles, disks, tapes, and ethernet. The standalone library consists of two parts: a run time startup module, typically located in /usr/lib/saio/crt0.o; and an archive of object modules, typically located in /usr/lib/saio/libc.a. The standalone command, will load against the standalone library automatically. If the load step is being done with the standalone loader, the startup module and archive must be specified explicitly, i.e.:
sald /usr/lib/saio/crt0.o other.o /usr/lib/saio/libc.a
The run time startup module performs initialization functions for the standalone library. This consists of initializing the global pointer register, initializing the standalone library fault handling, flushing the R2000 caches, copying the arguments and environment passed to the program, and checking if the debug monitor, dbgmon, should be loaded co-resident with the program. The standalone library provides support for dealing with R2000 detected exceptions. If a fault handler is not declared prior to a fault, the standalone library will field the fault, report the nature of the fault and the program counter at the time of the fault, and then terminate the programs executions and return to the prom monitor. A standalone program can declare a fault handler by setting the global variable "nofault" to the address of a jmp_buf, see setjmp(3spp). If nofault is non-zero, the standalone library will longjmp via the jmp_buf pointed to by nofault. "Nofault" is cleared while performing the longjmp, so once a fault has been taken, the fault handler must be re-enabled by again assigning a value to the global nofault. When a fault is taken the standalone library switches to second stack referred to as the "fault stack". The following integer global variables may be examined by the fault handler to determine the nature of the fault:
_epc_savepc at time of fault
_exc_saveexception vector type
Indicates if exception was via "utlbmiss",
general exception.
Literals EXCEPT_UTLB, and EXCEPT_NORM are
defined in <saio/saioctl.h>
_badvaddr_saveR2000 system coproc. badvaddr register
_cause_saveR2000 system coproc. cause register
_sp_savestack pointer at time of exception
_sr_saveR2000 system coproc. status register
_stack_modestack in use at time of exception
Literals MODE_NORMAL and MODE_FAULT are
defined in <saio/saioctl.h>
If the global _stack_mode is equal to MODE_NORMAL at the time of a fault, the contents of the R2000 registers are saved into the global integer array "_regs". This array may be subscripted with the literals "R_R0" .. "R_R31". These literals, and literals for offsets to other R2000 registers saved in the _regs array, are defined in <saio/saioctl.h>. The context that was interrupt by the exception may be resumed by calling the routine