DMA ATA commands support
This commit is contained in:
parent
908a8fc37a
commit
51f7e1acb7
4 changed files with 33 additions and 5 deletions
|
@ -398,6 +398,7 @@ grub_ahci_open (int id, int devnum, struct grub_ata *ata)
|
||||||
grub_dprintf ("ahci", "opening AHCI dev `ahci%d'\n", dev->num);
|
grub_dprintf ("ahci", "opening AHCI dev `ahci%d'\n", dev->num);
|
||||||
|
|
||||||
ata->data = dev;
|
ata->data = dev;
|
||||||
|
ata->dma = 0;
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,9 +255,17 @@ grub_ata_readwrite (grub_disk_t disk, grub_disk_addr_t sector,
|
||||||
if (addressing == GRUB_ATA_LBA48 && ((sector + size) >> 28) != 0)
|
if (addressing == GRUB_ATA_LBA48 && ((sector + size) >> 28) != 0)
|
||||||
{
|
{
|
||||||
batch = 65536;
|
batch = 65536;
|
||||||
|
if (ata->dma)
|
||||||
|
{
|
||||||
|
cmd = GRUB_ATA_CMD_READ_SECTORS_DMA_EXT;
|
||||||
|
cmd_write = GRUB_ATA_CMD_WRITE_SECTORS_DMA_EXT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
cmd = GRUB_ATA_CMD_READ_SECTORS_EXT;
|
cmd = GRUB_ATA_CMD_READ_SECTORS_EXT;
|
||||||
cmd_write = GRUB_ATA_CMD_WRITE_SECTORS_EXT;
|
cmd_write = GRUB_ATA_CMD_WRITE_SECTORS_EXT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (addressing == GRUB_ATA_LBA48)
|
if (addressing == GRUB_ATA_LBA48)
|
||||||
|
@ -266,9 +274,17 @@ grub_ata_readwrite (grub_disk_t disk, grub_disk_addr_t sector,
|
||||||
batch = 256;
|
batch = 256;
|
||||||
else
|
else
|
||||||
batch = 1;
|
batch = 1;
|
||||||
|
if (ata->dma)
|
||||||
|
{
|
||||||
|
cmd = GRUB_ATA_CMD_READ_SECTORS_DMA;
|
||||||
|
cmd_write = GRUB_ATA_CMD_WRITE_SECTORS_DMA;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
cmd = GRUB_ATA_CMD_READ_SECTORS;
|
cmd = GRUB_ATA_CMD_READ_SECTORS;
|
||||||
cmd_write = GRUB_ATA_CMD_WRITE_SECTORS;
|
cmd_write = GRUB_ATA_CMD_WRITE_SECTORS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
grub_size_t nsectors = 0;
|
grub_size_t nsectors = 0;
|
||||||
while (nsectors < size)
|
while (nsectors < size)
|
||||||
|
@ -285,6 +301,8 @@ grub_ata_readwrite (grub_disk_t disk, grub_disk_addr_t sector,
|
||||||
parms.taskfile.cmd = (! rw ? cmd : cmd_write);
|
parms.taskfile.cmd = (! rw ? cmd : cmd_write);
|
||||||
parms.buffer = buf;
|
parms.buffer = buf;
|
||||||
parms.size = batch * GRUB_DISK_SECTOR_SIZE;
|
parms.size = batch * GRUB_DISK_SECTOR_SIZE;
|
||||||
|
if (ata->dma)
|
||||||
|
parms.dma = 1;
|
||||||
|
|
||||||
err = ata->dev->readwrite (ata, &parms);
|
err = ata->dev->readwrite (ata, &parms);
|
||||||
if (err)
|
if (err)
|
||||||
|
|
|
@ -474,6 +474,7 @@ grub_pata_open (int id, int devnum, struct grub_ata *ata)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
ata->data = devfnd;
|
ata->data = devfnd;
|
||||||
|
ata->dma = 0;
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,9 @@ enum grub_ata_commands
|
||||||
GRUB_ATA_CMD_PACKET = 0xa0,
|
GRUB_ATA_CMD_PACKET = 0xa0,
|
||||||
GRUB_ATA_CMD_READ_SECTORS = 0x20,
|
GRUB_ATA_CMD_READ_SECTORS = 0x20,
|
||||||
GRUB_ATA_CMD_READ_SECTORS_EXT = 0x24,
|
GRUB_ATA_CMD_READ_SECTORS_EXT = 0x24,
|
||||||
|
GRUB_ATA_CMD_READ_SECTORS_DMA = 0xc8,
|
||||||
|
GRUB_ATA_CMD_READ_SECTORS_DMA_EXT = 0x25,
|
||||||
|
|
||||||
GRUB_ATA_CMD_SECURITY_FREEZE_LOCK = 0xf5,
|
GRUB_ATA_CMD_SECURITY_FREEZE_LOCK = 0xf5,
|
||||||
GRUB_ATA_CMD_SET_FEATURES = 0xef,
|
GRUB_ATA_CMD_SET_FEATURES = 0xef,
|
||||||
GRUB_ATA_CMD_SLEEP = 0xe6,
|
GRUB_ATA_CMD_SLEEP = 0xe6,
|
||||||
|
@ -89,6 +92,8 @@ enum grub_ata_commands
|
||||||
GRUB_ATA_CMD_STANDBY_IMMEDIATE = 0xe0,
|
GRUB_ATA_CMD_STANDBY_IMMEDIATE = 0xe0,
|
||||||
GRUB_ATA_CMD_WRITE_SECTORS = 0x30,
|
GRUB_ATA_CMD_WRITE_SECTORS = 0x30,
|
||||||
GRUB_ATA_CMD_WRITE_SECTORS_EXT = 0x34,
|
GRUB_ATA_CMD_WRITE_SECTORS_EXT = 0x34,
|
||||||
|
GRUB_ATA_CMD_WRITE_SECTORS_DMA_EXT = 0x35,
|
||||||
|
GRUB_ATA_CMD_WRITE_SECTORS_DMA = 0xca,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum grub_ata_timeout_milliseconds
|
enum grub_ata_timeout_milliseconds
|
||||||
|
@ -151,6 +156,7 @@ struct grub_disk_ata_pass_through_parms
|
||||||
int write;
|
int write;
|
||||||
void *cmd;
|
void *cmd;
|
||||||
int cmdsize;
|
int cmdsize;
|
||||||
|
int dma;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct grub_ata
|
struct grub_ata
|
||||||
|
@ -171,6 +177,8 @@ struct grub_ata
|
||||||
/* Set to 0 for ATA, set to 1 for ATAPI. */
|
/* Set to 0 for ATA, set to 1 for ATAPI. */
|
||||||
int atapi;
|
int atapi;
|
||||||
|
|
||||||
|
int dma;
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
struct grub_ata_dev *dev;
|
struct grub_ata_dev *dev;
|
||||||
|
|
Loading…
Reference in a new issue