X-Git-Url: http://git.linex4red.de/pub/lufa.git/blobdiff_plain/64f17a679f0d99741fb8101f02dfb3ef084e525c..726b325c73d2f6a2a733e67d1dad9fa7aedef1c0:/Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.h?ds=sidebyside diff --git a/Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.h b/Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.h index 2009b6847..98ea5cdd9 100644 --- a/Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.h +++ b/Bootloaders/Incomplete/MassStorage/Lib/VirtualFAT.h @@ -38,27 +38,35 @@ #include /* Macros: */ - #define VIRTUAL_MEMORY_BLOCK_SIZE 512 - #define ALLOCATION_UNIT_BLOCKS 4 - #define LUN_MEDIA_BLOCKS ((FLASHEND + 1) / VIRTUAL_MEMORY_BLOCK_SIZE) + 16 + #define FIRMWARE_FILE_SIZE (FLASHEND + 1UL) + + #define SECTOR_SIZE_BYTES 512 + #define SECTOR_PER_CLUSTER 4 + #define CLUSTER_SIZE_BYTES (SECTOR_PER_CLUSTER * SECTOR_SIZE_BYTES) + #define FILE_CLUSTERS(size) ((size / CLUSTER_SIZE_BYTES) + ((size % CLUSTER_SIZE_BYTES) ? 1 : 0)) + + #define LUN_MEDIA_BLOCKS ((FIRMWARE_FILE_SIZE / SECTOR_SIZE_BYTES) + 32) + + #define FAT_TIME(h, m, s) ((h << 11) | (m << 5) | (s >> 1)) + #define FAT_DATE(d, m, y) (((y - 1980) << 9) | (m << 5) | (d << 0)) /* Type Definitions: */ typedef struct { uint8_t Bootstrap[3]; uint8_t Description[8]; - uint16_t BlockSize; - uint8_t BlocksPerAllocationUnit; - uint16_t ReservedBlocks; + uint16_t SectorSize; + uint8_t SectorsPerCluster; + uint16_t ReservedSectors; uint8_t FATCopies; uint16_t RootDirectoryEntries; - uint16_t TotalBlocks16; + uint16_t TotalSectors16; uint8_t MediaDescriptor; - uint16_t BlocksPerFAT; - uint16_t BlocksPerTrack; + uint16_t SectorsPerFAT; + uint16_t SectorsPerTrack; uint16_t Heads; - uint32_t HiddenBlocks; - uint32_t TotalBlocks32; + uint32_t HiddenSectors; + uint32_t TotalSectors32; uint16_t PhysicalDriveNum; uint8_t ExtendedBootRecordSig; uint32_t VolumeSerialNumber; @@ -70,14 +78,14 @@ typedef struct { - uint8_t Filename[8]; - uint8_t Extension[3]; - uint8_t Attributes; - uint8_t Reserved[10]; + uint8_t Filename[8]; + uint8_t Extension[3]; + uint8_t Attributes; + uint8_t Reserved[10]; uint16_t CreationTime; uint16_t CreationDate; uint16_t StartingCluster; - uint32_t FileSize; + uint32_t FileSizeBytes; } FATDirectoryEntry_t; /* Function Prototypes: */