home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warphead.zip / H / BSEXCPT.H < prev    next >
C/C++ Source or Header  |  1997-08-17  |  12KB  |  360 lines

  1. /*      SCCSID = @(#)bsexcpt.h  6.9 92/03/15 */
  2.  
  3. /*************************** START OF SPECIFICATION *****************
  4.  *
  5.  * Source File Name: bsexcpt.h
  6.  *
  7.  * Descriptive Name: Thread Exception Constants and Structure Definitions.
  8.  *
  9.  * Copyright: IBM Corp. 1989  - 1992
  10.  *
  11.  * Function: This file provides constants and data structure
  12.  *      definitions required by application programs to use 32 bit
  13.  *      thread exceptions management facility.
  14.  *
  15.  * Notes: None.
  16.  *
  17.  *************************** END OF SPECIFICATION *******************/
  18.  
  19. #if __IBMC__ || __IBMCPP__
  20. #pragma info( none )
  21.    #ifndef __CHKHDR__
  22.       #pragma info( none )
  23.    #endif
  24. #pragma info( restore )
  25. #endif
  26. #ifdef __cplusplus
  27.       extern "C" {
  28. #endif
  29.  
  30. #ifndef __BSEXCPT__
  31. #define __BSEXCPT__
  32.  
  33. /*
  34.  * User Exception Handler Return Codes:
  35.  */
  36.  
  37. #define XCPT_CONTINUE_SEARCH    0x00000000      /* exception not handled   */
  38. #define XCPT_CONTINUE_EXECUTION 0xFFFFFFFF      /* exception handled       */
  39. #define XCPT_CONTINUE_STOP      0x00716668      /* exception handled by    */
  40.                                                 /* debugger (VIA DosDebug) */
  41.  
  42. /*
  43.  * fHandlerFlags values (see ExceptionReportRecord):
  44.  *
  45.  * The user may only set (but not clear) the EH_NONCONTINUABLE flag.
  46.  * All other flags are set by the system.
  47.  *
  48.  */
  49.  
  50. #define EH_NONCONTINUABLE   0x1          /* Noncontinuable exception */
  51. #define EH_UNWINDING        0x2          /* Unwind is in progress */
  52. #define EH_EXIT_UNWIND      0x4          /* Exit unwind is in progress */
  53. #define EH_STACK_INVALID    0x8          /* Stack out of limits or unaligned */
  54. #define EH_NESTED_CALL      0x10         /* Nested exception handler call */
  55.  
  56.  
  57. /*
  58.  * Unwind all exception handlers (see DosUnwindException API)
  59.  */
  60. #define UNWIND_ALL              0
  61.  
  62.  
  63. /*
  64.  *   Exception values are 32 bit values layed out as follows:
  65.  *
  66.  *   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  67.  *   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  68.  *   +---+-+-------------------------+-------------------------------+
  69.  *   |Sev|C|       Facility          |               Code            |
  70.  *   +---+-+-------------------------+-------------------------------+
  71.  *
  72.  *   where
  73.  *
  74.  *       Sev - is the severity code
  75.  *           00 - Success
  76.  *           01 - Informational
  77.  *           10 - Warning
  78.  *           11 - Error
  79.  *
  80.  *       C - is the Customer code flag
  81.  *
  82.  *       Facility - is the facility code
  83.  *
  84.  *       Code - is the facility's status code
  85.  *
  86.  *   Exceptions specific to OS/2 2.0 (e.g. XCPT_SIGNAL) will be marked
  87.  *   with a facility code of 1.
  88.  *
  89.  *   System defined exceptions have a facility code of zero.
  90.  *
  91.  *   Each exception may also have several pieces of additional information.
  92.  *   These are stored in the ExceptionInfo fields of the
  93.  *   ExceptionReportRecord. They are documented here with the exceptions
  94.  *   only for ease of reference.
  95.  */
  96.  
  97. #define XCPT_FATAL_EXCEPTION    0xC0000000
  98. #define XCPT_SEVERITY_CODE      0xC0000000
  99. #define XCPT_CUSTOMER_CODE      0x20000000
  100. #define XCPT_FACILITY_CODE      0x1FFF0000
  101. #define XCPT_EXCEPTION_CODE     0x0000FFFF
  102.  
  103. /*  Violation flags in ExceptionInfo */
  104.  
  105. #define XCPT_UNKNOWN_ACCESS     0x00000000      /* Unknown access */
  106. #define XCPT_READ_ACCESS        0x00000001      /* Read access    */
  107. #define XCPT_WRITE_ACCESS       0x00000002      /* Write access   */
  108. #define XCPT_EXECUTE_ACCESS     0x00000004      /* Execute access */
  109. #define XCPT_SPACE_ACCESS       0x00000008      /* Address space access */
  110. #define XCPT_LIMIT_ACCESS       0x00000010      /* Address space limit violation */
  111. #define XCPT_DATA_UNKNOWN       0xFFFFFFFF
  112.  
  113. /*  Signal numbers for XCPT_SIGNAL */
  114.  
  115. #define XCPT_SIGNAL_INTR        1
  116. #define XCPT_SIGNAL_KILLPROC    3
  117. #define XCPT_SIGNAL_BREAK       4
  118. #define XCPT_SIGNAL_APTERM      8
  119.  
  120. /*  Portable non-fatal software generated exceptions */
  121.  
  122. #define XCPT_GUARD_PAGE_VIOLATION       0x80000001
  123.       /* ExceptionInfo[ 0 ] - Access Code: XCPT_READ_ACCESS
  124.                                            XCPT_WRITE_ACCESS */
  125.       /* ExceptionInfo[ 1 ] - FaultAddr */
  126.  
  127. #define XCPT_UNABLE_TO_GROW_STACK       0x80010001
  128.  
  129. /*  Portable fatal hardware generated exceptions */
  130.  
  131. #define XCPT_DATATYPE_MISALIGNMENT      0xC000009E
  132.       /* ExceptionInfo[ 0 ] - Access Code: XCPT_READ_ACCESS
  133.                                            XCPT_WRITE_ACCESS */
  134.       /* ExceptionInfo[ 1 ] - Alignment */
  135.       /* ExceptionInfo[ 2 ] - FaultAddr */
  136.  
  137. #define XCPT_BREAKPOINT                 0xC000009F
  138. #define XCPT_SINGLE_STEP                0xC00000A0
  139. #define XCPT_ACCESS_VIOLATION           0xC0000005
  140.       /* ExceptionInfo[ 0 ] - Access Code: XCPT_READ_ACCESS
  141.                                            XCPT_WRITE_ACCESS
  142.                                            XCPT_SPACE_ACCESS
  143.                                            XCPT_LIMIT_ACCESS
  144.                                            XCPT_UNKNOWN_ACCESS */
  145.       /* ExceptionInfo[ 1 ] - FaultAddr (XCPT_READ_ACCESS/XCPT_WRITE_ACCESS)
  146.                               Selector  (XCPT_SPACE_ACCESS)
  147.                               -1        (XCPT_LIMIT_ACCESS) */
  148.  
  149. #define XCPT_ILLEGAL_INSTRUCTION        0xC000001C
  150. #define XCPT_FLOAT_DENORMAL_OPERAND     0xC0000094
  151. #define XCPT_FLOAT_DIVIDE_BY_ZERO       0xC0000095
  152. #define XCPT_FLOAT_INEXACT_RESULT       0xC0000096
  153. #define XCPT_FLOAT_INVALID_OPERATION    0xC0000097
  154. #define XCPT_FLOAT_OVERFLOW             0xC0000098
  155. #define XCPT_FLOAT_STACK_CHECK          0xC0000099
  156. #define XCPT_FLOAT_UNDERFLOW            0xC000009A
  157. #define XCPT_INTEGER_DIVIDE_BY_ZERO     0xC000009B
  158. #define XCPT_INTEGER_OVERFLOW           0xC000009C
  159. #define XCPT_PRIVILEGED_INSTRUCTION     0xC000009D
  160.  
  161. /*  Portable fatal software generated exceptions */
  162.  
  163. #define XCPT_IN_PAGE_ERROR              0xC0000006
  164.       /* ExceptionInfo[ 0 ] - FaultAddr */
  165.  
  166. #define XCPT_PROCESS_TERMINATE          0xC0010001
  167. #define XCPT_ASYNC_PROCESS_TERMINATE    0xC0010002
  168.       /* ExceptionInfo[ 0 ] - TID of 'terminator' thread */
  169.  
  170. #define XCPT_NONCONTINUABLE_EXCEPTION   0xC0000024
  171. #define XCPT_INVALID_DISPOSITION        0xC0000025
  172.  
  173. /*  Non-portable fatal exceptions */
  174.  
  175. #define XCPT_INVALID_LOCK_SEQUENCE      0xC000001D
  176. #define XCPT_ARRAY_BOUNDS_EXCEEDED      0xC0000093
  177. #define XCPT_B1NPX_ERRATA_02            0xC0010004
  178.  
  179. /*  Misc exceptions */
  180.  
  181. #define XCPT_UNWIND                     0xC0000026
  182. #define XCPT_BAD_STACK                  0xC0000027
  183. #define XCPT_INVALID_UNWIND_TARGET      0xC0000028
  184.  
  185. /*  Signal Exceptions */
  186.  
  187. #define XCPT_SIGNAL                     0xC0010003
  188.       /* ExceptionInfo[ 0 ] - Signal Number */
  189.  
  190. /*
  191.  * ContextRecord
  192.  *
  193.  * This is the machine specific register contents for the thread
  194.  * at the time of the exception. Note that only the register sets
  195.  * specified by ContextFlags contain valid data. Conversely, only
  196.  * registers specified in ContextFlags will be restored if an exception
  197.  * is handled.
  198.  */
  199.  
  200. /*  The following flags control the contents of the CONTEXT structure. */
  201.  
  202. #define CONTEXT_CONTROL         0x00000001L     /* SS:ESP, CS:EIP, EFLAGS,  */
  203.                                                 /* EBP                      */
  204. #define CONTEXT_INTEGER         0x00000002L     /* EAX, EBX, ECX, EDX, ESI, */
  205.                                                 /* EDI                      */
  206. #define CONTEXT_SEGMENTS        0x00000004L     /* DS, ES, FS, GS           */
  207. #define CONTEXT_FLOATING_POINT  0x00000008L     /* numeric coprocessor state */
  208.  
  209. #define CONTEXT_FULL            (CONTEXT_CONTROL | CONTEXT_INTEGER | \
  210.                                  CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT)
  211.  
  212. /*XLATOFF */
  213. #pragma pack(1)
  214. /*XLATON  */
  215. typedef struct  _fpreg      /* coprocessor stack register element */
  216.    {
  217.    ULONG losig;
  218.    ULONG hisig;
  219.    USHORT signexp;
  220.    } FPREG , *PFPREG ;
  221. #pragma pack()
  222.  
  223. struct _CONTEXT
  224.    {
  225.   /*
  226.    * The flags values within this flag control the contents of
  227.    * a ContextRecord.
  228.    *
  229.    * If the ContextRecord is used as an input parameter, then
  230.    * for each portion of the ContextRecord controlled by a flag
  231.    * whose value is set, it is assumed that that portion of the
  232.    * ContextRecord contains valid context. If the ContextRecord
  233.    * is being used to modify a thread's context, then only that
  234.    * portion of the thread's context will be modified.
  235.    *
  236.    * If the ContextRecord is used as an Input/Output parameter to
  237.    * capture the context of a thread, then only those portions of the
  238.    * thread's context corresponding to set flags will be returned.
  239.    */
  240.  
  241.    ULONG ContextFlags;
  242.  
  243.   /*
  244.    * This section is specified/returned if the ContextFlags
  245.    * contains the flag CONTEXT_FLOATING_POINT.
  246.    */
  247.  
  248.    ULONG   ctx_env[7];
  249.    FPREG   ctx_stack[8];
  250.  
  251.   /*
  252.    * This section is specified/returned if the ContextFlags
  253.    * contains the flag CONTEXT_SEGMENTS.
  254.    */
  255.  
  256.    ULONG ctx_SegGs;
  257.    ULONG ctx_SegFs;
  258.    ULONG ctx_SegEs;
  259.    ULONG ctx_SegDs;
  260.  
  261.   /*
  262.    * This section is specified/returned if the ContextFlags
  263.    * contains the flag CONTEXT_INTEGER.
  264.    */
  265.  
  266.    ULONG ctx_RegEdi;
  267.    ULONG ctx_RegEsi;
  268.    ULONG ctx_RegEax;
  269.    ULONG ctx_RegEbx;
  270.    ULONG ctx_RegEcx;
  271.    ULONG ctx_RegEdx;
  272.  
  273.   /*
  274.    * This section is specified/returned if the ContextFlags
  275.    * contains the flag CONTEXT_CONTROL.
  276.    */
  277.  
  278.    ULONG ctx_RegEbp;
  279.    ULONG ctx_RegEip;
  280.    ULONG ctx_SegCs;
  281.    ULONG ctx_EFlags;
  282.    ULONG ctx_RegEsp;
  283.    ULONG ctx_SegSs;
  284.  
  285.    };
  286.  
  287. typedef struct _CONTEXT CONTEXTRECORD;
  288. typedef struct _CONTEXT *PCONTEXTRECORD;
  289.  
  290.  
  291. /*
  292.  * ExceptionReportRecord
  293.  *
  294.  * This structure contains machine independant information about an
  295.  * exception/unwind. No system exception will ever have more than
  296.  * EXCEPTION_MAXIMUM_PARAMETERS parameters. User exceptions are not
  297.  * bound to this limit.
  298.  */
  299.  
  300.  
  301. #define EXCEPTION_MAXIMUM_PARAMETERS 4  /* Enough for all system exceptions. */
  302.  
  303. struct _EXCEPTIONREPORTRECORD
  304.    {
  305.    ULONG   ExceptionNum;                /* exception number */
  306.    ULONG   fHandlerFlags;
  307.    struct  _EXCEPTIONREPORTRECORD    *NestedExceptionReportRecord;
  308.    PVOID   ExceptionAddress;
  309.    ULONG   cParameters;                 /* Size of Exception Specific Info */
  310.    ULONG   ExceptionInfo[EXCEPTION_MAXIMUM_PARAMETERS];
  311.                                         /* Exception Specfic Info */
  312.    };
  313.  
  314. typedef struct _EXCEPTIONREPORTRECORD EXCEPTIONREPORTRECORD;
  315. typedef struct _EXCEPTIONREPORTRECORD *PEXCEPTIONREPORTRECORD;
  316.  
  317. /*
  318.  * ExceptionRegistrationRecord
  319.  *
  320.  * These are linked together to form a chain of exception handlers that
  321.  * will be dispatched to upon receipt of an exception.
  322.  */
  323.  
  324.  
  325. struct _EXCEPTIONREGISTRATIONRECORD;
  326.  
  327. typedef ULONG APIENTRY _ERR(PEXCEPTIONREPORTRECORD,
  328.                             struct _EXCEPTIONREGISTRATIONRECORD *,
  329.                             PCONTEXTRECORD,
  330.                             PVOID);
  331.  
  332. typedef _ERR  *ERR;
  333.  
  334. struct _EXCEPTIONREGISTRATIONRECORD
  335.    {
  336.    struct _EXCEPTIONREGISTRATIONRECORD * volatile prev_structure;
  337.    _ERR * volatile ExceptionHandler;
  338.    };
  339.  
  340. typedef struct _EXCEPTIONREGISTRATIONRECORD EXCEPTIONREGISTRATIONRECORD;
  341. typedef struct _EXCEPTIONREGISTRATIONRECORD *PEXCEPTIONREGISTRATIONRECORD;
  342.  
  343. /* End of exception chain marker. */
  344.  
  345. #define END_OF_CHAIN        ((PEXCEPTIONREGISTRATIONRECORD) -1)
  346. #pragma pack()
  347.  
  348. #endif /* __BSEXCPT__ */
  349.  
  350. #ifdef __cplusplus
  351.         }
  352. #endif
  353. #if __IBMC__ || __IBMCPP__
  354. #pragma info( none )
  355.    #ifndef __CHKHDR__
  356.       #pragma info( restore )
  357.    #endif
  358. #pragma info( restore )
  359. #endif
  360.