kexts: ahci: implement read support for ATA devices
This commit is contained in:
@@ -47,6 +47,11 @@ static void free_cmd_table(struct hba_cmd_table *table)
|
||||
}
|
||||
|
||||
kern_status_t send_ata_command(struct ahci_device *dev, unsigned int cmd, struct iovec *vec, size_t nvec)
|
||||
{
|
||||
return send_ata_command_ex(dev, NULL, cmd, vec, nvec);
|
||||
}
|
||||
|
||||
kern_status_t send_ata_command_ex(struct ahci_device *dev, struct fis_reg_h2d *fis, unsigned int cmd, struct iovec *vec, size_t nvec)
|
||||
{
|
||||
if (nvec == 0) {
|
||||
return KERN_OK;
|
||||
@@ -73,6 +78,12 @@ kern_status_t send_ata_command(struct ahci_device *dev, unsigned int cmd, struct
|
||||
|
||||
struct fis_reg_h2d *cmdfis = (struct fis_reg_h2d*)(&cmdtbl->cfis);
|
||||
|
||||
if (fis) {
|
||||
memcpy(cmdfis, fis, sizeof *cmdfis);
|
||||
} else {
|
||||
memset(cmdfis, 0x00, sizeof *cmdfis);
|
||||
}
|
||||
|
||||
cmdfis->fis_type = FIS_TYPE_REG_H2D;
|
||||
cmdfis->c = 1;
|
||||
cmdfis->command = cmd;
|
||||
@@ -96,12 +107,14 @@ kern_status_t send_ata_command(struct ahci_device *dev, unsigned int cmd, struct
|
||||
|
||||
if (port->is & HBA_PxIS_TFES) {
|
||||
free_cmd_table(cmdtbl);
|
||||
printk("ahci: command failed");
|
||||
return KERN_IO_ERROR;
|
||||
}
|
||||
}
|
||||
free_cmd_table(cmdtbl);
|
||||
|
||||
if (port->is & HBA_PxIS_TFES) {
|
||||
printk("ahci: command failed");
|
||||
return KERN_IO_ERROR;
|
||||
}
|
||||
|
||||
@@ -109,6 +122,11 @@ kern_status_t send_ata_command(struct ahci_device *dev, unsigned int cmd, struct
|
||||
}
|
||||
|
||||
kern_status_t send_atapi_command(struct ahci_device *dev, struct scsi_command *cmd, struct iovec *vec, size_t nvec)
|
||||
{
|
||||
return send_atapi_command_ex(dev, NULL, cmd, vec, nvec);
|
||||
}
|
||||
|
||||
kern_status_t send_atapi_command_ex(struct ahci_device *dev, struct fis_reg_h2d *fis, struct scsi_command *cmd, struct iovec *vec, size_t nvec)
|
||||
{
|
||||
if (nvec == 0) {
|
||||
return KERN_OK;
|
||||
@@ -136,7 +154,11 @@ kern_status_t send_atapi_command(struct ahci_device *dev, struct scsi_command *c
|
||||
memcpy(&cmdtbl->acmd, cmd, sizeof *cmd);
|
||||
|
||||
struct fis_reg_h2d *cmdfis = (struct fis_reg_h2d *)(&cmdtbl->cfis);
|
||||
memset(cmdfis, 0x0, sizeof *cmdfis);
|
||||
if (fis) {
|
||||
memcpy(cmdfis, fis, sizeof *cmdfis);
|
||||
} else {
|
||||
memset(cmdfis, 0x0, sizeof *cmdfis);
|
||||
}
|
||||
|
||||
cmdfis->fis_type = FIS_TYPE_REG_H2D;
|
||||
cmdfis->c = 1;
|
||||
|
||||
Reference in New Issue
Block a user