1 /* $Id$ */ 2 /* $NetBSD: bpb.h,v 1.3 1994/06/29 06:35:29 cgd Exp $ */ 3 4 /* 5 * Written by Paul Popelka (paulp@uts.amdahl.com) 6 * 7 * You can do anything you want with this software, just don't say you wrote 8 * it, and don't remove this notice. 9 * 10 * This software is provided "as is". 11 * 12 * The author supplies this software to be publicly redistributed on the 13 * understanding that the author is not responsible for the correct 14 * functioning of this software in any circumstances and is not liable for 15 * any damages caused by this software. 16 * 17 * October 1992 18 */ 19 20 /* 21 * BIOS Parameter Block (BPB) for DOS 3.3 22 */ 23 struct bpb33 { 24 u_short bpbBytesPerSec; /* bytes per sector */ 25 u_char bpbSecPerClust; /* sectors per cluster */ 26 u_short bpbResSectors; /* number of reserved sectors */ 27 u_char bpbFATs; /* number of FATs */ 28 u_short bpbRootDirEnts; /* number of root directory entries */ 29 u_short bpbSectors; /* total number of sectors */ 30 u_char bpbMedia; /* media descriptor */ 31 u_short bpbFATsecs; /* number of sectors per FAT */ 32 u_short bpbSecPerTrack; /* sectors per track */ 33 u_short bpbHeads; /* number of heads */ 34 u_short bpbHiddenSecs; /* number of hidden sectors */ 35 }; 36 37 /* 38 * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3, 39 * and bpbHugeSectors is not in the 3.3 bpb. 40 */ 41 struct bpb50 { 42 u_short bpbBytesPerSec; /* bytes per sector */ 43 u_char bpbSecPerClust; /* sectors per cluster */ 44 u_short bpbResSectors; /* number of reserved sectors */ 45 u_char bpbFATs; /* number of FATs */ 46 u_short bpbRootDirEnts; /* number of root directory entries */ 47 u_short bpbSectors; /* total number of sectors */ 48 u_char bpbMedia; /* media descriptor */ 49 u_short bpbFATsecs; /* number of sectors per FAT */ 50 u_short bpbSecPerTrack; /* sectors per track */ 51 u_short bpbHeads; /* number of heads */ 52 u_long bpbHiddenSecs; /* number of hidden sectors */ 53 u_long bpbHugeSectors; /* number of sectrs if bpbSectors == 0 */ 54 }; 55 56 /* 57 * The following structures represent how the bpb's look on disk. shorts 58 * and longs are just character arrays of the appropriate length. This is 59 * because the compiler forces shorts and longs to align on word or 60 * halfword boundaries. 61 * 62 * XXX The little-endian code here assumes that the processor can access 63 * 16-bit and 32-bit quantities on byte boundaries. If this is not true, 64 * use the macros for the big-endian case. 65 */ 66 #include <machine/endian.h> 67 #if BYTE_ORDER == LITTLE_ENDIAN /* && can do unaligned accesses */ 68 #define getushort(x) *((u_short *)(x)) 69 #define getulong(x) *((u_long *)(x)) 70 #define putushort(p, v) (*((u_short *)(p)) = (v)) 71 #define putulong(p, v) (*((u_long *)(p)) = (v)) 72 73 #else 74 #define getushort(x) (((u_char *)(x))[0] + (((u_char *)(x))[1] << 8)) 75 #define getulong(x) (((u_char *)(x))[0] + (((u_char *)(x))[1] << 8) \ 76 + (((u_char *)(x))[2] << 16) \ 77 + (((u_char *)(x))[3] << 24)) 78 #define putushort(p, v) (((u_char *)(p))[0] = (v), \ 79 ((u_char *)(p))[1] = (v) >> 8) 80 #define putulong(p, v) (((u_char *)(p))[0] = (v), \ 81 ((u_char *)(p))[1] = (v) >> 8, \ 82 ((u_char *)(p))[2] = (v) >> 16,\ 83 ((u_char *)(p))[3] = (v) >> 24) 84 #endif 85 86 /* 87 * BIOS Parameter Block (BPB) for DOS 3.3 88 */ 89 struct byte_bpb33 { 90 char bpbBytesPerSec[2]; /* bytes per sector */ 91 char bpbSecPerClust; /* sectors per cluster */ 92 char bpbResSectors[2]; /* number of reserved sectors */ 93 char bpbFATs; /* number of FATs */ 94 char bpbRootDirEnts[2]; /* number of root directory entries */ 95 char bpbSectors[2]; /* total number of sectors */ 96 char bpbMedia; /* media descriptor */ 97 char bpbFATsecs[2]; /* number of sectors per FAT */ 98 char bpbSecPerTrack[2]; /* sectors per track */ 99 char bpbHeads[2]; /* number of heads */ 100 char bpbHiddenSecs[2]; /* number of hidden sectors */ 101 }; 102 103 /* 104 * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3, 105 * and bpbHugeSectors is not in the 3.3 bpb. 106 */ 107 struct byte_bpb50 { 108 char bpbBytesPerSec[2]; /* bytes per sector */ 109 char bpbSecPerClust; /* sectors per cluster */ 110 char bpbResSectors[2]; /* number of reserved sectors */ 111 char bpbFATs; /* number of FATs */ 112 char bpbRootDirEnts[2]; /* number of root directory entries */ 113 char bpbSectors[2]; /* total number of sectors */ 114 char bpbMedia; /* media descriptor */ 115 char bpbFATsecs[2]; /* number of sectors per FAT */ 116 char bpbSecPerTrack[2]; /* sectors per track */ 117 char bpbHeads[2]; /* number of heads */ 118 char bpbHiddenSecs[4]; /* number of hidden sectors */ 119 char bpbHugeSectors[4]; /* number of sectrs if bpbSectors == 0 */ 120 }; 121