home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / aspisrc.zip / dev / DEVTYPE.H < prev    next >
C/C++ Source or Header  |  1994-10-09  |  7KB  |  175 lines

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