home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / borhead.zip / BSEXCPT.H < prev    next >
C/C++ Source or Header  |  1994-11-09  |  12KB  |  359 lines

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