home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warptlk3.zip / TOOLKIT / H / BSEXCPT.H < prev    next >
C/C++ Source or Header  |  1995-08-30  |  12KB  |  359 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.  
  119. /*  Portable non-fatal software generated exceptions */
  120.  
  121. #define XCPT_GUARD_PAGE_VIOLATION       0x80000001
  122.       /* ExceptionInfo[ 0 ] - Access Code: XCPT_READ_ACCESS
  123.                                            XCPT_WRITE_ACCESS */
  124.       /* ExceptionInfo[ 1 ] - FaultAddr */
  125.  
  126. #define XCPT_UNABLE_TO_GROW_STACK       0x80010001
  127.  
  128. /*  Portable fatal hardware generated exceptions */
  129.  
  130. #define XCPT_DATATYPE_MISALIGNMENT      0xC000009E
  131.       /* ExceptionInfo[ 0 ] - Access Code: XCPT_READ_ACCESS
  132.                                            XCPT_WRITE_ACCESS */
  133.       /* ExceptionInfo[ 1 ] - Alignment */
  134.       /* ExceptionInfo[ 2 ] - FaultAddr */
  135.  
  136. #define XCPT_BREAKPOINT                 0xC000009F
  137. #define XCPT_SINGLE_STEP                0xC00000A0
  138. #define XCPT_ACCESS_VIOLATION           0xC0000005
  139.       /* ExceptionInfo[ 0 ] - Access Code: XCPT_READ_ACCESS
  140.                                            XCPT_WRITE_ACCESS
  141.                                            XCPT_SPACE_ACCESS
  142.                                            XCPT_LIMIT_ACCESS
  143.                                            XCPT_UNKNOWN_ACCESS */
  144.       /* ExceptionInfo[ 1 ] - FaultAddr (XCPT_READ_ACCESS/XCPT_WRITE_ACCESS)
  145.                               Selector  (XCPT_SPACE_ACCESS)
  146.                               -1        (XCPT_LIMIT_ACCESS) */
  147.  
  148. #define XCPT_ILLEGAL_INSTRUCTION        0xC000001C
  149. #define XCPT_FLOAT_DENORMAL_OPERAND     0xC0000094
  150. #define XCPT_FLOAT_DIVIDE_BY_ZERO       0xC0000095
  151. #define XCPT_FLOAT_INEXACT_RESULT       0xC0000096
  152. #define XCPT_FLOAT_INVALID_OPERATION    0xC0000097
  153. #define XCPT_FLOAT_OVERFLOW             0xC0000098
  154. #define XCPT_FLOAT_STACK_CHECK          0xC0000099
  155. #define XCPT_FLOAT_UNDERFLOW            0xC000009A
  156. #define XCPT_INTEGER_DIVIDE_BY_ZERO     0xC000009B
  157. #define XCPT_INTEGER_OVERFLOW           0xC000009C
  158. #define XCPT_PRIVILEGED_INSTRUCTION     0xC000009D
  159.  
  160. /*  Portable fatal software generated exceptions */
  161.  
  162. #define XCPT_IN_PAGE_ERROR              0xC0000006
  163.       /* ExceptionInfo[ 0 ] - FaultAddr */
  164.  
  165. #define XCPT_PROCESS_TERMINATE          0xC0010001
  166. #define XCPT_ASYNC_PROCESS_TERMINATE    0xC0010002
  167.       /* ExceptionInfo[ 0 ] - TID of 'terminator' thread */
  168.  
  169. #define XCPT_NONCONTINUABLE_EXCEPTION   0xC0000024
  170. #define XCPT_INVALID_DISPOSITION        0xC0000025
  171.  
  172. /*  Non-portable fatal exceptions */
  173.  
  174. #define XCPT_INVALID_LOCK_SEQUENCE      0xC000001D
  175. #define XCPT_ARRAY_BOUNDS_EXCEEDED      0xC0000093
  176. #define XCPT_B1NPX_ERRATA_02            0xC0010004
  177.  
  178. /*  Misc exceptions */
  179.  
  180. #define XCPT_UNWIND                     0xC0000026
  181. #define XCPT_BAD_STACK                  0xC0000027
  182. #define XCPT_INVALID_UNWIND_TARGET      0xC0000028
  183.  
  184. /*  Signal Exceptions */
  185.  
  186. #define XCPT_SIGNAL                     0xC0010003
  187.       /* ExceptionInfo[ 0 ] - Signal Number */
  188.  
  189. /*
  190.  * ContextRecord
  191.  *
  192.  * This is the machine specific register contents for the thread
  193.  * at the time of the exception. Note that only the register sets
  194.  * specified by ContextFlags contain valid data. Conversely, only
  195.  * registers specified in ContextFlags will be restored if an exception
  196.  * is handled.
  197.  */
  198.  
  199. /*  The following flags control the contents of the CONTEXT structure. */
  200.  
  201. #define CONTEXT_CONTROL         0x00000001L     /* SS:ESP, CS:EIP, EFLAGS,  */
  202.                                                 /* EBP                      */
  203. #define CONTEXT_INTEGER         0x00000002L     /* EAX, EBX, ECX, EDX, ESI, */
  204.                                                 /* EDI                      */
  205. #define CONTEXT_SEGMENTS        0x00000004L     /* DS, ES, FS, GS           */
  206. #define CONTEXT_FLOATING_POINT  0x00000008L     /* numeric coprocessor state */
  207.  
  208. #define CONTEXT_FULL            (CONTEXT_CONTROL | CONTEXT_INTEGER | \
  209.                                  CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT)
  210.  
  211. /*XLATOFF */
  212. #pragma pack(1)
  213. /*XLATON  */
  214. typedef struct  _fpreg      /* coprocessor stack register element */
  215.    {
  216.    ULONG losig;
  217.    ULONG hisig;
  218.    USHORT signexp;
  219.    } FPREG , *PFPREG ;
  220. #pragma pack()
  221.  
  222. struct _CONTEXT
  223.    {
  224.   /*
  225.    * The flags values within this flag control the contents of
  226.    * a ContextRecord.
  227.    *
  228.    * If the ContextRecord is used as an input parameter, then
  229.    * for each portion of the ContextRecord controlled by a flag
  230.    * whose value is set, it is assumed that that portion of the
  231.    * ContextRecord contains valid context. If the ContextRecord
  232.    * is being used to modify a thread's context, then only that
  233.    * portion of the thread's context will be modified.
  234.    *
  235.    * If the ContextRecord is used as an Input/Output parameter to
  236.    * capture the context of a thread, then only those portions of the
  237.    * thread's context corresponding to set flags will be returned.
  238.    */
  239.  
  240.    ULONG ContextFlags;
  241.  
  242.   /*
  243.    * This section is specified/returned if the ContextFlags
  244.    * contains the flag CONTEXT_FLOATING_POINT.
  245.    */
  246.  
  247.    ULONG   ctx_env[7];
  248.    FPREG   ctx_stack[8];
  249.  
  250.   /*
  251.    * This section is specified/returned if the ContextFlags
  252.    * contains the flag CONTEXT_SEGMENTS.
  253.    */
  254.  
  255.    ULONG ctx_SegGs;
  256.    ULONG ctx_SegFs;
  257.    ULONG ctx_SegEs;
  258.    ULONG ctx_SegDs;
  259.  
  260.   /*
  261.    * This section is specified/returned if the ContextFlags
  262.    * contains the flag CONTEXT_INTEGER.
  263.    */
  264.  
  265.    ULONG ctx_RegEdi;
  266.    ULONG ctx_RegEsi;
  267.    ULONG ctx_RegEax;
  268.    ULONG ctx_RegEbx;
  269.    ULONG ctx_RegEcx;
  270.    ULONG ctx_RegEdx;
  271.  
  272.   /*
  273.    * This section is specified/returned if the ContextFlags
  274.    * contains the flag CONTEXT_CONTROL.
  275.    */
  276.  
  277.    ULONG ctx_RegEbp;
  278.    ULONG ctx_RegEip;
  279.    ULONG ctx_SegCs;
  280.    ULONG ctx_EFlags;
  281.    ULONG ctx_RegEsp;
  282.    ULONG ctx_SegSs;
  283.  
  284.    };
  285.  
  286. typedef struct _CONTEXT CONTEXTRECORD;
  287. typedef struct _CONTEXT *PCONTEXTRECORD;
  288.  
  289.  
  290. /*
  291.  * ExceptionReportRecord
  292.  *
  293.  * This structure contains machine independant information about an
  294.  * exception/unwind. No system exception will ever have more than
  295.  * EXCEPTION_MAXIMUM_PARAMETERS parameters. User exceptions are not
  296.  * bound to this limit.
  297.  */
  298.  
  299.  
  300. #define EXCEPTION_MAXIMUM_PARAMETERS 4  /* Enough for all system exceptions. */
  301.  
  302. struct _EXCEPTIONREPORTRECORD
  303.    {
  304.    ULONG   ExceptionNum;                /* exception number */
  305.    ULONG   fHandlerFlags;
  306.    struct  _EXCEPTIONREPORTRECORD    *NestedExceptionReportRecord;
  307.    PVOID   ExceptionAddress;
  308.    ULONG   cParameters;                 /* Size of Exception Specific Info */
  309.    ULONG   ExceptionInfo[EXCEPTION_MAXIMUM_PARAMETERS];
  310.                                         /* Exception Specfic Info */
  311.    };
  312.  
  313. typedef struct _EXCEPTIONREPORTRECORD EXCEPTIONREPORTRECORD;
  314. typedef struct _EXCEPTIONREPORTRECORD *PEXCEPTIONREPORTRECORD;
  315.  
  316. /*
  317.  * ExceptionRegistrationRecord
  318.  *
  319.  * These are linked together to form a chain of exception handlers that
  320.  * will be dispatched to upon receipt of an exception.
  321.  */
  322.  
  323.  
  324. struct _EXCEPTIONREGISTRATIONRECORD;
  325.  
  326. typedef ULONG APIENTRY _ERR(PEXCEPTIONREPORTRECORD,
  327.                             struct _EXCEPTIONREGISTRATIONRECORD *,
  328.                             PCONTEXTRECORD,
  329.                             PVOID);
  330.  
  331. typedef _ERR  *ERR;
  332.  
  333. struct _EXCEPTIONREGISTRATIONRECORD
  334.    {
  335.    struct _EXCEPTIONREGISTRATIONRECORD * volatile prev_structure;
  336.    _ERR * volatile ExceptionHandler;
  337.    };
  338.  
  339. typedef struct _EXCEPTIONREGISTRATIONRECORD EXCEPTIONREGISTRATIONRECORD;
  340. typedef struct _EXCEPTIONREGISTRATIONRECORD *PEXCEPTIONREGISTRATIONRECORD;
  341.  
  342. /* End of exception chain marker. */
  343.  
  344. #define END_OF_CHAIN        ((PEXCEPTIONREGISTRATIONRECORD) -1)
  345. #pragma pack()
  346.  
  347. #endif /* __BSEXCPT__ */
  348.  
  349. #ifdef __cplusplus
  350.         }
  351. #endif
  352. #if __IBMC__ || __IBMCPP__
  353. #pragma info( none )
  354.    #ifndef __CHKHDR__
  355.       #pragma info( restore )
  356.    #endif
  357. #pragma info( restore )
  358. #endif
  359.