Difference between revisions of "Unit FATFS"
Line 341: | Line 341: | ||
=== Type definitions === | === Type definitions === | ||
+ | ---- | ||
+ | |||
+ | '''FATFS specific types''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TFATType = (ftNONE,ftFAT12,ftFAT16,ftFAT32);</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''FATFS params''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TFATParams = record </code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: (Not Packed) Block values for various Sector sizes. | ||
+ | |- | ||
+ | | <code>SectorSize:Word;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>FATType:TFATType;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BlockShiftCount:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>EntriesPerBlock:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>SectorsPerBlock:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''FATFS geometry''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TFATGeometry = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: (Not Packed) FAT12 values for various Floppy Types. | ||
+ | |- | ||
+ | | <code>FloppyType:TFloppyType;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>SectorsPerFat:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>SectorsPerCluster:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>RootEntryCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>MediaId:Byte;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''FATFS cluster size''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TFATClusterSize = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: (Not Packed) Sectors per Cluster for various disk sizes (Fixed Disk only). | ||
+ | |- | ||
+ | | <code>SectorCount:LongWord;</code> | ||
+ | | Based on 512 bytes per sector only | ||
+ | |- | ||
+ | | <code>SectorsPerCluster:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''FATFS partition type''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TFATPartitionType = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: (Not Packed) Partition Type for various disk sizes (Fixed Disk only). | ||
+ | |- | ||
+ | | <code>Excluded:Boolean;</code> | ||
+ | | Entry is excluded from FAT Partition Type check | ||
+ | |- | ||
+ | | <code>Extended:Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>SectorCount:LongWord;</code> | ||
+ | | Based on 512 bytes per sector only | ||
+ | |- | ||
+ | | <code>PartitionId:Byte;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>LBAType:Byte;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''FATFS name''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PFATName = ^TFATName;</code> | ||
+ | |||
+ | <code>TFATName = packed record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: 11 Bytes | ||
+ | |- | ||
+ | | <code>Name:array[0..7] of Char;</code> | ||
+ | | File Name | ||
+ | |- | ||
+ | | <code>Ext:array[0..2] of Char;</code> | ||
+ | | File Extension | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''FATSFS directory''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PFATDirectory = ^TFATDirectory;</code> | ||
+ | |||
+ | <code>TFATDirectory = packed record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: 32 Bytes | ||
+ | |- | ||
+ | | <code>Name:array[0..7] of Char;</code> | ||
+ | | File Name | ||
+ | |- | ||
+ | | <code>Ext:array[0..2] of Char;</code> | ||
+ | | File Extension | ||
+ | |- | ||
+ | | <code>Attribute:Byte;</code> | ||
+ | | File Attributes - See Standard Values | ||
+ | |- | ||
+ | | <code>Reserved:Byte;</code> | ||
+ | | Always 0 (See below) | ||
+ | |- | ||
+ | | <code>CaseFlags:Byte;</code> | ||
+ | | Set to $08 if Name, $10 if Extension or $18 if both | ||
+ | |- | ||
+ | | <code>CreateTimeMsecs:Byte;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>CreateTime:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>CreateDate:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>LastAccessDate:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FirstClusterHigh:Word;</code> | ||
+ | | High word of the start cluster (FAT32 Only) | ||
+ | |- | ||
+ | | <code>WriteTime:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>WriteDate:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FirstClusterLow:Word;</code> | ||
+ | | Low Word of Start Cluster all versions | ||
+ | |- | ||
+ | | <code>Length:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''LFN directory''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PLFNDirectory = ^TLFNDirectory;</code> | ||
+ | |||
+ | <code>TLFNDirectory = packed record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: 32 Bytes | ||
+ | |- | ||
+ | | <code>Order:Byte;</code> | ||
+ | | Bit 6 = 1 if last LFN in chain, Bits 5-0 = Order of LFN chunks for this File | ||
+ | |- | ||
+ | | <code>Name1:array[0..4] of WideChar;</code> | ||
+ | | First 5 Characters in this chunk | ||
+ | |- | ||
+ | | <code>Attribute:Byte;</code> | ||
+ | | Always 0Fh - Volume, System, Hidden, ReadOnly | ||
+ | |- | ||
+ | | <code>FileType:Byte;</code> | ||
+ | | Usually 00h | ||
+ | |- | ||
+ | | <code>Checksum:Byte;</code> | ||
+ | | Checksum calculated on 8.3 name | ||
+ | |- | ||
+ | | <code>Name2:array[0..5] of WideChar;</code> | ||
+ | | Next 6 Characters in this chunk | ||
+ | |- | ||
+ | | <code>Reserved:Word;</code> | ||
+ | | Always 0000h - FirstCluster in Standard Entry | ||
+ | |- | ||
+ | | <code>Name3:array[0..1] of WideChar;</code> | ||
+ | | Next 2 Characters in this chunk | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''FATFS info sector''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PFATInfoSector = ^TFATInfoSector;</code> | ||
+ | |||
+ | <code>TFATInfoSector = packed record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>LeadSignature:LongWord;</code> | ||
+ | | Signature "RRaA" or 41615252h | ||
+ | |- | ||
+ | | <code>Reserved1:array[0..479] of Byte;</code> | ||
+ | | Always 0 | ||
+ | |- | ||
+ | | <code>StructureSignature:LongWord;</code> | ||
+ | | Signature "rrAa" or 61417272h | ||
+ | |- | ||
+ | | <code>FreeClusterCount:LongWord;</code> | ||
+ | | Free Clusters $FFFFFFFF if unknown | ||
+ | |- | ||
+ | | <code>LastFreeCluster:LongWord;</code> | ||
+ | | Most recently allocated cluster $FFFFFFFF if unknown | ||
+ | |- | ||
+ | | <code>Reserved2:array[0..11] of Byte;</code> | ||
+ | | Always 0 | ||
+ | |- | ||
+ | | <code>TrailSignature:LongWord;</code> | ||
+ | | Signature AA550000h | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | |||
+ | === Class definitions === | ||
---- | ---- | ||
Revision as of 04:36, 18 January 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*
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
To be documented
Public variables
None defined
Function declarations
Initialization functions
FATFS helper functions
Return to Unit Reference