ATAPI pass throug v4
Subsystems (2)
Hi,
This is the new version of the ATAPI pass through patches.
What's new from the v3 ?
- applied Christoph and Juan comments
- made some part of ide.c public and added new files:
- ide.h some defines, structures and function declarations
- atapi-defines.h atapi related defines and function to retrive name
from the command
- atapi-data.c some data tables - atapi-pt.h atapi pass through structures and public functions - atapi-pt.c atapi pass through implementation
I hope this one is alright.
Thanks.
PATCH 1/7 atapi: fix up a few comments
--- hw/ide.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
hw/ide.c +6 -6
@@ -1680,9 +1680,9 @@ static void ide_atapi_cmd(IDEState *s)switch (action) {case 0 :/* current values */ switch (code) { -case 0x01 :/* error recovery */ +case 0x01 :/* read write error recovery parameters */ cpu_to_ube16 (&buf[0 ],16 +6 ); - buf[2 ] =0x70 ; + buf[2 ] =0x70 ;/* Obsolete: medium type code */ buf[3 ] =0 ; buf[4 ] =0 ; buf[5 ] =0 ;
@@ -1699,17 +1699,17 @@ static void ide_atapi_cmd(IDEState *s) buf[15 ] =0x00 ;ide_atapi_cmd_reply (s,16 , max_len);break ; -case 0x2a : +case 0x2a :/* CD/DVD capabilities & mechanical status */ cpu_to_ube16 (&buf[0 ],28 +6 ); - buf[2 ] =0x70 ; + buf[2 ] =0x70 ;/* Obsolete: medium type code */ buf[3 ] =0 ; buf[4 ] =0 ; buf[5 ] =0 ; buf[6 ] =0 ; buf[7 ] =0 ; - buf[8 ] =0x2a ; - buf[9 ] =0x12 ; + buf[8 ] =0x2a ;/* page code */ + buf[9 ] =0x12 ;/* page length */ buf[10 ] =0x00 ; buf[11 ] =0x00 ;
Signature · 1 line
1.6.4
PATCH 2/7 atapi: protocol define updates
Add some missing ATAPI protocol defintions, and fix up some whitespaces and comments on the way.
--- hw/ide.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 60 insertions(+), 17 deletions(-)
hw/ide.c +60 -17
@@ -216,13 +216,17 @@#define ATAPI_PACKET_SIZE 12 -/* The generic packet command opcodes for CD/DVD Logical Units, -* From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ +/********************************************************************* +* Generic Packet commands, MMC commands, and such +*********************************************************************/ + +/* The generic packet command opcodes for CD/DVD Logical Units, +* From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ #define GPCMD_BLANK 0xa1#define GPCMD_CLOSE_TRACK 0x5b#define GPCMD_FLUSH_CACHE 0x35#define GPCMD_FORMAT_UNIT 0x04 -#define GPCMD_GET_CONFIGURATION 0x46 +#define GPCMD_GET_CONFIGURATION 0x46#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a#define GPCMD_GET_PERFORMANCE 0xac#define GPCMD_INQUIRY 0x12
@@ -238,6 +242,8 @@#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e#define GPCMD_READ_10 0x28#define GPCMD_READ_12 0xa8 +#define GPCMD_READ_BUFFER 0x3c +#define GPCMD_READ_BUFFER_CAPACITY 0x5c#define GPCMD_READ_CDVD_CAPACITY 0x25#define GPCMD_READ_CD 0xbe#define GPCMD_READ_CD_MSF 0xb9
@@ -246,15 +252,16 @@#define GPCMD_READ_FORMAT_CAPACITIES 0x23#define GPCMD_READ_HEADER 0x44#define GPCMD_READ_TRACK_RZONE_INFO 0x52 -#define GPCMD_READ_SUBCHANNEL 0x42 -#define GPCMD_READ_TOC_PMA_ATIP 0x43 +#define GPCMD_READ_SUBCHANNEL 0x42 +#define GPCMD_READ_TOC_PMA_ATIP 0x43#define GPCMD_REPAIR_RZONE_TRACK 0x58#define GPCMD_REPORT_KEY 0xa4#define GPCMD_REQUEST_SENSE 0x03#define GPCMD_RESERVE_RZONE_TRACK 0x53 +#define GPCMD_SEND_CUE_SHEET 0x5d#define GPCMD_SCAN 0xba#define GPCMD_SEEK 0x2b -#define GPCMD_SEND_DVD_STRUCTURE 0xad +#define GPCMD_SEND_DVD_STRUCTURE 0xbf#define GPCMD_SEND_EVENT 0xa2#define GPCMD_SEND_KEY 0xa3#define GPCMD_SEND_OPC 0x54
@@ -263,9 +270,11 @@#define GPCMD_START_STOP_UNIT 0x1b#define GPCMD_STOP_PLAY_SCAN 0x4e#define GPCMD_TEST_UNIT_READY 0x00 -#define GPCMD_VERIFY_10 0x2f +#define GPCMD_VERIFY_10 0x2f#define GPCMD_WRITE_10 0x2a +#define GPCMD_WRITE_12 0xaa#define GPCMD_WRITE_AND_VERIFY_10 0x2e +#define GPCMD_WRITE_BUFFER 0x3b/* This is listed as optional in ATAPI 2.6, but is (curiously) * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji * Table 377 as an MMC command for SCSi devices though... Most ATAPI
@@ -279,18 +288,20 @@* older drives only. */ #define GPCMD_GET_MEDIA_STATUS 0xda -#define GPCMD_MODE_SENSE_6 0x1a +#define GPCMD_MODE_SENSE_6 0x1a/* Mode page codes for mode sense/set */ +#define GPMODE_VENDOR_PAGE 0x00#define GPMODE_R_W_ERROR_PAGE 0x01#define GPMODE_WRITE_PARMS_PAGE 0x05 +#define GPMODE_WCACHING_PAGE 0x08#define GPMODE_AUDIO_CTL_PAGE 0x0e#define GPMODE_POWER_PAGE 0x1a#define GPMODE_FAULT_FAIL_PAGE 0x1c#define GPMODE_TO_PROTECT_PAGE 0x1d#define GPMODE_CAPABILITIES_PAGE 0x2a#define GPMODE_ALL_PAGES 0x3f -/* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor +/* Not in Mt. Fuji, but in ATAPI 2.6 -- deprecated now in favor * of MODE_SENSE_POWER_PAGE */ #define GPMODE_CDROM_PAGE 0x0d
@@ -304,10 +315,26 @@*/ /* Some generally useful CD-ROM information */ -#define CD_MINS 80/* max. minutes per CD */ -#define CD_SECS 60/* seconds per minute */ -#define CD_FRAMES 75/* frames per second */ -#define CD_FRAMESIZE 2048/* bytes per frame, "cooked" mode */ +#define CD_MINS 80/* max. minutes per CD */ +#define CD_SECS 60/* seconds per minute */ +#define CD_FRAMES 75/* frames per second */ +#define CD_SYNC_SIZE 12/* 12 sync bytes per raw data frame */ +#define CD_MSF_OFFSET 150/* MSF numbering offset of first frame */ +#define CD_CHUNK_SIZE 24/* lowest-level "data bytes piece" */ +#define CD_NUM_OF_CHUNKS 98/* chunks per frame */ +#define CD_FRAMESIZE_SUB 96/* subchannel data "frame" size */ +#define CD_HEAD_SIZE 4/* header (address) bytes per raw data frame */ +#define CD_SUBHEAD_SIZE 8/* subheader bytes per raw XA data frame */ +#define CD_EDC_SIZE 4/* bytes EDC per most raw data frame types */ +#define CD_ZERO_SIZE 8/* bytes zero per yellow book mode 1 frame */ +#define CD_ECC_SIZE 276/* bytes ECC per most raw data frame types */ +#define CD_FRAMESIZE 2048/* bytes per frame, "cooked" mode */ +#define CD_FRAMESIZE_RAW 2352/* bytes per frame, "raw" mode */ +#define CD_FRAMESIZE_RAWER 2646/* The maximum possible returned bytes */ +/* most drives don't deliver everything: */ +#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE)/*2340*/ +#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE)/*2336*/ +#define CD_MAX_BYTES (CD_MINS * CD_SECS * CD_FRAMES * CD_FRAMESIZE)#define CD_MAX_SECTORS (CD_MAX_BYTES / 512)
@@ -346,12 +373,15 @@#define MMC_PROFILE_HDDVD_RW_DL 0x005A#define MMC_PROFILE_INVALID 0xFFFF +#define ATAPI_INT_REASON_CD 0x01/* 0 = data transfer */ #define ATAPI_INT_REASON_IO 0x02/* 1 = transfer to the host */ #define ATAPI_INT_REASON_REL 0x04#define ATAPI_INT_REASON_TAG 0xf8/* same constants as bochs */ +#define ASC_NONE 0x00 +#define ASC_READ_ERROR 0x11#define ASC_ILLEGAL_OPCODE 0x20#define ASC_LOGICAL_BLOCK_OOR 0x21#define ASC_INV_FIELD_IN_CMD_PACKET 0x24
@@ -367,10 +397,23 @@#define CFA_INVALID_ADDRESS 0x21#define CFA_ADDRESS_OVERFLOW 0x2f -#define SENSE_NONE 0 -#define SENSE_NOT_READY 2 -#define SENSE_ILLEGAL_REQUEST 5 -#define SENSE_UNIT_ATTENTION 6 +/* Sense keys */ +#define SENSE_NONE 0 +#define SENSE_RECOVERED_ERROR 1 +#define SENSE_NOT_READY 2 +#define SENSE_MEDIUM_ERROR 3 +#define SENSE_HARDWARE_ERROR 4 +#define SENSE_ILLEGAL_REQUEST 5 +#define SENSE_UNIT_ATTENTION 6 +#define SENSE_DATA_PROTECT 7 +#define SENSE_BLANK_CHECK 8 +#define SENSE_VENDOR_SPECIFIC 9 +#define SENSE_COPY_ABORTED 10 +#define SENSE_ABORTED_COMMAND 11 +#define SENSE_VOLUME_OVERFLOW 13 +#define SENSE_MISCOMPARE 14 + +#define IO_BUFFER_MAX_SIZE (IDE_DMA_BUF_SECTORS * 512 + 4)struct IDEState ;
Signature · 1 line
1.6.4
PATCH 3/7 atapi: guessing if the cdrom device is a scsi device.
ATAPI pass through code is enabled when the block device is a scsi device. So we have to guess if the block device is a scsi device in cdrom_open().
--- block/raw-posix.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
block/raw-posix.c +8 -0
@@ -1305,6 +1305,14 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags) s->type =FTYPE_CD ;/* open will not fail even if no CD is inserted, so add O_NONBLOCK */ +#if defined(__linux__) && defined(CONFIG_AIO ) +if (strstart (filename,"/dev/sg" ,NULL ) || +strstart (filename,"/dev/cd" ,NULL ) || +strstart (filename,"/dev/dvd" ,NULL ) || +strstart (filename,"/dev/sr" ,NULL )) { + bs->sg =1 ; + } +#endif return raw_open_common (bs, filename, flags,O_NONBLOCK ); }
Signature · 1 line
1.6.4
PATCH 4/7 atapi: adds header guards to hw/pcmia.h
--- hw/pcmcia.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
hw/pcmcia.h +5 -0
@@ -1,5 +1,8 @@/* PCMCIA/Cardbus */ +#ifndef PCMCIA_H +#define PCMCIA_H + #include "qemu-common.h" typedef struct {
@@ -49,3 +52,5 @@ struct PCMCIACardState {/* dscm1xxxx.c */ PCMCIACardState *dscm1xxxx_init (BlockDriverState *bdrv); + +#endif
Signature · 1 line
1.6.4
PATCH 5/7 atapi: adds header guards to hw/mac_dbdma.h
--- hw/mac_dbdma.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
hw/mac_dbdma.h +5 -0
@@ -20,6 +20,9 @@* THE SOFTWARE. */ +#ifndef MAC_DBDMA_H +#define MAC_DBDMA_H +typedef struct DBDMA_io DBDMA_io ;typedef void (*DBDMA_flush )(DBDMA_io *io);
@@ -41,3 +44,5 @@ void DBDMA_register_channel(void *dbdma, int nchan, qemu_irq irq, void *opaque);void DBDMA_schedule (void );void *DBDMA_init (int *dbdma_mem_index); + +#endif /* !MAC_DBDMA_H */
Signature · 1 line
1.6.4
PATCH 6/7 atapi: made some part of ide.c public and moved some part to atapi.
--- hw/atapi-data.c | 269 ++++++++++++++++++++++++++ hw/atapi-defines.h | 234 ++++++++++++++++++++++ hw/ide.c | 544 ++-------------------------------------------------- hw/ide.h | 377 ++++++++++++++++++++++++++++++++++++ 4 files changed, 893 insertions(+), 531 deletions(-) create mode 100644 hw/atapi-data.c create mode 100644 hw/atapi-defines.h create mode 100644 hw/ide.h
hw/atapi-data.c new file +269 -0
@@ -0,0 +1,269 @@ +/* +* ATAPI pass through addition data +* +* Copyright (c) 2009 Alexandre Bique +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include "atapi-defines.h" + +/* The generic packet command opcodes for CD/DVD Logical Units, +* From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ +static const struct { +unsigned short packet_command; +const char *const text; +} packet_command_texts[] = { + {GPCMD_TEST_UNIT_READY ,"Test Unit Ready" }, + {GPCMD_REQUEST_SENSE ,"Request Sense" }, + {GPCMD_FORMAT_UNIT ,"Format Unit" }, + {GPCMD_INQUIRY ,"Inquiry" }, + {GPCMD_START_STOP_UNIT ,"Start/Stop Unit" }, + {GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL ,"Prevent/Allow Medium Removal" }, + {GPCMD_READ_FORMAT_CAPACITIES ,"Read Format Capacities" }, + {GPCMD_READ_CDVD_CAPACITY ,"Read Cd/Dvd Capacity" }, + {GPCMD_READ_10 ,"Read 10" }, + {GPCMD_WRITE_10 ,"Write 10" }, + {GPCMD_SEEK ,"Seek" }, + {GPCMD_WRITE_AND_VERIFY_10 ,"Write and Verify 10" }, + {GPCMD_VERIFY_10 ,"Verify 10" }, + {GPCMD_FLUSH_CACHE ,"Flush Cache" }, + {GPCMD_READ_SUBCHANNEL ,"Read Subchannel" }, + {GPCMD_READ_TOC_PMA_ATIP ,"Read Table of Contents" }, + {GPCMD_READ_HEADER ,"Read Header" }, + {GPCMD_PLAY_AUDIO_10 ,"Play Audio 10" }, + {GPCMD_GET_CONFIGURATION ,"Get Configuration" }, + {GPCMD_PLAY_AUDIO_MSF ,"Play Audio MSF" }, + {GPCMD_PLAYAUDIO_TI ,"Play Audio TrackIndex" }, + {GPCMD_GET_EVENT_STATUS_NOTIFICATION , +"Get Event Status Notification" }, + {GPCMD_PAUSE_RESUME ,"Pause/Resume" }, + {GPCMD_STOP_PLAY_SCAN ,"Stop Play/Scan" }, + {GPCMD_READ_DISC_INFO ,"Read Disc Info" }, + {GPCMD_READ_TRACK_RZONE_INFO ,"Read Track Rzone Info" }, + {GPCMD_RESERVE_RZONE_TRACK ,"Reserve Rzone Track" }, + {GPCMD_SEND_OPC ,"Send OPC" }, + {GPCMD_MODE_SELECT_10 ,"Mode Select 10" }, + {GPCMD_REPAIR_RZONE_TRACK ,"Repair Rzone Track" }, + {GPCMD_MODE_SENSE_10 ,"Mode Sense 10" }, + {GPCMD_CLOSE_TRACK ,"Close Track" }, + {GPCMD_BLANK ,"Blank" }, + {GPCMD_SEND_EVENT ,"Send Event" }, + {GPCMD_SEND_KEY ,"Send Key" }, + {GPCMD_REPORT_KEY ,"Report Key" }, + {GPCMD_LOAD_UNLOAD ,"Load/Unload" }, + {GPCMD_SET_READ_AHEAD ,"Set Read-ahead" }, + {GPCMD_READ_12 ,"Read 12" }, + {GPCMD_GET_PERFORMANCE ,"Get Performance" }, + {GPCMD_SEND_DVD_STRUCTURE ,"Send DVD Structure" }, + {GPCMD_READ_DVD_STRUCTURE ,"Read DVD Structure" }, + {GPCMD_SET_STREAMING ,"Set Streaming" }, + {GPCMD_READ_CD_MSF ,"Read CD MSF" }, + {GPCMD_SCAN ,"Scan" }, + {GPCMD_SET_SPEED ,"Set Speed" }, + {GPCMD_PLAY_CD ,"Play CD" }, + {GPCMD_MECHANISM_STATUS ,"Mechanism Status" }, + {GPCMD_READ_CD ,"Read CD" }, + {GPCMD_READ_BUFFER_CAPACITY ,"Read Buffer Capacity" }, + {GPCMD_READ_BUFFER ,"Read Buffer" }, + {GPCMD_SEND_CUE_SHEET ,"Send Cue Sheet" }, + {0 ,0 } +}; + +const char *atapi_cmd_to_str (int cmd) +{ +int i; + +for (i =0 ; packet_command_texts[i].text; ++i) +if (packet_command_texts[i].packet_command == cmd) +return packet_command_texts[i].text; +return 0 ; +} + +/* From Table 303 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ +const char *const sense_key_texts[16 ] = { +"No sense data" , +"Recovered error" , +"Not ready" , +"Medium error" , +"Hardware error" , +"Illegal request" , +"Unit attention" , +"Data protect" , +"Blank check" , +"(reserved)" , +"(reserved)" , +"Aborted command" , +"(reserved)" , +"(reserved)" , +"Miscompare" , +"(reserved)" , +}; + +/* From Table 304 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ +static const struct { +unsigned long asc_ascq; +const char *const text; +} sense_data_texts[] = { + {0x000000 ,"No additional sense information" }, + {0x000011 ,"Play operation in progress" }, + {0x000012 ,"Play operation paused" }, + {0x000013 ,"Play operation successfully completed" }, + {0x000014 ,"Play operation stopped due to error" }, + {0x000015 ,"No current audio status to return" }, + {0x010c0a ,"Write error - padding blocks added" }, + {0x011700 ,"Recovered data with no error correction applied" }, + {0x011701 ,"Recovered data with retries" }, + {0x011702 ,"Recovered data with positive head offset" }, + {0x011703 ,"Recovered data with negative head offset" }, + {0x011704 ,"Recovered data with retries and/or CIRC applied" }, + {0x011705 ,"Recovered data using previous sector ID" }, + {0x011800 ,"Recovered data with error correction applied" }, + {0x011801 ,"Recovered data with error correction and retries applied" }, + {0x011802 ,"Recovered data - the data was auto-reallocated" }, + {0x011803 ,"Recovered data with CIRC" }, + {0x011804 ,"Recovered data with L-EC" }, + {0x015d00 ,"Failure prediction threshold exceeded" +" - Predicted logical unit failure" }, + {0x015d01 ,"Failure prediction threshold exceeded" +" - Predicted media failure" }, + {0x015dff ,"Failure prediction threshold exceeded - False" }, + {0x017301 ,"Power calibration area almost full" }, + {0x020400 ,"Logical unit not ready - cause not reportable" }, +/* Following is misspelled in ATAPI 2.6, _and_ in Mt. Fuji */ + {0x020401 ,"Logical unit not ready" +" - in progress [sic] of becoming ready" }, + {0x020402 ,"Logical unit not ready - initializing command required" }, + {0x020403 ,"Logical unit not ready - manual intervention required" }, + {0x020404 ,"Logical unit not ready - format in progress" }, + {0x020407 ,"Logical unit not ready - operation in progress" }, + {0x020408 ,"Logical unit not ready - long write in progress" }, + {0x020600 ,"No reference position found (media may be upside down)" }, + {0x023000 ,"Incompatible medium installed" }, + {0x023a00 ,"Medium not present" }, + {0x025300 ,"Media load or eject failed" }, + {0x025700 ,"Unable to recover table of contents" }, + {0x030300 ,"Peripheral device write fault" }, + {0x030301 ,"No write current" }, + {0x030302 ,"Excessive write errors" }, + {0x030c00 ,"Write error" }, + {0x030c01 ,"Write error - Recovered with auto reallocation" }, + {0x030c02 ,"Write error - auto reallocation failed" }, + {0x030c03 ,"Write error - recommend reassignment" }, + {0x030c04 ,"Compression check miscompare error" }, + {0x030c05 ,"Data expansion occurred during compress" }, + {0x030c06 ,"Block not compressible" }, + {0x030c07 ,"Write error - recovery needed" }, + {0x030c08 ,"Write error - recovery failed" }, + {0x030c09 ,"Write error - loss of streaming" }, + {0x031100 ,"Unrecovered read error" }, + {0x031106 ,"CIRC unrecovered error" }, + {0x033101 ,"Format command failed" }, + {0x033200 ,"No defect spare location available" }, + {0x033201 ,"Defect list update failure" }, + {0x035100 ,"Erase failure" }, + {0x037200 ,"Session fixation error" }, + {0x037201 ,"Session fixation error writin lead-in" }, + {0x037202 ,"Session fixation error writin lead-out" }, + {0x037300 ,"CD control error" }, + {0x037302 ,"Power calibration area is full" }, + {0x037303 ,"Power calibration area error" }, + {0x037304 ,"Program memory area / RMA update failure" }, + {0x037305 ,"Program memory area / RMA is full" }, + {0x037306 ,"Program memory area / RMA is (almost) full" }, + {0x040200 ,"No seek complete" }, + {0x040300 ,"Write fault" }, + {0x040900 ,"Track following error" }, + {0x040901 ,"Tracking servo failure" }, + {0x040902 ,"Focus servo failure" }, + {0x040903 ,"Spindle servo failure" }, + {0x041500 ,"Random positioning error" }, + {0x041501 ,"Mechanical positioning or changer error" }, + {0x041502 ,"Positioning error detected by read of medium" }, + {0x043c00 ,"Mechanical positioning or changer error" }, + {0x044000 ,"Diagnostic failure on component (ASCQ)" }, + {0x044400 ,"Internal CD/DVD logical unit failure" }, + {0x04b600 ,"Media load mechanism failed" }, + {0x051a00 ,"Parameter list length error" }, + {0x052000 ,"Invalid command operation code" }, + {0x052100 ,"Logical block address out of range" }, + {0x052102 ,"Invalid address for write" }, + {0x052400 ,"Invalid field in command packet" }, + {0x052600 ,"Invalid field in parameter list" }, + {0x052601 ,"Parameter not supported" }, + {0x052602 ,"Parameter value invalid" }, + {0x052700 ,"Write protected media" }, + {0x052c00 ,"Command sequence error" }, + {0x052c03 ,"Current program area is not empty" }, + {0x052c04 ,"Current program area is empty" }, + {0x053001 ,"Cannot read medium - unknown format" }, + {0x053002 ,"Cannot read medium - incompatible format" }, + {0x053900 ,"Saving parameters not supported" }, + {0x054e00 ,"Overlapped commands attempted" }, + {0x055302 ,"Medium removal prevented" }, + {0x055500 ,"System resource failure" }, + {0x056300 ,"End of user area encountered on this track" }, + {0x056400 ,"Illegal mode for this track or incompatible medium" }, + {0x056f00 ,"Copy protection key exchange failure" +" - Authentication failure" }, + {0x056f01 ,"Copy protection key exchange failure - Key not present" }, + {0x056f02 ,"Copy protection key exchange failure" +" - Key not established" }, + {0x056f03 ,"Read of scrambled sector without authentication" }, + {0x056f04 ,"Media region code is mismatched to logical unit" }, + {0x056f05 ,"Drive region must be permanent" +" / region reset count error" }, + {0x057203 ,"Session fixation error - incomplete track in session" }, + {0x057204 ,"Empty or partially written reserved track" }, + {0x057205 ,"No more RZONE reservations are allowed" }, + {0x05bf00 ,"Loss of streaming" }, + {0x062800 ,"Not ready to ready transition, medium may have changed" }, + {0x062900 ,"Power on, reset or hardware reset occurred" }, + {0x062a00 ,"Parameters changed" }, + {0x062a01 ,"Mode parameters changed" }, + {0x062e00 ,"Insufficient time for operation" }, + {0x063f00 ,"Logical unit operating conditions have changed" }, + {0x063f01 ,"Microcode has been changed" }, + {0x065a00 ,"Operator request or state change input (unspecified)" }, + {0x065a01 ,"Operator medium removal request" }, + {0x0bb900 ,"Play operation aborted" }, +/* Here we use 0xff for the key (not a valid key) to signify +* that these can have _any_ key value associated with them... */ + {0xff0401 ,"Logical unit is in process of becoming ready" }, + {0xff0400 ,"Logical unit not ready, cause not reportable" }, + {0xff0402 ,"Logical unit not ready, initializing command required" }, + {0xff0403 ,"Logical unit not ready, manual intervention required" }, + {0xff0500 ,"Logical unit does not respond to selection" }, + {0xff0800 ,"Logical unit communication failure" }, + {0xff0802 ,"Logical unit communication parity error" }, + {0xff0801 ,"Logical unit communication time-out" }, + {0xff2500 ,"Logical unit not supported" }, + {0xff4c00 ,"Logical unit failed self-configuration" }, + {0xff3e00 ,"Logical unit has not self-configured yet" }, +}; + +const char *atapi_ascq_to_str (int ascq) +{ +int i; + +for (i =0 ; sense_data_texts[i].text; ++i) +if (sense_data_texts[i].asc_ascq == ascq) +return sense_data_texts[i].text; +return 0 ; +}
hw/atapi-defines.h new file +234 -0
234 lines not on this page · raw message
hw/ide.c +13 -531
624 lines not on this page · raw message
hw/ide.h new file +377 -0
377 lines not on this page · raw message
Signature · 1 line
1.6.4
PATCH 7/7 atapi: introducing atapi pass through
This patch introduce atapi pass through. The pass through code is used by default when the underlying block is a scsi device.
This brings 1 new option to the command line interface:
-cdrom-allow-fw-upgrade which allow to pass through the firmware
upgrade which is blocked by default. See the WRITE_BUFFER command for more details.
--- Makefile.target | 14 +- hw/atapi-pt.c | 796 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/atapi-pt.h | 35 +++ hw/ide.c | 31 +-- hw/ide.h | 104 ++++++-- qemu-options.hx | 7 + vl.c | 5 + 7 files changed, 952 insertions(+), 40 deletions(-) create mode 100644 hw/atapi-pt.c create mode 100644 hw/atapi-pt.h
Makefile.target +8 -6
@@ -327,7 +327,7 @@ obj-y += e1000.o obj-y += wdt_ib700.o wdt_i6300esb.o # Hardware support -obj-i386-y = ide.o pckbd.o vga.o $(sound-obj-y) dma.o +obj-i386-y = ide.o atapi-pt.o atapi-data.o pckbd.o vga.o $(sound-obj-y) dma.o obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
@@ -338,7 +338,8 @@ CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE endif # shared objects -obj-ppc-y = ppc.o ide.o vga.o $(sound-obj-y) dma.o openpic.o +obj-ppc-y = ppc.o ide.o atapi-pt.o atapi-data.o +obj-ppc-y += vga.o $(sound-obj-y) dma.o openpic.o # PREP target obj-ppc-y += pckbd.o serial.o i8259.o i8254.o fdc.o mc146818rtc.o obj-ppc-y += prep_pci.o ppc_prep.o
@@ -365,7 +366,8 @@ LIBS+= $(FDT_LIBS) obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o rc4030.o obj-mips-y += g364fb.o jazz_led.o dp8393x.o -obj-mips-y += ide.o gt64xxx.o pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o +obj-mips-y += ide.o atapi-pt.o atapi-data.o gt64xxx.o +obj-mips-y += pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o obj-mips-y += piix_pci.o parallel.o cirrus_vga.o pcspk.o $(sound-obj-y) obj-mips-y += mipsnet.o obj-mips-y += pflash_cfi01.o
@@ -401,7 +403,7 @@ obj-cris-y += etraxfs_ser.o obj-cris-y += pflash_cfi02.o ifeq ($(TARGET_ARCH), sparc64) -obj-sparc-y = sun4u.o ide.o pckbd.o vga.o apb_pci.o +obj-sparc-y = sun4u.o ide.o atapi-pt.o atapi-data.o pckbd.o vga.o apb_pci.o obj-sparc-y += fdc.o mc146818rtc.o serial.o obj-sparc-y += cirrus_vga.o parallel.o else
@@ -420,7 +422,7 @@ obj-arm-y += arm-semi.o obj-arm-y += pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o obj-arm-y += pflash_cfi01.o gumstix.o -obj-arm-y += zaurus.o ide.o serial.o spitz.o tosa.o tc6393xb.o +obj-arm-y += zaurus.o ide.o atapi-pt.o atapi-data.o serial.o spitz.o tosa.o tc6393xb.o obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o obj-arm-y += omap2.o omap_dss.o soc_dma.o obj-arm-y += omap_sx1.o palm.o tsc210x.o
@@ -438,7 +440,7 @@ endif obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o serial.o -obj-sh4-y += ide.o +obj-sh4-y += ide.o atapi-pt.o atapi-data.o obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o obj-m68k-y += m68k-semi.o dummy_m68k.o
hw/atapi-pt.c new file +796 -0
796 lines not on this page · raw message
hw/atapi-pt.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* ATAPI pass through declarations +* +* Copyright (c) 2009 Alexandre Bique +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#ifndef ATAPI_PT_H +# define ATAPI_PT_H + +# include "ide.h" + +extern int atapi_pt_allow_fw_upgrade; + +void ide_atapi_pt_cmd (IDEState * s); +void ide_atapi_pt_identify (IDEState * s); + +#endif /* !ATAPI_PT_H */
hw/ide.c +14 -17
@@ -22,21 +22,8 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "hw.h" -#include "pc.h" -#include "pci.h" -#include "scsi-disk.h" -#include "pcmcia.h" -#include "block.h" -#include "block_int.h" -#include "qemu-timer.h" -#include "sysemu.h" -#include "ppc_mac.h" -#include "mac_dbdma.h" -#include "sh.h" -#include "dma.h" #include "ide.h" -#include "atapi-defines.h" +#include "atapi-pt.h" /* debug IDE devices */ //#define DEBUG_IDE
@@ -44,6 +31,7 @@//#define DEBUG_AIO #define USE_DMA_CDROM +/* XXX: DVDs that could fit on a CD will be reported as a CD */ static inline int media_present (IDEState *s) {
@@ -62,7 +50,6 @@ static inline int media_is_cd(IDEState *s)static void ide_dma_restart (IDEState *s);static void ide_atapi_cmd_read_dma_cb (void *opaque,int ret); -static void ide_atapi_cmd_error (IDEState *s,int sense_key,int asc);static void padstr (char *str,const char *src,int len) {
@@ -1977,7 +1964,7 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)/* ATAPI commands */ case WIN_PIDENTIFY :if (s->is_cdrom) { -ide_atapi_identify (s); + s->atapi_identify (s); s->status =READY_STAT |SEEK_STAT ;ide_transfer_start (s, s->io_buffer,512 , ide_transfer_stop); }else {
@@ -2015,7 +2002,7 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) s->atapi_dma = s->feature &1 ; s->nsector =1 ;ide_transfer_start (s, s->io_buffer,ATAPI_PACKET_SIZE , - ide_atapi_cmd); + s->atapi_cmd);break ;/* CF-ATA commands */ case CFA_REQ_EXT_ERROR_CODE :
@@ -2354,6 +2341,16 @@ static void ide_init2(IDEState *ide_state,if (bdrv_get_type_hint (s->bs) ==BDRV_TYPE_CDROM ) { s->is_cdrom =1 ; +if (!bdrv_is_sg (s->bs)) { + s->atapi_cmd = ide_atapi_cmd; + s->atapi_identify = ide_atapi_identify; + } +#if CONFIG_ATAPI_PT + else { + s->atapi_cmd = ide_atapi_pt_cmd; + s->atapi_identify = ide_atapi_pt_identify; + } +#endif /* CONFIG_ATAPI_PT */ bdrv_set_change_cb (s->bs, cdrom_change_cb, s); } }
hw/ide.h +87 -17
139 lines not on this page · raw message
qemu-options.hx +7 -0
@@ -91,6 +91,13 @@ Use @var{file} as CD-ROM image (you cannot use @option{-hdc} and using @file{/dev/cdrom} as filename (@pxref{host_drives}). ETEXI +DEF("cdrom-allow-fw-upgrade", 0, QEMU_OPTION_cdrom_allow_fw_upgrade, + "-cdrom-allow-fw-upgrade allow the guest to process cdrom firmware upgrade.\n") +STEXI +@item -cdrom-allow-fw-upgrade +Allow Qemu to pass through ATAPI firmware upgrade command. +ETEXI + DEF("drive", HAS_ARG, QEMU_OPTION_drive, "-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n" " [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
vl.c +5 -0
@@ -142,6 +142,7 @@ int main(int argc, char **argv)#include "hw/smbios.h" #include "hw/xen.h" #include "hw/qdev.h" +#include "hw/atapi-pt.h" #include "bt-host.h" #include "net.h" #include "monitor.h"
@@ -1792,6 +1793,7 @@ static int bt_parse(const char *opt)#define HD_ALIAS "index=%d,media=disk"#define CDROM_ALIAS "index=2,media=cdrom" +#define CDROM_PT_ALIAS "index=2,media=cdrompt"#define FD_ALIAS "index=%d,if=floppy"#define PFLASH_ALIAS "if=pflash"#define MTD_ALIAS "if=mtd"
@@ -5119,6 +5121,9 @@ int main(int argc, char **argv, char **envp)case QEMU_OPTION_cdrom:drive_add (optarg,CDROM_ALIAS );break ; +case QEMU_OPTION_cdrom_allow_fw_upgrade: + atapi_pt_allow_fw_upgrade =1 ; +break ;case QEMU_OPTION_boot: {static const char *const params[] = {
Signature · 1 line
1.6.4
Quoted 4 lines · Alexandre Bique
Hi,
This is the new version of the ATAPI pass through patches.
This series breaks the cris-softmmu build.
Also, I think Paul and I both requested that fw upgrade not be disabled by default. I would also suggest that you only expose this as an option through qdev properties instead of a new command line option as it should be controllable on a per-device basis.
Regards,
Anthony Liguori