home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v1.zip / DDKX86 / IBMH / BSEXCPT.H < prev    next >
C/C++ Source or Header  |  1995-04-14  |  13KB  |  363 lines

  1. /*DDK*************************************************************************/
  2. /*                                                                           */
  3. /* COPYRIGHT    Copyright (C) 1995 IBM Corporation                           */
  4. /*                                                                           */
  5. /*    The following IBM OS/2 WARP source code is provided to you solely for  */
  6. /*    the purpose of assisting you in your development of OS/2 WARP device   */
  7. /*    drivers. You may use this code in accordance with the IBM License      */
  8. /*    Agreement provided in the IBM Device Driver Source Kit for OS/2. This  */
  9. /*    Copyright statement may not be removed.                                */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12. /*      SCCSID = @(#)bsexcpt.h    6.9 92/03/15 */
  13.  
  14. /*************************** START OF SPECIFICATION *****************
  15.  *
  16.  * Source File Name: bsexcpt.h
  17.  *
  18.  * Descriptive Name: Thread Exception Constants and Structure Definitions.
  19.  *
  20.  *
  21.  * Function: This file provides constants and data structure
  22.  *      definitions required by application programs to use 32 bit
  23.  *      thread exceptions management facility.
  24.  *
  25.  * Notes: None.
  26.  *
  27.  *************************** END OF SPECIFICATION *******************/
  28.  
  29. #ifdef __IBMC__
  30. #pragma checkout( suspend )
  31.    #ifndef __CHKHDR__
  32.       #pragma checkout( suspend )
  33.    #endif
  34. #pragma checkout( resume )
  35. #endif
  36.  
  37. #ifndef __BSEXCPT__
  38. #define __BSEXCPT__
  39.  
  40. /*
  41.  * User Exception Handler Return Codes:
  42.  */
  43.  
  44. #define XCPT_CONTINUE_SEARCH    0x00000000      /* exception not handled   */
  45. #define XCPT_CONTINUE_EXECUTION 0xFFFFFFFF      /* exception handled       */
  46. #define XCPT_CONTINUE_STOP      0x00716668      /* exception handled by    */
  47.                                                 /* debugger (VIA DosDebug) */
  48.  
  49. /*
  50.  * fHandlerFlags values (see ExceptionReportRecord):
  51.  *
  52.  * The user may only set (but not clear) the EH_NONCONTINUABLE flag.
  53.  * All other flags are set by the system.
  54.  *
  55.  */
  56.  
  57. #define EH_NONCONTINUABLE   0x1          /* Noncontinuable exception */
  58. #define EH_UNWINDING        0x2          /* Unwind is in progress */
  59. #define EH_EXIT_UNWIND      0x4          /* Exit unwind is in progress */
  60. #define EH_STACK_INVALID    0x8          /* Stack out of limits or unaligned */
  61. #define EH_NESTED_CALL      0x10         /* Nested exception handler call */
  62.  
  63.  
  64. /*
  65.  * Unwind all exception handlers (see DosUnwindException API)
  66.  */
  67. #define UNWIND_ALL              0
  68.  
  69.  
  70. /*
  71.  *   Exception values are 32 bit values layed out as follows:
  72.  *
  73.  *   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  74.  *   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
  75.  *   +---+-+-------------------------+-------------------------------+
  76.  *   |Sev|C|       Facility          |               Code            |
  77.  *   +---+-+-------------------------+-------------------------------+
  78.  *
  79.  *   where
  80.  *
  81.  *       Sev - is the severity code
  82.  *           00 - Success
  83.  *           01 - Informational
  84.  *           10 - Warning
  85.  *           11 - Error
  86.  *
  87.  *       C - is the Customer code flag
  88.  *
  89.  *       Facility - is the facility code
  90.  *
  91.  *       Code - is the facility's status code
  92.  *
  93.  *   Exceptions specific to OS/2 2.0 (e.g. XCPT_SIGNAL) will be marked
  94.  *   with a facility code of 1.
  95.  *
  96.  *   System defined exceptions have a facility code of zero.
  97.  *
  98.  *   Each exception may also have several pieces of additional information.
  99.  *   These are stored in the ExceptionInfo fields of the
  100.  *   ExceptionReportRecord. They are documented here with the exceptions
  101.  *   only for ease of reference.
  102.  */
  103.  
  104. #define XCPT_FATAL_EXCEPTION    0xC0000000
  105. #define XCPT_SEVERITY_CODE      0xC0000000
  106. #define XCPT_CUSTOMER_CODE      0x20000000
  107. #define XCPT_FACILITY_CODE      0x1FFF0000
  108. #define XCPT_EXCEPTION_CODE     0x0000FFFF
  109.  
  110. /*  Violation flags in ExceptionInfo */
  111.  
  112. #define XCPT_UNKNOWN_ACCESS     0x00000000      /* Unknown access */
  113. #define XCPT_READ_ACCESS        0x00000001      /* Read access    */
  114. #define XCPT_WRITE_ACCESS       0x00000002      /* Write access   */
  115. #define XCPT_EXECUTE_ACCESS     0x00000004      /* Execute access */
  116. #define XCPT_SPACE_ACCESS       0x00000008      /* Address space access */
  117. #define XCPT_LIMIT_ACCESS       0x00000010      /* Address space limit violation */
  118. #define XCPT_DATA_UNKNOWN       0xFFFFFFFF
  119.  
  120. /*  Signal numbers for XCPT_SIGNAL */
  121.  
  122. #define XCPT_SIGNAL_INTR        1
  123. #define XCPT_SIGNAL_KILLPROC    3
  124. #define XCPT_SIGNAL_BREAK       4
  125.  
  126. /*  Portable non-fatal software generated exceptions */
  127.  
  128. #define XCPT_GUARD_PAGE_VIOLATION       0x80000001
  129.       /* ExceptionInfo[ 0 ] - Access Code: XCPT_READ_ACCESS
  130.                                            XCPT_WRITE_ACCESS */
  131.       /* ExceptionInfo[ 1 ] - FaultAddr */
  132.  
  133. #define XCPT_UNABLE_TO_GROW_STACK       0x80010001
  134.  
  135. /*  Portable fatal hardware generated exceptions */
  136.  
  137. #define XCPT_DATATYPE_MISALIGNMENT      0xC000009E
  138.       /* ExceptionInfo[ 0 ] - Access Code: XCPT_READ_ACCESS
  139.                                            XCPT_WRITE_ACCESS */
  140.       /* ExceptionInfo[ 1 ] - Alignment */
  141.       /* ExceptionInfo[ 2 ] - FaultAddr */
  142.  
  143. #define XCPT_BREAKPOINT                 0xC000009F
  144. #define XCPT_SINGLE_STEP                0xC00000A0
  145. #define XCPT_ACCESS_VIOLATION           0xC0000005
  146.       /* ExceptionInfo[ 0 ] - Access Code: XCPT_READ_ACCESS
  147.                                            XCPT_WRITE_ACCESS
  148.                                            XCPT_SPACE_ACCESS
  149.                                            XCPT_LIMIT_ACCESS
  150.                                            XCPT_UNKNOWN_ACCESS */
  151.       /* ExceptionInfo[ 1 ] - FaultAddr (XCPT_READ_ACCESS/XCPT_WRITE_ACCESS)
  152.                               Selector  (XCPT_SPACE_ACCESS)
  153.                               -1        (XCPT_LIMIT_ACCESS) */
  154.  
  155. #define XCPT_ILLEGAL_INSTRUCTION        0xC000001C
  156. #define XCPT_FLOAT_DENORMAL_OPERAND     0xC0000094
  157. #define XCPT_FLOAT_DIVIDE_BY_ZERO       0xC0000095
  158. #define XCPT_FLOAT_INEXACT_RESULT       0xC0000096
  159. #define XCPT_FLOAT_INVALID_OPERATION    0xC0000097
  160. #define XCPT_FLOAT_OVERFLOW             0xC0000098
  161. #define XCPT_FLOAT_STACK_CHECK          0xC0000099
  162. #define XCPT_FLOAT_UNDERFLOW            0xC000009A
  163. #define XCPT_INTEGER_DIVIDE_BY_ZERO     0xC000009B
  164. #define XCPT_INTEGER_OVERFLOW           0xC000009C
  165. #define XCPT_PRIVILEGED_INSTRUCTION     0xC000009D
  166.  
  167. /*  Portable fatal software generated exceptions */
  168.  
  169. #define XCPT_IN_PAGE_ERROR              0xC0000006
  170.       /* ExceptionInfo[ 0 ] - FaultAddr */
  171.  
  172. #define XCPT_PROCESS_TERMINATE          0xC0010001
  173. #define XCPT_ASYNC_PROCESS_TERMINATE    0xC0010002
  174.       /* ExceptionInfo[ 0 ] - TID of 'terminator' thread */
  175.  
  176. #define XCPT_NONCONTINUABLE_EXCEPTION   0xC0000024
  177. #define XCPT_INVALID_DISPOSITION        0xC0000025
  178.  
  179. /*  Non-portable fatal exceptions */
  180.  
  181. #define XCPT_INVALID_LOCK_SEQUENCE      0xC000001D
  182. #define XCPT_ARRAY_BOUNDS_EXCEEDED      0xC0000093
  183. #define XCPT_B1NPX_ERRATA_02            0xC0010004
  184.  
  185. /*  Misc exceptions */
  186.  
  187. #define XCPT_UNWIND                     0xC0000026
  188. #define XCPT_BAD_STACK                  0xC0000027
  189. #define XCPT_INVALID_UNWIND_TARGET      0xC0000028
  190.  
  191. /*  Signal Exceptions */
  192.  
  193. #define XCPT_SIGNAL                     0xC0010003
  194.       /* ExceptionInfo[ 0 ] - Signal Number */
  195.  
  196. /*
  197.  * ContextRecord
  198.  *
  199.  * This is the machine specific register contents for the thread
  200.  * at the time of the exception. Note that only the register sets
  201.  * specified by ContextFlags contain valid data. Conversely, only
  202.  * registers specified in ContextFlags will be restored if an exception
  203.  * is handled.
  204.  */
  205.  
  206. /*  The following flags control the contents of the CONTEXT structure. */
  207.  
  208. #define CONTEXT_CONTROL         0x00000001L     /* SS:ESP, CS:EIP, EFLAGS,  */
  209.                                                 /* EBP                      */
  210. #define CONTEXT_INTEGER         0x00000002L     /* EAX, EBX, ECX, EDX, ESI, */
  211.                                                 /* EDI                      */
  212. #define CONTEXT_SEGMENTS        0x00000004L     /* DS, ES, FS, GS           */
  213. #define CONTEXT_FLOATING_POINT  0x00000008L     /* numeric coprocessor state */
  214.  
  215. #define CONTEXT_FULL            (CONTEXT_CONTROL | CONTEXT_INTEGER | \
  216.                                  CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT)
  217.  
  218. /*XLATOFF */
  219. #pragma pack(1)
  220. /*XLATON  */
  221. typedef struct  _fpreg      /* coprocessor stack register element */
  222.    {
  223.    ULONG losig;
  224.    ULONG hisig;
  225.    USHORT signexp;
  226.    } FPREG , *PFPREG ;
  227. #pragma pack()
  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. typedef ULONG APIENTRY _ERR(PEXCEPTIONREPORTRECORD,
  334.                             struct _EXCEPTIONREGISTRATIONRECORD *,
  335.                             PCONTEXTRECORD,
  336.                             PVOID);
  337.  
  338. typedef _ERR  *ERR;
  339.  
  340. struct _EXCEPTIONREGISTRATIONRECORD
  341.    {
  342.    struct _EXCEPTIONREGISTRATIONRECORD * volatile prev_structure;
  343.    _ERR * volatile ExceptionHandler;
  344.    };
  345.  
  346. typedef struct _EXCEPTIONREGISTRATIONRECORD EXCEPTIONREGISTRATIONRECORD;
  347. typedef struct _EXCEPTIONREGISTRATIONRECORD *PEXCEPTIONREGISTRATIONRECORD;
  348.  
  349. /* End of exception chain marker. */
  350.  
  351. #define END_OF_CHAIN        ((PEXCEPTIONREGISTRATIONRECORD) -1)
  352. #pragma pack()
  353.  
  354. #endif /* __BSEXCPT__ */
  355.  
  356. #ifdef __IBMC__
  357. #pragma checkout( suspend )
  358.    #ifndef __CHKHDR__
  359.       #pragma checkout( resume )
  360.    #endif
  361. #pragma checkout( resume )
  362. #endif
  363.