X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fatapi.h;h=27bed29013c38b629e9376f839022c63013fac07;hb=e03d97f01158ab87a941e1eac394e68643fd7194;hp=ec613d7f5627fea0db304e6af368b4e8f8bfcd8d;hpb=e89fcf9ca3b902f647593a816b750551ac3840ca;p=palacios-OLD.git diff --git a/palacios/src/devices/atapi.h b/palacios/src/devices/atapi.h index ec613d7..27bed29 100644 --- a/palacios/src/devices/atapi.h +++ b/palacios/src/devices/atapi.h @@ -404,6 +404,51 @@ static int atapi_mode_sense(struct vm_device * dev, struct ide_channel * channel } +static int atapi_inquiry(struct vm_device * dev, struct ide_channel * channel) { + struct ide_drive * drive = get_selected_drive(channel); + struct atapi_inquiry_cmd * inquiry_cmd = (struct atapi_inquiry_cmd *)(drive->data_buf); + uint16_t alloc_len = be_to_le_16(inquiry_cmd->alloc_len); + struct atapi_inquiry_resp * resp = (struct atapi_inquiry_resp *)(drive->data_buf); + int xfer_len = sizeof(struct atapi_inquiry_resp); + const char * vendor_id = "VTAB "; + const char * product_id = "Turbo CD-ROM "; + const char * product_rev = "1.0 "; + + memset(resp, 0, sizeof(struct atapi_inquiry_resp)); + + resp->dev_type = DEV_TYPE_CDROM; + resp->removable_media = 1; + resp->resp_data_fmt = 0x1; + resp->atapi_trans_ver = 0x2; + resp->additional_len = 31; + + memcpy(resp->t10_vendor_id, vendor_id, strlen(vendor_id)); + memcpy(resp->product_id, product_id, strlen(product_id)); + memcpy(resp->product_rev, product_rev, strlen(product_rev)); + + if (alloc_len < xfer_len) { + xfer_len = alloc_len; + } + + atapi_setup_cmd_resp(dev, channel, xfer_len); + + return 0; +} + + +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]; @@ -424,6 +469,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); @@ -468,21 +517,25 @@ static int atapi_handle_packet(struct vm_device * dev, struct ide_channel * chan ide_raise_irq(dev, channel); break; - + case 0x12: // inquiry + if (atapi_inquiry(dev, channel) == -1) { + PrintError("IDE: Error in ATAPI inquiry (%x)\n", cmd); + return -1; + } + break; case 0xa8: // read(12) case 0x1b: // start/stop drive case 0xbd: // mechanism status - case 0x12: // inquiry case 0xbe: // read cd case 0x2b: // seek - case 0x1e: // lock door + case 0x42: // read sub-channel