xref: /netbsd-src/sys/fs/msdosfs/bootsect.h (revision 20fff34fc519c63c2d4f1e8a02359326041af9e1)
1*20fff34fSandvar /*	$NetBSD: bootsect.h,v 1.7 2021/08/09 21:38:05 andvar Exp $	*/
298d58548Sjdolecek 
398d58548Sjdolecek /*
498d58548Sjdolecek  * Written by Paul Popelka (paulp@uts.amdahl.com)
598d58548Sjdolecek  *
698d58548Sjdolecek  * You can do anything you want with this software, just don't say you wrote
798d58548Sjdolecek  * it, and don't remove this notice.
898d58548Sjdolecek  *
998d58548Sjdolecek  * This software is provided "as is".
1098d58548Sjdolecek  *
1198d58548Sjdolecek  * The author supplies this software to be publicly redistributed on the
1298d58548Sjdolecek  * understanding that the author is not responsible for the correct
1398d58548Sjdolecek  * functioning of this software in any circumstances and is not liable for
1498d58548Sjdolecek  * any damages caused by this software.
1598d58548Sjdolecek  *
1698d58548Sjdolecek  * October 1992
1798d58548Sjdolecek  */
184bffed72Schristos #ifndef _MSDOSFS_BOOTSECT_H_
194bffed72Schristos #define _MSDOSFS_BOOTSECT_H_
2098d58548Sjdolecek 
2198d58548Sjdolecek /*
2298d58548Sjdolecek  * Format of a boot sector.  This is the first sector on a DOS floppy disk
23*20fff34fSandvar  * or the first sector of a partition on a hard disk.  But, it is not the
2498d58548Sjdolecek  * first sector of a partitioned hard disk.
2598d58548Sjdolecek  */
2698d58548Sjdolecek struct bootsector33 {
27cbeb0247Sdholland 	uint8_t		bsJump[3];		/* jump inst E9xxxx or EBxx90 */
2898d58548Sjdolecek 	int8_t		bsOemName[8];		/* OEM name and version */
2998d58548Sjdolecek 	int8_t		bsBPB[19];		/* BIOS parameter block */
3098d58548Sjdolecek 	int8_t		bsDriveNumber;		/* drive number (0x80) */
3198d58548Sjdolecek 	int8_t		bsBootCode[479];	/* pad so struct is 512b */
32cbeb0247Sdholland 	uint8_t		bsBootSectSig0;
33cbeb0247Sdholland 	uint8_t		bsBootSectSig1;
3498d58548Sjdolecek #define	BOOTSIG0	0x55
3598d58548Sjdolecek #define	BOOTSIG1	0xaa
3698d58548Sjdolecek };
3798d58548Sjdolecek 
3898d58548Sjdolecek struct extboot {
3998d58548Sjdolecek 	int8_t		exDriveNumber;		/* drive number (0x80) */
4098d58548Sjdolecek 	int8_t		exReserved1;		/* reserved */
4198d58548Sjdolecek 	int8_t		exBootSignature;	/* ext. boot signature (0x29) */
4298d58548Sjdolecek #define	EXBOOTSIG	0x29
4398d58548Sjdolecek 	int8_t		exVolumeID[4];		/* volume ID number */
4498d58548Sjdolecek 	int8_t		exVolumeLabel[11];	/* volume label */
4598d58548Sjdolecek 	int8_t		exFileSysType[8];	/* fs type (FAT12 or FAT16) */
4698d58548Sjdolecek };
4798d58548Sjdolecek 
4898d58548Sjdolecek struct bootsector50 {
49cbeb0247Sdholland 	uint8_t		bsJump[3];		/* jump inst E9xxxx or EBxx90 */
5098d58548Sjdolecek 	int8_t		bsOemName[8];		/* OEM name and version */
5198d58548Sjdolecek 	int8_t		bsBPB[25];		/* BIOS parameter block */
5298d58548Sjdolecek 	int8_t		bsExt[26];		/* Bootsector Extension */
5398d58548Sjdolecek 	int8_t		bsBootCode[448];	/* pad so structure is 512b */
54cbeb0247Sdholland 	uint8_t		bsBootSectSig0;
55cbeb0247Sdholland 	uint8_t		bsBootSectSig1;
5698d58548Sjdolecek #define	BOOTSIG0	0x55
5798d58548Sjdolecek #define	BOOTSIG1	0xaa
5898d58548Sjdolecek };
5998d58548Sjdolecek 
6098d58548Sjdolecek struct bootsector710 {
61cbeb0247Sdholland 	uint8_t		bsJump[3];		/* jump inst E9xxxx or EBxx90 */
6298d58548Sjdolecek 	int8_t		bsOEMName[8];		/* OEM name and version */
631ab040b9Slukem 	int8_t		bsBPB[53];		/* BIOS parameter block */
6498d58548Sjdolecek 	int8_t		bsExt[26];		/* Bootsector Extension */
657db024f8Sgdt 	int8_t		bsBootCode[420];	/* pad so structure is 512b */
66cbeb0247Sdholland 	uint8_t		bsBootSectSig0;
67cbeb0247Sdholland 	uint8_t		bsBootSectSig1;
6898d58548Sjdolecek #define	BOOTSIG0	0x55
6998d58548Sjdolecek #define	BOOTSIG1	0xaa
7098d58548Sjdolecek };
7198d58548Sjdolecek #ifdef	atari
7298d58548Sjdolecek /*
7348958e52Sjakllsch  * The boot sector on a GEMDOS FS is a little bit different from the MSDOS FS
7498d58548Sjdolecek  * format. Currently there is no need to declare a separate structure, the
7598d58548Sjdolecek  * bootsector33 struct will do.
7698d58548Sjdolecek  */
7798d58548Sjdolecek #if 0
7898d58548Sjdolecek struct bootsec_atari {
79cbeb0247Sdholland 	uint8_t		bsBranch[2];		/* branch inst if auto-boot	*/
8098d58548Sjdolecek 	int8_t		bsFiller[6];		/* anything or nothing		*/
8198d58548Sjdolecek 	int8_t		bsSerial[3];		/* serial no. for mediachange	*/
8298d58548Sjdolecek 	int8_t		bsBPB[19];		/* BIOS parameter block		*/
8398d58548Sjdolecek 	int8_t		bsBootCode[482];	/* pad so struct is 512b	*/
8498d58548Sjdolecek };
8598d58548Sjdolecek #endif
8698d58548Sjdolecek #endif /* atari */
8798d58548Sjdolecek 
8898d58548Sjdolecek union bootsector {
8998d58548Sjdolecek 	struct bootsector33 bs33;
9098d58548Sjdolecek 	struct bootsector50 bs50;
9198d58548Sjdolecek 	struct bootsector710 bs710;
9298d58548Sjdolecek };
9398d58548Sjdolecek 
9498d58548Sjdolecek #if 0
9598d58548Sjdolecek /*
9698d58548Sjdolecek  * Shorthand for fields in the bpb.
9798d58548Sjdolecek  */
9898d58548Sjdolecek #define	bsBytesPerSec	bsBPB.bpbBytesPerSec
9998d58548Sjdolecek #define	bsSectPerClust	bsBPB.bpbSectPerClust
10098d58548Sjdolecek #define	bsResSectors	bsBPB.bpbResSectors
10198d58548Sjdolecek #define	bsFATS		bsBPB.bpbFATS
10298d58548Sjdolecek #define	bsRootDirEnts	bsBPB.bpbRootDirEnts
10398d58548Sjdolecek #define	bsSectors	bsBPB.bpbSectors
10498d58548Sjdolecek #define	bsMedia		bsBPB.bpbMedia
10598d58548Sjdolecek #define	bsFATsecs	bsBPB.bpbFATsecs
10698d58548Sjdolecek #define	bsSectPerTrack	bsBPB.bpbSectPerTrack
10798d58548Sjdolecek #define	bsHeads		bsBPB.bpbHeads
10898d58548Sjdolecek #define	bsHiddenSecs	bsBPB.bpbHiddenSecs
10998d58548Sjdolecek #define	bsHugeSectors	bsBPB.bpbHugeSectors
11098d58548Sjdolecek #endif
1114bffed72Schristos 
1124bffed72Schristos #endif /* _MSDOSFS_BOOTSECT_H_ */
113