home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Aktief 1995 #6 / CDA_6.iso / shell / utils / disked29.arj / SOURCE.ZIP / DPB.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-19  |  5.0 KB  |  141 lines

  1. /***
  2. *dpb.h - disked definitions/declarations for DOS Drive Parameter Information
  3. *
  4. *Copyright (c) 1993-1995, Gregg Jennings.  All wrongs reserved.
  5. *   P O Box 200, Falmouth, MA 02541-0200
  6. *
  7. *Purpose:
  8. *   For use with the diskio() functions
  9. *
  10. *Notice:
  11. *   This progam may be freely used and distributed.  Any distrubution
  12. *   with modifications must retain the above copyright statement and
  13. *   modifications noted.
  14. *   No pulp-publication, in whole or in part, permitted without
  15. *   permission (magazines or books).
  16. *******************************************************************************/
  17.  
  18. #ifndef GENERAL_H
  19. #include "general.h"
  20. #endif
  21.  
  22. /* DOS Disk structure definitions */
  23.  
  24. #pragma pack(1)
  25.  
  26. /* Format of a Boot Sector */
  27.  
  28. /* This is verbatim MS-DOS Technical Referance for DOS 3.3 */
  29.  
  30. struct BOOT {
  31.    unsigned char jump[3];           /* 3 byte Near Jump to boot code */
  32.    unsigned char name[8];           /* 8 byte OEM name and version */
  33.    unsigned int  sec_size; /*BPB*/  /* WORD Bytes per sector */
  34.    unsigned char secs_cluster;      /* BYTE Sectors per allocation unit */
  35.    unsigned int  reserved_secs;     /* WORD Reserved sectors (note 1) */
  36.    unsigned char num_fats;          /* BYTE Number of FATs */
  37.    unsigned int  dir_entries;       /* WORD Number of root dir entries */
  38.    unsigned int  num_sectors;       /* WORD Number of sectors in logical
  39.                                        image or 0 (note 2) */
  40.    unsigned char media_desc;        /* BYTE Media descriptor */
  41.    unsigned int  secs_fat; /*BPB*/  /* WORD Number of FAT sectors */
  42.    unsigned int  secs_track;        /* WORD Sectors per track */
  43.    unsigned int  num_heads;         /* WORD Number of heads */
  44.    unsigned int  hidden_sectors;    /* WORD Number of hidden sectors (note 3) */
  45.    unsigned int  large_sectors;     /* WORD High order number of hidden
  46.                                        sectors */
  47.    unsigned long total_sectors;     /* DWORD Number of logical sectors */
  48.  
  49.    /*
  50.       I've added this to keep it the same as the BPB structure defined
  51.       later.
  52.    */
  53.    unsigned char reserved[6];
  54. };
  55.  
  56. /* This is the text from the Technical Reference:
  57.  
  58.    "Although MS-DOS does not use the five fields that follow the BPB, these
  59.    fields may be used by a device driver to help it understand the media.
  60.  
  61.    "The "Sectors per track" and "Number of heads" fields are useful for
  62.    supporting different media that may have the same logical layout, but
  63.    a different physical layout (for example, 40-track, double-sided versus
  64.    80-track, single-sided). "Sectors per track" tells the device driver how
  65.    the logical disk format is laid out on the physical disk.
  66.  
  67.    "The "Number of hidden sectors" and "High order number of hidden
  68.    sectors" fields may be used to support drive-partitioning schemes.
  69.  
  70.    The "Number of logical sectors" field tells the device driver how many
  71.    sectors to reserve if the "Number of sectors in logical image" field is zero
  72.    (Notice taht this is intended for supporting devices that access more than
  73.    32 megabytes.)"
  74.  
  75.    Note 1: Reserved sectors are the number of sectors that make up the
  76.    boot record.  Although usually 1 that is not always the case.
  77.  
  78.    Mote 2: If the num_sectors is 0, then there are more than can fit
  79.    in a WORD (65535), i.e. > 32 megabytes (this is how DOS has changed
  80.    to support "un-thought-of" drive sizes), and total_sectors must be
  81.    used. (This is an assumption on my part.)
  82.  
  83.    Note 3: Hidden sectors are for hard-drives to hold Partitioning
  84.    information.  They are "hidden" from DOS Interrupts 25 and 26, and BIOS
  85.    Interrupt 13, but can be accessed by DOS Interrupt 21/44. (Interrupt
  86.    13 may read them, but I have not tried it.)
  87.    There has been a problem with 'hidden_sectors'.  BPB says DWORD but
  88.    BOOT says WORD (?); WORD seems to work but I've found that it also
  89.    depends on the compiler and the optimizations ;-).
  90.  
  91. */
  92.  
  93. /* BIOS Parameter Block definition */
  94.  
  95. /*
  96.    There are more fields than described by the BPB area of the BOOT
  97.    structure as defined by MS (bounded by / *BPB* / above), but they are
  98.    the same except for the "reserved" bytes at the end.
  99. */
  100.  
  101. struct BPB {
  102.    unsigned int  sec_size;
  103.    unsigned char secs_cluster;
  104.    unsigned int  reserved_secs;
  105.    unsigned char num_fats;
  106.    unsigned int  dir_entries;
  107.    unsigned int  num_sectors;
  108.    unsigned char media_desc;
  109.    unsigned int  secs_fat;
  110.    unsigned int  secs_track;
  111.    unsigned int  num_heads;
  112.    unsigned long hidden_sectors;
  113.    unsigned long total_sectors;
  114.    unsigned char reserved[6];
  115. };
  116.  
  117. /* Disk Parameter Block */
  118.  
  119. /* IOCTL Int 21/44 interface */
  120.  
  121. struct DPB {
  122.    unsigned char special;
  123.    unsigned char dev_type;
  124.    unsigned int  dev_attrib;
  125.    unsigned int  cylinders;
  126.    unsigned char media;
  127.    struct BPB bpb;
  128. };
  129.  
  130. /* Disk Control Block */
  131.  
  132. /* For drives larger than 32M */
  133.  
  134. struct DCB {
  135.      unsigned long sector;
  136.      unsigned int  number;
  137.      unsigned char _far *buffer;
  138. };
  139.  
  140. #pragma pack()
  141.