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