ahci: fix bug causing count sent to device to be incorrect
This commit is contained in:
parent
d3f04046f4
commit
b760b9bace
2 changed files with 13 additions and 10 deletions
22
dev/ahci.c
22
dev/ahci.c
|
|
@ -142,15 +142,6 @@ bool ahci_access_sectors(struct sata_device *dev, paddr_t lba, uint16_t count, p
|
||||||
struct hba_cmd_tbl *cmdtbl = (struct hba_cmd_tbl *)(cmdheader->cmd_table_base | hhdm_start);
|
struct hba_cmd_tbl *cmdtbl = (struct hba_cmd_tbl *)(cmdheader->cmd_table_base | hhdm_start);
|
||||||
memset(cmdtbl, 0, sizeof(struct hba_cmd_tbl) + (cmdheader->prdt_len - 1) * sizeof(struct hba_prdt_entry));
|
memset(cmdtbl, 0, sizeof(struct hba_cmd_tbl) + (cmdheader->prdt_len - 1) * sizeof(struct hba_prdt_entry));
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < cmdheader->prdt_len; i++) {
|
|
||||||
cmdtbl->prdt_entry[i].data_base = buf;
|
|
||||||
cmdtbl->prdt_entry[i].byte_count = 8 * 1024 - 1;
|
|
||||||
cmdtbl->prdt_entry[i].interrupt = 1;
|
|
||||||
buf += 8 * 1024;
|
|
||||||
count -= 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct fis_reg_h2d *cmdfis = (struct fis_reg_h2d *)(&cmdtbl->cfis);
|
struct fis_reg_h2d *cmdfis = (struct fis_reg_h2d *)(&cmdtbl->cfis);
|
||||||
cmdfis->fis_type = FIS_REG_H2D;
|
cmdfis->fis_type = FIS_REG_H2D;
|
||||||
cmdfis->cmd_mode = 1;
|
cmdfis->cmd_mode = 1;
|
||||||
|
|
@ -167,6 +158,15 @@ bool ahci_access_sectors(struct sata_device *dev, paddr_t lba, uint16_t count, p
|
||||||
cmdfis->count_low = count & 0xff;
|
cmdfis->count_low = count & 0xff;
|
||||||
cmdfis->count_high = (count >> 8) & 0xff;
|
cmdfis->count_high = (count >> 8) & 0xff;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < cmdheader->prdt_len; i++) {
|
||||||
|
cmdtbl->prdt_entry[i].data_base = buf;
|
||||||
|
cmdtbl->prdt_entry[i].byte_count = 8 * 1024 - 1;
|
||||||
|
cmdtbl->prdt_entry[i].interrupt = 1;
|
||||||
|
buf += 8 * 1024;
|
||||||
|
count -= 16;
|
||||||
|
}
|
||||||
|
|
||||||
/* wait until port is free */
|
/* wait until port is free */
|
||||||
while ((port->tfd & (ATA_DEV_BUSY | ATA_DEV_DRQ)) && spin < 1000000) {
|
while ((port->tfd & (ATA_DEV_BUSY | ATA_DEV_DRQ)) && spin < 1000000) {
|
||||||
spin++;
|
spin++;
|
||||||
|
|
@ -196,6 +196,10 @@ bool ahci_access_sectors(struct sata_device *dev, paddr_t lba, uint16_t count, p
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* disk read success */
|
||||||
|
#ifdef KDEBUG
|
||||||
|
printf(LOG_DEBUG "Read %d sectors from disk\n", count);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@
|
||||||
#define AHCI_DEV_PM 3
|
#define AHCI_DEV_PM 3
|
||||||
#define AHCI_DEV_SATAPI 4
|
#define AHCI_DEV_SATAPI 4
|
||||||
|
|
||||||
#define AHCI_GHC_ENABLE 0x1
|
|
||||||
#define AHCI_GHC_IE 0x2
|
#define AHCI_GHC_IE 0x2
|
||||||
#define AHCI_GHC_AE 0x80000000
|
#define AHCI_GHC_AE 0x80000000
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue