home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v1.zip / DDKX86 / H / BSEXCPT.H < prev    next >
Text File  |  1995-04-14  |  14KB  |  386 lines

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