bootsect.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* $OpenBSD: bootsect.h,v 1.5 2006/12/15 03:04:24 krw Exp $ */
  2. /* $NetBSD: bootsect.h,v 1.8 1997/10/17 11:23:29 ws Exp $ */
  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. /*
  19. * Format of a boot sector. This is the first sector on a DOS floppy disk
  20. * or the fist sector of a partition on a hard disk. But, it is not the
  21. * first sector of a partitioned hard disk.
  22. */
  23. struct bootsector33 {
  24. u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */
  25. int8_t bsOemName[8]; /* OEM name and version */
  26. int8_t bsBPB[19]; /* BIOS parameter block */
  27. int8_t bsDriveNumber; /* drive number (0x80) */
  28. int8_t bsBootCode[479]; /* pad so struct is 512b */
  29. u_int8_t bsBootSectSig0;
  30. u_int8_t bsBootSectSig1;
  31. #define BOOTSIG0 0x55
  32. #define BOOTSIG1 0xaa
  33. };
  34. struct extboot {
  35. int8_t exDriveNumber; /* drive number (0x80) */
  36. int8_t exReserved1; /* reserved */
  37. int8_t exBootSignature; /* ext. boot signature (0x29) */
  38. #define EXBOOTSIG 0x29
  39. int8_t exVolumeID[4]; /* volume ID number */
  40. int8_t exVolumeLabel[11]; /* volume label */
  41. int8_t exFileSysType[8]; /* fs type (FAT12 or FAT16) */
  42. };
  43. struct bootsector50 {
  44. u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */
  45. int8_t bsOemName[8]; /* OEM name and version */
  46. int8_t bsBPB[25]; /* BIOS parameter block */
  47. int8_t bsExt[26]; /* Bootsector Extension */
  48. int8_t bsBootCode[448]; /* pad so structure is 512b */
  49. u_int8_t bsBootSectSig0;
  50. u_int8_t bsBootSectSig1;
  51. #define BOOTSIG0 0x55
  52. #define BOOTSIG1 0xaa
  53. };
  54. struct bootsector710 {
  55. u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */
  56. int8_t bsOEMName[8]; /* OEM name and version */
  57. int8_t bsPBP[53]; /* BIOS parameter block */
  58. int8_t bsExt[26]; /* Bootsector Extension */
  59. int8_t bsBootCode[418]; /* pad so structure is 512b */
  60. u_int8_t bsBootSectSig2; /* 2 & 3 are only defined for FAT32? */
  61. u_int8_t bsBootSectSig3;
  62. u_int8_t bsBootSectSig0;
  63. u_int8_t bsBootSectSig1;
  64. #define BOOTSIG0 0x55
  65. #define BOOTSIG1 0xaa
  66. #define BOOTSIG2 0
  67. #define BOOTSIG3 0
  68. };
  69. union bootsector {
  70. struct bootsector33 bs33;
  71. struct bootsector50 bs50;
  72. struct bootsector710 bs710;
  73. };
  74. #if 0
  75. /*
  76. * Shorthand for fields in the bpb.
  77. */
  78. #define bsBytesPerSec bsBPB.bpbBytesPerSec
  79. #define bsSectPerClust bsBPB.bpbSectPerClust
  80. #define bsResSectors bsBPB.bpbResSectors
  81. #define bsFATS bsBPB.bpbFATS
  82. #define bsRootDirEnts bsBPB.bpbRootDirEnts
  83. #define bsSectors bsBPB.bpbSectors
  84. #define bsMedia bsBPB.bpbMedia
  85. #define bsFATsecs bsBPB.bpbFATsecs
  86. #define bsSectPerTrack bsBPB.bpbSectPerTrack
  87. #define bsHeads bsBPB.bpbHeads
  88. #define bsHiddenSecs bsBPB.bpbHiddenSecs
  89. #define bsHugeSectors bsBPB.bpbHugeSectors
  90. #endif