MachineExceptions.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:10k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       MachineExceptions.h
  3.  
  4.      Contains:   Processor Exception Handling Interfaces.
  5.  
  6.      Version:    Technology: Mac OS 8
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1993-2001 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. #ifndef __MACHINEEXCEPTIONS__
  18. #define __MACHINEEXCEPTIONS__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #ifndef __MIXEDMODE__
  23. #include "MixedMode.h"
  24. #endif
  25. #if PRAGMA_ONCE
  26. #pragma once
  27. #endif
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #if PRAGMA_IMPORT
  32. #pragma import on
  33. #endif
  34. #if PRAGMA_STRUCT_ALIGN
  35.     #pragma options align=power
  36. #elif PRAGMA_STRUCT_PACKPUSH
  37.     #pragma pack(push, 2)
  38. #elif PRAGMA_STRUCT_PACK
  39.     #pragma pack(2)
  40. #endif
  41. /* Some basic declarations used throughout the kernel */
  42. typedef struct OpaqueAreaID*            AreaID;
  43. #if TARGET_OS_MAC
  44. /* Machine Dependent types for PowerPC: */
  45. struct MachineInformationPowerPC {
  46.     UnsignedWide                    CTR;
  47.     UnsignedWide                    LR;
  48.     UnsignedWide                    PC;
  49.     unsigned long                   CR;
  50.     unsigned long                   XER;
  51.     unsigned long                   MSR;
  52.     unsigned long                   MQ;
  53.     unsigned long                   ExceptKind;
  54.     unsigned long                   DSISR;
  55.     UnsignedWide                    DAR;
  56.     UnsignedWide                    Reserved;
  57. };
  58. typedef struct MachineInformationPowerPC MachineInformationPowerPC;
  59. struct RegisterInformationPowerPC {
  60.     UnsignedWide                    R0;
  61.     UnsignedWide                    R1;
  62.     UnsignedWide                    R2;
  63.     UnsignedWide                    R3;
  64.     UnsignedWide                    R4;
  65.     UnsignedWide                    R5;
  66.     UnsignedWide                    R6;
  67.     UnsignedWide                    R7;
  68.     UnsignedWide                    R8;
  69.     UnsignedWide                    R9;
  70.     UnsignedWide                    R10;
  71.     UnsignedWide                    R11;
  72.     UnsignedWide                    R12;
  73.     UnsignedWide                    R13;
  74.     UnsignedWide                    R14;
  75.     UnsignedWide                    R15;
  76.     UnsignedWide                    R16;
  77.     UnsignedWide                    R17;
  78.     UnsignedWide                    R18;
  79.     UnsignedWide                    R19;
  80.     UnsignedWide                    R20;
  81.     UnsignedWide                    R21;
  82.     UnsignedWide                    R22;
  83.     UnsignedWide                    R23;
  84.     UnsignedWide                    R24;
  85.     UnsignedWide                    R25;
  86.     UnsignedWide                    R26;
  87.     UnsignedWide                    R27;
  88.     UnsignedWide                    R28;
  89.     UnsignedWide                    R29;
  90.     UnsignedWide                    R30;
  91.     UnsignedWide                    R31;
  92. };
  93. typedef struct RegisterInformationPowerPC RegisterInformationPowerPC;
  94. struct FPUInformationPowerPC {
  95.     UnsignedWide                    Registers[32];
  96.     unsigned long                   FPSCR;
  97.     unsigned long                   Reserved;
  98. };
  99. typedef struct FPUInformationPowerPC    FPUInformationPowerPC;
  100. union Vector128 {
  101. #ifdef __VEC__
  102.  vector unsigned long            v;
  103. #endif
  104.     unsigned long                   l[4];
  105.     unsigned short                  s[8];
  106.     unsigned char                   c[16];
  107. };
  108. typedef union Vector128                 Vector128;
  109. struct VectorInformationPowerPC {
  110.     Vector128                       Registers[32];
  111.     Vector128                       VSCR;
  112.     UInt32                          VRsave;
  113. };
  114. typedef struct VectorInformationPowerPC VectorInformationPowerPC;
  115. /* Exception related declarations */
  116. enum {
  117.     kWriteReference             = 0,
  118.     kReadReference              = 1,
  119.     kFetchReference             = 2,
  120.     writeReference              = kWriteReference,              /* Obsolete name*/
  121.     readReference               = kReadReference,               /* Obsolete name*/
  122.     fetchReference              = kFetchReference               /* Obsolete name*/
  123. };
  124. typedef unsigned long                   MemoryReferenceKind;
  125. struct MemoryExceptionInformation {
  126.     AreaID                          theArea;
  127.     LogicalAddress                  theAddress;
  128.     OSStatus                        theError;
  129.     MemoryReferenceKind             theReference;
  130. };
  131. typedef struct MemoryExceptionInformation MemoryExceptionInformation;
  132. enum {
  133.     kUnknownException           = 0,
  134.     kIllegalInstructionException = 1,
  135.     kTrapException              = 2,
  136.     kAccessException            = 3,
  137.     kUnmappedMemoryException    = 4,
  138.     kExcludedMemoryException    = 5,
  139.     kReadOnlyMemoryException    = 6,
  140.     kUnresolvablePageFaultException = 7,
  141.     kPrivilegeViolationException = 8,
  142.     kTraceException             = 9,
  143.     kInstructionBreakpointException = 10,
  144.     kDataBreakpointException    = 11,
  145.     kIntegerException           = 12,
  146.     kFloatingPointException     = 13,
  147.     kStackOverflowException     = 14,
  148.     kTaskTerminationException   = 15,
  149.     kTaskCreationException      = 16,
  150.     kDataAlignmentException     = 17
  151. };
  152. #if OLDROUTINENAMES
  153. enum {
  154.     unknownException            = kUnknownException,            /* Obsolete name*/
  155.     illegalInstructionException = kIllegalInstructionException, /* Obsolete name*/
  156.     trapException               = kTrapException,               /* Obsolete name*/
  157.     accessException             = kAccessException,             /* Obsolete name*/
  158.     unmappedMemoryException     = kUnmappedMemoryException,     /* Obsolete name*/
  159.     excludedMemoryException     = kExcludedMemoryException,     /* Obsolete name*/
  160.     readOnlyMemoryException     = kReadOnlyMemoryException,     /* Obsolete name*/
  161.     unresolvablePageFaultException = kUnresolvablePageFaultException, /* Obsolete name*/
  162.     privilegeViolationException = kPrivilegeViolationException, /* Obsolete name*/
  163.     traceException              = kTraceException,              /* Obsolete name*/
  164.     instructionBreakpointException = kInstructionBreakpointException, /* Obsolete name*/
  165.     dataBreakpointException     = kDataBreakpointException,     /* Obsolete name*/
  166.     integerException            = kIntegerException,            /* Obsolete name*/
  167.     floatingPointException      = kFloatingPointException,      /* Obsolete name*/
  168.     stackOverflowException      = kStackOverflowException,      /* Obsolete name*/
  169.     terminationException        = kTaskTerminationException,    /* Obsolete name*/
  170.     kTerminationException       = kTaskTerminationException     /* Obsolete name*/
  171. };
  172. #endif  /* OLDROUTINENAMES */
  173. typedef unsigned long                   ExceptionKind;
  174. union ExceptionInfo {
  175.     MemoryExceptionInformation *    memoryInfo;
  176. };
  177. typedef union ExceptionInfo             ExceptionInfo;
  178. struct ExceptionInformationPowerPC {
  179.     ExceptionKind                   theKind;
  180.     MachineInformationPowerPC *     machineState;
  181.     RegisterInformationPowerPC *    registerImage;
  182.     FPUInformationPowerPC *         FPUImage;
  183.     ExceptionInfo                   info;
  184.     VectorInformationPowerPC *      vectorImage;
  185. };
  186. typedef struct ExceptionInformationPowerPC ExceptionInformationPowerPC;
  187. #if TARGET_CPU_PPC || TARGET_CPU_68K
  188. typedef ExceptionInformationPowerPC     ExceptionInformation;
  189. typedef MachineInformationPowerPC       MachineInformation;
  190. typedef RegisterInformationPowerPC      RegisterInformation;
  191. typedef FPUInformationPowerPC           FPUInformation;
  192. typedef VectorInformationPowerPC        VectorInformation;
  193. #endif  /* TARGET_CPU_PPC || TARGET_CPU_68K */
  194. /* 
  195.     Note:   An ExceptionHandler is NOT a UniversalProcPtr, except in Carbon.
  196.             It must be a PowerPC function pointer with NO routine descriptor, 
  197.             except on Carbon, where it must be a UniversalProcPtr (TPP actually)
  198.             to allow the interface to work from both CFM and Mach-O.
  199. */
  200. typedef CALLBACK_API_C( OSStatus , ExceptionHandlerProcPtr )(ExceptionInformation *theException);
  201. typedef TVECTOR_UPP_TYPE(ExceptionHandlerProcPtr)               ExceptionHandlerUPP;
  202. #if OPAQUE_UPP_TYPES
  203.     EXTERN_API(ExceptionHandlerUPP)
  204.     NewExceptionHandlerUPP         (ExceptionHandlerProcPtr userRoutine);
  205.     EXTERN_API(void)
  206.     DisposeExceptionHandlerUPP     (ExceptionHandlerUPP     userUPP);
  207.     EXTERN_API(OSStatus)
  208.     InvokeExceptionHandlerUPP      (ExceptionInformation *  theException,
  209.                                     ExceptionHandlerUPP     userUPP);
  210. #else
  211.     #define NewExceptionHandlerUPP(userRoutine)                     (userRoutine)
  212.     #define DisposeExceptionHandlerUPP(userUPP)                     
  213.     #define InvokeExceptionHandlerUPP(theException, userUPP)        (*userUPP)(theException)
  214. #endif
  215. /*
  216.    ExceptionHandler function pointers (TPP):
  217.    on classic PowerPC, use raw function pointers
  218.    on classic PowerPC with OPAQUE_UPP_TYPES=1, use UPP's
  219.    on Carbon, use UPP's
  220. */
  221. #if TARGET_OS_MAC && !OPAQUE_UPP_TYPES
  222. /* use raw function pointers*/
  223. typedef ExceptionHandlerProcPtr         ExceptionHandlerTPP;
  224. #else
  225. /* use UPP's*/
  226. typedef ExceptionHandlerUPP             ExceptionHandlerTPP;
  227. #endif  /* TARGET_OS_MAC && !OPAQUE_UPP_TYPES */
  228. typedef ExceptionHandlerTPP             ExceptionHandler;
  229. /* Routine for installing per-process exception handlers */
  230. EXTERN_API( ExceptionHandlerTPP ) InstallExceptionHandler(ExceptionHandlerTPP theHandler);
  231. #endif  /* TARGET_OS_MAC */
  232. #if PRAGMA_STRUCT_ALIGN
  233.     #pragma options align=reset
  234. #elif PRAGMA_STRUCT_PACKPUSH
  235.     #pragma pack(pop)
  236. #elif PRAGMA_STRUCT_PACK
  237.     #pragma pack()
  238. #endif
  239. #ifdef PRAGMA_IMPORT_OFF
  240. #pragma import off
  241. #elif PRAGMA_IMPORT
  242. #pragma import reset
  243. #endif
  244. #ifdef __cplusplus
  245. }
  246. #endif
  247. #endif /* __MACHINEEXCEPTIONS__ */