Minor cleanup of the Mass Storage bootloader VirtualFAT code.

pull/1469/head
Dean Camera 12 years ago
parent ddd6632295
commit b956fedeeb

@ -72,7 +72,7 @@ static const FATBootBlock_t BootBlock =
}; };
/** FAT 8.3 style directory entry, for the virtual FLASH contents file. */ /** FAT 8.3 style directory entry, for the virtual FLASH contents file. */
FATDirectoryEntry_t FirmwareFileEntries[] = static FATDirectoryEntry_t FirmwareFileEntries[] =
{ {
/* Root volume label entry; disk label is contained in the Filename and /* Root volume label entry; disk label is contained in the Filename and
* Extension fields (concatenated) with a special attribute flag - other * Extension fields (concatenated) with a special attribute flag - other
@ -143,7 +143,7 @@ FATDirectoryEntry_t FirmwareFileEntries[] =
* are (usually?) replaced using the original file's physical sectors. On Linux * are (usually?) replaced using the original file's physical sectors. On Linux
* file replacements are performed with an offset. * file replacements are performed with an offset.
*/ */
uint16_t FileStartBlock = DISK_BLOCK_DataStartBlock; static uint16_t FileStartBlock = DISK_BLOCK_DataStartBlock;
/** Updates a FAT12 cluster entry in the FAT file table with the specified next /** Updates a FAT12 cluster entry in the FAT file table with the specified next
@ -252,8 +252,16 @@ void VirtualFAT_WriteBlock(const uint16_t BlockNumber)
Endpoint_Read_Stream_LE(BlockBuffer, sizeof(BlockBuffer), NULL); Endpoint_Read_Stream_LE(BlockBuffer, sizeof(BlockBuffer), NULL);
Endpoint_ClearOUT(); Endpoint_ClearOUT();
if (BlockNumber == DISK_BLOCK_RootFilesBlock) switch (BlockNumber)
{ {
case DISK_BLOCK_BootBlock:
case DISK_BLOCK_FATBlock1:
case DISK_BLOCK_FATBlock2:
/* Ignore writes to the boot and FAT blocks */
break;
case DISK_BLOCK_RootFilesBlock:
/* Copy over the updated directory entries */ /* Copy over the updated directory entries */
memcpy(FirmwareFileEntries, BlockBuffer, sizeof(FirmwareFileEntries)); memcpy(FirmwareFileEntries, BlockBuffer, sizeof(FirmwareFileEntries));
@ -261,10 +269,13 @@ void VirtualFAT_WriteBlock(const uint16_t BlockNumber)
* contents can be correctly mapped to the device's FLASH pages */ * contents can be correctly mapped to the device's FLASH pages */
FileStartBlock = DISK_BLOCK_DataStartBlock + FileStartBlock = DISK_BLOCK_DataStartBlock +
(FirmwareFileEntries[DISK_FILE_ENTRY_FirmwareMSDOS].MSDOS_File.StartingCluster - 2) * SECTOR_PER_CLUSTER; (FirmwareFileEntries[DISK_FILE_ENTRY_FirmwareMSDOS].MSDOS_File.StartingCluster - 2) * SECTOR_PER_CLUSTER;
}
else break;
{
default:
ReadWriteFirmwareFileBlock(BlockNumber, BlockBuffer, false); ReadWriteFirmwareFileBlock(BlockNumber, BlockBuffer, false);
break;
} }
} }
@ -317,7 +328,7 @@ void VirtualFAT_ReadBlock(const uint16_t BlockNumber)
break; break;
default: /* Blocks 4 onwards: Data allocation section */ default:
ReadWriteFirmwareFileBlock(BlockNumber, BlockBuffer, true); ReadWriteFirmwareFileBlock(BlockNumber, BlockBuffer, true);
break; break;

Loading…
Cancel
Save