1356721aeSGerd Hoffmann #ifndef HW_IDE_INTERNAL_H 2356721aeSGerd Hoffmann #define HW_IDE_INTERNAL_H 3356721aeSGerd Hoffmann 4356721aeSGerd Hoffmann /* 5356721aeSGerd Hoffmann * QEMU IDE Emulation -- internal header file 659f2a787SGerd Hoffmann * only files in hw/ide/ are supposed to include this file. 7356721aeSGerd Hoffmann * non-internal declarations are in hw/ide.h 8356721aeSGerd Hoffmann */ 92f780b6aSMarkus Armbruster 10a9c94277SMarkus Armbruster #include "hw/ide.h" 119c17d615SPaolo Bonzini #include "sysemu/dma.h" 120d09e41aSPaolo Bonzini #include "hw/block/block.h" 131f7a0d03SPhilippe Mathieu-Daudé #include "exec/ioport.h" 14356721aeSGerd Hoffmann 15356721aeSGerd Hoffmann /* debug IDE devices */ 16356721aeSGerd Hoffmann #define USE_DMA_CDROM 17db1015e9SEduardo Habkost #include "qom/object.h" 18356721aeSGerd Hoffmann 19da4d0419SGerd Hoffmann typedef struct IDEDevice IDEDevice; 20356721aeSGerd Hoffmann typedef struct IDEState IDEState; 2140a6238aSAlexander Graf typedef struct IDEDMA IDEDMA; 2240a6238aSAlexander Graf typedef struct IDEDMAOps IDEDMAOps; 23356721aeSGerd Hoffmann 240d936928SAnthony Liguori #define TYPE_IDE_BUS "IDE" 258063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(IDEBus, IDE_BUS) 260d936928SAnthony Liguori 27d475fb12SBALATON Zoltan #define MAX_IDE_DEVS 2 28d475fb12SBALATON Zoltan 290c7515e1SJohn Snow /* Device/Head ("select") Register */ 300c7515e1SJohn Snow #define ATA_DEV_SELECT 0x10 310c7515e1SJohn Snow /* ATA1,3: Defined as '1'. 320c7515e1SJohn Snow * ATA2: Reserved. 330c7515e1SJohn Snow * ATA3-7: obsolete. */ 340c7515e1SJohn Snow #define ATA_DEV_ALWAYS_ON 0xA0 350c7515e1SJohn Snow #define ATA_DEV_LBA 0x40 360c7515e1SJohn Snow #define ATA_DEV_LBA_MSB 0x0F /* LBA 24:27 */ 370c7515e1SJohn Snow #define ATA_DEV_HS 0x0F /* HS 3:0 */ 380c7515e1SJohn Snow 390c7515e1SJohn Snow 40356721aeSGerd Hoffmann /* Bits of HD_STATUS */ 41356721aeSGerd Hoffmann #define ERR_STAT 0x01 42356721aeSGerd Hoffmann #define INDEX_STAT 0x02 43356721aeSGerd Hoffmann #define ECC_STAT 0x04 /* Corrected error */ 44356721aeSGerd Hoffmann #define DRQ_STAT 0x08 45356721aeSGerd Hoffmann #define SEEK_STAT 0x10 46356721aeSGerd Hoffmann #define SRV_STAT 0x10 47356721aeSGerd Hoffmann #define WRERR_STAT 0x20 48356721aeSGerd Hoffmann #define READY_STAT 0x40 49356721aeSGerd Hoffmann #define BUSY_STAT 0x80 50356721aeSGerd Hoffmann 51356721aeSGerd Hoffmann /* Bits for HD_ERROR */ 52356721aeSGerd Hoffmann #define MARK_ERR 0x01 /* Bad address mark */ 53356721aeSGerd Hoffmann #define TRK0_ERR 0x02 /* couldn't find track 0 */ 54356721aeSGerd Hoffmann #define ABRT_ERR 0x04 /* Command aborted */ 55356721aeSGerd Hoffmann #define MCR_ERR 0x08 /* media change request */ 56356721aeSGerd Hoffmann #define ID_ERR 0x10 /* ID field not found */ 57356721aeSGerd Hoffmann #define MC_ERR 0x20 /* media changed */ 58356721aeSGerd Hoffmann #define ECC_ERR 0x40 /* Uncorrectable ECC error */ 59356721aeSGerd Hoffmann #define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */ 60356721aeSGerd Hoffmann #define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */ 61356721aeSGerd Hoffmann 62356721aeSGerd Hoffmann /* Bits of HD_NSECTOR */ 63356721aeSGerd Hoffmann #define CD 0x01 64356721aeSGerd Hoffmann #define IO 0x02 65356721aeSGerd Hoffmann #define REL 0x04 66356721aeSGerd Hoffmann #define TAG_MASK 0xf8 67356721aeSGerd Hoffmann 6898d98912SJohn Snow /* Bits of Device Control register */ 69be8c9423SJohn Snow #define IDE_CTRL_HOB 0x80 7098d98912SJohn Snow #define IDE_CTRL_RESET 0x04 7198d98912SJohn Snow #define IDE_CTRL_DISABLE_IRQ 0x02 72356721aeSGerd Hoffmann 731d4316d3SMarkus Armbruster /* ACS-2 T13/2015-D Table B.2 Command codes */ 74356721aeSGerd Hoffmann #define WIN_NOP 0x00 751d4316d3SMarkus Armbruster /* reserved 0x01..0x02 */ 76356721aeSGerd Hoffmann #define CFA_REQ_EXT_ERROR_CODE 0x03 /* CFA Request Extended Error Code */ 771d4316d3SMarkus Armbruster /* reserved 0x04..0x05 */ 78d353fb72SChristoph Hellwig #define WIN_DSM 0x06 791d4316d3SMarkus Armbruster /* reserved 0x07 */ 80356721aeSGerd Hoffmann #define WIN_DEVICE_RESET 0x08 811d4316d3SMarkus Armbruster /* reserved 0x09..0x0a */ 821d4316d3SMarkus Armbruster /* REQUEST SENSE DATA EXT 0x0B */ 831d4316d3SMarkus Armbruster /* reserved 0x0C..0x0F */ 841d4316d3SMarkus Armbruster #define WIN_RECAL 0x10 /* obsolete since ATA4 */ 851d4316d3SMarkus Armbruster /* obsolete since ATA3, retired in ATA4 0x11..0x1F */ 86356721aeSGerd Hoffmann #define WIN_READ 0x20 /* 28-Bit */ 871d4316d3SMarkus Armbruster #define WIN_READ_ONCE 0x21 /* 28-Bit w/o retries, obsolete since ATA5 */ 881d4316d3SMarkus Armbruster /* obsolete since ATA4 0x22..0x23 */ 89356721aeSGerd Hoffmann #define WIN_READ_EXT 0x24 /* 48-Bit */ 90356721aeSGerd Hoffmann #define WIN_READDMA_EXT 0x25 /* 48-Bit */ 911d4316d3SMarkus Armbruster #define WIN_READDMA_QUEUED_EXT 0x26 /* 48-Bit, obsolete since ACS2 */ 92356721aeSGerd Hoffmann #define WIN_READ_NATIVE_MAX_EXT 0x27 /* 48-Bit */ 931d4316d3SMarkus Armbruster /* reserved 0x28 */ 94356721aeSGerd Hoffmann #define WIN_MULTREAD_EXT 0x29 /* 48-Bit */ 951d4316d3SMarkus Armbruster /* READ STREAM DMA EXT 0x2A */ 961d4316d3SMarkus Armbruster /* READ STREAM EXT 0x2B */ 971d4316d3SMarkus Armbruster /* reserved 0x2C..0x2E */ 981d4316d3SMarkus Armbruster /* READ LOG EXT 0x2F */ 99356721aeSGerd Hoffmann #define WIN_WRITE 0x30 /* 28-Bit */ 1001d4316d3SMarkus Armbruster #define WIN_WRITE_ONCE 0x31 /* 28-Bit w/o retries, obsolete since ATA5 */ 1011d4316d3SMarkus Armbruster /* obsolete since ATA4 0x32..0x33 */ 102356721aeSGerd Hoffmann #define WIN_WRITE_EXT 0x34 /* 48-Bit */ 103356721aeSGerd Hoffmann #define WIN_WRITEDMA_EXT 0x35 /* 48-Bit */ 104356721aeSGerd Hoffmann #define WIN_WRITEDMA_QUEUED_EXT 0x36 /* 48-Bit */ 1051d4316d3SMarkus Armbruster #define WIN_SET_MAX_EXT 0x37 /* 48-Bit, obsolete since ACS2 */ 106356721aeSGerd Hoffmann #define WIN_SET_MAX_EXT 0x37 /* 48-Bit */ 107356721aeSGerd Hoffmann #define CFA_WRITE_SECT_WO_ERASE 0x38 /* CFA Write Sectors without erase */ 108356721aeSGerd Hoffmann #define WIN_MULTWRITE_EXT 0x39 /* 48-Bit */ 1091d4316d3SMarkus Armbruster /* WRITE STREAM DMA EXT 0x3A */ 1101d4316d3SMarkus Armbruster /* WRITE STREAM EXT 0x3B */ 1111d4316d3SMarkus Armbruster #define WIN_WRITE_VERIFY 0x3C /* 28-Bit, obsolete since ATA4 */ 1121d4316d3SMarkus Armbruster /* WRITE DMA FUA EXT 0x3D */ 1131d4316d3SMarkus Armbruster /* obsolete since ACS2 0x3E */ 1141d4316d3SMarkus Armbruster /* WRITE LOG EXT 0x3F */ 115356721aeSGerd Hoffmann #define WIN_VERIFY 0x40 /* 28-Bit - Read Verify Sectors */ 1161d4316d3SMarkus Armbruster #define WIN_VERIFY_ONCE 0x41 /* 28-Bit - w/o retries, obsolete since ATA5 */ 117356721aeSGerd Hoffmann #define WIN_VERIFY_EXT 0x42 /* 48-Bit */ 1181d4316d3SMarkus Armbruster /* reserved 0x43..0x44 */ 1191d4316d3SMarkus Armbruster /* WRITE UNCORRECTABLE EXT 0x45 */ 1201d4316d3SMarkus Armbruster /* reserved 0x46 */ 1211d4316d3SMarkus Armbruster /* READ LOG DMA EXT 0x47 */ 1221d4316d3SMarkus Armbruster /* reserved 0x48..0x4F */ 1231d4316d3SMarkus Armbruster /* obsolete since ATA4 0x50 */ 1241d4316d3SMarkus Armbruster /* CONFIGURE STREAM 0x51 */ 1251d4316d3SMarkus Armbruster /* reserved 0x52..0x56 */ 1261d4316d3SMarkus Armbruster /* WRITE LOG DMA EXT 0x57 */ 1271d4316d3SMarkus Armbruster /* reserved 0x58..0x5A */ 1281d4316d3SMarkus Armbruster /* TRUSTED NON DATA 0x5B */ 1291d4316d3SMarkus Armbruster /* TRUSTED RECEIVE 0x5C */ 1301d4316d3SMarkus Armbruster /* TRUSTED RECEIVE DMA 0x5D */ 1311d4316d3SMarkus Armbruster /* TRUSTED SEND 0x5E */ 1321d4316d3SMarkus Armbruster /* TRUSTED SEND DMA 0x5F */ 1331d4316d3SMarkus Armbruster /* READ FPDMA QUEUED 0x60 */ 1341d4316d3SMarkus Armbruster /* WRITE FPDMA QUEUED 0x61 */ 1351d4316d3SMarkus Armbruster /* reserved 0x62->0x6F */ 1361d4316d3SMarkus Armbruster #define WIN_SEEK 0x70 /* obsolete since ATA7 */ 1371d4316d3SMarkus Armbruster /* reserved 0x71-0x7F */ 1381d4316d3SMarkus Armbruster /* vendor specific 0x80-0x86 */ 139356721aeSGerd Hoffmann #define CFA_TRANSLATE_SECTOR 0x87 /* CFA Translate Sector */ 1401d4316d3SMarkus Armbruster /* vendor specific 0x88-0x8F */ 141356721aeSGerd Hoffmann #define WIN_DIAGNOSE 0x90 1421d4316d3SMarkus Armbruster #define WIN_SPECIFY 0x91 /* set drive geometry translation, obsolete since ATA6 */ 143356721aeSGerd Hoffmann #define WIN_DOWNLOAD_MICROCODE 0x92 1441d4316d3SMarkus Armbruster /* DOWNLOAD MICROCODE DMA 0x93 */ 1451d4316d3SMarkus Armbruster #define WIN_STANDBYNOW2 0x94 /* retired in ATA4 */ 1461d4316d3SMarkus Armbruster #define WIN_IDLEIMMEDIATE2 0x95 /* force drive to become "ready", retired in ATA4 */ 1471d4316d3SMarkus Armbruster #define WIN_STANDBY2 0x96 /* retired in ATA4 */ 1481d4316d3SMarkus Armbruster #define WIN_SETIDLE2 0x97 /* retired in ATA4 */ 1491d4316d3SMarkus Armbruster #define WIN_CHECKPOWERMODE2 0x98 /* retired in ATA4 */ 1501d4316d3SMarkus Armbruster #define WIN_SLEEPNOW2 0x99 /* retired in ATA4 */ 1511d4316d3SMarkus Armbruster /* vendor specific 0x9A */ 1521d4316d3SMarkus Armbruster /* reserved 0x9B..0x9F */ 153356721aeSGerd Hoffmann #define WIN_PACKETCMD 0xA0 /* Send a packet command. */ 154356721aeSGerd Hoffmann #define WIN_PIDENTIFY 0xA1 /* identify ATAPI device */ 1551d4316d3SMarkus Armbruster #define WIN_QUEUED_SERVICE 0xA2 /* obsolete since ACS2 */ 1561d4316d3SMarkus Armbruster /* reserved 0xA3..0xAF */ 157356721aeSGerd Hoffmann #define WIN_SMART 0xB0 /* self-monitoring and reporting */ 1581d4316d3SMarkus Armbruster /* Device Configuration Overlay 0xB1 */ 1591d4316d3SMarkus Armbruster /* reserved 0xB2..0xB3 */ 1601d4316d3SMarkus Armbruster /* Sanitize Device 0xB4 */ 1611d4316d3SMarkus Armbruster /* reserved 0xB5 */ 1621d4316d3SMarkus Armbruster /* NV Cache 0xB6 */ 1631d4316d3SMarkus Armbruster /* reserved for CFA 0xB7..0xBB */ 164356721aeSGerd Hoffmann #define CFA_ACCESS_METADATA_STORAGE 0xB8 1651d4316d3SMarkus Armbruster /* reserved 0xBC..0xBF */ 166356721aeSGerd Hoffmann #define CFA_ERASE_SECTORS 0xC0 /* microdrives implement as NOP */ 1671d4316d3SMarkus Armbruster /* vendor specific 0xC1..0xC3 */ 168356721aeSGerd Hoffmann #define WIN_MULTREAD 0xC4 /* read sectors using multiple mode*/ 169356721aeSGerd Hoffmann #define WIN_MULTWRITE 0xC5 /* write sectors using multiple mode */ 170356721aeSGerd Hoffmann #define WIN_SETMULT 0xC6 /* enable/disable multiple mode */ 1711d4316d3SMarkus Armbruster #define WIN_READDMA_QUEUED 0xC7 /* read sectors using Queued DMA transfers, obsolete since ACS2 */ 172356721aeSGerd Hoffmann #define WIN_READDMA 0xC8 /* read sectors using DMA transfers */ 1731d4316d3SMarkus Armbruster #define WIN_READDMA_ONCE 0xC9 /* 28-Bit - w/o retries, obsolete since ATA5 */ 174356721aeSGerd Hoffmann #define WIN_WRITEDMA 0xCA /* write sectors using DMA transfers */ 1751d4316d3SMarkus Armbruster #define WIN_WRITEDMA_ONCE 0xCB /* 28-Bit - w/o retries, obsolete since ATA5 */ 1761d4316d3SMarkus Armbruster #define WIN_WRITEDMA_QUEUED 0xCC /* write sectors using Queued DMA transfers, obsolete since ACS2 */ 177356721aeSGerd Hoffmann #define CFA_WRITE_MULTI_WO_ERASE 0xCD /* CFA Write multiple without erase */ 1781d4316d3SMarkus Armbruster /* WRITE MULTIPLE FUA EXT 0xCE */ 1791d4316d3SMarkus Armbruster /* reserved 0xCF..0xDO */ 1801d4316d3SMarkus Armbruster /* CHECK MEDIA CARD TYPE 0xD1 */ 1811d4316d3SMarkus Armbruster /* reserved for media card pass through 0xD2..0xD4 */ 1821d4316d3SMarkus Armbruster /* reserved 0xD5..0xD9 */ 1831d4316d3SMarkus Armbruster #define WIN_GETMEDIASTATUS 0xDA /* obsolete since ATA8 */ 1841d4316d3SMarkus Armbruster /* obsolete since ATA3, retired in ATA4 0xDB..0xDD */ 1851d4316d3SMarkus Armbruster #define WIN_DOORLOCK 0xDE /* lock door on removable drives, obsolete since ATA8 */ 1861d4316d3SMarkus Armbruster #define WIN_DOORUNLOCK 0xDF /* unlock door on removable drives, obsolete since ATA8 */ 187356721aeSGerd Hoffmann #define WIN_STANDBYNOW1 0xE0 188356721aeSGerd Hoffmann #define WIN_IDLEIMMEDIATE 0xE1 /* force drive to become "ready" */ 189356721aeSGerd Hoffmann #define WIN_STANDBY 0xE2 /* Set device in Standby Mode */ 190356721aeSGerd Hoffmann #define WIN_SETIDLE1 0xE3 191356721aeSGerd Hoffmann #define WIN_READ_BUFFER 0xE4 /* force read only 1 sector */ 192356721aeSGerd Hoffmann #define WIN_CHECKPOWERMODE1 0xE5 193356721aeSGerd Hoffmann #define WIN_SLEEPNOW1 0xE6 194356721aeSGerd Hoffmann #define WIN_FLUSH_CACHE 0xE7 195356721aeSGerd Hoffmann #define WIN_WRITE_BUFFER 0xE8 /* force write only 1 sector */ 1961d4316d3SMarkus Armbruster /* READ BUFFER DMA 0xE9 */ 197356721aeSGerd Hoffmann #define WIN_FLUSH_CACHE_EXT 0xEA /* 48-Bit */ 1981d4316d3SMarkus Armbruster /* WRITE BUFFER DMA 0xEB */ 199356721aeSGerd Hoffmann #define WIN_IDENTIFY 0xEC /* ask drive to identify itself */ 2001d4316d3SMarkus Armbruster #define WIN_MEDIAEJECT 0xED /* obsolete since ATA8 */ 2011d4316d3SMarkus Armbruster /* obsolete since ATA4 0xEE */ 202356721aeSGerd Hoffmann #define WIN_SETFEATURES 0xEF /* set special drive features */ 2031d4316d3SMarkus Armbruster #define IBM_SENSE_CONDITION 0xF0 /* measure disk temperature, vendor specific */ 204356721aeSGerd Hoffmann #define WIN_SECURITY_SET_PASS 0xF1 205356721aeSGerd Hoffmann #define WIN_SECURITY_UNLOCK 0xF2 206356721aeSGerd Hoffmann #define WIN_SECURITY_ERASE_PREPARE 0xF3 207356721aeSGerd Hoffmann #define WIN_SECURITY_ERASE_UNIT 0xF4 208356721aeSGerd Hoffmann #define WIN_SECURITY_FREEZE_LOCK 0xF5 2091d4316d3SMarkus Armbruster #define CFA_WEAR_LEVEL 0xF5 /* microdrives implement as NOP; not specified in T13! */ 210356721aeSGerd Hoffmann #define WIN_SECURITY_DISABLE 0xF6 2111d4316d3SMarkus Armbruster /* vendor specific 0xF7 */ 212356721aeSGerd Hoffmann #define WIN_READ_NATIVE_MAX 0xF8 /* return the native maximum address */ 213356721aeSGerd Hoffmann #define WIN_SET_MAX 0xF9 2141d4316d3SMarkus Armbruster /* vendor specific 0xFA..0xFF */ 215356721aeSGerd Hoffmann 216356721aeSGerd Hoffmann /* set to 1 set disable mult support */ 217356721aeSGerd Hoffmann #define MAX_MULT_SECTORS 16 218356721aeSGerd Hoffmann 219356721aeSGerd Hoffmann #define IDE_DMA_BUF_SECTORS 256 220356721aeSGerd Hoffmann 221d353fb72SChristoph Hellwig /* feature values for Data Set Management */ 222d353fb72SChristoph Hellwig #define DSM_TRIM 0x01 223d353fb72SChristoph Hellwig 224356721aeSGerd Hoffmann #if (IDE_DMA_BUF_SECTORS < MAX_MULT_SECTORS) 225356721aeSGerd Hoffmann #error "IDE_DMA_BUF_SECTORS must be bigger or equal to MAX_MULT_SECTORS" 226356721aeSGerd Hoffmann #endif 227356721aeSGerd Hoffmann 228356721aeSGerd Hoffmann /* ATAPI defines */ 229356721aeSGerd Hoffmann 230356721aeSGerd Hoffmann #define ATAPI_PACKET_SIZE 12 231356721aeSGerd Hoffmann 232356721aeSGerd Hoffmann /* The generic packet command opcodes for CD/DVD Logical Units, 233356721aeSGerd Hoffmann * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ 234356721aeSGerd Hoffmann #define GPCMD_BLANK 0xa1 235356721aeSGerd Hoffmann #define GPCMD_CLOSE_TRACK 0x5b 236356721aeSGerd Hoffmann #define GPCMD_FLUSH_CACHE 0x35 237356721aeSGerd Hoffmann #define GPCMD_FORMAT_UNIT 0x04 238356721aeSGerd Hoffmann #define GPCMD_GET_CONFIGURATION 0x46 239356721aeSGerd Hoffmann #define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a 240356721aeSGerd Hoffmann #define GPCMD_GET_PERFORMANCE 0xac 241356721aeSGerd Hoffmann #define GPCMD_INQUIRY 0x12 242356721aeSGerd Hoffmann #define GPCMD_LOAD_UNLOAD 0xa6 243356721aeSGerd Hoffmann #define GPCMD_MECHANISM_STATUS 0xbd 244356721aeSGerd Hoffmann #define GPCMD_MODE_SELECT_10 0x55 245356721aeSGerd Hoffmann #define GPCMD_MODE_SENSE_10 0x5a 246356721aeSGerd Hoffmann #define GPCMD_PAUSE_RESUME 0x4b 247356721aeSGerd Hoffmann #define GPCMD_PLAY_AUDIO_10 0x45 248356721aeSGerd Hoffmann #define GPCMD_PLAY_AUDIO_MSF 0x47 249356721aeSGerd Hoffmann #define GPCMD_PLAY_AUDIO_TI 0x48 250356721aeSGerd Hoffmann #define GPCMD_PLAY_CD 0xbc 251356721aeSGerd Hoffmann #define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e 252356721aeSGerd Hoffmann #define GPCMD_READ_10 0x28 253356721aeSGerd Hoffmann #define GPCMD_READ_12 0xa8 254356721aeSGerd Hoffmann #define GPCMD_READ_CDVD_CAPACITY 0x25 255356721aeSGerd Hoffmann #define GPCMD_READ_CD 0xbe 256356721aeSGerd Hoffmann #define GPCMD_READ_CD_MSF 0xb9 257356721aeSGerd Hoffmann #define GPCMD_READ_DISC_INFO 0x51 258356721aeSGerd Hoffmann #define GPCMD_READ_DVD_STRUCTURE 0xad 259356721aeSGerd Hoffmann #define GPCMD_READ_FORMAT_CAPACITIES 0x23 260356721aeSGerd Hoffmann #define GPCMD_READ_HEADER 0x44 261356721aeSGerd Hoffmann #define GPCMD_READ_TRACK_RZONE_INFO 0x52 262356721aeSGerd Hoffmann #define GPCMD_READ_SUBCHANNEL 0x42 263356721aeSGerd Hoffmann #define GPCMD_READ_TOC_PMA_ATIP 0x43 264356721aeSGerd Hoffmann #define GPCMD_REPAIR_RZONE_TRACK 0x58 265356721aeSGerd Hoffmann #define GPCMD_REPORT_KEY 0xa4 266356721aeSGerd Hoffmann #define GPCMD_REQUEST_SENSE 0x03 267356721aeSGerd Hoffmann #define GPCMD_RESERVE_RZONE_TRACK 0x53 268356721aeSGerd Hoffmann #define GPCMD_SCAN 0xba 269356721aeSGerd Hoffmann #define GPCMD_SEEK 0x2b 270356721aeSGerd Hoffmann #define GPCMD_SEND_DVD_STRUCTURE 0xad 271356721aeSGerd Hoffmann #define GPCMD_SEND_EVENT 0xa2 272356721aeSGerd Hoffmann #define GPCMD_SEND_KEY 0xa3 273356721aeSGerd Hoffmann #define GPCMD_SEND_OPC 0x54 274356721aeSGerd Hoffmann #define GPCMD_SET_READ_AHEAD 0xa7 275356721aeSGerd Hoffmann #define GPCMD_SET_STREAMING 0xb6 276356721aeSGerd Hoffmann #define GPCMD_START_STOP_UNIT 0x1b 277356721aeSGerd Hoffmann #define GPCMD_STOP_PLAY_SCAN 0x4e 278356721aeSGerd Hoffmann #define GPCMD_TEST_UNIT_READY 0x00 279356721aeSGerd Hoffmann #define GPCMD_VERIFY_10 0x2f 280356721aeSGerd Hoffmann #define GPCMD_WRITE_10 0x2a 281356721aeSGerd Hoffmann #define GPCMD_WRITE_AND_VERIFY_10 0x2e 282356721aeSGerd Hoffmann /* This is listed as optional in ATAPI 2.6, but is (curiously) 283356721aeSGerd Hoffmann * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji 284356721aeSGerd Hoffmann * Table 377 as an MMC command for SCSi devices though... Most ATAPI 285356721aeSGerd Hoffmann * drives support it. */ 286356721aeSGerd Hoffmann #define GPCMD_SET_SPEED 0xbb 287356721aeSGerd Hoffmann /* This seems to be a SCSI specific CD-ROM opcode 288356721aeSGerd Hoffmann * to play data at track/index */ 289356721aeSGerd Hoffmann #define GPCMD_PLAYAUDIO_TI 0x48 290356721aeSGerd Hoffmann /* 291356721aeSGerd Hoffmann * From MS Media Status Notification Support Specification. For 292356721aeSGerd Hoffmann * older drives only. 293356721aeSGerd Hoffmann */ 294356721aeSGerd Hoffmann #define GPCMD_GET_MEDIA_STATUS 0xda 295356721aeSGerd Hoffmann #define GPCMD_MODE_SENSE_6 0x1a 296356721aeSGerd Hoffmann 297356721aeSGerd Hoffmann #define ATAPI_INT_REASON_CD 0x01 /* 0 = data transfer */ 298356721aeSGerd Hoffmann #define ATAPI_INT_REASON_IO 0x02 /* 1 = transfer to the host */ 299356721aeSGerd Hoffmann #define ATAPI_INT_REASON_REL 0x04 300356721aeSGerd Hoffmann #define ATAPI_INT_REASON_TAG 0xf8 301356721aeSGerd Hoffmann 302356721aeSGerd Hoffmann /* same constants as bochs */ 303a71754e5SDr. David Alan Gilbert #define ASC_NO_SEEK_COMPLETE 0x02 304356721aeSGerd Hoffmann #define ASC_ILLEGAL_OPCODE 0x20 305356721aeSGerd Hoffmann #define ASC_LOGICAL_BLOCK_OOR 0x21 306356721aeSGerd Hoffmann #define ASC_INV_FIELD_IN_CMD_PACKET 0x24 307356721aeSGerd Hoffmann #define ASC_MEDIUM_MAY_HAVE_CHANGED 0x28 308356721aeSGerd Hoffmann #define ASC_INCOMPATIBLE_FORMAT 0x30 309356721aeSGerd Hoffmann #define ASC_MEDIUM_NOT_PRESENT 0x3a 310356721aeSGerd Hoffmann #define ASC_SAVING_PARAMETERS_NOT_SUPPORTED 0x39 3119a502563SJohn Snow #define ASC_DATA_PHASE_ERROR 0x4b 312356721aeSGerd Hoffmann #define ASC_MEDIA_REMOVAL_PREVENTED 0x53 313356721aeSGerd Hoffmann 314356721aeSGerd Hoffmann #define CFA_NO_ERROR 0x00 315356721aeSGerd Hoffmann #define CFA_MISC_ERROR 0x09 316356721aeSGerd Hoffmann #define CFA_INVALID_COMMAND 0x20 317356721aeSGerd Hoffmann #define CFA_INVALID_ADDRESS 0x21 318356721aeSGerd Hoffmann #define CFA_ADDRESS_OVERFLOW 0x2f 319356721aeSGerd Hoffmann 320356721aeSGerd Hoffmann #define SMART_READ_DATA 0xd0 321356721aeSGerd Hoffmann #define SMART_READ_THRESH 0xd1 322356721aeSGerd Hoffmann #define SMART_ATTR_AUTOSAVE 0xd2 323356721aeSGerd Hoffmann #define SMART_SAVE_ATTR 0xd3 324356721aeSGerd Hoffmann #define SMART_EXECUTE_OFFLINE 0xd4 325356721aeSGerd Hoffmann #define SMART_READ_LOG 0xd5 326356721aeSGerd Hoffmann #define SMART_WRITE_LOG 0xd6 327356721aeSGerd Hoffmann #define SMART_ENABLE 0xd8 328356721aeSGerd Hoffmann #define SMART_DISABLE 0xd9 329356721aeSGerd Hoffmann #define SMART_STATUS 0xda 330356721aeSGerd Hoffmann 331cd8722bbSMarkus Armbruster typedef enum { IDE_HD, IDE_CD, IDE_CFATA } IDEDriveKind; 332cd8722bbSMarkus Armbruster 333356721aeSGerd Hoffmann typedef void EndTransferFunc(IDEState *); 334356721aeSGerd Hoffmann 335ae0cebd7SPhilippe Mathieu-Daudé typedef void DMAStartFunc(const IDEDMA *, IDEState *, BlockCompletionFunc *); 336ae0cebd7SPhilippe Mathieu-Daudé typedef void DMAVoidFunc(const IDEDMA *); 337ae0cebd7SPhilippe Mathieu-Daudé typedef int DMAIntFunc(const IDEDMA *, bool); 338ae0cebd7SPhilippe Mathieu-Daudé typedef int32_t DMAInt32Func(const IDEDMA *, int32_t len); 339ae0cebd7SPhilippe Mathieu-Daudé typedef void DMAu32Func(const IDEDMA *, uint32_t); 340ae0cebd7SPhilippe Mathieu-Daudé typedef void DMAStopFunc(const IDEDMA *, bool); 34140a6238aSAlexander Graf 342996faf1aSAmit Shah struct unreported_events { 343996faf1aSAmit Shah bool eject_request; 344996faf1aSAmit Shah bool new_media; 345996faf1aSAmit Shah }; 346996faf1aSAmit Shah 3474e1e0051SChristoph Hellwig enum ide_dma_cmd { 348159a9df0SJohn Snow IDE_DMA_READ = 0, 3494e1e0051SChristoph Hellwig IDE_DMA_WRITE, 350d353fb72SChristoph Hellwig IDE_DMA_TRIM, 351502356eeSPavel Butsykin IDE_DMA_ATAPI, 3520e168d35SJohn Snow IDE_DMA__COUNT 3534e1e0051SChristoph Hellwig }; 3544e1e0051SChristoph Hellwig 3550e168d35SJohn Snow extern const char *IDE_DMA_CMD_lookup[IDE_DMA__COUNT]; 3560e168d35SJohn Snow 357*75524884SMark Cave-Ayland extern const MemoryRegionPortio ide_portio_list[]; 358*75524884SMark Cave-Ayland extern const MemoryRegionPortio ide_portio2_list[]; 359*75524884SMark Cave-Ayland 3604e1e0051SChristoph Hellwig #define ide_cmd_is_read(s) \ 3614e1e0051SChristoph Hellwig ((s)->dma_cmd == IDE_DMA_READ) 3624e1e0051SChristoph Hellwig 3631d8c11d6SPeter Lieven typedef struct IDEBufferedRequest { 3641d8c11d6SPeter Lieven QLIST_ENTRY(IDEBufferedRequest) list; 3651d8c11d6SPeter Lieven QEMUIOVector qiov; 3661d8c11d6SPeter Lieven QEMUIOVector *original_qiov; 3671d8c11d6SPeter Lieven BlockCompletionFunc *original_cb; 3681d8c11d6SPeter Lieven void *original_opaque; 3691d8c11d6SPeter Lieven bool orphaned; 3701d8c11d6SPeter Lieven } IDEBufferedRequest; 3711d8c11d6SPeter Lieven 372356721aeSGerd Hoffmann /* NOTE: IDEState represents in fact one drive */ 373356721aeSGerd Hoffmann struct IDEState { 374356721aeSGerd Hoffmann IDEBus *bus; 375356721aeSGerd Hoffmann uint8_t unit; 376356721aeSGerd Hoffmann /* ide config */ 377cd8722bbSMarkus Armbruster IDEDriveKind drive_kind; 378176e4961SLev Kujawski int drive_heads, drive_sectors; 3799139046cSMarkus Armbruster int cylinders, heads, sectors, chs_trans; 380356721aeSGerd Hoffmann int64_t nb_sectors; 381356721aeSGerd Hoffmann int mult_sectors; 382356721aeSGerd Hoffmann int identify_set; 38396c35cebSJuan Quintela uint8_t identify_data[512]; 384356721aeSGerd Hoffmann int drive_serial; 385356721aeSGerd Hoffmann char drive_serial_str[21]; 38627e0c9a1SFloris Bos char drive_model_str[41]; 38795ebda85SFloris Bos uint64_t wwn; 388356721aeSGerd Hoffmann /* ide regs */ 389356721aeSGerd Hoffmann uint8_t feature; 390356721aeSGerd Hoffmann uint8_t error; 391356721aeSGerd Hoffmann uint32_t nsector; 392356721aeSGerd Hoffmann uint8_t sector; 393356721aeSGerd Hoffmann uint8_t lcyl; 394356721aeSGerd Hoffmann uint8_t hcyl; 395356721aeSGerd Hoffmann /* other part of tf for lba48 support */ 396356721aeSGerd Hoffmann uint8_t hob_feature; 397356721aeSGerd Hoffmann uint8_t hob_nsector; 398356721aeSGerd Hoffmann uint8_t hob_sector; 399356721aeSGerd Hoffmann uint8_t hob_lcyl; 400356721aeSGerd Hoffmann uint8_t hob_hcyl; 401356721aeSGerd Hoffmann 402356721aeSGerd Hoffmann uint8_t select; 403356721aeSGerd Hoffmann uint8_t status; 404356721aeSGerd Hoffmann 4051ea17d22SLubomir Rintel bool io8; 406176e4961SLev Kujawski bool reset_reverts; 407176e4961SLev Kujawski 408356721aeSGerd Hoffmann /* set for lba48 access */ 409356721aeSGerd Hoffmann uint8_t lba48; 4104be74634SMarkus Armbruster BlockBackend *blk; 41147c06340SGerd Hoffmann char version[9]; 412356721aeSGerd Hoffmann /* ATAPI specific */ 413996faf1aSAmit Shah struct unreported_events events; 414356721aeSGerd Hoffmann uint8_t sense_key; 415356721aeSGerd Hoffmann uint8_t asc; 416dd063333SMarkus Armbruster bool tray_open; 417a0a7573bSMarkus Armbruster bool tray_locked; 418356721aeSGerd Hoffmann uint8_t cdrom_changed; 419356721aeSGerd Hoffmann int packet_transfer_size; 420356721aeSGerd Hoffmann int elementary_transfer_size; 4213251bdcfSJohn Snow int32_t io_buffer_index; 422356721aeSGerd Hoffmann int lba; 423356721aeSGerd Hoffmann int cd_sector_size; 424356721aeSGerd Hoffmann int atapi_dma; /* true if dma is requested for the packet cmd */ 425a597e79cSChristoph Hellwig BlockAcctCookie acct; 4267c84b1b8SMarkus Armbruster BlockAIOCB *pio_aiocb; 427bef0fd59SStefan Hajnoczi QEMUIOVector qiov; 4281d8c11d6SPeter Lieven QLIST_HEAD(, IDEBufferedRequest) buffered_requests; 429356721aeSGerd Hoffmann /* ATA DMA state */ 4309fbf0fa8SJohn Snow uint64_t io_buffer_offset; 4313251bdcfSJohn Snow int32_t io_buffer_size; 432356721aeSGerd Hoffmann QEMUSGList sg; 433356721aeSGerd Hoffmann /* PIO transfer handling */ 434356721aeSGerd Hoffmann int req_nb_sectors; /* number of sectors per interrupt */ 435356721aeSGerd Hoffmann EndTransferFunc *end_transfer_func; 436356721aeSGerd Hoffmann uint8_t *data_ptr; 437356721aeSGerd Hoffmann uint8_t *data_end; 438356721aeSGerd Hoffmann uint8_t *io_buffer; 43950641c5cSJuan Quintela /* PIO save/restore */ 44050641c5cSJuan Quintela int32_t io_buffer_total_len; 4413251bdcfSJohn Snow int32_t cur_io_buffer_offset; 4423251bdcfSJohn Snow int32_t cur_io_buffer_len; 44350641c5cSJuan Quintela uint8_t end_transfer_fn_idx; 444356721aeSGerd Hoffmann QEMUTimer *sector_write_timer; /* only used for win2k install hack */ 445356721aeSGerd Hoffmann uint32_t irq_count; /* counts IRQs when using win2k install hack */ 446356721aeSGerd Hoffmann /* CF-ATA extended error */ 447356721aeSGerd Hoffmann uint8_t ext_error; 448356721aeSGerd Hoffmann /* CF-ATA metadata storage */ 449356721aeSGerd Hoffmann uint32_t mdata_size; 450356721aeSGerd Hoffmann uint8_t *mdata_storage; 451356721aeSGerd Hoffmann int media_changed; 4524e1e0051SChristoph Hellwig enum ide_dma_cmd dma_cmd; 453356721aeSGerd Hoffmann /* SMART */ 454356721aeSGerd Hoffmann uint8_t smart_enabled; 455356721aeSGerd Hoffmann uint8_t smart_autosave; 456356721aeSGerd Hoffmann int smart_errors; 457356721aeSGerd Hoffmann uint8_t smart_selftest_count; 458356721aeSGerd Hoffmann uint8_t *smart_selftest_data; 459ccf0fd8bSRoland Elek /* AHCI */ 460ccf0fd8bSRoland Elek int ncq_queues; 461356721aeSGerd Hoffmann }; 462356721aeSGerd Hoffmann 46340a6238aSAlexander Graf struct IDEDMAOps { 46440a6238aSAlexander Graf DMAStartFunc *start_dma; 465bed9bcfaSPaolo Bonzini DMAVoidFunc *pio_transfer; 4663251bdcfSJohn Snow DMAInt32Func *prepare_buf; 467659142ecSJohn Snow DMAu32Func *commit_buf; 46840a6238aSAlexander Graf DMAIntFunc *rw_buf; 4697c03a691SJohn Snow DMAVoidFunc *restart; 470bd8892c4SPaolo Bonzini DMAVoidFunc *restart_dma; 4710e7ce54cSPaolo Bonzini DMAStopFunc *set_inactive; 472c7e73adbSPaolo Bonzini DMAVoidFunc *cmd_done; 4731374bec0SPaolo Bonzini DMAVoidFunc *reset; 47440a6238aSAlexander Graf }; 47540a6238aSAlexander Graf 47640a6238aSAlexander Graf struct IDEDMA { 47740a6238aSAlexander Graf const struct IDEDMAOps *ops; 47840a6238aSAlexander Graf QEMUIOVector qiov; 4797c84b1b8SMarkus Armbruster BlockAIOCB *aiocb; 48040a6238aSAlexander Graf }; 48140a6238aSAlexander Graf 482356721aeSGerd Hoffmann struct IDEBus { 483356721aeSGerd Hoffmann BusState qbus; 484da4d0419SGerd Hoffmann IDEDevice *master; 485da4d0419SGerd Hoffmann IDEDevice *slave; 486356721aeSGerd Hoffmann IDEState ifs[2]; 4879898586dSPaolo Bonzini QEMUBH *bh; 4889898586dSPaolo Bonzini 4893835510fSGleb Natapov int bus_id; 4900ee20e66SKevin Wolf int max_units; 49140a6238aSAlexander Graf IDEDMA *dma; 492356721aeSGerd Hoffmann uint8_t unit; 4939cdd03a7SGerd Hoffmann uint8_t cmd; 494c9519630SPhilippe Mathieu-Daudé qemu_irq irq; /* bus output */ 495def93791SKevin Wolf 496def93791SKevin Wolf int error_status; 497a96cb236SPaolo Bonzini uint8_t retry_unit; 498dc5d0af4SPaolo Bonzini int64_t retry_sector_num; 499dc5d0af4SPaolo Bonzini uint32_t retry_nsector; 500e305a165SMarc-André Lureau PortioList portio_list; 501e305a165SMarc-André Lureau PortioList portio2_list; 502ca44141dSAshijeet Acharya VMChangeStateEntry *vmstate; 503356721aeSGerd Hoffmann }; 504356721aeSGerd Hoffmann 505d148211cSAnthony Liguori #define TYPE_IDE_DEVICE "ide-device" 506a489d195SEduardo Habkost OBJECT_DECLARE_TYPE(IDEDevice, IDEDeviceClass, IDE_DEVICE) 507d148211cSAnthony Liguori 508db1015e9SEduardo Habkost struct IDEDeviceClass { 509d148211cSAnthony Liguori DeviceClass parent_class; 510794939e8SMao Zhongyi void (*realize)(IDEDevice *dev, Error **errp); 511db1015e9SEduardo Habkost }; 512d148211cSAnthony Liguori 513da4d0419SGerd Hoffmann struct IDEDevice { 514da4d0419SGerd Hoffmann DeviceState qdev; 515da4d0419SGerd Hoffmann uint32_t unit; 516428c149bSChristoph Hellwig BlockConf conf; 5176e6f61a6SMarkus Armbruster int chs_trans; 51847c06340SGerd Hoffmann char *version; 5196ced55a5SMarkus Armbruster char *serial; 52027e0c9a1SFloris Bos char *model; 52195ebda85SFloris Bos uint64_t wwn; 5223b19f450SDaniel P. Berrange /* 5233b19f450SDaniel P. Berrange * 0x0000 - rotation rate not reported 5243b19f450SDaniel P. Berrange * 0x0001 - non-rotating medium (SSD) 5253b19f450SDaniel P. Berrange * 0x0002-0x0400 - reserved 5263b19f450SDaniel P. Berrange * 0x0401-0xffe - rotations per minute 5273b19f450SDaniel P. Berrange * 0xffff - reserved 5283b19f450SDaniel P. Berrange */ 5293b19f450SDaniel P. Berrange uint16_t rotation_rate; 530da4d0419SGerd Hoffmann }; 531da4d0419SGerd Hoffmann 532fd648f10SPaolo Bonzini /* These are used for the error_status field of IDEBus */ 533502356eeSPavel Butsykin #define IDE_RETRY_MASK 0xf8 534fd648f10SPaolo Bonzini #define IDE_RETRY_DMA 0x08 535fd648f10SPaolo Bonzini #define IDE_RETRY_PIO 0x10 536502356eeSPavel Butsykin #define IDE_RETRY_ATAPI 0x20 /* reused IDE_RETRY_READ bit */ 537fd648f10SPaolo Bonzini #define IDE_RETRY_READ 0x20 538fd648f10SPaolo Bonzini #define IDE_RETRY_FLUSH 0x40 539fd648f10SPaolo Bonzini #define IDE_RETRY_TRIM 0x80 5407c03a691SJohn Snow #define IDE_RETRY_HBA 0x100 541356721aeSGerd Hoffmann 542502356eeSPavel Butsykin #define IS_IDE_RETRY_DMA(_status) \ 543502356eeSPavel Butsykin ((_status) & IDE_RETRY_DMA) 544502356eeSPavel Butsykin 545502356eeSPavel Butsykin #define IS_IDE_RETRY_PIO(_status) \ 546502356eeSPavel Butsykin ((_status) & IDE_RETRY_PIO) 547502356eeSPavel Butsykin 548502356eeSPavel Butsykin /* 549502356eeSPavel Butsykin * The method of the IDE_RETRY_ATAPI determination is to use a previously 550502356eeSPavel Butsykin * impossible bit combination as a new status value. 551502356eeSPavel Butsykin */ 552502356eeSPavel Butsykin #define IS_IDE_RETRY_ATAPI(_status) \ 553502356eeSPavel Butsykin (((_status) & IDE_RETRY_MASK) == IDE_RETRY_ATAPI) 554502356eeSPavel Butsykin 555218fd37cSPavel Butsykin static inline uint8_t ide_dma_cmd_to_retry(uint8_t dma_cmd) 556218fd37cSPavel Butsykin { 557218fd37cSPavel Butsykin switch (dma_cmd) { 558218fd37cSPavel Butsykin case IDE_DMA_READ: 559218fd37cSPavel Butsykin return IDE_RETRY_DMA | IDE_RETRY_READ; 560218fd37cSPavel Butsykin case IDE_DMA_WRITE: 561218fd37cSPavel Butsykin return IDE_RETRY_DMA; 562218fd37cSPavel Butsykin case IDE_DMA_TRIM: 563218fd37cSPavel Butsykin return IDE_RETRY_DMA | IDE_RETRY_TRIM; 564502356eeSPavel Butsykin case IDE_DMA_ATAPI: 565502356eeSPavel Butsykin return IDE_RETRY_ATAPI; 566218fd37cSPavel Butsykin default: 567218fd37cSPavel Butsykin break; 568218fd37cSPavel Butsykin } 569218fd37cSPavel Butsykin return 0; 570218fd37cSPavel Butsykin } 571218fd37cSPavel Butsykin 5722c50207fSPhilippe Mathieu-Daudé static inline IDEState *ide_bus_active_if(IDEBus *bus) 573356721aeSGerd Hoffmann { 574356721aeSGerd Hoffmann return bus->ifs + bus->unit; 575356721aeSGerd Hoffmann } 576356721aeSGerd Hoffmann 577da4d0419SGerd Hoffmann /* hw/ide/core.c */ 578b38436e3SJuan Quintela extern const VMStateDescription vmstate_ide_bus; 579b38436e3SJuan Quintela 580b38436e3SJuan Quintela #define VMSTATE_IDE_BUS(_field, _state) \ 581b38436e3SJuan Quintela VMSTATE_STRUCT(_field, _state, 1, vmstate_ide_bus, IDEBus) 582b38436e3SJuan Quintela 583407a4f30SJuan Quintela #define VMSTATE_IDE_BUS_ARRAY(_field, _state, _num) \ 584407a4f30SJuan Quintela VMSTATE_STRUCT_ARRAY(_field, _state, _num, 1, vmstate_ide_bus, IDEBus) 585407a4f30SJuan Quintela 586b38436e3SJuan Quintela extern const VMStateDescription vmstate_ide_drive; 587b38436e3SJuan Quintela 588b38436e3SJuan Quintela #define VMSTATE_IDE_DRIVES(_field, _state) \ 589b38436e3SJuan Quintela VMSTATE_STRUCT_ARRAY(_field, _state, 2, 3, vmstate_ide_drive, IDEState) 590b38436e3SJuan Quintela 591bd664910SJohn Snow #define VMSTATE_IDE_DRIVE(_field, _state) \ 592bd664910SJohn Snow VMSTATE_STRUCT(_field, _state, 1, vmstate_ide_drive, IDEState) 593bd664910SJohn Snow 5944a643563SBlue Swirl void ide_bus_reset(IDEBus *bus); 595356721aeSGerd Hoffmann int64_t ide_get_sector(IDEState *s); 596356721aeSGerd Hoffmann void ide_set_sector(IDEState *s, int64_t sector_num); 597356721aeSGerd Hoffmann 598097310b5SMarkus Armbruster void ide_start_dma(IDEState *s, BlockCompletionFunc *cb); 599aaeda4a3SJohn Snow void dma_buf_commit(IDEState *s, uint32_t tx_bytes); 600356721aeSGerd Hoffmann void ide_dma_error(IDEState *s); 6019ef2e93fSJohn Snow void ide_abort_command(IDEState *s); 602356721aeSGerd Hoffmann 603356721aeSGerd Hoffmann void ide_atapi_cmd_ok(IDEState *s); 604356721aeSGerd Hoffmann void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc); 605a71754e5SDr. David Alan Gilbert void ide_atapi_dma_restart(IDEState *s); 606356721aeSGerd Hoffmann void ide_atapi_io_error(IDEState *s, int ret); 607356721aeSGerd Hoffmann 608356721aeSGerd Hoffmann void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val); 609356721aeSGerd Hoffmann uint32_t ide_ioport_read(void *opaque, uint32_t addr1); 610356721aeSGerd Hoffmann uint32_t ide_status_read(void *opaque, uint32_t addr); 61198d98912SJohn Snow void ide_ctrl_write(void *opaque, uint32_t addr, uint32_t val); 612356721aeSGerd Hoffmann void ide_data_writew(void *opaque, uint32_t addr, uint32_t val); 613356721aeSGerd Hoffmann uint32_t ide_data_readw(void *opaque, uint32_t addr); 614356721aeSGerd Hoffmann void ide_data_writel(void *opaque, uint32_t addr, uint32_t val); 615356721aeSGerd Hoffmann uint32_t ide_data_readl(void *opaque, uint32_t addr); 616356721aeSGerd Hoffmann 6174be74634SMarkus Armbruster int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind, 61895ebda85SFloris Bos const char *version, const char *serial, const char *model, 619ba801960SMarkus Armbruster uint64_t wwn, 620ba801960SMarkus Armbruster uint32_t cylinders, uint32_t heads, uint32_t secs, 621794939e8SMao Zhongyi int chs_trans, Error **errp); 622c9f08641SLi Qiang void ide_exit(IDEState *s); 623c9519630SPhilippe Mathieu-Daudé void ide_bus_init_output_irq(IDEBus *bus, qemu_irq irq_out); 6249405d87bSThomas Huth int ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2); 6250cfe719dSPhilippe Mathieu-Daudé void ide_bus_set_irq(IDEBus *bus); 626e29b1246SPhilippe Mathieu-Daudé void ide_bus_register_restart_cb(IDEBus *bus); 627356721aeSGerd Hoffmann 628783f4474SPhilippe Mathieu-Daudé void ide_bus_exec_cmd(IDEBus *bus, uint32_t val); 6297cff87ffSAlexander Graf 63033231e0eSKevin Wolf void ide_transfer_start(IDEState *s, uint8_t *buf, int size, 63133231e0eSKevin Wolf EndTransferFunc *end_transfer_func); 632c173723fSPaolo Bonzini bool ide_transfer_start_norecurse(IDEState *s, uint8_t *buf, int size, 633c173723fSPaolo Bonzini EndTransferFunc *end_transfer_func); 63433231e0eSKevin Wolf void ide_transfer_stop(IDEState *s); 6350e7ce54cSPaolo Bonzini void ide_set_inactive(IDEState *s, bool more); 6368a8e63ebSPaolo Bonzini BlockAIOCB *ide_issue_trim( 6378a8e63ebSPaolo Bonzini int64_t offset, QEMUIOVector *qiov, 6388a8e63ebSPaolo Bonzini BlockCompletionFunc *cb, void *cb_opaque, void *opaque); 6391d8c11d6SPeter Lieven BlockAIOCB *ide_buffered_readv(IDEState *s, int64_t sector_num, 6401d8c11d6SPeter Lieven QEMUIOVector *iov, int nb_sectors, 6411d8c11d6SPeter Lieven BlockCompletionFunc *cb, void *opaque); 64286698a12SJohn Snow void ide_cancel_dma_sync(IDEState *s); 64333231e0eSKevin Wolf 64433231e0eSKevin Wolf /* hw/ide/atapi.c */ 64533231e0eSKevin Wolf void ide_atapi_cmd(IDEState *s); 64633231e0eSKevin Wolf void ide_atapi_cmd_reply_end(IDEState *s); 64733231e0eSKevin Wolf 648da4d0419SGerd Hoffmann /* hw/ide/qdev.c */ 64982c74ac4SPeter Maydell void ide_bus_init(IDEBus *idebus, size_t idebus_size, DeviceState *dev, 650c6baf942SAndreas Färber int bus_id, int max_units); 651b6a5ab27SPhilippe Mathieu-Daudé IDEDevice *ide_bus_create_drive(IDEBus *bus, int unit, DriveInfo *drive); 652da4d0419SGerd Hoffmann 65306628267SPhilippe Mathieu-Daudé int ide_get_geometry(BusState *bus, int unit, 65406628267SPhilippe Mathieu-Daudé int16_t *cyls, int8_t *heads, int8_t *secs); 65506628267SPhilippe Mathieu-Daudé int ide_get_bios_chs_trans(BusState *bus, int unit); 65606628267SPhilippe Mathieu-Daudé 657502356eeSPavel Butsykin int ide_handle_rw_error(IDEState *s, int error, int op); 658502356eeSPavel Butsykin 659356721aeSGerd Hoffmann #endif /* HW_IDE_INTERNAL_H */ 660