X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fatapi.h;h=ad03ee97750b5fc2fe3331245844454a526edac8;hp=78e0751255fff2d924e877bfa269465579aafd97;hb=123a1ba27ea09c8fa77a1b36ce625b43d7c48b14;hpb=7b22bd6ad6a5bb413fd38e9ed7df668e34c052bb diff --git a/palacios/src/devices/atapi.h b/palacios/src/devices/atapi.h index 78e0751..ad03ee9 100644 --- a/palacios/src/devices/atapi.h +++ b/palacios/src/devices/atapi.h @@ -128,7 +128,8 @@ static void atapi_cmd_nop(struct vm_device * dev, struct ide_channel * channel) static int atapi_read_chunk(struct vm_device * dev, struct ide_channel * channel) { struct ide_drive * drive = get_selected_drive(channel); - int ret = drive->cd_ops->read(drive->data_buf, 1, drive->current_lba, drive->private_data); + int ret = drive->ops->read(drive->data_buf, drive->current_lba * ATAPI_BLOCK_SIZE, ATAPI_BLOCK_SIZE, +drive->private_data); if (ret == -1) { PrintError("IDE: Error reading CD block (LBA=%p)\n", (void *)(addr_t)(drive->current_lba)); @@ -177,10 +178,10 @@ static int atapi_read10(struct vm_device * dev, struct ide_channel * channel) { return 0; } - if (lba + xfer_len > drive->cd_ops->get_capacity(drive->private_data)) { + if (lba + xfer_len > drive->ops->get_capacity(drive->private_data)) { PrintError("IDE: xfer len exceeded capacity (lba=%d) (xfer_len=%d) (ReadEnd=%d) (capacity=%d)\n", lba, xfer_len, lba + xfer_len, - drive->cd_ops->get_capacity(drive->private_data)); + (uint32_t)drive->ops->get_capacity(drive->private_data)); atapi_cmd_error(dev, channel, ATAPI_SEN_ILL_REQ, ASC_LOG_BLK_OOR); ide_raise_irq(dev, channel); return 0; @@ -238,7 +239,7 @@ static void atapi_req_sense(struct vm_device * dev, struct ide_channel * channel static int atapi_get_capacity(struct vm_device * dev, struct ide_channel * channel) { struct ide_drive * drive = get_selected_drive(channel); struct atapi_rd_capacity_resp * resp = (struct atapi_rd_capacity_resp *)(drive->data_buf); - uint32_t capacity = drive->cd_ops->get_capacity(drive->private_data); + uint32_t capacity = drive->ops->get_capacity(drive->private_data); resp->lba = le_to_be_32(capacity); resp->block_len = le_to_be_32(ATAPI_BLOCK_SIZE); @@ -436,6 +437,19 @@ static int atapi_inquiry(struct vm_device * dev, struct ide_channel * channel) { } +static int atapi_cmd_is_data_op(uint8_t cmd) { + switch (cmd) { + case 0x28: // read (10) + case 0xa8: // read (12) + case 0x2a: // write (10) + case 0xaa: // write (12) + return 1; + default: + return 0; + } +} + + static int atapi_handle_packet(struct vm_device * dev, struct ide_channel * channel) { struct ide_drive * drive = get_selected_drive(channel); uint8_t cmd = drive->data_buf[0]; @@ -456,6 +470,10 @@ static int atapi_handle_packet(struct vm_device * dev, struct ide_channel * chan atapi_req_sense(dev, channel); break; + case 0x1e: // lock door + atapi_cmd_nop(dev, channel); + break; + case 0x28: // read(10) if (atapi_read10(dev, channel) == -1) { PrintError("IDE: Error in ATAPI read (%x)\n", cmd); @@ -518,7 +536,7 @@ static int atapi_handle_packet(struct vm_device * dev, struct ide_channel * chan case 0x2b: // seek - case 0x1e: // lock door + case 0x42: // read sub-channel