Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC System Software /
Chapter 4 - Exception Manager


Summary of the Exception Manager

C Summary

Constants

enum {
   /*exception codes*/
   unknownException                    = 0,     /*unknown exception type*/
   illegalInstructionException         = 1,     /*illegal instruction*/
   trapException                       = 2,     /*unknown trap type*/
   accessException                     = 3,     /*failed memory access*/
   unmappedMemoryException             = 4,     /*memory is unmapped*/
   excludedMemoryException             = 5,     /*memory is excluded*/
   readOnlyMemoryException             = 6,     /*memory is read-only*/
   unresolvablePageFaultException      = 7,     /*unresolvable page fault*/
   privilegeViolationException         = 8,     /*privilege violation*/
   traceException                      = 9,     /*trace*/
   instructionBreakpointException      = 10,    /*instruction breakpoint*/
   dataBreakpointException             = 11,    /*data breakpoint*/
   integerException                    = 12,    /*unused*/
   floatingPointException              = 13,    /*floating point*/
   stackOverflowException              = 14,    /*stack overflow*/
   terminationException                = 15     /*task is being terminated*/
};
enum {
   /*memory reference codes*/
   writeReference                      = 0,     /*write operation*/
   readReference                       = 1,     /*read operation*/
   fetchReference                      = 2      /*fetch operation*/
};

Data Types

typedef unsigned long         ExceptionKind;    /*kind of exception*/
typedef unsigned long         MemoryReferenceKind;
typedef void                  *Ref;
typedef Ref                   AreaID;
typedef Ref                   LogicalAddress;
struct UnsignedWide {
   unsigned long              hi;
   unsigned long              lo;
};
typedef struct UnsignedWide UnsignedWide;
struct RegisterInformation {
   UnsignedWide         R0;
   UnsignedWide         R1;
   UnsignedWide         R2;
   UnsignedWide         R3;
   UnsignedWide         R4;
   UnsignedWide         R5;
   UnsignedWide         R6;
   UnsignedWide         R7;
   UnsignedWide         R8;
   UnsignedWide         R9;
   UnsignedWide         R10;
   UnsignedWide         R11;
   UnsignedWide         R12;
   UnsignedWide         R13;
   UnsignedWide         R14;
   UnsignedWide         R15;
   UnsignedWide         R16;
   UnsignedWide         R17;
   UnsignedWide         R18;
   UnsignedWide         R19;
   UnsignedWide         R20;
   UnsignedWide         R21;
   UnsignedWide         R22;
   UnsignedWide         R23;
   UnsignedWide         R24;
   UnsignedWide         R25;
   UnsignedWide         R26;
   UnsignedWide         R27;
   UnsignedWide         R28;
   UnsignedWide         R29;
   UnsignedWide         R30;
   UnsignedWide         R31;
};
typedef struct RegisterInformation RegisterInformation;
typedef long                  OSStatus;
typedef OSStatus (*ExceptionHandler) (ExceptionInformation *theException);
struct MachineInformation {
   UnsignedWide                     CTR;  /*Count Register*/
   UnsignedWide                     LR;   /*Link Register*/
   UnsignedWide                     PC;   /*Program Counter Register*/
   unsigned long                    CR;   /*Condition Register*/
   unsigned long                    XER;  /*Fixed-Point Exception Register*/
   unsigned long                    MSR;  /*Machine State Register*/
};
typedef struct MachineInformation MachineInformation;
struct FPUInformation {
   UnsignedWide                     Registers[32]; /*FPU registers*/
   unsigned long                    FPSCR;         /*status/control reg*/
};
typedef struct FPUInformation FPUInformation;
struct MemoryExceptionInformation {
   AreaID                           theArea;
   LogicalAddress                   theAddress;
   OSStatus                         theError;
   MemoryReferenceKind              theReference;
};
typedef struct MemoryExceptionInformation MemoryExceptionInformation;
struct ExceptionInformation {
   ExceptionKind                    theKind;
   MachineInformation               *machineState;
   RegisterInformation              *registerImage;
   FPUInformation                   *FPUImage;
   union {
      MemoryExceptionInformation    *memoryInfo;
   } info;
};
typedef struct ExceptionInformation ExceptionInformation;

Exception Manager Routines

Installing Exception Handlers

extern ExceptionHandler InstallExceptionHandler
            (ExceptionHandler theHandler);

Application-Defined Routines

Exception Handlers

OSStatus MyExceptionHandler
            (ExceptionInformation *theException);


Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996