33 #define INCLUDE_FROM_SCSI_C
41 .PeripheralQualifier = 0,
47 .ResponseDataFormat = 2,
52 .AdditionalLength = 0x1F,
58 .WideBus16Bit =
false,
59 .WideBus32Bit =
false,
63 .ProductID =
"Dataflash Disk",
64 .RevisionID = {
'0',
'.',
'0',
'0'},
72 .AdditionalLength = 0x0A,
78 #define CACHE_SIZE 8 * 1024
79 #define CACHE_SECTORS (CACHE_SIZE / 512)
80 uint8_t *disk_cache = (uint8_t *) 0x10008000;
81 int32_t current_ncache = -1;
83 static uint32_t MSC_Get_Block_Count(
void)
95 bool CommandSuccess =
false;
131 CommandSuccess =
true;
144 if (CommandSuccess) {
161 uint16_t BytesTransferred =
MIN(AllocationLength,
sizeof(
InquiryData));
164 if ((MSInterfaceInfo->
State.
CommandBlock.SCSICommandData[1] & ((1 << 0) | (1 << 1))) ||
193 uint8_t AllocationLength = MSInterfaceInfo->
State.
CommandBlock.SCSICommandData[4];
194 uint8_t BytesTransferred =
MIN(AllocationLength,
sizeof(
SenseData));
213 uint32_t LastBlockAddressInLUN = MSC_Get_Block_Count() - 1;
255 const bool IsDataRead)
258 uint16_t TotalBlocks;
286 if (BlockAddress >= MSC_Get_Block_Count())
308 uint32_t ncache = (BlockAddress * 512) / CACHE_SIZE;
309 uint32_t modcache = (BlockAddress * 512) % CACHE_SIZE;
310 if (current_ncache != ncache) {
311 current_ncache = ncache;
322 uint16_t blocks, dummyblocks;
326 dummyblocks = TotalBlocks;
328 else if (blocks < TotalBlocks) {
329 dummyblocks = TotalBlocks - blocks;
331 else {dummyblocks = 0; }