CPSC-410/611 Operating Systems
1
Exceptions, MIPS-Style
- Reminder:
– MIPS CPU deals with exceptions.
- Interrupts are just a special case of exceptions.
– The MIPS Architecture has no interrupt-vector table!
- All exceptions trigger a jump to the same location, and de-
multiplexing happens in the exception handler, after looking up the reason for the exception in the CAUSE register.
exception handler specific service routine exception
Exception Handling MIPS-Style (I): Data Structures
/*-----------------------------------------------------------------------*/ /* DATA STRUCTURES */ /*-----------------------------------------------------------------------*/ typedef enum {Int = 0, Mod = 1, TLBL = 2, TLBS = 3, AdEL = 4, AdES = 5, IBE = 6, DBE = 7, Syscall = 8, Bp = 9, RI = 10, CpU = 11, Ov = 12, TRAP = 13, VCEI = 14, FPE = 15, C2E = 16, Watch = 23, VCED = 31} EXCEPTION_CODE; typedef unsigned int reg_t; typedef struct xcptcontext { /* This is the exception context frame that is passed to the exception
- handlers. It gets filled in by the low-level exception handler in
"machine.S". An assembler version of this structure can be found at the bottom of "machine.H".*/ reg_t sr; /* Status Register */ reg_t cr; /* Cause Register */ reg_t epc; /* PC at time of exception. */ reg_t vaddr; reg_t regs[32]; /* Copy of all general purpose registers */ reg_t mdlo; /* HI/LO registers (used for memory management) */ reg_t mdhi; reg_t count; /* Timer registers */ reg_t compare; struct xcptcontext * prev; /* To link exceptions. (unused for now) */ unsigned xclass; /* Priority class of this exception. (unused for now). */ } EXCEPTION_CONTEXT;
xcptlow_handler set up exception frame
- n stack
save enough registers to get by save rest of registers call C exception handler restore registers return from exception