home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lxapi32.zip / Include / DEVTYPE.H < prev    next >
C/C++ Source or Header  |  2002-04-26  |  8KB  |  208 lines

  1. /* $Id: DEVTYPE.H,v 1.2 2002/04/26 23:09:00 smilcke Exp $ */
  2.  
  3. /************************************************************************\
  4. **                                                                      **
  5. **               OS/2(r) Physical Device Driver Libraries               **
  6. **                         for Watcom C/C++ 10                          **
  7. **                                                                      **
  8. **  COPYRIGHT:                                                          **
  9. **                                                                      **
  10. **    (C) Copyright Advanced Gravis Computer Technology Ltd 1994.       **
  11. **        All Rights Reserved.                                          **
  12. **                                                                      **
  13. **  DISCLAIMER OF WARRANTIES:                                           **
  14. **                                                                      **
  15. **    The following [enclosed] code is provided to you "AS IS",         **
  16. **    without warranty of any kind.  You have a royalty-free right to   **
  17. **    use, modify, reproduce and distribute the following code (and/or  **
  18. **    any modified version) provided that you agree that Advanced       **
  19. **    Gravis has no warranty obligations and shall not be liable for    **
  20. **    any damages arising out of your use of this code, even if they    **
  21. **    have been advised of the possibility of such damages.  This       **
  22. **    Copyright statement and Disclaimer of Warranties may not be       **
  23. **    removed.                                                          **
  24. **                                                                      **
  25. \************************************************************************/
  26.  
  27.  
  28. // DevType.h
  29. //
  30. // Type definitions for OS/2 2.x physical device drivers.
  31. //
  32. // History:
  33. //
  34. // Sep 30, 94  David Bollo    Initial version
  35.  
  36.  
  37. // Prevent multiple inclusion
  38. #if !defined(DevType_h)
  39. #define DevType_h 1
  40.  
  41. #if !defined(__WATCOMC__) || !defined(__cplusplus)
  42. #error Watcom C++ must be used for strict type checking.
  43. #endif
  44.  
  45. #pragma pack(1)
  46.  
  47. // Match OS/2's layout model for structures
  48. #pragma pack(1);
  49. #define FAR48     __far
  50.  
  51. #undef NEAR
  52. #define NEAR __near
  53.  
  54. #undef FAR
  55. #define FAR  __far
  56.  
  57. //SvL: Replaces iw/types.h
  58. #ifndef NULL
  59. #define NULL 0L
  60. #endif
  61. typedef int    Status;
  62. #define SUCCESS    (Status)0
  63. #define FAIL    (Status)-1
  64.  
  65. typedef int    Boolean;
  66. #define False    (Boolean)0
  67. #define True    (Boolean)1
  68.  
  69. #define FALSE    0
  70. #define TRUE    1
  71.  
  72. // Standard types
  73. typedef       unsigned long   DWORD;
  74. typedef       unsigned short  WORD16;
  75. typedef       unsigned long   WORD32;
  76. typedef       void            (*FUNCTION)();
  77. typedef       unsigned short  PORT;
  78. typedef       ULONG           FARPTR16;
  79.  
  80. // Pointer type for physical addresses
  81. typedef       WORD32          PHYSICAL;
  82.  
  83. // Pointer type for linear addresses
  84. typedef       BYTE NEAR *       LINEAR;
  85.  
  86. // Pointer types for virtual addresses
  87. typedef       WORD16          SEGMENT;
  88. typedef       WORD16          OFFSET;
  89. typedef       WORD32          VIRTUAL;
  90.  
  91. // Selector type for local and global descriptor tables
  92. typedef       WORD16          SEL;
  93.  
  94. // Functions to convert between virtual address types
  95. //inline SEL SELECTOROF(VIRTUAL addr)       {return (WORD16)((WORD32)addr>>16);}
  96. //inline SEGMENT SEGMENTOF(VIRTUAL addr)    {return (WORD16)((WORD32)addr>>16);}
  97. //inline OFFSET OFFSETOF(VIRTUAL addr)      {return (WORD16)addr;}
  98.  
  99. // Locked segment handle type
  100. typedef       WORD32          HLOCK;
  101.  
  102. // Context hook handle type
  103. typedef       WORD32          HCONTEXT;
  104.  
  105. // Semaphore handle type for system semaphores
  106. typedef       WORD32          HSEMAPHORE;
  107.  
  108. // Character queues
  109. struct QBASE
  110.   {
  111.   WORD16      Size;           // Size of queue (in bytes)
  112.   WORD16      Index;          // Index of next byte out
  113.   WORD16      Count;          // Count of bytes in queue
  114.   };
  115. template <int s> struct QUEUE : public QBASE
  116.   {
  117.   BYTE        Buffer[s];      // Queue buffer
  118.   };
  119.  
  120. // Inter device driver communication structure
  121. struct        IDCDATA
  122.   {
  123.   WORD16      Reserved1;      // Reserved (formerly real mode offset)
  124.   WORD16      Reserved2;      // Reserved (formerly real mode code segment)
  125.   WORD16      Reserved3;      // Reserved (formerly real mode data segment)
  126.   OFFSET      Offset;         // Offset of IDC entry point
  127.   SEGMENT     Segment;        // Segment of IDC entry point
  128.   SEGMENT     Data;           // Data segment of IDC device driver
  129.   };
  130.  
  131. // Stack usage information
  132. struct        STACKUSAGE
  133.   {
  134.   WORD16      Size;           // Size of this structure = sizeof(STACKUSAGE)
  135.   WORD16      Flags;          // Flags: bit 1 on = driver enables interrupts
  136.   WORD16      IRQ;            // IRQ number for this stack information
  137.   WORD16      CLIStack;       // Bytes of stack used while interrupts are clear
  138.   WORD16      STIStack;       // Bytes of stack used while interrupts are set
  139.   WORD16      EOIStack;       // Bytes of stack used after EOI is issued
  140.   WORD16      NestingLevel;   // Maximum number of times to nest interrupt
  141.   };
  142.  
  143. // Device driver header
  144. //
  145. // Instances of this structure should be placed in the header segment to
  146. // ensure that they are located at the beginning of the device driver
  147. // file.
  148. struct DEVHEADER
  149.   {
  150.   DEVHEADER FAR* Link;        // Link to next header in chain
  151.   WORD16      DAWFlags;       // Device attribute word
  152.   VOID*       StrategyEntry;  // Entry point to strategy routine
  153.   VOID*       IDCEntry;       // Entry point to IDC routine
  154.   CHAR        Name[8];        // Device driver name
  155.   CHAR        Reserved[8];    // Reserved
  156.   WORD32      Capabilities;   // Capabilities bit strip (for level 3 DDs)
  157.   };
  158.  
  159. // Constant for final DEVHEADER in chain
  160. #define       FinalLink       ((DEVHEADER FAR*)0xFFFFFFFFul)
  161.  
  162. // Constants for device attribute word
  163. #define  DAW_CHARACTER = 0x8000;     // Character device
  164. #define  DAW_IDC       = 0x4000;     // IDC aware device
  165. #define  DAW_NONIBM    = 0x2000;     // Non-IBM Block device
  166. #define  DAW_SHARE     = 0x1000;     // Sharable device
  167. #define  DAW_OPEN      = 0x0800;     // Requires open and close requests
  168. #define  DAW_LEVEL3    = 0x0180;     // Level 3 device
  169. #define  DAW_LEVEL2    = 0x0100;     // Level 2 device
  170. #define  DAW_LEVEL1    = 0x0080;     // Level 1 device
  171. #define  DAW_CLOCK     = 0x0008;     // Clock device
  172. #define  DAW_NUL       = 0x0004;     // Nul device
  173. #define  DAW_STDOUT    = 0x0002;     // Standard output device
  174. #define  DAW_STDIN     = 0x0001;     // Standard input device
  175.  
  176. // Constants for capabilities bit strip (used by level 3 devices)
  177. #define  CAP_COMPLETE  = 0x00000010; // Supports Init Complete request
  178. #define  CAP_ADD       = 0x00000008; // Participates in ADD strategy
  179. #define  CAP_PARALLEL  = 0x00000004; // Supports parallel ports
  180. #define  CAP_32BIT     = 0x00000002; // Supports addressing above 16MB
  181. #define  CAP_SHUTDOWN  = 0x00000001; // Supports IOCtl2 and shutdown
  182.  
  183. //VMLock flags
  184. #define VMDHL_WRITE             0x0008
  185. #define VMDHL_LONG              0x0010
  186. #define VMDHL_VERIFY            0x0020
  187.  
  188. // Offsets for the end of the resident code and data segments
  189.  
  190. #define OffsetFinalCS32        ((WORD32)&_OffFinalCS32)
  191. #define OffsetFinalDS32        ((WORD32)&_OffFinalDS32)
  192. #define OffsetBeginCS32        ((WORD32)&_OffBeginCS32)
  193. #define OffsetBeginDS32        ((WORD32)&_OffBeginDS32)
  194.  
  195. extern "C"
  196. {
  197.   extern BYTE _OffFinalCS32;               // End of resident code
  198.   extern BYTE _OffFinalDS32;               // End of resident code
  199.   extern BYTE _OffBeginCS32;               // Begin of resident data
  200.   extern BYTE _OffBeginDS32;               // Begin of resident data
  201.   extern WORD16 _OffsetFinalCS16;
  202.   extern WORD16 _OffsetFinalDS16;
  203. }
  204.  
  205. #pragma pack()
  206.  
  207. #endif // DevType_h
  208.