home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / rng-810.zip / randdrv.h < prev    next >
C/C++ Source or Header  |  1994-01-24  |  8KB  |  223 lines

  1. //
  2. // Copyright (c) Sirius Software 1992.
  3. // All rights reserved.
  4. // But the README.DOC file from Sirius Software says:
  5. // This software is hereby placed in the public domain.
  6. /*
  7.  RANDDRV.SYS random number driver for RNG-810 random # or similar.
  8.  Copyright (C) 1994 Paul Elliot
  9.  
  10.  This program is free software; you can redistribute it and/or
  11.  modify it under the terms of the GNU General Public License
  12.  as published by the Free Software Foundation; either version 2
  13.  of the License, or (at your option) any later version.
  14.  
  15.  This program is distributed in the hope that it will be useful,
  16.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  GNU General Public License for more details.
  19.  
  20.  You should have received a copy of the GNU General Public License
  21.  along with this program; if not, write to the Free Software
  22.  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  
  24. Paul.Elliott@Hrnowl.LoneStar.Org
  25.  
  26. Paul Elliott
  27.  
  28. 3986 South Gessner #224 Houston TX 77063
  29.  
  30. */
  31. //
  32. //
  33. // file_name = randdrv.h
  34. //
  35. // Notes
  36. //        - created June 1, 1993 Greg Smith
  37. //        - various defines and external declarations used by SampDrv
  38. //
  39.  
  40.  
  41. #if !defined( RANDDRV_H )
  42.  
  43. #define RANDDRV_H
  44.  
  45. // misc types and defines
  46.  
  47. #define TRUE     1
  48. #define FALSE   0
  49.  
  50. /* RPstatus bit values */
  51.  
  52. #define RPERR   0x8000              /*  error occurred, err in RPstatus    */
  53. #define RPDEV   0x4000              /*  error code defined by driver       */
  54. #define RPBUSY  0x0200              /*  device is busy                     */
  55. #define RPDONE  0x0100              /*  driver done with request packet    */
  56.  
  57. /* error codes returned in RPstatus */
  58.  
  59. #define ERROR_WRITE_PROTECT         0x0000
  60. #define ERROR_BAD_UNIT              0x0001
  61. #define ERROR_NOT_READY             0x0002
  62. #define ERROR_BAD_COMMAND           0x0003
  63. #define ERROR_CRC                   0x0004
  64. #define ERROR_BAD_LENGTH            0x0005    
  65. #define ERROR_SEEK                  0x0006
  66. #define ERROR_NOT_DOS_DISK          0x0007
  67. #define ERROR_SECTOR_NOT_FOUND      0x0008
  68. #define ERROR_OUT_OF_PAPER          0x0009
  69. #define ERROR_WRITE_FAULT           0x000A
  70. #define ERROR_READ_FAULT            0x000B
  71. #define ERROR_GEN_FAILURE           0x000C
  72. #define ERROR_DISK_CHANGE           0x000D
  73. #define ERROR_WRONG_DISK            0x000F
  74. #define ERROR_UNCERTAIN_MEDIA       0x0010
  75. #define ERROR_CHAR_CALL_INTERRUPTED 0x0011
  76. #define ERROR_NO_MONITOR_SUPPORT    0x0012
  77. #define ERROR_INVALID_PARAMETER     0x0013
  78. #define ERROR_DEVICE_IN_USE         0x0014
  79.  
  80. /*  driver device attributes word */
  81.  
  82. #define DAW_CHR    0x8000           /* 1=char, 0=block                     */
  83. #define DAW_IDC    0x4000           /* 1=IDC available in this DD          */
  84. #define DAW_IBM    0x2000           /* 1=non-IBM block format              */
  85. #define DAW_SHR    0x1000           /* 1=supports shared device access     */
  86. #define DAW_OPN    0x0800           /* 1=open/close, or removable media    */
  87. #define DAW_LEVEL1 0x0080           /* level 1                             */
  88. #define DAW_LEVEL2 0x0100           /* level 2 DosDevIOCtl2                */
  89. #define DAW_LEVEL3 0x0180           /* level 3 bit strip                   */
  90. #define DAW_GIO    0x0040           /* 1=generic IOCtl supported           */
  91. #define DAW_CLK    0x0008           /* 1=CLOCK device                      */
  92. #define DAW_NUL    0x0004           /* 1=NUL device                        */
  93. #define DAW_SCR    0x0002           /* 1=STDOUT (screen)                   */
  94. #define DAW_KBD    0x0001           /* 1=STDIN  (keyboard)                 */
  95.  
  96. /* capabilities bit strip */
  97.  
  98. #define CBS_SHD    0x0001           /* 1=shutdown/DevIOCtl2                */
  99. #define CBS_HMEM   0x0002           /* hign memory map for adapters        */
  100. #define CBS_PP     0x0004           /* supports parallel ports             */
  101.  
  102.  
  103.  
  104. typedef unsigned char byte;
  105. typedef unsigned short word;
  106. typedef unsigned long dword;
  107. typedef int Boolean;
  108.  
  109. inline word MSB( word x ){
  110.     return x >> 8;
  111. }
  112.  
  113. inline word LSB( word x ){
  114.     return x & 0xff;
  115. }
  116.  
  117. inline word MSW( dword x ){
  118.     return ( x >> 16 ) & 0xffff;
  119. }
  120.  
  121. inline word LSW( dword x ){
  122.     return x & 0xffff;
  123. }
  124.  
  125. #define dim(x)  ( sizeof(x)/sizeof(x[0]) )
  126.  
  127. /****************************************************************************/
  128. // 
  129. // OS/2 device driver request packet structure
  130. //
  131. /****************************************************************************/
  132.  
  133. typedef struct {
  134.     byte requestPacketLength;                               // the size of the request packet
  135.     byte blockDeviceUnitNumber;                            //
  136.     byte commandCode;                                       // type of command for the request packet
  137.     word status;                                           // the status returned to the kernel
  138.     byte reserved1[4];                                       //
  139.     dword qLinkage;                                        //
  140.     union {                                                // now the variable part of the request packet
  141.         struct {                                        //
  142.             byte reserved2;                                //
  143.             dword devHlpEntry;                             //
  144.             char far *initArgs;                                //
  145.         } initEntry;                                    //
  146.         struct {                                        //
  147.             byte logicalUnits;                            //
  148.             word csLength;                                //
  149.             word dsLength;                                //
  150.             void far *bpbAddress;                            //
  151.         } initReturn;                                    //
  152.         struct {                                        //
  153.             byte mediaDescriptor;                        //
  154.             dword transferAddress;                        // physical address of the transfer buffer
  155.             word bytesToTransfer;                        //
  156.             dword startingSectorNumber;                    //
  157.         } transfer;                                        //
  158.         byte nonDestructiveReadChar;                    //
  159.         struct {                                        //
  160.             byte categoryCode;                            //
  161.             byte functionCode;                            //
  162.             void far *parameterBuffer;                        //
  163.             void far *dataBuffer;                            //
  164.         } ioctl;                                        //
  165.     };                                                    //
  166. } RequestPacket;                                        //
  167. typedef RequestPacket far * PRequestPacket;
  168. /****************************************************************************/
  169. // 
  170. // OS/2 device driver header structure
  171. //
  172. /****************************************************************************/
  173.  
  174. typedef struct DeviceDriverHeaderStruct {
  175.     struct DeviceDriverHeaderStruct far *next;     // pointer to next header, -1 if this is the end of the chain
  176.     word deviceAttributeWord;                                // attributes of the device
  177.     void (* near cdecl strategyEntryPoint)( void );    // offset of the strategy routine
  178.     void (* near cdecl idcEntryPoint)( void );        // offset of the IDC routine
  179.     char name[8];                                                // name of device
  180.     char reserved[8];                                            // reserved
  181. } DeviceDriverHeader;
  182.  
  183. typedef enum {
  184.     init, mediaCheck, buildBPB, reserved1, read, nonDestructiveRead, inputStatus,
  185.     inputFlush, write, writeWithVerify, outputStatus, outputFlush, reserved2,
  186.     deviceOpen, deviceClose, removableMedia, genericIOCTL, resetMedia,
  187.     getLogicalDrive, setLogicalDrive, deinstall, reserved3, partitionableFixedDisk,
  188.     getFixedDiskUnitMap, reserved4, reserved5, reserved6
  189. } CommandCodes;
  190.  
  191. //
  192. // OS/2 16 bit API defines, if you have access to the 16 bit headers then
  193. // remove this code. If you don't have the 16 bit headers and library and 
  194. // require other functions then place the function import definition in
  195. // the .def file and add the prototype here
  196. //
  197.  
  198. #define OS2stdout 1
  199.  
  200. #define API far pascal 
  201.  
  202.  
  203. // external declarations, these are defined in the c0.asm file but are
  204. // needed in the device driver module.
  205.  
  206. extern "C" {
  207.  
  208. extern byte memoryEnd;
  209. extern void CodeEnd();
  210. extern void Entry1(void);
  211. void near Strategy1( RequestPacket far *requestPacket );
  212. unsigned API DosWrite( unsigned handle , void far *data, int dataLength, unsigned far * returnStatus );
  213.  
  214. }
  215.  
  216. #endif
  217.  
  218. // table of request handler routines used to dispatch request calls.
  219. typedef word near (* near DispatchFunctionType)( RequestPacket far *requestPacket );
  220.  
  221.  
  222. /* end of file */
  223.