[BACK]Return to bpb.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / fs / msdosfs

Annotation of src/sys/fs/msdosfs/bpb.h, Revision 1.8

1.8     ! dholland    1: /*     $NetBSD: bpb.h,v 1.7 2012/11/04 17:57:59 jakllsch Exp $ */
1.1       jdolecek    2:
                      3: /*
                      4:  * Written by Paul Popelka (paulp@uts.amdahl.com)
                      5:  *
                      6:  * You can do anything you want with this software, just don't say you wrote
                      7:  * it, and don't remove this notice.
                      8:  *
                      9:  * This software is provided "as is".
                     10:  *
                     11:  * The author supplies this software to be publicly redistributed on the
                     12:  * understanding that the author is not responsible for the correct
                     13:  * functioning of this software in any circumstances and is not liable for
                     14:  * any damages caused by this software.
                     15:  *
                     16:  * October 1992
                     17:  */
                     18:
1.4       christos   19: #ifndef _MSDOSFS_BPB_H_
                     20: #define _MSDOSFS_BPB_H_
                     21:
1.1       jdolecek   22: /*
                     23:  * BIOS Parameter Block (BPB) for DOS 3.3
                     24:  */
                     25: struct bpb33 {
1.8     ! dholland   26:        uint16_t        bpbBytesPerSec; /* bytes per sector */
        !            27:        uint8_t         bpbSecPerClust; /* sectors per cluster */
        !            28:        uint16_t        bpbResSectors;  /* number of reserved sectors */
        !            29:        uint8_t         bpbFATs;        /* number of FATs */
        !            30:        uint16_t        bpbRootDirEnts; /* number of root directory entries */
        !            31:        uint16_t        bpbSectors;     /* total number of sectors */
        !            32:        uint8_t         bpbMedia;       /* media descriptor */
        !            33:        uint16_t        bpbFATsecs;     /* number of sectors per FAT */
        !            34:        uint16_t        bpbSecPerTrack; /* sectors per track */
        !            35:        uint16_t        bpbHeads;       /* number of heads */
        !            36:        uint16_t        bpbHiddenSecs;  /* number of hidden sectors */
1.1       jdolecek   37: };
                     38:
                     39: /*
                     40:  * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
                     41:  * and bpbHugeSectors is not in the 3.3 bpb.
                     42:  */
                     43: struct bpb50 {
1.8     ! dholland   44:        uint16_t        bpbBytesPerSec; /* bytes per sector */
        !            45:        uint8_t         bpbSecPerClust; /* sectors per cluster */
        !            46:        uint16_t        bpbResSectors;  /* number of reserved sectors */
        !            47:        uint8_t         bpbFATs;        /* number of FATs */
        !            48:        uint16_t        bpbRootDirEnts; /* number of root directory entries */
        !            49:        uint16_t        bpbSectors;     /* total number of sectors */
        !            50:        uint8_t         bpbMedia;       /* media descriptor */
        !            51:        uint16_t        bpbFATsecs;     /* number of sectors per FAT */
        !            52:        uint16_t        bpbSecPerTrack; /* sectors per track */
        !            53:        uint16_t        bpbHeads;       /* number of heads */
        !            54:        uint32_t        bpbHiddenSecs;  /* # of hidden sectors */
        !            55:        uint32_t        bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
1.1       jdolecek   56: };
                     57:
                     58: /*
                     59:  * BPB for DOS 7.10 (FAT32).  This one has a few extensions to bpb50.
                     60:  */
                     61: struct bpb710 {
1.8     ! dholland   62:        uint16_t        bpbBytesPerSec; /* bytes per sector */
        !            63:        uint8_t         bpbSecPerClust; /* sectors per cluster */
        !            64:        uint16_t        bpbResSectors;  /* number of reserved sectors */
        !            65:        uint8_t         bpbFATs;        /* number of FATs */
        !            66:        uint16_t        bpbRootDirEnts; /* number of root directory entries */
        !            67:        uint16_t        bpbSectors;     /* total number of sectors */
        !            68:        uint8_t         bpbMedia;       /* media descriptor */
        !            69:        uint16_t        bpbFATsecs;     /* number of sectors per FAT */
        !            70:        uint16_t        bpbSecPerTrack; /* sectors per track */
        !            71:        uint16_t        bpbHeads;       /* number of heads */
        !            72:        uint32_t        bpbHiddenSecs;  /* # of hidden sectors */
        !            73:        uint32_t        bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
        !            74:        uint32_t        bpbBigFATsecs;  /* like bpbFATsecs for FAT32 */
        !            75:        uint16_t        bpbExtFlags;    /* extended flags: */
1.1       jdolecek   76: #define        FATNUM          0xf             /* mask for numbering active FAT */
                     77: #define        FATMIRROR       0x80            /* FAT is mirrored (like it always was) */
1.8     ! dholland   78:        uint16_t        bpbFSVers;      /* filesystem version */
1.1       jdolecek   79: #define        FSVERS          0               /* currently only 0 is understood */
1.8     ! dholland   80:        uint32_t        bpbRootClust;   /* start cluster for root directory */
        !            81:        uint16_t        bpbFSInfo;      /* filesystem info structure sector */
        !            82:        uint16_t        bpbBackup;      /* backup boot sector */
        !            83:        uint8_t         bpbReserved[12]; /* Reserved for future expansion */
1.1       jdolecek   84: };
                     85:
                     86: #ifdef atari
                     87: /*
1.7       jakllsch   88:  * BPB for GEMDOS filesystems. Atari leaves the obsolete stuff undefined.
1.1       jdolecek   89:  * Currently there is no need for a separate BPB structure.
                     90:  */
                     91: #if 0
                     92: struct bpb_a {
1.8     ! dholland   93:        uint16_t        bpbBytesPerSec; /* bytes per sector             */
        !            94:        uint8_t         bpbSecPerClust; /* sectors per cluster          */
        !            95:        uint16_t        bpbResSectors;  /* number of reserved sectors   */
        !            96:        uint8_t         bpbFATs;        /* number of FATs               */
        !            97:        uint16_t        bpbRootDirEnts; /* number of root directory entries */
        !            98:        uint16_t        bpbSectors;     /* total number of sectors      */
        !            99:        uint8_t         bpbUseless1;    /* meaningless on GEMDOS FS     */
        !           100:        uint16_t        bpbFATsecs;     /* number of sectors per FAT    */
        !           101:        uint16_t        bpbUseless2;    /* meaningless for harddisk fs  */
        !           102:        uint16_t        bpbUseless3;    /* meaningless for harddisk fs  */
        !           103:        uint16_t        bpbHiddenSecs;  /* the TOS-BIOS ignores this    */
1.1       jdolecek  104: };
                    105: #endif
                    106: #endif /* atari */
                    107:
                    108: /*
                    109:  * The following structures represent how the bpb's look on disk.  shorts
                    110:  * and longs are just character arrays of the appropriate length.  This is
                    111:  * because the compiler forces shorts and longs to align on word or
                    112:  * halfword boundaries.
1.6       cbiere    113:  */
                    114:
                    115: #include <sys/endian.h>
                    116:
                    117: #define        getushort(p)    le16dec(p)
                    118: #define        getulong(p)     le32dec(p)
                    119: #define        putushort(p, v) le16enc((p), (v))
                    120: #define        putulong(p, v)  le32enc((p), (v))
1.1       jdolecek  121:
                    122: /*
                    123:  * BIOS Parameter Block (BPB) for DOS 3.3
                    124:  */
                    125: struct byte_bpb33 {
                    126:        int8_t bpbBytesPerSec[2];       /* bytes per sector */
                    127:        int8_t bpbSecPerClust;          /* sectors per cluster */
                    128:        int8_t bpbResSectors[2];        /* number of reserved sectors */
                    129:        int8_t bpbFATs;                 /* number of FATs */
                    130:        int8_t bpbRootDirEnts[2];       /* number of root directory entries */
                    131:        int8_t bpbSectors[2];           /* total number of sectors */
                    132:        int8_t bpbMedia;                /* media descriptor */
                    133:        int8_t bpbFATsecs[2];           /* number of sectors per FAT */
                    134:        int8_t bpbSecPerTrack[2];       /* sectors per track */
                    135:        int8_t bpbHeads[2];             /* number of heads */
                    136:        int8_t bpbHiddenSecs[2];        /* number of hidden sectors */
                    137: };
                    138:
                    139: /*
                    140:  * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
                    141:  * and bpbHugeSectors is not in the 3.3 bpb.
                    142:  */
                    143: struct byte_bpb50 {
                    144:        int8_t bpbBytesPerSec[2];       /* bytes per sector */
                    145:        int8_t bpbSecPerClust;          /* sectors per cluster */
                    146:        int8_t bpbResSectors[2];        /* number of reserved sectors */
                    147:        int8_t bpbFATs;                 /* number of FATs */
                    148:        int8_t bpbRootDirEnts[2];       /* number of root directory entries */
                    149:        int8_t bpbSectors[2];           /* total number of sectors */
                    150:        int8_t bpbMedia;                /* media descriptor */
                    151:        int8_t bpbFATsecs[2];           /* number of sectors per FAT */
                    152:        int8_t bpbSecPerTrack[2];       /* sectors per track */
                    153:        int8_t bpbHeads[2];             /* number of heads */
                    154:        int8_t bpbHiddenSecs[4];        /* number of hidden sectors */
                    155:        int8_t bpbHugeSectors[4];       /* # of sectors if bpbSectors == 0 */
                    156: };
                    157:
                    158: /*
                    159:  * BPB for DOS 7.10 (FAT32).  This one has a few extensions to bpb50.
                    160:  */
                    161: struct byte_bpb710 {
1.8     ! dholland  162:        uint8_t bpbBytesPerSec[2];      /* bytes per sector */
        !           163:        uint8_t bpbSecPerClust;         /* sectors per cluster */
        !           164:        uint8_t bpbResSectors[2];       /* number of reserved sectors */
        !           165:        uint8_t bpbFATs;                /* number of FATs */
        !           166:        uint8_t bpbRootDirEnts[2];      /* number of root directory entries */
        !           167:        uint8_t bpbSectors[2];          /* total number of sectors */
        !           168:        uint8_t bpbMedia;               /* media descriptor */
        !           169:        uint8_t bpbFATsecs[2];          /* number of sectors per FAT */
        !           170:        uint8_t bpbSecPerTrack[2];      /* sectors per track */
        !           171:        uint8_t bpbHeads[2];            /* number of heads */
        !           172:        uint8_t bpbHiddenSecs[4];       /* # of hidden sectors */
        !           173:        uint8_t bpbHugeSectors[4];      /* # of sectors if bpbSectors == 0 */
        !           174:        uint8_t bpbBigFATsecs[4];       /* like bpbFATsecs for FAT32 */
        !           175:        uint8_t bpbExtFlags[2];         /* extended flags: */
        !           176:        uint8_t bpbFSVers[2];           /* filesystem version */
        !           177:        uint8_t bpbRootClust[4];        /* start cluster for root directory */
        !           178:        uint8_t bpbFSInfo[2];           /* filesystem info structure sector */
        !           179:        uint8_t bpbBackup[2];           /* backup boot sector */
        !           180:        uint8_t bpbReserved[12];        /* Reserved for future expansion */
1.1       jdolecek  181: };
                    182:
                    183: /*
                    184:  * FAT32 FSInfo block.
                    185:  */
                    186: struct fsinfo {
1.8     ! dholland  187:        uint8_t fsisig1[4];
        !           188:        uint8_t fsifill1[480];
        !           189:        uint8_t fsisig2[4];
        !           190:        uint8_t fsinfree[4];
        !           191:        uint8_t fsinxtfree[4];
        !           192:        uint8_t fsifill2[12];
        !           193:        uint8_t fsisig3[4];
        !           194:        uint8_t fsifill3[508];
        !           195:        uint8_t fsisig4[4];
1.1       jdolecek  196: };
1.4       christos  197: #endif /* _MSDOSFS_BPB_H_ */

CVSweb <webmaster@jp.NetBSD.org>