diff --git a/ChangeLog b/ChangeLog index a6c135e2f..738ecefcc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-11-03 Vladimir Serbinenko + + * grub-core/disk/ahci.c (grub_ahci_pciinit): Detect ATAPI devices. + * grub-core/disk/ata.c (grub_ata_identify): Use atapi_identify if + device is known to be ATAPI. + 2013-11-03 Mike Frysinger * configure.ac: Don't add target-prefix. diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index 0f5785662..0b13fb8eb 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -133,6 +133,7 @@ struct grub_ahci_device volatile struct grub_ahci_cmd_table *command_table; struct grub_pci_dma_chunk *rfis; int present; + int atapi; }; static grub_err_t @@ -616,6 +617,10 @@ grub_ahci_pciinit (grub_pci_device_t dev, grub_dma_free (failed_adevs[i]->rfis); } + for (i = 0; i < nports; i++) + if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].sig >> 16) == 0xeb14) + adevs[i]->atapi = 1; + for (i = 0; i < nports; i++) if (adevs[i]) { @@ -1075,6 +1080,7 @@ grub_ahci_open (int id, int devnum, struct grub_ata *ata) ata->data = dev; ata->dma = 1; + ata->atapi = dev->atapi; ata->maxbuffer = GRUB_AHCI_PRDT_MAX_CHUNK_LENGTH; ata->present = &dev->present; diff --git a/grub-core/disk/ata.c b/grub-core/disk/ata.c index a79519cc7..2b988490f 100644 --- a/grub-core/disk/ata.c +++ b/grub-core/disk/ata.c @@ -108,6 +108,9 @@ grub_ata_identify (struct grub_ata *dev) grub_uint16_t *info16; grub_err_t err; + if (dev->atapi) + return grub_atapi_identify (dev); + info64 = grub_malloc (GRUB_DISK_SECTOR_SIZE); info32 = (grub_uint32_t *) info64; info16 = (grub_uint16_t *) info64; @@ -129,7 +132,7 @@ grub_ata_identify (struct grub_ata *dev) grub_free (info16); grub_errno = GRUB_ERR_NONE; if ((sts & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ - | GRUB_ATA_STATUS_ERR)) == GRUB_ATA_STATUS_ERR + | GRUB_ATA_STATUS_ERR)) == GRUB_ATA_STATUS_ERR && (parms.taskfile.error & 0x04 /* ABRT */)) /* Device without ATA IDENTIFY, try ATAPI. */ return grub_atapi_identify (dev); @@ -363,7 +366,7 @@ grub_ata_real_open (int id, int bus) struct grub_ata *ata; grub_ata_dev_t p; - ata = grub_malloc (sizeof (*ata)); + ata = grub_zalloc (sizeof (*ata)); if (!ata) return NULL; for (p = grub_ata_dev_list; p; p = p->next)