forked from mfulz_github/qmk_firmware
Significantly reduce the size of the Mass Storage class bootloader, by removing dependencies on large LUFA internal functions.
This commit is contained in:
parent
6e8642185a
commit
199cf8f183
|
@ -29,7 +29,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if AUX_BOOT_SECTION_SIZE > 0
|
#if AUX_BOOT_SECTION_SIZE > 0
|
||||||
|
|
||||||
#warning Using a AUX bootloader section in addition to the defined bootloader space (see documentation).
|
#warning Using a AUX bootloader section in addition to the defined bootloader space (see documentation).
|
||||||
|
|
||||||
; Trampoline to jump over the AUX bootloader section to the start of the bootloader,
|
; Trampoline to jump over the AUX bootloader section to the start of the bootloader,
|
||||||
|
@ -38,7 +37,6 @@
|
||||||
.global Boot_AUX_Trampoline
|
.global Boot_AUX_Trampoline
|
||||||
Boot_AUX_Trampoline:
|
Boot_AUX_Trampoline:
|
||||||
jmp BOOT_START_ADDR
|
jmp BOOT_START_ADDR
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
; Trampolines to actual API implementations if the target address is outside the
|
; Trampolines to actual API implementations if the target address is outside the
|
||||||
|
|
|
@ -212,11 +212,8 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
||||||
*/
|
*/
|
||||||
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||||
{
|
{
|
||||||
uint32_t LastBlockAddressInLUN = (LUN_MEDIA_BLOCKS - 1);
|
Endpoint_Write_32_BE(LUN_MEDIA_BLOCKS - 1);
|
||||||
uint32_t MediaBlockSize = SECTOR_SIZE_BYTES;
|
Endpoint_Write_32_BE(SECTOR_SIZE_BYTES);
|
||||||
|
|
||||||
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NULL);
|
|
||||||
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NULL);
|
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
/* Succeed the command and update the bytes transferred counter */
|
/* Succeed the command and update the bytes transferred counter */
|
||||||
|
@ -237,7 +234,7 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
||||||
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||||
const bool IsDataRead)
|
const bool IsDataRead)
|
||||||
{
|
{
|
||||||
uint32_t BlockAddress;
|
uint16_t BlockAddress;
|
||||||
uint16_t TotalBlocks;
|
uint16_t TotalBlocks;
|
||||||
|
|
||||||
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
|
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
|
||||||
|
@ -259,9 +256,9 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
||||||
|
|
||||||
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
|
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
|
||||||
if (IsDataRead == DATA_READ)
|
if (IsDataRead == DATA_READ)
|
||||||
VirtualFAT_ReadBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
|
VirtualFAT_ReadBlocks(BlockAddress, TotalBlocks);
|
||||||
else
|
else
|
||||||
VirtualFAT_WriteBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
|
VirtualFAT_WriteBlocks(BlockAddress, TotalBlocks);
|
||||||
|
|
||||||
/* Update the bytes transferred counter and succeed the command */
|
/* Update the bytes transferred counter and succeed the command */
|
||||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * SECTOR_SIZE_BYTES);
|
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * SECTOR_SIZE_BYTES);
|
||||||
|
|
|
@ -245,12 +245,10 @@ static void ReadVirtualBlock(const uint16_t BlockNumber)
|
||||||
/** Writes a number of blocks to the virtual FAT file system, from the host
|
/** Writes a number of blocks to the virtual FAT file system, from the host
|
||||||
* PC via the USB Mass Storage interface.
|
* PC via the USB Mass Storage interface.
|
||||||
*
|
*
|
||||||
* \param[in] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state
|
|
||||||
* \param[in] BlockAddress Data block starting address for the write sequence
|
* \param[in] BlockAddress Data block starting address for the write sequence
|
||||||
* \param[in] TotalBlocks Number of blocks of data to write
|
* \param[in] TotalBlocks Number of blocks of data to write
|
||||||
*/
|
*/
|
||||||
void VirtualFAT_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
void VirtualFAT_WriteBlocks(const uint16_t BlockAddress,
|
||||||
const uint32_t BlockAddress,
|
|
||||||
uint16_t TotalBlocks)
|
uint16_t TotalBlocks)
|
||||||
{
|
{
|
||||||
uint16_t CurrentBlock = (uint16_t)BlockAddress;
|
uint16_t CurrentBlock = (uint16_t)BlockAddress;
|
||||||
|
@ -264,12 +262,10 @@ void VirtualFAT_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||||
/** Reads a number of blocks from the virtual FAT file system, and sends them
|
/** Reads a number of blocks from the virtual FAT file system, and sends them
|
||||||
* to the host PC via the USB Mass Storage interface.
|
* to the host PC via the USB Mass Storage interface.
|
||||||
*
|
*
|
||||||
* \param[in] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state
|
|
||||||
* \param[in] BlockAddress Data block starting address for the read sequence
|
* \param[in] BlockAddress Data block starting address for the read sequence
|
||||||
* \param[in] TotalBlocks Number of blocks of data to read
|
* \param[in] TotalBlocks Number of blocks of data to read
|
||||||
*/
|
*/
|
||||||
void VirtualFAT_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
void VirtualFAT_ReadBlocks(const uint16_t BlockAddress,
|
||||||
const uint32_t BlockAddress,
|
|
||||||
uint16_t TotalBlocks)
|
uint16_t TotalBlocks)
|
||||||
{
|
{
|
||||||
uint16_t CurrentBlock = (uint16_t)BlockAddress;
|
uint16_t CurrentBlock = (uint16_t)BlockAddress;
|
||||||
|
|
|
@ -151,11 +151,9 @@
|
||||||
static void ReadVirtualBlock(const uint16_t BlockNumber) AUX_BOOT_SECTION;
|
static void ReadVirtualBlock(const uint16_t BlockNumber) AUX_BOOT_SECTION;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void VirtualFAT_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
void VirtualFAT_WriteBlocks(const uint16_t BlockAddress,
|
||||||
const uint32_t BlockAddress,
|
|
||||||
uint16_t TotalBlocks) AUX_BOOT_SECTION;
|
uint16_t TotalBlocks) AUX_BOOT_SECTION;
|
||||||
|
|
||||||
void VirtualFAT_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
void VirtualFAT_ReadBlocks(const uint16_t BlockAddress,
|
||||||
const uint32_t BlockAddress,
|
|
||||||
uint16_t TotalBlocks) AUX_BOOT_SECTION;
|
uint16_t TotalBlocks) AUX_BOOT_SECTION;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue