The Exception module is a basic C64+ exception handler. It is generally
considered to be a program endpoint, since an exception usually
indicates something fatal to the system.
During initialization, the Exception module sets TSR.GEE and TSR.XEN to
enable the CPU to recognize the EXECP input.
Function hooks are provided to the user for hooking in their own functions
at different points of an exception. The hook functions are called in the
following order:
(1) exceptionHook - called whenever an exception occurs.
(2) internalHook - called only when an internal exception occurs.
(3) externalHook - called only when an external exception occurs.
(4) nmiHook - called only when a legacy NMI occurs.
(5) returnHook - called whenever an exception occurs.
const Exception_ECREXF |
|
EXCEP flag
const Exception_ECRIXF |
|
Internal exception flag
const Exception_ECRNXF |
|
NMI exception flag
const Exception_ECRSXF |
|
Software exception flag
const Exception_EFREXF |
|
EXCEP flag
#define Exception_EFREXF (Bits32)0x40000000
const Exception_EFRIXF |
|
Internal exception flag
#define Exception_EFRIXF (Bits32)0x00000002
const Exception_EFRNXF |
|
NMI exception flag
#define Exception_EFRNXF (Bits32)0x80000000
const Exception_EFRSXF |
|
Software exception flag
#define Exception_EFRSXF (Bits32)0x00000001
const Exception_IERREPX |
|
Execute packet exception
#define Exception_IERREPX (Bits32)0x00000004
const Exception_IERRFPX |
|
Fetch packet exception
#define Exception_IERRFPX (Bits32)0x00000002
const Exception_IERRIFX |
|
Instruction fetch exception
#define Exception_IERRIFX (Bits32)0x00000001
const Exception_IERRLBX |
|
Loop buffer exception
#define Exception_IERRLBX (Bits32)0x00000080
const Exception_IERRMSX |
|
Missed stall exception
#define Exception_IERRMSX (Bits32)0x00000100
const Exception_IERROPX |
|
Opcode exception
#define Exception_IERROPX (Bits32)0x00000008
const Exception_IERRPRX |
|
Priviledge exception
#define Exception_IERRPRX (Bits32)0x00000040
const Exception_IERRRAX |
|
Resource access exeption
#define Exception_IERRRAX (Bits32)0x00000020
const Exception_IERRRCX |
|
Resource conflict exception
#define Exception_IERRRCX (Bits32)0x00000010
const Exception_TSRCXM |
|
Current execution mode bits
#define Exception_TSRCXM (Bits32)0x000000C0
const Exception_TSRCXMSHIFT |
|
TSR.CXM left shift value
#define Exception_TSRCXMSHIFT (Bits32)6
const Exception_TSRCXMSV |
|
Supervisor mode
#define Exception_TSRCXMSV (Bits32)0x00000000
const Exception_TSRCXMUS |
|
User mode
#define Exception_TSRCXMUS (Bits32)0x00000040
const Exception_TSREXC |
|
Exception processing
#define Exception_TSREXC (Bits32)0x00000400
const Exception_TSRGEE |
|
Global exception enable
#define Exception_TSRGEE (Bits32)0x00000004
const Exception_TSRXEN |
|
External exception enable
#define Exception_TSRXEN (Bits32)0x00000008
const Exception_sizeContextBuf |
|
#define Exception_sizeContextBuf (UInt32)320
typedef Exception_FuncPtr |
|
FuncPtr - Hook function type definition
typedef Void (*Exception_FuncPtr)(Void);
struct Exception_Status |
|
Status - structure filled by getLastStatus()
typedef struct Exception_Status {
Bits32 efr;
// Exception flag register
Bits32 nrp;
// NMI return pointer register
Bits32 ntsr;
// NMI/Exception task state register
Bits32 ierr;
// Internal Exception report register
// Context structure filled by last exception
} Exception_Status;
config Exception_E_exceptionMax // module-wide |
|
Error raised when Exception.enablePrint is true
extern const Error_Id Exception_E_exceptionMax;
config Exception_E_exceptionMin // module-wide |
|
Error raised when Exception.enablePrint is false
extern const Error_Id Exception_E_exceptionMin;
config Exception_enableExternalMPC // module-wide |
|
enableExternalMPC - Enable handling of Memory Protection
Controller (MPC) exceptions
extern const Bool Exception_enableExternalMPC;
config Exception_enablePrint // module-wide |
|
enablePrint - Enable print of exception details and Register values
extern const Bool Exception_enablePrint;
config Exception_exceptionHook // module-wide |
|
exceptionHook - Function hook called by handler
This is called anytime an exception occurs
config Exception_externalHook // module-wide |
|
externalHook - Function hook called by externalHandler
Function is only called when an external exception has occurred
config Exception_internalHook // module-wide |
|
internalHook - Function hook called by internalHandler
Function is only called when an internal exception has occurred
config Exception_nmiHook // module-wide |
|
nmiHook - Function hook called by nmiHandler
Function is called for legacy NMI exceptions only
config Exception_returnHook // module-wide |
|
returnHook - Function hook called at the end of Exception_dispatch
config Exception_useInternalBuffer // module-wide |
|
If true, the exception context is saved to an internal buffer.
If false, the exception context is saved to the bottom of the isr stack
and no memory for the internal buffer is allocated
extern const Bool Exception_useInternalBuffer;
Exception_clearLastStatus() // module-wide |
|
clearLastStatus - Clears internal Status structure
Void Exception_clearLastStatus();
Exception_evtEvtClear() // module-wide |
|
evtEvtClear - Clear a C64+ event from the EVTFLAG register
Void Exception_evtEvtClear(UInt event);
Exception_evtExpMaskEnable() // module-wide |
|
evtExpMaskEnable - Enable a C64+ event to generate an exception
Void Exception_evtExpMaskEnable(UInt event);
Exception_getLastStatus() // module-wide |
|
getLastStatus - Fills passed status structure with the Status
fields that were recorded by the last invocation of
dispatch(), handler() and internalHandler().
The 'excContext' is valid only in the scope of sub-handler
"Hook" functions
Exception_setReturnPtr() // module-wide |
|
setReturnPtr - Configures dispatch() to "return" (branch) to the
passed ptr
Module-Wide Built-Ins |
|
// Get this module's unique id
Bool Exception_Module_startupDone();
// Test if this module has completed startup
// The heap from which this module allocates memory
Bool Exception_Module_hasMask();
// Test whether this module has a diagnostics mask
Bits16 Exception_Module_getMask();
// Returns the diagnostics mask for this module
Void Exception_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
const Exception.ECREXF |
|
EXCEP flag
C SYNOPSIS
const Exception.ECRIXF |
|
Internal exception flag
C SYNOPSIS
const Exception.ECRNXF |
|
NMI exception flag
C SYNOPSIS
const Exception.ECRSXF |
|
Software exception flag
C SYNOPSIS
const Exception.EFREXF |
|
EXCEP flag
const Exception.EFREXF = 0x40000000;
C SYNOPSIS
const Exception.EFRIXF |
|
Internal exception flag
const Exception.EFRIXF = 0x00000002;
C SYNOPSIS
const Exception.EFRNXF |
|
NMI exception flag
const Exception.EFRNXF = 0x80000000;
C SYNOPSIS
const Exception.EFRSXF |
|
Software exception flag
const Exception.EFRSXF = 0x00000001;
C SYNOPSIS
const Exception.IERREPX |
|
Execute packet exception
const Exception.IERREPX = 0x00000004;
C SYNOPSIS
const Exception.IERRFPX |
|
Fetch packet exception
const Exception.IERRFPX = 0x00000002;
C SYNOPSIS
const Exception.IERRIFX |
|
Instruction fetch exception
const Exception.IERRIFX = 0x00000001;
C SYNOPSIS
const Exception.IERRLBX |
|
Loop buffer exception
const Exception.IERRLBX = 0x00000080;
C SYNOPSIS
const Exception.IERRMSX |
|
Missed stall exception
const Exception.IERRMSX = 0x00000100;
C SYNOPSIS
const Exception.IERROPX |
|
Opcode exception
const Exception.IERROPX = 0x00000008;
C SYNOPSIS
const Exception.IERRPRX |
|
Priviledge exception
const Exception.IERRPRX = 0x00000040;
C SYNOPSIS
const Exception.IERRRAX |
|
Resource access exeption
const Exception.IERRRAX = 0x00000020;
C SYNOPSIS
const Exception.IERRRCX |
|
Resource conflict exception
const Exception.IERRRCX = 0x00000010;
C SYNOPSIS
const Exception.TSRCXM |
|
Current execution mode bits
const Exception.TSRCXM = 0x000000C0;
C SYNOPSIS
const Exception.TSRCXMSHIFT |
|
TSR.CXM left shift value
const Exception.TSRCXMSHIFT = 6;
C SYNOPSIS
const Exception.TSRCXMSV |
|
Supervisor mode
const Exception.TSRCXMSV = 0x00000000;
C SYNOPSIS
const Exception.TSRCXMUS |
|
User mode
const Exception.TSRCXMUS = 0x00000040;
C SYNOPSIS
const Exception.TSREXC |
|
Exception processing
const Exception.TSREXC = 0x00000400;
C SYNOPSIS
const Exception.TSRGEE |
|
Global exception enable
const Exception.TSRGEE = 0x00000004;
C SYNOPSIS
const Exception.TSRXEN |
|
External exception enable
const Exception.TSRXEN = 0x00000008;
C SYNOPSIS
const Exception.sizeContextBuf |
|
const Exception.sizeContextBuf = 320;
C SYNOPSIS
struct Exception.Status |
|
Status - structure filled by getLastStatus()
var obj = new Exception.Status;
obj.efr = Bits32 ...
// Exception flag register
obj.nrp = Bits32 ...
// NMI return pointer register
obj.ntsr = Bits32 ...
// NMI/Exception task state register
obj.ierr = Bits32 ...
// Internal Exception report register
// Context structure filled by last exception
C SYNOPSIS
config Exception.E_exceptionMax // module-wide |
|
Error raised when Exception.enablePrint is true
msg: "E_exceptionMax: pc = 0x%08x, sp = 0x%08x."
};
C SYNOPSIS
config Exception.E_exceptionMin // module-wide |
|
Error raised when Exception.enablePrint is false
msg: "E_exceptionMin: pc = 0x%08x, sp = 0x%08x.\nTo see more exception detail, use ROV or set 'ti.sysbios.family.c64p.Exception.enablePrint = true;'"
};
C SYNOPSIS
config Exception.enableExternalMPC // module-wide |
|
enableExternalMPC - Enable handling of Memory Protection
Controller (MPC) exceptions
Exception.enableExternalMPC = Bool false;
C SYNOPSIS
config Exception.enablePrint // module-wide |
|
enablePrint - Enable print of exception details and Register values
Exception.enablePrint = Bool true;
C SYNOPSIS
config Exception.exceptionHook // module-wide |
|
exceptionHook - Function hook called by handler
This is called anytime an exception occurs
Exception.exceptionHook = Void(*)(Void) null;
C SYNOPSIS
config Exception.externalHook // module-wide |
|
externalHook - Function hook called by externalHandler
Function is only called when an external exception has occurred
Exception.externalHook = Void(*)(Void) null;
C SYNOPSIS
config Exception.internalHook // module-wide |
|
internalHook - Function hook called by internalHandler
Function is only called when an internal exception has occurred
Exception.internalHook = Void(*)(Void) null;
C SYNOPSIS
config Exception.nmiHook // module-wide |
|
nmiHook - Function hook called by nmiHandler
Function is called for legacy NMI exceptions only
Exception.nmiHook = Void(*)(Void) null;
C SYNOPSIS
config Exception.returnHook // module-wide |
|
returnHook - Function hook called at the end of Exception_dispatch
Exception.returnHook = Void(*)(Void) null;
C SYNOPSIS
config Exception.useInternalBuffer // module-wide |
|
If true, the exception context is saved to an internal buffer.
If false, the exception context is saved to the bottom of the isr stack
and no memory for the internal buffer is allocated
Exception.useInternalBuffer = Bool false;
C SYNOPSIS
metaonly config Exception.common$ // module-wide |
|
Common module configuration parameters
DETAILS
All modules have this configuration parameter. Its name
contains the '$' character to ensure it does not conflict with
configuration parameters declared by the module. This allows
new configuration parameters to be added in the future without
any chance of breaking existing modules.