1 1.3 christos /* $NetBSD: bootsect.h,v 1.3 2005/12/03 17:34:43 christos 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.3 christos #ifndef _MSDOSFS_BOOTSECT_H_ 19 1.3 christos #define _MSDOSFS_BOOTSECT_H_ 20 1.1 jdolecek 21 1.1 jdolecek /* 22 1.1 jdolecek * Format of a boot sector. This is the first sector on a DOS floppy disk 23 1.1 jdolecek * or the fist sector of a partition on a hard disk. But, it is not the 24 1.1 jdolecek * first sector of a partitioned hard disk. 25 1.1 jdolecek */ 26 1.1 jdolecek struct bootsector33 { 27 1.1 jdolecek u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */ 28 1.1 jdolecek int8_t bsOemName[8]; /* OEM name and version */ 29 1.1 jdolecek int8_t bsBPB[19]; /* BIOS parameter block */ 30 1.1 jdolecek int8_t bsDriveNumber; /* drive number (0x80) */ 31 1.1 jdolecek int8_t bsBootCode[479]; /* pad so struct is 512b */ 32 1.1 jdolecek u_int8_t bsBootSectSig0; 33 1.1 jdolecek u_int8_t bsBootSectSig1; 34 1.1 jdolecek #define BOOTSIG0 0x55 35 1.1 jdolecek #define BOOTSIG1 0xaa 36 1.1 jdolecek }; 37 1.1 jdolecek 38 1.1 jdolecek struct extboot { 39 1.1 jdolecek int8_t exDriveNumber; /* drive number (0x80) */ 40 1.1 jdolecek int8_t exReserved1; /* reserved */ 41 1.1 jdolecek int8_t exBootSignature; /* ext. boot signature (0x29) */ 42 1.1 jdolecek #define EXBOOTSIG 0x29 43 1.1 jdolecek int8_t exVolumeID[4]; /* volume ID number */ 44 1.1 jdolecek int8_t exVolumeLabel[11]; /* volume label */ 45 1.1 jdolecek int8_t exFileSysType[8]; /* fs type (FAT12 or FAT16) */ 46 1.1 jdolecek }; 47 1.1 jdolecek 48 1.1 jdolecek struct bootsector50 { 49 1.1 jdolecek u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */ 50 1.1 jdolecek int8_t bsOemName[8]; /* OEM name and version */ 51 1.1 jdolecek int8_t bsBPB[25]; /* BIOS parameter block */ 52 1.1 jdolecek int8_t bsExt[26]; /* Bootsector Extension */ 53 1.1 jdolecek int8_t bsBootCode[448]; /* pad so structure is 512b */ 54 1.1 jdolecek u_int8_t bsBootSectSig0; 55 1.1 jdolecek u_int8_t bsBootSectSig1; 56 1.1 jdolecek #define BOOTSIG0 0x55 57 1.1 jdolecek #define BOOTSIG1 0xaa 58 1.1 jdolecek }; 59 1.1 jdolecek 60 1.1 jdolecek struct bootsector710 { 61 1.1 jdolecek u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */ 62 1.1 jdolecek int8_t bsOEMName[8]; /* OEM name and version */ 63 1.2 lukem int8_t bsBPB[53]; /* BIOS parameter block */ 64 1.1 jdolecek int8_t bsExt[26]; /* Bootsector Extension */ 65 1.1 jdolecek int8_t bsBootCode[418]; /* pad so structure is 512b */ 66 1.1 jdolecek u_int8_t bsBootSectSig2; /* 2 & 3 are only defined for FAT32? */ 67 1.1 jdolecek u_int8_t bsBootSectSig3; 68 1.1 jdolecek u_int8_t bsBootSectSig0; 69 1.1 jdolecek u_int8_t bsBootSectSig1; 70 1.1 jdolecek #define BOOTSIG0 0x55 71 1.1 jdolecek #define BOOTSIG1 0xaa 72 1.1 jdolecek #define BOOTSIG2 0 73 1.1 jdolecek #define BOOTSIG3 0 74 1.1 jdolecek }; 75 1.1 jdolecek #ifdef atari 76 1.1 jdolecek /* 77 1.1 jdolecek * The boot sector on a gemdos fs is a little bit different from the msdos fs 78 1.1 jdolecek * format. Currently there is no need to declare a separate structure, the 79 1.1 jdolecek * bootsector33 struct will do. 80 1.1 jdolecek */ 81 1.1 jdolecek #if 0 82 1.1 jdolecek struct bootsec_atari { 83 1.1 jdolecek u_int8_t bsBranch[2]; /* branch inst if auto-boot */ 84 1.1 jdolecek int8_t bsFiller[6]; /* anything or nothing */ 85 1.1 jdolecek int8_t bsSerial[3]; /* serial no. for mediachange */ 86 1.1 jdolecek int8_t bsBPB[19]; /* BIOS parameter block */ 87 1.1 jdolecek int8_t bsBootCode[482]; /* pad so struct is 512b */ 88 1.1 jdolecek }; 89 1.1 jdolecek #endif 90 1.1 jdolecek #endif /* atari */ 91 1.1 jdolecek 92 1.1 jdolecek union bootsector { 93 1.1 jdolecek struct bootsector33 bs33; 94 1.1 jdolecek struct bootsector50 bs50; 95 1.1 jdolecek struct bootsector710 bs710; 96 1.1 jdolecek }; 97 1.1 jdolecek 98 1.1 jdolecek #if 0 99 1.1 jdolecek /* 100 1.1 jdolecek * Shorthand for fields in the bpb. 101 1.1 jdolecek */ 102 1.1 jdolecek #define bsBytesPerSec bsBPB.bpbBytesPerSec 103 1.1 jdolecek #define bsSectPerClust bsBPB.bpbSectPerClust 104 1.1 jdolecek #define bsResSectors bsBPB.bpbResSectors 105 1.1 jdolecek #define bsFATS bsBPB.bpbFATS 106 1.1 jdolecek #define bsRootDirEnts bsBPB.bpbRootDirEnts 107 1.1 jdolecek #define bsSectors bsBPB.bpbSectors 108 1.1 jdolecek #define bsMedia bsBPB.bpbMedia 109 1.1 jdolecek #define bsFATsecs bsBPB.bpbFATsecs 110 1.1 jdolecek #define bsSectPerTrack bsBPB.bpbSectPerTrack 111 1.1 jdolecek #define bsHeads bsBPB.bpbHeads 112 1.1 jdolecek #define bsHiddenSecs bsBPB.bpbHiddenSecs 113 1.1 jdolecek #define bsHugeSectors bsBPB.bpbHugeSectors 114 1.1 jdolecek #endif 115 1.3 christos 116 1.3 christos #endif /* _MSDOSFS_BOOTSECT_H_ */ 117