Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ () — UMIPS/BSD System Programmer's Package 2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

 

nofault − fault handling for standalone programs

#include <saio/saioctl.h>
int *nofault;

is a global variable that may be assigned the address of a
(see
If
is not zero, a longjmp will be made via the jmp_buf pointed
to by
should a fault occur.
is typically used in code sequences like:

#include <saio/setjmp.h>
#include <saio/saioctl.h>
jmp_buf jb;
extern int *nofault;
if (setjmp(jb)) {
/*
* control is transferred here after a fault,
* place fault handling code here
*/
} else {
/*
* setting nofault to address on jmp_buf enables
* longjmp to fault handler above, should fault
* occur
*/
nofault = jb;
/*
* code that may cause a fault goes here
*/
}
/* cancel special fault handling */
nofault = NULL;

is cleared while performing the longjmp, so once a fault has been taken, if necessary, the fault handler must be re-enabled by again assigning a value to the global variable When a fault is taken the standalone library switches to a second stack referred to as the "fault stack" and always saves a small amount of state for the fault handler to examine.  The following global integer 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", or
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>

Additional state beyond that shown above is saved, if the global variable is equal to at the time of a fault.  In this case, the contents of the R2000 registers are saved into the global integer array and is changed to If the floating point coprocessor was marked as usable in the R2000 status register at the time of a fault on the normal stack, it’s state is also saved into Further faults will not alter the array until is reassigned to is initialized to when a program is started.  The array may be subscripted with the literals R_R0 .. R_R31.  These literals, and literals for offsets to other R2000 registers saved in the array, are defined in <saio/saioctl.h>.  The context that is represented by the contents of may be resumed by calling the routine restores all R2000 registers from the contents of floating point coprocessor registers will be restored if the coprocessor is marked usable in the status register saved in Calling resets to setjmp(3spp)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026