ZFAT ZFAT is a modification of the FAT32 file system for use with ZephyrOS, and should be at least capable of reading FAT32 volumes without any special software. Modifications include; Using full 32-bit cluster addressing (minus special cluster values), . In order to maintain compatibility with FAT32, all multi-byte values are little-endian format. BIOS Parameter Block Offset Bytes Description -------------------------------------------------------------------------------------------------------------------------- 0x000 3 Jump to boot code. Typically 0xC3 0x?? 0x?? (0x?? denotes a 1-byte value) 0x003 8 OEM Name Identifier. Identifier of the system that formatted the volume. Default: 'ZephyrOS' 0x00B 2 Count of bytes per sector. Only powers of two above or equal to 512 supported. Typically 512. 0x00D 1 Number of sectors per cluster, must be nonzero power of two. Typically 1 for volumes < 2TiB 0x00E 2 Number of reserved sectors, must be non-zero. 0x010 1 Number of FATs, typically 2. 0x011 2 Reserved, set to 0. 0x013 2 Sector count if < 65536, otherwise 0. 0x015 1 Media descriptor, typically 0xF8 for 'fixed' disks. 0x016 2 Reserved, set to 0. 0x018 2 Sectors per track (unused in ZFAT) 0x01A 2 Number of heads (unused in ZFAT) 0x01C 4 Count of hidden sectors preceding the partition that contains this ZFAT volume. 0x020 4 Sector count if >= 65536, otherwise 0. 0x024 4 Sectors per FAT 0x028 2 Flags [See 'FLAGS' descritpion below] 0x02A 2 High byte is major version number, low byte is minor version number. 0x02C 4 Cluster address of initial cluster of root directory. Should be 2 or the next usable (not bad) cluster. 0x030 2 Sector number of FSINFO structure in reserved area of the ZFAT volume. Typically 1. 0x032 2 First logical sector number of a backup copy of the three ZFAT BPB sectors. Typically 6. 0x034 12 Reserved. Set to 0. 0x040 1 Drive number. Either 0x80 or 0x00. 0x041 1 Reserved. Set to 0. 0x042 1 Extended boot signature. Set to 0x29 if either of the following fields are nonzero. 0x043 4 Volume serial number. Should be generated by combining the current date and time into a 32-bit value. 0x047 11 Volume label. This field should be updated to match the 11-byte volume label in root directory. 0x052 8 File System identifier, space padded. 'ZFAT ' 0x05A 420 Boot code. 0x1FE 2 Set to 0x55, 0xAA (low byte, high byte). FLAGS Bits Description -------------------------------------------------------------------------------------------------------------------------- 0-3 Zero-based number of active FAT. Only valid if mirroring is disabled. 4-6 Reserved 7 0 = FAT is mirrored at runtime into all FATs. 1 = Only one FAT is active, referenced by bits 0-3 8-15 Reserved FSINFO Offset Bytes Description -------------------------------------------------------------------------------------------------------------------------- 0x000 4 Value = 0x41615252. This value is used as a signature marking the start of the FSINFO sector. 0x004 480 Reserved. Set to 0. 0x1E4 4 Value = 0x61417272. Additional signature for FSINFO sector. 0x1E8 4 Contains last known free cluster count on the volume. 0xFFFFFFFF indicates unknown count. 0x1EC 4 Contains the cluster address of first available free cluster on the volume. 0xFFFFFFFF indicates unknown. 0x1F0 12 Reserved. Set to 0. 0x1FC 4 Value = 0xAA550000. Trail signature is used to validate the FSINFO sector. Cluster Map The data area is divided into clusters, and the cluster map determines wether a cluster is the final cluster for a file or else what cluster continues the file. The first two cluster entries are reserved as special entries. Entry 1 (cluster 0 in the FAT) holds the FAT ID (allowed values 0x0, 0x8-0xF) in the low byte low nibble, which is also copied into the BPB, offset 0x15. The upper nibble of the low byte holds flags for drive integrity status. Bit flags as follows: 7 - Drive Clean (volume was properly unmounted before shutdown) and FSINFO sector up to date. 6 - No Disk I/O errors on startup 5 - Reserved 4 - Reserved The other 24 bits are set to 1. Entry 2 (cluster 1 in the FAT) typically stores the end-of-cluster-chain marker 0xFFFFFFFF. Directory Entry Offset Bytes Description -------------------------------------------------------------------------------------------------------------------------- 0x00 8 File name, padded with spaces. First byte can be used for special values. 0x00 - Entry is available and no subsequent entry is in use. 0x05 - Initial character is actually 0xE5, or file marked for deletion. 0x2E - 'Dot' entry; either '.' or '..' 0xE5 - Entry deleted. 0x08 3 File extension, padded with spaces. 0x0B 1 File Attributes: Bit Description 0 Read Only 1 Hidden 2 System 3 Volume Label 4 Subdirectory 5 Archive 6 Device 7 Reserved 0x0C 1 Reserved, set to 0. 0x0D 1 First character of a deleted file, or creation time in tens of milliseconds (0-199) 0x0E 2 Creation time in the following format: 15-11 - Hours (0-23) 10-5 - Minutes (0-59) 4-0 - Seconds/2 (0-29) 0x10 2 Creation date in the following format: 15-9 - Year (0=1980, 119=2099 supported under DOS/Windows, theoretical max of 127=2107 8-5 - Month (1-12) 4-0 - Day (1-31) 0x12 2 Last access date, see 0x10 for format. 0x14 2 High bytes of first cluster number, low two bytes stored at 0x1A. 0x16 2 Last modified time, see 0x0E for format. 0x18 2 Last modified date, see 0x10 for format. 0x1A 2 Low bytes of first cluster number. Entries with the volume label flag, subdirectory, '..', and empty files should have first cluster 0. 0x1C 4 File size in bytes. Sector ordering Sector Sectors Description -------------------------------------------------------------------------------------------------------------------------- 0x00 1 BIOS Parameter Sector (BPB) 0x01 1 FSINFO sector 0x02 4 Extra boot loader code (if necessary) 0x06 1 Backup BPB 0x07 Varies FAT(s) region Varies Varies Data region Default BPB Offset Data Comment -------------------------------------------------------------------------------------------------------------------------- 0x000 0xC3, 0x5A, 0x50 Jump to bootloader code (assume sector loaded to 0x5000) 0x003 'ZEPHYROS' OEM Name 0x00B