scsiRead(uint8_t* data, uint32_t count)\r
{\r
int i = 0;\r
+\r
+\r
+ uint32_t chunk = ((count - i) > SCSI_FIFO_DEPTH)\r
+ ? SCSI_FIFO_DEPTH : (count - i);\r
+ if (chunk >= 16)\r
+ {\r
+ // DMA is doing 32bit transfers.\r
+ chunk = chunk & 0xFFFFFFF8;\r
+ }\r
+ startScsiRx(chunk);\r
+\r
while (i < count && likely(!scsiDev.resetFlag))\r
{\r
- uint32_t chunk = ((count - i) > SCSI_FIFO_DEPTH)\r
- ? SCSI_FIFO_DEPTH : (count - i);\r
+ while (!scsiPhyComplete() && likely(!scsiDev.resetFlag)) {}\r
+ scsiPhyFifoFlip();\r
\r
- if (chunk >= 16)\r
+ uint32_t nextChunk = ((count - i - chunk) > SCSI_FIFO_DEPTH)\r
+ ? SCSI_FIFO_DEPTH : (count - i - chunk);\r
+ if (nextChunk >= 16)\r
{\r
- // DMA is doing 32bit transfers.\r
- chunk = chunk & 0xFFFFFFF8;\r
+ nextChunk = nextChunk & 0xFFFFFFF8;\r
}\r
-\r
-#if FIFODEBUG\r
- if (!scsiPhyFifoAltEmpty()) {\r
- // Force a lock-up.\r
- assertFail();\r
+ if (nextChunk > 0)\r
+ {\r
+ startScsiRx(nextChunk);\r
}\r
-#endif\r
-\r
- startScsiRx(chunk);\r
- // Wait for the next scsi interrupt (or the 1ms systick)\r
- __WFI();\r
-\r
- while (!scsiPhyComplete() && likely(!scsiDev.resetFlag)) {}\r
- scsiPhyFifoFlip();\r
\r
if (chunk < 16)\r
{\r
{\r
scsiReadDMA(data + i, chunk);\r
\r
- // Wait for the next DMA interrupt (or the 1ms systick)\r
- // It's beneficial to halt the processor to\r
- // give the DMA controller more memory bandwidth to work with.\r
- __WFI();\r
trace(trace_spinReadDMAPoll);\r
\r
while (!scsiReadDMAPoll() && likely(!scsiDev.resetFlag))\r
{\r
- __WFI();\r
};\r
}\r
\r
}\r
#endif\r
i += chunk;\r
+ chunk = nextChunk;\r
}\r
}\r
\r
chunk = chunk & 0xFFFFFFF8;\r
scsiWriteDMA(data + i, chunk);\r
\r
- // Wait for the next DMA interrupt (or the 1ms systick)\r
- // It's beneficial to halt the processor to\r
- // give the DMA controller more memory bandwidth to work with.\r
- __WFI();\r
trace(trace_spinReadDMAPoll);\r
\r
while (!scsiWriteDMAPoll() && likely(!scsiDev.resetFlag))\r
{\r
- __WFI();\r
- };\r
+ }\r
}\r
\r
while (!scsiPhyComplete() && likely(!scsiDev.resetFlag))\r
{\r
- __WFI();\r
}\r
\r
#if FIFODEBUG\r
}\r
while (!scsiPhyComplete() && likely(!scsiDev.resetFlag))\r
{\r
- __WFI();\r
}\r
\r
#if FIFODEBUG\r