Home | History | Annotate | Line # | Download | only in msdosfs
bootsect.h revision 1.1
      1  1.1  jdolecek /*	$NetBSD: bootsect.h,v 1.1 2002/12/26 12:31:32 jdolecek Exp $	*/
      2  1.1  jdolecek 
      3  1.1  jdolecek /*
      4  1.1  jdolecek  * Written by Paul Popelka (paulp (at) uts.amdahl.com)
      5  1.1  jdolecek  *
      6  1.1  jdolecek  * You can do anything you want with this software, just don't say you wrote
      7  1.1  jdolecek  * it, and don't remove this notice.
      8  1.1  jdolecek  *
      9  1.1  jdolecek  * This software is provided "as is".
     10  1.1  jdolecek  *
     11  1.1  jdolecek  * The author supplies this software to be publicly redistributed on the
     12  1.1  jdolecek  * understanding that the author is not responsible for the correct
     13  1.1  jdolecek  * functioning of this software in any circumstances and is not liable for
     14  1.1  jdolecek  * any damages caused by this software.
     15  1.1  jdolecek  *
     16  1.1  jdolecek  * October 1992
     17  1.1  jdolecek  */
     18  1.1  jdolecek 
     19  1.1  jdolecek /*
     20  1.1  jdolecek  * Format of a boot sector.  This is the first sector on a DOS floppy disk
     21  1.1  jdolecek  * or the fist sector of a partition on a hard disk.  But, it is not the
     22  1.1  jdolecek  * first sector of a partitioned hard disk.
     23  1.1  jdolecek  */
     24  1.1  jdolecek struct bootsector33 {
     25  1.1  jdolecek 	u_int8_t	bsJump[3];		/* jump inst E9xxxx or EBxx90 */
     26  1.1  jdolecek 	int8_t		bsOemName[8];		/* OEM name and version */
     27  1.1  jdolecek 	int8_t		bsBPB[19];		/* BIOS parameter block */
     28  1.1  jdolecek 	int8_t		bsDriveNumber;		/* drive number (0x80) */
     29  1.1  jdolecek 	int8_t		bsBootCode[479];	/* pad so struct is 512b */
     30  1.1  jdolecek 	u_int8_t	bsBootSectSig0;
     31  1.1  jdolecek 	u_int8_t	bsBootSectSig1;
     32  1.1  jdolecek #define	BOOTSIG0	0x55
     33  1.1  jdolecek #define	BOOTSIG1	0xaa
     34  1.1  jdolecek };
     35  1.1  jdolecek 
     36  1.1  jdolecek struct extboot {
     37  1.1  jdolecek 	int8_t		exDriveNumber;		/* drive number (0x80) */
     38  1.1  jdolecek 	int8_t		exReserved1;		/* reserved */
     39  1.1  jdolecek 	int8_t		exBootSignature;	/* ext. boot signature (0x29) */
     40  1.1  jdolecek #define	EXBOOTSIG	0x29
     41  1.1  jdolecek 	int8_t		exVolumeID[4];		/* volume ID number */
     42  1.1  jdolecek 	int8_t		exVolumeLabel[11];	/* volume label */
     43  1.1  jdolecek 	int8_t		exFileSysType[8];	/* fs type (FAT12 or FAT16) */
     44  1.1  jdolecek };
     45  1.1  jdolecek 
     46  1.1  jdolecek struct bootsector50 {
     47  1.1  jdolecek 	u_int8_t	bsJump[3];		/* jump inst E9xxxx or EBxx90 */
     48  1.1  jdolecek 	int8_t		bsOemName[8];		/* OEM name and version */
     49  1.1  jdolecek 	int8_t		bsBPB[25];		/* BIOS parameter block */
     50  1.1  jdolecek 	int8_t		bsExt[26];		/* Bootsector Extension */
     51  1.1  jdolecek 	int8_t		bsBootCode[448];	/* pad so structure is 512b */
     52  1.1  jdolecek 	u_int8_t	bsBootSectSig0;
     53  1.1  jdolecek 	u_int8_t	bsBootSectSig1;
     54  1.1  jdolecek #define	BOOTSIG0	0x55
     55  1.1  jdolecek #define	BOOTSIG1	0xaa
     56  1.1  jdolecek };
     57  1.1  jdolecek 
     58  1.1  jdolecek struct bootsector710 {
     59  1.1  jdolecek 	u_int8_t	bsJump[3];		/* jump inst E9xxxx or EBxx90 */
     60  1.1  jdolecek 	int8_t		bsOEMName[8];		/* OEM name and version */
     61  1.1  jdolecek 	int8_t		bsPBP[53];		/* BIOS parameter block */
     62  1.1  jdolecek 	int8_t		bsExt[26];		/* Bootsector Extension */
     63  1.1  jdolecek 	int8_t		bsBootCode[418];	/* pad so structure is 512b */
     64  1.1  jdolecek 	u_int8_t	bsBootSectSig2;		/* 2 & 3 are only defined for FAT32? */
     65  1.1  jdolecek 	u_int8_t	bsBootSectSig3;
     66  1.1  jdolecek 	u_int8_t	bsBootSectSig0;
     67  1.1  jdolecek 	u_int8_t	bsBootSectSig1;
     68  1.1  jdolecek #define	BOOTSIG0	0x55
     69  1.1  jdolecek #define	BOOTSIG1	0xaa
     70  1.1  jdolecek #define	BOOTSIG2	0
     71  1.1  jdolecek #define	BOOTSIG3	0
     72  1.1  jdolecek };
     73  1.1  jdolecek #ifdef	atari
     74  1.1  jdolecek /*
     75  1.1  jdolecek  * The boot sector on a gemdos fs is a little bit different from the msdos fs
     76  1.1  jdolecek  * format. Currently there is no need to declare a separate structure, the
     77  1.1  jdolecek  * bootsector33 struct will do.
     78  1.1  jdolecek  */
     79  1.1  jdolecek #if 0
     80  1.1  jdolecek struct bootsec_atari {
     81  1.1  jdolecek 	u_int8_t	bsBranch[2];		/* branch inst if auto-boot	*/
     82  1.1  jdolecek 	int8_t		bsFiller[6];		/* anything or nothing		*/
     83  1.1  jdolecek 	int8_t		bsSerial[3];		/* serial no. for mediachange	*/
     84  1.1  jdolecek 	int8_t		bsBPB[19];		/* BIOS parameter block		*/
     85  1.1  jdolecek 	int8_t		bsBootCode[482];	/* pad so struct is 512b	*/
     86  1.1  jdolecek };
     87  1.1  jdolecek #endif
     88  1.1  jdolecek #endif /* atari */
     89  1.1  jdolecek 
     90  1.1  jdolecek union bootsector {
     91  1.1  jdolecek 	struct bootsector33 bs33;
     92  1.1  jdolecek 	struct bootsector50 bs50;
     93  1.1  jdolecek 	struct bootsector710 bs710;
     94  1.1  jdolecek };
     95  1.1  jdolecek 
     96  1.1  jdolecek #if 0
     97  1.1  jdolecek /*
     98  1.1  jdolecek  * Shorthand for fields in the bpb.
     99  1.1  jdolecek  */
    100  1.1  jdolecek #define	bsBytesPerSec	bsBPB.bpbBytesPerSec
    101  1.1  jdolecek #define	bsSectPerClust	bsBPB.bpbSectPerClust
    102  1.1  jdolecek #define	bsResSectors	bsBPB.bpbResSectors
    103  1.1  jdolecek #define	bsFATS		bsBPB.bpbFATS
    104  1.1  jdolecek #define	bsRootDirEnts	bsBPB.bpbRootDirEnts
    105  1.1  jdolecek #define	bsSectors	bsBPB.bpbSectors
    106  1.1  jdolecek #define	bsMedia		bsBPB.bpbMedia
    107  1.1  jdolecek #define	bsFATsecs	bsBPB.bpbFATsecs
    108  1.1  jdolecek #define	bsSectPerTrack	bsBPB.bpbSectPerTrack
    109  1.1  jdolecek #define	bsHeads		bsBPB.bpbHeads
    110  1.1  jdolecek #define	bsHiddenSecs	bsBPB.bpbHiddenSecs
    111  1.1  jdolecek #define	bsHugeSectors	bsBPB.bpbHugeSectors
    112  1.1  jdolecek #endif
    113