Information Technology Reference
In-Depth Information
Table 8-7: A FAT entry tells whether a cluster is available, bad, or in use and if
in use, the number of the next cluster in a file or directory, if any.
FAT16 Range (hex)
FAT32 Range (hex)
(ignore bits 28--31)
Description
0000
0000000
available cluster
0001
0000001
reserved cluster
0002--FFEF
0000002--FFFFFEF
the number of the next cluster in
the file
FFF0--FFF6
FFFFFF0--FFFFFF6
reserved (not currently defined)
FFF7
FFFFFF7
bad cluster
FFF8--FFFF
FFFFFF8--FFFFFFF
the file's last cluster (EOC marker)
Accessing the FAT
The PIC18F4550 FAT16 firmware that follows shows how to convert a
data-cluster number to a logical block address, how to read and write to the
FAT, how to find a file's next cluster, and how to find an empty cluster.
Volume Information
A DISK structure can hold in information about a volume and its FAT:
#define FAT16 2
#define FAT32 3
typedef struct
{
byte*
buffer;
// pointer to a buffer equal to one sector
dword
firsts;
// LBA of the volume's first sector
dword
fat;
// LBA of the volume's FAT
dword
root;
// LBA of the volume's root directory
dword
data;
// LBA of the volume's data area
word
maxroot;
// maximum number of entries in the root directory
dword
maxcls;
// maximum number of data clusters in the volume
word
fatsize;
// number of sectors in the FAT
byte
fatcopy;
// number of copies of the FAT
byte
SecPerClus;
// number of sectors per cluster
byte
type;
// type of FAT (FAT16, FAT32)
byte
mount;
// TRUE if the media is mounted, FALSE if not mounted)
} DISK;
Search WWH ::




Custom Search