Difference between revisions of "Unit FATFS"
Line 332: | Line 332: | ||
| <code>fatLowercaseChars:set of Byte = [$61..$7A];</code> | | <code>fatLowercaseChars:set of Byte = [$61..$7A];</code> | ||
| 97..122 (These dont account for the code page) | | 97..122 (These dont account for the code page) | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''FATFS params table''' <code> fatParams* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Used for FAT entry block loading | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>fatMaxParams = 11;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>fatParams:array[0..fatMaxParams] of TFATParams = (</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''SectorSize,FATType,BlockShiftCount,EntriesPerBlock,SectorsPerBlock'' | ||
+ | |- | ||
+ | |colspan="2"|''FAT12'' | ||
+ | |- | ||
+ | | <code>(SectorSize:512; FATType:ftFAT12; BlockShiftCount:10; EntriesPerBlock:1024; SectorsPerBlock:3),</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>(SectorSize:1024; FATType:ftFAT12; BlockShiftCount:11 ;EntriesPerBlock:2048; SectorsPerBlock:3),</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>(SectorSize:2048; FATType:ftFAT12; BlockShiftCount:12; EntriesPerBlock:4096; SectorsPerBlock:3),</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>(SectorSize:4096; FATType:ftFAT12; BlockShiftCount:13; EntriesPerBlock:8192; SectorsPerBlock:3),</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''FAT16'' | ||
+ | |- | ||
+ | | <code>(SectorSize:512; FATType:ftFAT16; BlockShiftCount:10; EntriesPerBlock:1024; SectorsPerBlock:4),</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>(SectorSize:1024; FATType:ftFAT16; BlockShiftCount:11; EntriesPerBlock:2048; SectorsPerBlock:4),</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>(SectorSize:2048; FATType:ftFAT16; BlockShiftCount:12; EntriesPerBlock:4096; SectorsPerBlock:4),</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>(SectorSize:4096 ;FATType:ftFAT16 ;BlockShiftCount:13; EntriesPerBlock:8192; SectorsPerBlock:4),</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''FAT32'' | ||
+ | |- | ||
+ | | <code>(SectorSize:512; FATType:ftFAT32; BlockShiftCount:10; EntriesPerBlock:1024; SectorsPerBlock:8),</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>(SectorSize:1024; FATType:ftFAT32; BlockShiftCount:11; EntriesPerBlock:2048; SectorsPerBlock:8),</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>(SectorSize:2048; FATType:ftFAT32; BlockShiftCount:12; EntriesPerBlock:4096; SectorsPerBlock:8),</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>(SectorSize:4096; FATType:ftFAT32; BlockShiftCount:13; EntriesPerBlock:8192; SectorsPerBlock:8));</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''FATFS geometry tables''' <code> fat12Geometry* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Used for FAT formatting (Floppy Disk only) | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>fat12MaxGeometry = 4;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>fat12Geometry:array[0..fat12MaxGeometry] of TFATGeometry = (</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''FloppyType,SectorsPerFat,SectorsPerCluster,RootEntryCount,MediaId'' | ||
+ | |- | ||
+ | | <code>(FloppyType:ft360K; SectorsPerFat:2; SectorsPerCluster:2; RootEntryCount:112; MediaId:$FD),</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>(FloppyType:ft12M;SectorsPerFat:7;SectorsPerCluster:1;RootEntryCount:224;MediaId:$F9),</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>(FloppyType:ft720K; SectorsPerFat:3; SectorsPerCluster:2; RootEntryCount:112; MediaId:$F9),</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>(FloppyType:ft144M; SectorsPerFat:9; SectorsPerCluster:1; RootEntryCount:224; MediaId:$F0),</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>(FloppyType:ft288M; SectorsPerFat:9; SectorsPerCluster:2; RootEntryCount:240; MediaId:$F0));</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''FATFS cluster size tables''' <code> fat_ClusterSize* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Used for FAT formatting (Fixed Disk only) | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>fat12MaxClusterSize = 2;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>fat12ClusterSize:array[0..fat12MaxClusterSize] of TFATClusterSize = (</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''SectorCount,SectorsPerCluster'' | ||
+ | |- | ||
+ | | <code>(SectorCount:6; SectorsPerCluster:0),</code> | ||
+ | | up to 3 KB, the 0 value for SectorsPerCluster trips an error (Not possible due to 512 Root entries) | ||
+ | |- | ||
+ | | <code>(SectorCount:798; SectorsPerCluster:0),</code> | ||
+ | | up to 399 KB, the 0 value for SectorsPerCluster trips an error | ||
+ | |- | ||
+ | | <code>(SectorCount:32623; SectorsPerCluster:8),</code> | ||
+ | | up to 15.9 MB, 4k cluster | ||
+ | |- | ||
+ | | <code>(SectorCount:$FFFFFFFF; SectorsPerCluster:0));</code> | ||
+ | | greater than 15.9 MB, 0 value for SectorsPerCluster trips an error | ||
+ | |- | ||
+ | |colspan="2"|See FAT12 Notes for Min/Max and Values | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>fat16MaxClusterSize = 8;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>fat16ClusterSize:array[0..fat16MaxClusterSize] of TFATClusterSize = (</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''SectorCount,SectorsPerCluster'' | ||
+ | |- | ||
+ | | <code>(SectorCount:8400; SectorsPerCluster:0),</code> | ||
+ | | up to 4.1 MB, the 0 value for SectorsPerCluster trips an error | ||
+ | |- | ||
+ | | <code>(SectorCount:32680; SectorsPerCluster:2),</code> | ||
+ | | up to 16 MB, 1k cluster | ||
+ | |- | ||
+ | | <code>(SectorCount:262144; SectorsPerCluster:4),</code> | ||
+ | | up to 128 MB, 2k cluster | ||
+ | |- | ||
+ | | <code>(SectorCount:524288; SectorsPerCluster:8),</code> | ||
+ | | up to 256 MB, 4k cluster | ||
+ | |- | ||
+ | | <code>(SectorCount:1048576; SectorsPerCluster:16),</code> | ||
+ | | up to 512 MB, 8k cluster | ||
+ | |- | ||
+ | |colspan="2"|The entries after this point are not used unless FAT16 is forced | ||
+ | |- | ||
+ | | <code>(SectorCount:2097152; SectorsPerCluster:32),</code> | ||
+ | | up to 1 GB, 16k cluster | ||
+ | |- | ||
+ | | <code>(SectorCount:4194304; SectorsPerCluster:64),</code> | ||
+ | | up to 2 GB, 32k cluster | ||
+ | |- | ||
+ | | <code>(SectorCount:8388608; SectorsPerCluster:128),</code> | ||
+ | | up to 4 GB, 64k cluster | ||
+ | |- | ||
+ | | <code>(SectorCount:$FFFFFFFF;SectorsPerCluster:0));</code> | ||
+ | | greater than 4 GB, 0 value for SectorsPerCluster trips an error | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>fat32MaxClusterSize = 5;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>fat32ClusterSize:array[0..fat32MaxClusterSize] of TFATClusterSize = (</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''SectorCount,SectorsPerCluster'' | ||
+ | |- | ||
+ | | <code>(SectorCount:66600; SectorsPerCluster:0),</code> | ||
+ | | up to 32.5 MB, the 0 value for SectorsPerCluster trips an error | ||
+ | |- | ||
+ | | <code>(SectorCount:532480 ;SectorsPerCluster:1),</code> | ||
+ | | up to 260 MB, .5k cluster | ||
+ | |- | ||
+ | |colspan="2"|The entries before this point are not used unless FAT32 is forced | ||
+ | |- | ||
+ | | <code>(SectorCount:16777216; SectorsPerCluster:8),</code> | ||
+ | | up to 8 GB, 4k cluster | ||
+ | |- | ||
+ | | <code>(SectorCount:33554432; SectorsPerCluster:16),</code> | ||
+ | | up to 16 GB, 8k cluster | ||
+ | |- | ||
+ | | <code>(SectorCount:67108864; SectorsPerCluster:32),</code> | ||
+ | | up to 32 GB, 16k cluster | ||
+ | |- | ||
+ | | <code>(SectorCount:$FFFFFFFF; SectorsPerCluster:64));</code> | ||
+ | | greater than 32 GB, 32k cluster | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''FATFS partition types''' <code> fatPartitionType* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>fatMaxPartitionType = 5;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>fatPartitionType:array[0..fatMaxPartitionType] of TFATPartitionType = (</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''Excluded,Extended,SectorCount,PartitionId,LBAType'' | ||
+ | |- | ||
+ | |colspan="2"|''Extended Partitions'' | ||
+ | |- | ||
+ | | <code>(Excluded:False; Extended:True; SectorCount:$FFFFFFFF ;PartitionId:pidExtended; LBAType:pidExtLBA),</code> | ||
+ | | any size, Extended | ||
+ | |- | ||
+ | |colspan="2"|Primary and Logical Partitions | ||
+ | |- | ||
+ | |colspan="2"|''Unused'' | ||
+ | |- | ||
+ | | <code>(Excluded:False; Extended:False; SectorCount:798; PartitionId:pidUnused; LBAType:pidUnused),</code> | ||
+ | | up to 399 KB, Unused (Unused type trips an error) | ||
+ | |- | ||
+ | |colspan="2"|''FAT12'' | ||
+ | |- | ||
+ | | <code>(Excluded:False; Extended:False; SectorCount:32680; PartitionId:pidFAT12; LBAType:pidFAT12),</code> | ||
+ | | up to 16 MB, FAT12 | ||
+ | |- | ||
+ | |colspan="2"|''FAT16'' | ||
+ | |- | ||
+ | | <code>(Excluded:False; Extended:False; SectorCount:65360; PartitionId:pidFAT16; LBAType:pidFAT16LBA),</code> | ||
+ | | up to 32 MB, FAT16 | ||
+ | |- | ||
+ | | <code>(Excluded:False; Extended:False; SectorCount:1048576; PartitionId:pidFAT16HUGE; LBAType:pidFAT16LBA),</code> | ||
+ | | up to 512 MB, FAT16 HUGE | ||
+ | |- | ||
+ | |colspan="2"|''FAT32'' | ||
+ | |- | ||
+ | | <code>(Excluded:False; Extended:False; SectorCount:$FFFFFFFF; PartitionId:pidFAT32; LBAType:pidFAT32LBA));</code> | ||
+ | | above 512 MB, FAT32 | ||
|- | |- | ||
|} | |} |
Revision as of 02:48, 30 May 2017
Return to Unit Reference
Contents
[hide]Description
Ultibo FAT12/16/32/exFAT interface unit
Notes:
Based on information from numerous sources, primarily the document fatgen103.pdf from Microsoft. FAT Disk Blocks are based on reading a group of sectors into a block at once. The BlockNo of each block is therefore the FAT entry no of the first FAT in the block.
The use of IsEightDotThree and GenerateShortName(Ex) from the UltiboUtils unit should be replaced by internal routines optimised for maximum performance. All Block and Entry Offsets have been expanded to 32bit to avoid 16bit overflow on 64K clusters.
Constants
fat*
fatParams*
fat12Geometry*
fat_ClusterSize*
fatPartitionType*
Type definitions
FATFS specific types
TFATType = (ftNONE,ftFAT12,ftFAT16,ftFAT32);
|
FATFS params
TFATParams = record
FATFS geometry
TFATGeometry = record
FATFS cluster size
TFATClusterSize = record
FATFS partition type
TFATPartitionType = record
FATFS name
FATSFS directory
LFN directory
FATFS info sector
Class definitions
FAT recognizer
TFATRecognizer = class(TRecognizer)
FAT partitioner
TFATPartitioner = class(TDiskPartitioner)
FAT formatter
TFATFormatter = class(TDiskFormatter)
FAT defragger
TFATDefragger = class(TDiskDefragger)
FAT repairer
TFATRepairer = class(TDiskRepairer)
FAT file system
TFATFileSystem = class(TFileSystem)
FAT disk table
TFATDiskTable = class(TDiskTable)
FAT disk block
TFATDiskBlock = class(TDiskBlock)
FAT disk entry
TFATDiskEntry = class(TDiskEntry)
Public variables
None defined
Function declarations
Initialization functions
FATFS helper functions
Return to Unit Reference