00001 00006 #ifndef BUFFER_H 00007 #define BUFFER_H 00008 00009 typedef unsigned char byte; 00010 typedef unsigned int word; 00011 typedef unsigned long u_32; 00015 union DirRecordUnion { 00017 struct Entry { 00018 byte Name[11]; 00019 byte Attr; 00020 byte NTRes; 00021 byte CrtTimeTenth; 00022 word CrtTime; 00023 word CrtDate; 00024 word LstAccDate; 00025 word FstClusHi; 00026 word WrtTime; 00027 word WrtDate; 00028 word FstClusLo; 00029 u_32 FileSize; 00030 } entry; 00031 00033 struct LongEntry { 00034 byte Ord; 00035 word Name1[5]; 00036 byte Attr; 00037 byte Type; 00038 byte Chksum; 00039 word Name2[6]; 00040 word FstClusLO; 00041 word Name3[2]; 00042 } longentry; 00043 }; 00044 00046 typedef union DirRecordUnion dirrecordtype; 00047 00048 00050 /* FAT structure definition from Microsoft's FAT32 File System 00051 * Specification, version 1.03. Always use 512 byte disk block. */ 00052 00053 typedef union DiskBlock { 00054 00056 struct Fat { 00057 byte BS_jmpBoot[3]; 00058 byte BS_OEMName[8]; 00060 word BPB_BytsPerSec; 00061 byte BPB_SecPerClus; 00062 word BPB_RsvdSecCnt; 00063 byte BPB_NumFATs; 00064 word BPB_RootEntCnt; 00065 word BPB_TotSec16; 00066 byte BPB_Media; 00067 word BPB_FATSz16; 00068 word BPB_SecPerTrk; 00069 word BPB_NumHeads; 00070 u_32 BPB_HiddSec; 00071 u_32 BPB_TotSec32; 00074 union Extensions{ 00075 00077 struct Fat16Specific { 00078 byte BS_DrvNum; 00079 byte BS_Reserved1; 00080 byte BS_BootSig; 00081 byte BS_VolID[4]; 00082 byte BS_VolLab[11]; 00083 byte BS_FilSysType[8]; 00084 } _16; 00085 00087 struct Fat32Specific { 00088 u_32 BPB_FATSz32; 00089 word BPB_ExtFlags; 00090 word BPB_FSVer; 00091 u_32 BPB_RootClus; 00092 word BPB_FSInfo; 00093 word BPB_BkBootSec; 00094 byte BPB_Reserved[12]; 00095 byte BS_DrvNum; 00096 byte BS_Reserved1; 00097 byte BS_BootSig; 00098 byte BS_VolID[4]; 00099 byte BS_VolLab[11]; 00100 byte BS_FilSysType[8]; 00101 } _32; 00102 } ext; 00103 } fat; 00104 00106 struct Raw { 00107 byte buf[512]; 00108 } raw; 00109 00111 dirrecordtype dir[16]; 00112 00114 word Fat16Table[256]; 00115 00117 u_32 Fat32Table[128]; 00118 00119 00120 00121 } DiskBlockType; 00122 00123 00124 00128 union Address { 00129 unsigned long l; 00130 struct B { 00131 unsigned char b0; 00132 unsigned char b1; 00133 unsigned char b2; 00134 unsigned char b3; 00135 } b; 00136 }; 00137 00139 typedef union Address addressType; 00140 00145 extern addressType sectorAddress; 00146 00148 extern xdata DiskBlockType diskSect; 00149 00154 extern xdata unsigned char *dataBufPtr; 00155 00156 00157 00158 #endif