home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / PInterfaces / MachineExceptions.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  6.3 KB  |  244 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        MachineExceptions.p
  3.  
  4.      Contains:    Processor Exception Handling Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1993-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT MachineExceptions;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __MACHINEEXCEPTIONS__}
  27. {$SETC __MACHINEEXCEPTIONS__ := 1}
  28.  
  29. {$I+}
  30. {$SETC MachineExceptionsIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __MACTYPES__}
  34. {$I MacTypes.p}
  35. {$ENDC}
  36.  
  37.  
  38. {$PUSH}
  39. {$ALIGN POWER}
  40. {$LibExport+}
  41.  
  42. { Some basic declarations used throughout the kernel }
  43.  
  44. TYPE
  45.     AreaID = ^LONGINT;
  46. {$IFC TARGET_OS_MAC }
  47. { Machine Dependent types for PowerPC: }
  48.     MachineInformationPowerPCPtr = ^MachineInformationPowerPC;
  49.     MachineInformationPowerPC = RECORD
  50.         CTR:                    UnsignedWide;
  51.         LR:                        UnsignedWide;
  52.         PC:                        UnsignedWide;
  53.         CR:                        UInt32;
  54.         XER:                    UInt32;
  55.         MSR:                    UInt32;
  56.         MQ:                        UInt32;
  57.         ExceptKind:                UInt32;
  58.         DSISR:                    UInt32;
  59.         DAR:                    UnsignedWide;
  60.         Reserved:                UnsignedWide;
  61.     END;
  62.  
  63.     RegisterInformationPowerPCPtr = ^RegisterInformationPowerPC;
  64.     RegisterInformationPowerPC = RECORD
  65.         R0:                        UnsignedWide;
  66.         R1:                        UnsignedWide;
  67.         R2:                        UnsignedWide;
  68.         R3:                        UnsignedWide;
  69.         R4:                        UnsignedWide;
  70.         R5:                        UnsignedWide;
  71.         R6:                        UnsignedWide;
  72.         R7:                        UnsignedWide;
  73.         R8:                        UnsignedWide;
  74.         R9:                        UnsignedWide;
  75.         R10:                    UnsignedWide;
  76.         R11:                    UnsignedWide;
  77.         R12:                    UnsignedWide;
  78.         R13:                    UnsignedWide;
  79.         R14:                    UnsignedWide;
  80.         R15:                    UnsignedWide;
  81.         R16:                    UnsignedWide;
  82.         R17:                    UnsignedWide;
  83.         R18:                    UnsignedWide;
  84.         R19:                    UnsignedWide;
  85.         R20:                    UnsignedWide;
  86.         R21:                    UnsignedWide;
  87.         R22:                    UnsignedWide;
  88.         R23:                    UnsignedWide;
  89.         R24:                    UnsignedWide;
  90.         R25:                    UnsignedWide;
  91.         R26:                    UnsignedWide;
  92.         R27:                    UnsignedWide;
  93.         R28:                    UnsignedWide;
  94.         R29:                    UnsignedWide;
  95.         R30:                    UnsignedWide;
  96.         R31:                    UnsignedWide;
  97.     END;
  98.  
  99.     FPUInformationPowerPCPtr = ^FPUInformationPowerPC;
  100.     FPUInformationPowerPC = RECORD
  101.         Registers:                ARRAY [0..31] OF UnsignedWide;
  102.         FPSCR:                    UInt32;
  103.         Reserved:                UInt32;
  104.     END;
  105.  
  106.     Vector128Ptr = ^Vector128;
  107.     Vector128 = RECORD
  108.         CASE INTEGER OF
  109.         0: (
  110.             l:                    ARRAY [0..3] OF UInt32;
  111.             );
  112.         1: (
  113.             s:                    ARRAY [0..7] OF UInt16;
  114.             );
  115.         2: (
  116.             c:                    PACKED ARRAY [0..15] OF UInt8;
  117.             );
  118.     END;
  119.  
  120.     VectorInformationPowerPCPtr = ^VectorInformationPowerPC;
  121.     VectorInformationPowerPC = RECORD
  122.         Registers:                ARRAY [0..31] OF Vector128;
  123.         VSCR:                    Vector128;
  124.         VRsave:                    UInt32;
  125.     END;
  126.  
  127. { Exception related declarations }
  128.  
  129. CONST
  130.     kWriteReference                = 0;
  131.     kReadReference                = 1;
  132.     kFetchReference                = 2;
  133.     writeReference                = 0;                            {  Obsolete name }
  134.     readReference                = 1;                            {  Obsolete name }
  135.     fetchReference                = 2;                            {  Obsolete name }
  136.  
  137.  
  138. TYPE
  139.     MemoryReferenceKind                    = UInt32;
  140.     MemoryExceptionInformationPtr = ^MemoryExceptionInformation;
  141.     MemoryExceptionInformation = RECORD
  142.         theArea:                AreaID;
  143.         theAddress:                LogicalAddress;
  144.         theError:                OSStatus;
  145.         theReference:            MemoryReferenceKind;
  146.     END;
  147.  
  148.  
  149. CONST
  150.     kUnknownException            = 0;
  151.     kIllegalInstructionException = 1;
  152.     kTrapException                = 2;
  153.     kAccessException            = 3;
  154.     kUnmappedMemoryException    = 4;
  155.     kExcludedMemoryException    = 5;
  156.     kReadOnlyMemoryException    = 6;
  157.     kUnresolvablePageFaultException = 7;
  158.     kPrivilegeViolationException = 8;
  159.     kTraceException                = 9;
  160.     kInstructionBreakpointException = 10;
  161.     kDataBreakpointException    = 11;
  162.     kIntegerException            = 12;
  163.     kFloatingPointException        = 13;
  164.     kStackOverflowException        = 14;
  165.     kTaskTerminationException    = 15;
  166.     kTaskCreationException        = 16;
  167.  
  168. {$IFC OLDROUTINENAMES }
  169.     unknownException            = 0;                            {  Obsolete name }
  170.     illegalInstructionException    = 1;                            {  Obsolete name }
  171.     trapException                = 2;                            {  Obsolete name }
  172.     accessException                = 3;                            {  Obsolete name }
  173.     unmappedMemoryException        = 4;                            {  Obsolete name }
  174.     excludedMemoryException        = 5;                            {  Obsolete name }
  175.     readOnlyMemoryException        = 6;                            {  Obsolete name }
  176.     unresolvablePageFaultException = 7;                            {  Obsolete name }
  177.     privilegeViolationException    = 8;                            {  Obsolete name }
  178.     traceException                = 9;                            {  Obsolete name }
  179.     instructionBreakpointException = 10;                        {  Obsolete name }
  180.     dataBreakpointException        = 11;                            {  Obsolete name }
  181.     integerException            = 12;                            {  Obsolete name }
  182.     floatingPointException        = 13;                            {  Obsolete name }
  183.     stackOverflowException        = 14;                            {  Obsolete name }
  184.     terminationException        = 15;                            {  Obsolete name }
  185.     kTerminationException        = 15;                            {  Obsolete name }
  186.  
  187. {$ENDC}
  188.  
  189. TYPE
  190.     ExceptionKind                        = UInt32;
  191.     ExceptionInfoPtr = ^ExceptionInfo;
  192.     ExceptionInfo = RECORD
  193.         CASE INTEGER OF
  194.         0: (
  195.             memoryInfo:            MemoryExceptionInformationPtr;
  196.             );
  197.     END;
  198.  
  199.     ExceptionInformationPowerPCPtr = ^ExceptionInformationPowerPC;
  200.     ExceptionInformationPowerPC = RECORD
  201.         theKind:                ExceptionKind;
  202.         machineState:            MachineInformationPowerPCPtr;
  203.         registerImage:            RegisterInformationPowerPCPtr;
  204.         FPUImage:                FPUInformationPowerPCPtr;
  205.         info:                    ExceptionInfo;
  206.         vectorImage:            VectorInformationPowerPCPtr;
  207.     END;
  208.  
  209.     ExceptionInformation                = ExceptionInformationPowerPC;
  210.     ExceptionInformationPtr             = ^ExceptionInformation;
  211.     MachineInformation                    = MachineInformationPowerPC;
  212.     MachineInformationPtr                 = ^MachineInformation;
  213.     RegisterInformation                    = RegisterInformationPowerPC;
  214.     RegisterInformationPtr                 = ^RegisterInformation;
  215.     FPUInformation                        = FPUInformationPowerPC;
  216.     FPUInformationPtr                     = ^FPUInformation;
  217.     VectorInformation                    = VectorInformationPowerPC;
  218.     VectorInformationPtr                 = ^VectorInformation;
  219.     Note:    An ExceptionHandler is NOT a UniversalProcPtr.
  220.             It must be a PowerPC function pointer with NO routine descriptor. 
  221. }
  222. {$IFC TYPED_FUNCTION_POINTERS}
  223.     ExceptionHandler = FUNCTION(VAR theException: ExceptionInformationPowerPC): OSStatus; C;
  224. {$ELSEC}
  225.     ExceptionHandler = ProcPtr;
  226. {$ENDC}
  227.  
  228. { Routine for installing per-process exception handlers }
  229. FUNCTION InstallExceptionHandler(theHandler: ExceptionHandler): ExceptionHandler;
  230. {$ENDC}  {TARGET_OS_MAC}
  231.  
  232.  
  233. {$ALIGN RESET}
  234. {$POP}
  235.  
  236. {$SETC UsingIncludes := MachineExceptionsIncludes}
  237.  
  238. {$ENDC} {__MACHINEEXCEPTIONS__}
  239.  
  240. {$IFC NOT UsingIncludes}
  241.  END.
  242. {$ENDC}
  243.