software/liblitesata/sata_read: handle errors.

This commit is contained in:
Florent Kermarrec 2020-10-28 18:59:36 +01:00
parent 2bb46b305b
commit 1fca7b9a91

View file

@ -26,11 +26,19 @@ int sata_init(void) {
void sata_read(uint32_t block, uint32_t count, uint8_t* buf)
{
uint32_t i;
/* Read blocks */
for (i=0; i<count; i++) {
sata_block2mem_base_write(((uint32_t) buf) + i*512);
uint8_t done = 0;
while (done == 0) {
sata_block2mem_base_write((uint64_t) buf);
sata_block2mem_sector_write(block + i);
sata_block2mem_start_write(1);
while ((sata_block2mem_done_read() & 0x1) == 0);
done = ((sata_block2mem_error_read() & 0x1) == 0);
busy_wait_us(10);
}
buf += 512;
}
#ifndef CONFIG_CPU_HAS_DMA_BUS