home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / FORMAT.H < prev    next >
C/C++ Source or Header  |  1997-07-05  |  5KB  |  200 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. ** Data structures and discriptions for IOCTL comes from the following
  5. ** MS-DOS Functions ISBN 1-55615-128-4
  6. ** Ralf Brown's Interupt List
  7. */
  8.  
  9. #ifndef FORMAT__H
  10. #define FORMAT__H
  11.  
  12. #include "extkword.h"          /* For FAR  */
  13.  
  14. #ifdef  _MSC_VER
  15.  #pragma warning(disable:4103)
  16. #endif
  17.  
  18. #define MAX_SECTORS 18
  19.  
  20. #pragma pack(1)
  21.  
  22. #define IOCTL               0x4400
  23. #define IOCTL_REMOVABLE     0x08
  24. #define IOCTL_REMOTE        0x09
  25. #define IOCTL_BLOCK         0x0D
  26. #define SetDeviceParameters 0x40
  27. #define WriteTrack          0x41
  28. #define FormatVerifyTrack   0x42
  29. #define SetAccessFlag       0x47        /* dos 4.0+ */
  30. #define GetDeviceParameters 0x60
  31. #define ReadTrack           0x61
  32. #define VerifyTrack         0x62
  33. #define GetAccessFlag       0x67        /* dos 4.0+ */
  34. #define DiskDrive           0x0800
  35.  
  36. #define CHECK_REMOVABLE (IOCTL + IOCTL_REMOVABLE)
  37. #define CHECK_REMOTE    (IOCTL + IOCTL_REMOTE)
  38. #define GENERIC_IO      (IOCTL + IOCTL_BLOCK)
  39. #define GENERIC_GETDEV  (DiskDrive + GetDeviceParameters)
  40. #define GENERIC_SETDEV  (DiskDrive + SetDeviceParameters)
  41. #define GENERIC_READ    (DiskDrive + ReadTrack)
  42. #define GENERIC_WRITE   (DiskDrive + WriteTrack)
  43. #define GENERIC_VERIFY  (DiskDrive + VerifyTrack)
  44. #define GENERIC_FORMAT  (DiskDrive + FormatVerifyTrack)
  45. #define GENERIC_GETACC  (DiskDrive + GetAccessFlag)
  46. #define GENERIC_SETACC  (DiskDrive + SetAccessFlag)
  47.  
  48. #define SERIAL_NUMBER       0x6900
  49. #define GetDate             0x2A00
  50. #define GetTime             0x2C00
  51. #define SERIAL_READ             0
  52. #define SERIAL_WRITE            1
  53.  
  54. typedef struct
  55.     {
  56.     char            Formats_[6];
  57.     unsigned char   Device_Type;
  58.     unsigned char   Media_Type;
  59.     unsigned int    Heads;
  60.     unsigned int    Tracks;
  61.     unsigned int    Sectors_Per_Tracks;
  62.     unsigned int    Max_Entries;        /* in sectors */
  63.     unsigned char   Media_Descriptor;
  64.     unsigned char   Cluster_Size;
  65.     unsigned int    FatSize;
  66.     unsigned int    Available;
  67.     } FORMAT_TABLE;
  68.  
  69. /*
  70. **  Bios Parameter Block:
  71. **      Function 44
  72. **      Sub-function 0D
  73. **      minor code 40 and 60
  74. */
  75.  
  76. typedef struct
  77.     {
  78.     unsigned int    Bytes_Sector;
  79.     unsigned char   Cluster_Size;
  80.     unsigned int    Reserved_Sectors;
  81.     unsigned char   Number_FATS;
  82.     unsigned int    Max_Root_Entries;
  83.     unsigned int    Number_Sectors;
  84.     unsigned char   Media_Descriptor;
  85.     unsigned int    Sectors_FAT;
  86.     unsigned int    Sectors_Track;
  87.     unsigned int    Number_Heads;
  88.     unsigned long   Hidden_Sectors;
  89.     unsigned long   Large_Number_Sectors;   /* if Number_Sectors == 0 */
  90.     unsigned char   Reserved[6];
  91.     } BPB;
  92.  
  93. /*
  94. **  Device Parameter Block:
  95. **      Function 44
  96. **      Sub-function 0D
  97. **      minor codes 40 and 60
  98. */
  99.  
  100. typedef struct
  101.     {
  102.     unsigned char   Function;
  103.     unsigned char   Device_Type;
  104.     unsigned int    Device_Attribute;
  105.     unsigned int    Tracks;
  106.     unsigned char   Media_Type;
  107.     BPB             bpb;
  108.     struct TL
  109.         {
  110.         unsigned int    Number_Sectors;
  111.         struct SECID
  112.             {
  113.             unsigned int    Sector_Number;
  114.             unsigned int    Sector_Size;
  115.             } track_layout[MAX_SECTORS];
  116.         } track;
  117.     } DPB;
  118.  
  119. /*
  120. **  Format Parameter Block:
  121. **      Function 44
  122. **      Sub-function 0D,
  123. **      minor code 42 and 62
  124. */
  125.  
  126. typedef struct
  127.     {
  128.     unsigned char   Function;
  129.     unsigned int    Head;
  130.     unsigned int    Track;
  131.     } FPB;
  132.  
  133. /*
  134. **  Volume Serial Parameter Block:
  135. **      Function 44
  136. **      Sub-function 0D,
  137. **      minor code 46 and 66
  138. */
  139.  
  140. typedef struct
  141.     {
  142.     unsigned int    Function;           /* should be 0              */
  143.     unsigned long   SerialNumber;       /* binary                   */
  144.     unsigned char   VolumeLabel[11];    /* or "NO NAME   "          */
  145.     unsigned char   FileSystemType[8];  /* "FAT12   " or "FAT16   " */
  146.     } VPB;
  147.  
  148. /*
  149. **  Access Parameter Block:
  150. **      Function 44
  151. **      Sub-function 0D
  152. **      minor code 47 and 67
  153. */
  154.  
  155. typedef struct
  156.     {
  157.     unsigned char   Function;
  158.     unsigned char   Flag;
  159.     } APB;
  160.  
  161. /*
  162. **  IO Parameter Block:
  163. **      Function 44
  164. **      Sub-function 0D
  165. **      minor code 41, 61 and 62
  166. */
  167.  
  168. typedef struct
  169.     {
  170.     unsigned char       Function;
  171.     unsigned int        Side;
  172.     unsigned int        Track;
  173.     unsigned int        FirstSector;
  174.     unsigned int        NumberSectors;
  175.     unsigned char FAR  *dta;
  176.     } IOPB;
  177.  
  178.  
  179. /* boot sector description */
  180.  
  181. #define BJLEN   3
  182. #define OLEN    8
  183. #define BREV    1
  184. #define NLEN    11
  185. #define FLEN    8
  186. #define BLEN    512 - (FLEN + NLEN + BREV + OLEN + BJLEN + sizeof(BPB))
  187.  
  188. typedef struct
  189.     {
  190.     unsigned char   boot_start_[BJLEN];
  191.     unsigned char   os_name_[OLEN];
  192.     BPB             bpb;
  193.     unsigned char   rev_[BREV];
  194.     unsigned char   volname_[NLEN];
  195.     unsigned char   fat_[FLEN];
  196.     unsigned char   boot_code_[BLEN];
  197.     } BOOTSECTOR;
  198.  
  199. #endif /* FORMAT__H */
  200.