summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/fat.c43
-rw-r--r--firmware/drivers/fat.h44
2 files changed, 43 insertions, 44 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index 88d13c3eab..91019faf0e 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -114,6 +114,49 @@ struct fsinfo {
114#define FSINFO_FREECOUNT 488 114#define FSINFO_FREECOUNT 488
115#define FSINFO_NEXTFREE 492 115#define FSINFO_NEXTFREE 492
116 116
117struct bpb
118{
119 char bs_oemname[9]; /* OEM string, ending with \0 */
120 int bpb_bytspersec; /* Bytes per sectory, typically 512 */
121 int bpb_secperclus; /* Sectors per cluster */
122 int bpb_rsvdseccnt; /* Number of reserved sectors */
123 int bpb_numfats; /* Number of FAT structures, typically 2 */
124 int bpb_rootentcnt; /* Number of dir entries in the root */
125 int bpb_totsec16; /* Number of sectors on the volume (old 16-bit) */
126 int bpb_media; /* Media type (typically 0xf0 or 0xf8) */
127 int bpb_fatsz16; /* Number of used sectors per FAT structure */
128 int bpb_secpertrk; /* Number of sectors per track */
129 int bpb_numheads; /* Number of heads */
130 int bpb_hiddsec; /* Hidden sectors before the volume */
131 unsigned int bpb_totsec32; /* Number of sectors on the volume
132 (new 32-bit) */
133 int last_word; /* 0xAA55 */
134
135 /**** FAT12/16 specific *****/
136 int bs_drvnum; /* Drive number */
137 int bs_bootsig; /* Is 0x29 if the following 3 fields are valid */
138 unsigned int bs_volid; /* Volume ID */
139 char bs_vollab[12]; /* Volume label, 11 chars plus \0 */
140 char bs_filsystype[9]; /* File system type, 8 chars plus \0 */
141
142 /**** FAT32 specific *****/
143 int bpb_fatsz32;
144 int bpb_extflags;
145 int bpb_fsver;
146 int bpb_rootclus;
147 int bpb_fsinfo;
148 int bpb_bkbootsec;
149
150 /* variables for internal use */
151 int fatsize;
152 int totalsectors;
153 int rootdirsector;
154 int firstdatasector;
155 int startsector;
156};
157
158struct bpb fat_bpb;
159
117static int first_sector_of_cluster(int cluster); 160static int first_sector_of_cluster(int cluster);
118static int bpb_is_sane(void); 161static int bpb_is_sane(void);
119static void *cache_fat_sector(int secnum); 162static void *cache_fat_sector(int secnum);
diff --git a/firmware/drivers/fat.h b/firmware/drivers/fat.h
index 463910d52e..844864d88b 100644
--- a/firmware/drivers/fat.h
+++ b/firmware/drivers/fat.h
@@ -22,47 +22,6 @@
22 22
23#define SECTOR_SIZE 512 23#define SECTOR_SIZE 512
24 24
25struct bpb
26{
27 char bs_oemname[9]; /* OEM string, ending with \0 */
28 int bpb_bytspersec; /* Bytes per sectory, typically 512 */
29 int bpb_secperclus; /* Sectors per cluster */
30 int bpb_rsvdseccnt; /* Number of reserved sectors */
31 int bpb_numfats; /* Number of FAT structures, typically 2 */
32 int bpb_rootentcnt; /* Number of dir entries in the root */
33 int bpb_totsec16; /* Number of sectors on the volume (old 16-bit) */
34 int bpb_media; /* Media type (typically 0xf0 or 0xf8) */
35 int bpb_fatsz16; /* Number of used sectors per FAT structure */
36 int bpb_secpertrk; /* Number of sectors per track */
37 int bpb_numheads; /* Number of heads */
38 int bpb_hiddsec; /* Hidden sectors before the volume */
39 unsigned int bpb_totsec32; /* Number of sectors on the volume
40 (new 32-bit) */
41 int last_word; /* 0xAA55 */
42
43 /**** FAT12/16 specific *****/
44 int bs_drvnum; /* Drive number */
45 int bs_bootsig; /* Is 0x29 if the following 3 fields are valid */
46 unsigned int bs_volid; /* Volume ID */
47 char bs_vollab[12]; /* Volume label, 11 chars plus \0 */
48 char bs_filsystype[9]; /* File system type, 8 chars plus \0 */
49
50 /**** FAT32 specific *****/
51 int bpb_fatsz32;
52 int bpb_extflags;
53 int bpb_fsver;
54 int bpb_rootclus;
55 int bpb_fsinfo;
56 int bpb_bkbootsec;
57
58 /* variables for internal use */
59 int fatsize;
60 int totalsectors;
61 int rootdirsector;
62 int firstdatasector;
63 int startsector;
64};
65
66struct fat_direntry 25struct fat_direntry
67{ 26{
68 unsigned char name[256]; /* Name plus \0 */ 27 unsigned char name[256]; /* Name plus \0 */
@@ -101,9 +60,6 @@ struct fat_file
101 int sectornum; /* sector number in this cluster */ 60 int sectornum; /* sector number in this cluster */
102}; 61};
103 62
104/* global FAT info struct */
105extern struct bpb fat_bpb;
106
107extern int fat_mount(int startsector); 63extern int fat_mount(int startsector);
108 64
109#ifdef DISK_WRITE 65#ifdef DISK_WRITE