Annotation of qemu/hw/ide/internal.h, revision 1.1.1.5

1.1       root        1: #ifndef HW_IDE_INTERNAL_H
                      2: #define HW_IDE_INTERNAL_H
                      3: 
                      4: /*
                      5:  * QEMU IDE Emulation -- internal header file
                      6:  * only files in hw/ide/ are supposed to include this file.
                      7:  * non-internal declarations are in hw/ide.h
                      8:  */
                      9: #include <hw/ide.h>
1.1.1.4   root       10: #include "block_int.h"
1.1.1.5 ! root       11: #include "iorange.h"
1.1       root       12: 
                     13: /* debug IDE devices */
                     14: //#define DEBUG_IDE
                     15: //#define DEBUG_IDE_ATAPI
                     16: //#define DEBUG_AIO
                     17: #define USE_DMA_CDROM
                     18: 
                     19: typedef struct IDEBus IDEBus;
                     20: typedef struct IDEDevice IDEDevice;
                     21: typedef struct IDEDeviceInfo IDEDeviceInfo;
                     22: typedef struct IDEState IDEState;
1.1.1.5 ! root       23: typedef struct IDEDMA IDEDMA;
        !            24: typedef struct IDEDMAOps IDEDMAOps;
1.1       root       25: 
                     26: /* Bits of HD_STATUS */
                     27: #define ERR_STAT               0x01
                     28: #define INDEX_STAT             0x02
                     29: #define ECC_STAT               0x04    /* Corrected error */
                     30: #define DRQ_STAT               0x08
                     31: #define SEEK_STAT              0x10
                     32: #define SRV_STAT               0x10
                     33: #define WRERR_STAT             0x20
                     34: #define READY_STAT             0x40
                     35: #define BUSY_STAT              0x80
                     36: 
                     37: /* Bits for HD_ERROR */
                     38: #define MARK_ERR               0x01    /* Bad address mark */
                     39: #define TRK0_ERR               0x02    /* couldn't find track 0 */
                     40: #define ABRT_ERR               0x04    /* Command aborted */
                     41: #define MCR_ERR                        0x08    /* media change request */
                     42: #define ID_ERR                 0x10    /* ID field not found */
                     43: #define MC_ERR                 0x20    /* media changed */
                     44: #define ECC_ERR                        0x40    /* Uncorrectable ECC error */
                     45: #define BBD_ERR                        0x80    /* pre-EIDE meaning:  block marked bad */
                     46: #define ICRC_ERR               0x80    /* new meaning:  CRC error during transfer */
                     47: 
                     48: /* Bits of HD_NSECTOR */
                     49: #define CD                     0x01
                     50: #define IO                     0x02
                     51: #define REL                    0x04
                     52: #define TAG_MASK               0xf8
                     53: 
                     54: #define IDE_CMD_RESET           0x04
                     55: #define IDE_CMD_DISABLE_IRQ     0x02
                     56: 
                     57: /* ATA/ATAPI Commands pre T13 Spec */
                     58: #define WIN_NOP                                0x00
                     59: /*
                     60:  *     0x01->0x02 Reserved
                     61:  */
                     62: #define CFA_REQ_EXT_ERROR_CODE         0x03 /* CFA Request Extended Error Code */
                     63: /*
                     64:  *     0x04->0x07 Reserved
                     65:  */
                     66: #define WIN_SRST                       0x08 /* ATAPI soft reset command */
                     67: #define WIN_DEVICE_RESET               0x08
                     68: /*
                     69:  *     0x09->0x0F Reserved
                     70:  */
                     71: #define WIN_RECAL                      0x10
                     72: #define WIN_RESTORE                    WIN_RECAL
                     73: /*
                     74:  *     0x10->0x1F Reserved
                     75:  */
                     76: #define WIN_READ                       0x20 /* 28-Bit */
                     77: #define WIN_READ_ONCE                  0x21 /* 28-Bit without retries */
                     78: #define WIN_READ_LONG                  0x22 /* 28-Bit */
                     79: #define WIN_READ_LONG_ONCE             0x23 /* 28-Bit without retries */
                     80: #define WIN_READ_EXT                   0x24 /* 48-Bit */
                     81: #define WIN_READDMA_EXT                        0x25 /* 48-Bit */
                     82: #define WIN_READDMA_QUEUED_EXT         0x26 /* 48-Bit */
                     83: #define WIN_READ_NATIVE_MAX_EXT                0x27 /* 48-Bit */
                     84: /*
                     85:  *     0x28
                     86:  */
                     87: #define WIN_MULTREAD_EXT               0x29 /* 48-Bit */
                     88: /*
                     89:  *     0x2A->0x2F Reserved
                     90:  */
                     91: #define WIN_WRITE                      0x30 /* 28-Bit */
                     92: #define WIN_WRITE_ONCE                 0x31 /* 28-Bit without retries */
                     93: #define WIN_WRITE_LONG                 0x32 /* 28-Bit */
                     94: #define WIN_WRITE_LONG_ONCE            0x33 /* 28-Bit without retries */
                     95: #define WIN_WRITE_EXT                  0x34 /* 48-Bit */
                     96: #define WIN_WRITEDMA_EXT               0x35 /* 48-Bit */
                     97: #define WIN_WRITEDMA_QUEUED_EXT                0x36 /* 48-Bit */
                     98: #define WIN_SET_MAX_EXT                        0x37 /* 48-Bit */
                     99: #define CFA_WRITE_SECT_WO_ERASE                0x38 /* CFA Write Sectors without erase */
                    100: #define WIN_MULTWRITE_EXT              0x39 /* 48-Bit */
                    101: /*
                    102:  *     0x3A->0x3B Reserved
                    103:  */
                    104: #define WIN_WRITE_VERIFY               0x3C /* 28-Bit */
                    105: /*
                    106:  *     0x3D->0x3F Reserved
                    107:  */
                    108: #define WIN_VERIFY                     0x40 /* 28-Bit - Read Verify Sectors */
                    109: #define WIN_VERIFY_ONCE                        0x41 /* 28-Bit - without retries */
                    110: #define WIN_VERIFY_EXT                 0x42 /* 48-Bit */
                    111: /*
                    112:  *     0x43->0x4F Reserved
                    113:  */
                    114: #define WIN_FORMAT                     0x50
                    115: /*
                    116:  *     0x51->0x5F Reserved
                    117:  */
                    118: #define WIN_INIT                       0x60
                    119: /*
                    120:  *     0x61->0x5F Reserved
                    121:  */
                    122: #define WIN_SEEK                       0x70 /* 0x70-0x7F Reserved */
                    123: #define CFA_TRANSLATE_SECTOR           0x87 /* CFA Translate Sector */
                    124: #define WIN_DIAGNOSE                   0x90
                    125: #define WIN_SPECIFY                    0x91 /* set drive geometry translation */
                    126: #define WIN_DOWNLOAD_MICROCODE         0x92
                    127: #define WIN_STANDBYNOW2                        0x94
                    128: #define CFA_IDLEIMMEDIATE              0x95 /* force drive to become "ready" */
                    129: #define WIN_STANDBY2                   0x96
                    130: #define WIN_SETIDLE2                   0x97
                    131: #define WIN_CHECKPOWERMODE2            0x98
                    132: #define WIN_SLEEPNOW2                  0x99
                    133: /*
                    134:  *     0x9A VENDOR
                    135:  */
                    136: #define WIN_PACKETCMD                  0xA0 /* Send a packet command. */
                    137: #define WIN_PIDENTIFY                  0xA1 /* identify ATAPI device   */
                    138: #define WIN_QUEUED_SERVICE             0xA2
                    139: #define WIN_SMART                      0xB0 /* self-monitoring and reporting */
                    140: #define CFA_ACCESS_METADATA_STORAGE    0xB8
                    141: #define CFA_ERASE_SECTORS              0xC0 /* microdrives implement as NOP */
                    142: #define WIN_MULTREAD                   0xC4 /* read sectors using multiple mode*/
                    143: #define WIN_MULTWRITE                  0xC5 /* write sectors using multiple mode */
                    144: #define WIN_SETMULT                    0xC6 /* enable/disable multiple mode */
                    145: #define WIN_READDMA_QUEUED             0xC7 /* read sectors using Queued DMA transfers */
                    146: #define WIN_READDMA                    0xC8 /* read sectors using DMA transfers */
                    147: #define WIN_READDMA_ONCE               0xC9 /* 28-Bit - without retries */
                    148: #define WIN_WRITEDMA                   0xCA /* write sectors using DMA transfers */
                    149: #define WIN_WRITEDMA_ONCE              0xCB /* 28-Bit - without retries */
                    150: #define WIN_WRITEDMA_QUEUED            0xCC /* write sectors using Queued DMA transfers */
                    151: #define CFA_WRITE_MULTI_WO_ERASE       0xCD /* CFA Write multiple without erase */
                    152: #define WIN_GETMEDIASTATUS             0xDA
                    153: #define WIN_ACKMEDIACHANGE             0xDB /* ATA-1, ATA-2 vendor */
                    154: #define WIN_POSTBOOT                   0xDC
                    155: #define WIN_PREBOOT                    0xDD
                    156: #define WIN_DOORLOCK                   0xDE /* lock door on removable drives */
                    157: #define WIN_DOORUNLOCK                 0xDF /* unlock door on removable drives */
                    158: #define WIN_STANDBYNOW1                        0xE0
                    159: #define WIN_IDLEIMMEDIATE              0xE1 /* force drive to become "ready" */
                    160: #define WIN_STANDBY                    0xE2 /* Set device in Standby Mode */
                    161: #define WIN_SETIDLE1                   0xE3
                    162: #define WIN_READ_BUFFER                        0xE4 /* force read only 1 sector */
                    163: #define WIN_CHECKPOWERMODE1            0xE5
                    164: #define WIN_SLEEPNOW1                  0xE6
                    165: #define WIN_FLUSH_CACHE                        0xE7
                    166: #define WIN_WRITE_BUFFER               0xE8 /* force write only 1 sector */
                    167: #define WIN_WRITE_SAME                 0xE9 /* read ata-2 to use */
                    168:        /* SET_FEATURES 0x22 or 0xDD */
                    169: #define WIN_FLUSH_CACHE_EXT            0xEA /* 48-Bit */
                    170: #define WIN_IDENTIFY                   0xEC /* ask drive to identify itself    */
                    171: #define WIN_MEDIAEJECT                 0xED
                    172: #define WIN_IDENTIFY_DMA               0xEE /* same as WIN_IDENTIFY, but DMA */
                    173: #define WIN_SETFEATURES                        0xEF /* set special drive features */
                    174: #define EXABYTE_ENABLE_NEST            0xF0
                    175: #define IBM_SENSE_CONDITION            0xF0 /* measure disk temperature */
                    176: #define WIN_SECURITY_SET_PASS          0xF1
                    177: #define WIN_SECURITY_UNLOCK            0xF2
                    178: #define WIN_SECURITY_ERASE_PREPARE     0xF3
                    179: #define WIN_SECURITY_ERASE_UNIT                0xF4
                    180: #define WIN_SECURITY_FREEZE_LOCK       0xF5
                    181: #define CFA_WEAR_LEVEL                 0xF5 /* microdrives implement as NOP */
                    182: #define WIN_SECURITY_DISABLE           0xF6
                    183: #define WIN_READ_NATIVE_MAX            0xF8 /* return the native maximum address */
                    184: #define WIN_SET_MAX                    0xF9
                    185: #define DISABLE_SEAGATE                        0xFB
                    186: 
                    187: /* set to 1 set disable mult support */
                    188: #define MAX_MULT_SECTORS 16
                    189: 
                    190: #define IDE_DMA_BUF_SECTORS 256
                    191: 
                    192: #if (IDE_DMA_BUF_SECTORS < MAX_MULT_SECTORS)
                    193: #error "IDE_DMA_BUF_SECTORS must be bigger or equal to MAX_MULT_SECTORS"
                    194: #endif
                    195: 
                    196: /* ATAPI defines */
                    197: 
                    198: #define ATAPI_PACKET_SIZE 12
                    199: 
                    200: /* The generic packet command opcodes for CD/DVD Logical Units,
                    201:  * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
                    202: #define GPCMD_BLANK                        0xa1
                    203: #define GPCMD_CLOSE_TRACK                  0x5b
                    204: #define GPCMD_FLUSH_CACHE                  0x35
                    205: #define GPCMD_FORMAT_UNIT                  0x04
                    206: #define GPCMD_GET_CONFIGURATION                    0x46
                    207: #define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a
                    208: #define GPCMD_GET_PERFORMANCE              0xac
                    209: #define GPCMD_INQUIRY                      0x12
                    210: #define GPCMD_LOAD_UNLOAD                  0xa6
                    211: #define GPCMD_MECHANISM_STATUS             0xbd
                    212: #define GPCMD_MODE_SELECT_10               0x55
                    213: #define GPCMD_MODE_SENSE_10                0x5a
                    214: #define GPCMD_PAUSE_RESUME                 0x4b
                    215: #define GPCMD_PLAY_AUDIO_10                0x45
                    216: #define GPCMD_PLAY_AUDIO_MSF               0x47
                    217: #define GPCMD_PLAY_AUDIO_TI                0x48
                    218: #define GPCMD_PLAY_CD                      0xbc
                    219: #define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL  0x1e
                    220: #define GPCMD_READ_10                      0x28
                    221: #define GPCMD_READ_12                      0xa8
                    222: #define GPCMD_READ_CDVD_CAPACITY           0x25
                    223: #define GPCMD_READ_CD                      0xbe
                    224: #define GPCMD_READ_CD_MSF                  0xb9
                    225: #define GPCMD_READ_DISC_INFO               0x51
                    226: #define GPCMD_READ_DVD_STRUCTURE           0xad
                    227: #define GPCMD_READ_FORMAT_CAPACITIES       0x23
                    228: #define GPCMD_READ_HEADER                  0x44
                    229: #define GPCMD_READ_TRACK_RZONE_INFO        0x52
                    230: #define GPCMD_READ_SUBCHANNEL              0x42
                    231: #define GPCMD_READ_TOC_PMA_ATIP                    0x43
                    232: #define GPCMD_REPAIR_RZONE_TRACK           0x58
                    233: #define GPCMD_REPORT_KEY                   0xa4
                    234: #define GPCMD_REQUEST_SENSE                0x03
                    235: #define GPCMD_RESERVE_RZONE_TRACK          0x53
                    236: #define GPCMD_SCAN                         0xba
                    237: #define GPCMD_SEEK                         0x2b
                    238: #define GPCMD_SEND_DVD_STRUCTURE           0xad
                    239: #define GPCMD_SEND_EVENT                   0xa2
                    240: #define GPCMD_SEND_KEY                     0xa3
                    241: #define GPCMD_SEND_OPC                     0x54
                    242: #define GPCMD_SET_READ_AHEAD               0xa7
                    243: #define GPCMD_SET_STREAMING                0xb6
                    244: #define GPCMD_START_STOP_UNIT              0x1b
                    245: #define GPCMD_STOP_PLAY_SCAN               0x4e
                    246: #define GPCMD_TEST_UNIT_READY              0x00
                    247: #define GPCMD_VERIFY_10                            0x2f
                    248: #define GPCMD_WRITE_10                     0x2a
                    249: #define GPCMD_WRITE_AND_VERIFY_10          0x2e
                    250: /* This is listed as optional in ATAPI 2.6, but is (curiously)
                    251:  * missing from Mt. Fuji, Table 57.  It _is_ mentioned in Mt. Fuji
                    252:  * Table 377 as an MMC command for SCSi devices though...  Most ATAPI
                    253:  * drives support it. */
                    254: #define GPCMD_SET_SPEED                            0xbb
                    255: /* This seems to be a SCSI specific CD-ROM opcode
                    256:  * to play data at track/index */
                    257: #define GPCMD_PLAYAUDIO_TI                 0x48
                    258: /*
                    259:  * From MS Media Status Notification Support Specification. For
                    260:  * older drives only.
                    261:  */
                    262: #define GPCMD_GET_MEDIA_STATUS             0xda
                    263: #define GPCMD_MODE_SENSE_6                 0x1a
                    264: 
                    265: /* Mode page codes for mode sense/set */
                    266: #define GPMODE_R_W_ERROR_PAGE          0x01
                    267: #define GPMODE_WRITE_PARMS_PAGE                0x05
                    268: #define GPMODE_AUDIO_CTL_PAGE          0x0e
                    269: #define GPMODE_POWER_PAGE              0x1a
                    270: #define GPMODE_FAULT_FAIL_PAGE         0x1c
                    271: #define GPMODE_TO_PROTECT_PAGE         0x1d
                    272: #define GPMODE_CAPABILITIES_PAGE       0x2a
                    273: #define GPMODE_ALL_PAGES               0x3f
                    274: /* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor
                    275:  * of MODE_SENSE_POWER_PAGE */
                    276: #define GPMODE_CDROM_PAGE              0x0d
                    277: 
                    278: /*
                    279:  * Based on values from <linux/cdrom.h> but extending CD_MINS
                    280:  * to the maximum common size allowed by the Orange's Book ATIP
                    281:  *
                    282:  * 90 and 99 min CDs are also available but using them as the
                    283:  * upper limit reduces the effectiveness of the heuristic to
                    284:  * detect DVDs burned to less than 25% of their maximum capacity
                    285:  */
                    286: 
                    287: /* Some generally useful CD-ROM information */
                    288: #define CD_MINS                       80 /* max. minutes per CD */
                    289: #define CD_SECS                       60 /* seconds per minute */
                    290: #define CD_FRAMES                     75 /* frames per second */
                    291: #define CD_FRAMESIZE                2048 /* bytes per frame, "cooked" mode */
                    292: #define CD_MAX_BYTES       (CD_MINS * CD_SECS * CD_FRAMES * CD_FRAMESIZE)
                    293: #define CD_MAX_SECTORS     (CD_MAX_BYTES / 512)
                    294: 
                    295: /*
                    296:  * The MMC values are not IDE specific and might need to be moved
                    297:  * to a common header if they are also needed for the SCSI emulation
                    298:  */
                    299: 
                    300: /* Profile list from MMC-6 revision 1 table 91 */
                    301: #define MMC_PROFILE_NONE                0x0000
                    302: #define MMC_PROFILE_CD_ROM              0x0008
                    303: #define MMC_PROFILE_CD_R                0x0009
                    304: #define MMC_PROFILE_CD_RW               0x000A
                    305: #define MMC_PROFILE_DVD_ROM             0x0010
                    306: #define MMC_PROFILE_DVD_R_SR            0x0011
                    307: #define MMC_PROFILE_DVD_RAM             0x0012
                    308: #define MMC_PROFILE_DVD_RW_RO           0x0013
                    309: #define MMC_PROFILE_DVD_RW_SR           0x0014
                    310: #define MMC_PROFILE_DVD_R_DL_SR         0x0015
                    311: #define MMC_PROFILE_DVD_R_DL_JR         0x0016
                    312: #define MMC_PROFILE_DVD_RW_DL           0x0017
                    313: #define MMC_PROFILE_DVD_DDR             0x0018
                    314: #define MMC_PROFILE_DVD_PLUS_RW         0x001A
                    315: #define MMC_PROFILE_DVD_PLUS_R          0x001B
                    316: #define MMC_PROFILE_DVD_PLUS_RW_DL      0x002A
                    317: #define MMC_PROFILE_DVD_PLUS_R_DL       0x002B
                    318: #define MMC_PROFILE_BD_ROM              0x0040
                    319: #define MMC_PROFILE_BD_R_SRM            0x0041
                    320: #define MMC_PROFILE_BD_R_RRM            0x0042
                    321: #define MMC_PROFILE_BD_RE               0x0043
                    322: #define MMC_PROFILE_HDDVD_ROM           0x0050
                    323: #define MMC_PROFILE_HDDVD_R             0x0051
                    324: #define MMC_PROFILE_HDDVD_RAM           0x0052
                    325: #define MMC_PROFILE_HDDVD_RW            0x0053
                    326: #define MMC_PROFILE_HDDVD_R_DL          0x0058
                    327: #define MMC_PROFILE_HDDVD_RW_DL         0x005A
                    328: #define MMC_PROFILE_INVALID             0xFFFF
                    329: 
                    330: #define ATAPI_INT_REASON_CD             0x01 /* 0 = data transfer */
                    331: #define ATAPI_INT_REASON_IO             0x02 /* 1 = transfer to the host */
                    332: #define ATAPI_INT_REASON_REL            0x04
                    333: #define ATAPI_INT_REASON_TAG            0xf8
                    334: 
                    335: /* same constants as bochs */
                    336: #define ASC_ILLEGAL_OPCODE                   0x20
                    337: #define ASC_LOGICAL_BLOCK_OOR                0x21
                    338: #define ASC_INV_FIELD_IN_CMD_PACKET          0x24
                    339: #define ASC_MEDIUM_MAY_HAVE_CHANGED          0x28
                    340: #define ASC_INCOMPATIBLE_FORMAT              0x30
                    341: #define ASC_MEDIUM_NOT_PRESENT               0x3a
                    342: #define ASC_SAVING_PARAMETERS_NOT_SUPPORTED  0x39
                    343: #define ASC_MEDIA_REMOVAL_PREVENTED          0x53
                    344: 
                    345: #define CFA_NO_ERROR            0x00
                    346: #define CFA_MISC_ERROR          0x09
                    347: #define CFA_INVALID_COMMAND     0x20
                    348: #define CFA_INVALID_ADDRESS     0x21
                    349: #define CFA_ADDRESS_OVERFLOW    0x2f
                    350: 
                    351: #define SENSE_NONE            0
                    352: #define SENSE_NOT_READY       2
                    353: #define SENSE_ILLEGAL_REQUEST 5
                    354: #define SENSE_UNIT_ATTENTION  6
                    355: 
                    356: #define SMART_READ_DATA       0xd0
                    357: #define SMART_READ_THRESH     0xd1
                    358: #define SMART_ATTR_AUTOSAVE   0xd2
                    359: #define SMART_SAVE_ATTR       0xd3
                    360: #define SMART_EXECUTE_OFFLINE 0xd4
                    361: #define SMART_READ_LOG        0xd5
                    362: #define SMART_WRITE_LOG       0xd6
                    363: #define SMART_ENABLE          0xd8
                    364: #define SMART_DISABLE         0xd9
                    365: #define SMART_STATUS          0xda
                    366: 
1.1.1.4   root      367: typedef enum { IDE_HD, IDE_CD, IDE_CFATA } IDEDriveKind;
                    368: 
1.1       root      369: typedef void EndTransferFunc(IDEState *);
                    370: 
1.1.1.5 ! root      371: typedef void DMAStartFunc(IDEDMA *, IDEState *, BlockDriverCompletionFunc *);
        !           372: typedef int DMAFunc(IDEDMA *);
        !           373: typedef int DMAIntFunc(IDEDMA *, int);
        !           374: typedef void DMARestartFunc(void *, int, int);
        !           375: 
1.1       root      376: /* NOTE: IDEState represents in fact one drive */
                    377: struct IDEState {
                    378:     IDEBus *bus;
                    379:     uint8_t unit;
                    380:     /* ide config */
1.1.1.4   root      381:     IDEDriveKind drive_kind;
1.1       root      382:     int cylinders, heads, sectors;
                    383:     int64_t nb_sectors;
                    384:     int mult_sectors;
                    385:     int identify_set;
                    386:     uint8_t identify_data[512];
                    387:     int drive_serial;
                    388:     char drive_serial_str[21];
                    389:     /* ide regs */
                    390:     uint8_t feature;
                    391:     uint8_t error;
                    392:     uint32_t nsector;
                    393:     uint8_t sector;
                    394:     uint8_t lcyl;
                    395:     uint8_t hcyl;
                    396:     /* other part of tf for lba48 support */
                    397:     uint8_t hob_feature;
                    398:     uint8_t hob_nsector;
                    399:     uint8_t hob_sector;
                    400:     uint8_t hob_lcyl;
                    401:     uint8_t hob_hcyl;
                    402: 
                    403:     uint8_t select;
                    404:     uint8_t status;
                    405: 
                    406:     /* set for lba48 access */
                    407:     uint8_t lba48;
                    408:     BlockDriverState *bs;
1.1.1.2   root      409:     char version[9];
1.1       root      410:     /* ATAPI specific */
                    411:     uint8_t sense_key;
                    412:     uint8_t asc;
                    413:     uint8_t cdrom_changed;
                    414:     int packet_transfer_size;
                    415:     int elementary_transfer_size;
                    416:     int io_buffer_index;
                    417:     int lba;
                    418:     int cd_sector_size;
                    419:     int atapi_dma; /* true if dma is requested for the packet cmd */
                    420:     /* ATA DMA state */
                    421:     int io_buffer_size;
                    422:     QEMUSGList sg;
                    423:     /* PIO transfer handling */
                    424:     int req_nb_sectors; /* number of sectors per interrupt */
                    425:     EndTransferFunc *end_transfer_func;
                    426:     uint8_t *data_ptr;
                    427:     uint8_t *data_end;
                    428:     uint8_t *io_buffer;
1.1.1.2   root      429:     /* PIO save/restore */
                    430:     int32_t io_buffer_total_len;
                    431:     int cur_io_buffer_offset;
                    432:     int cur_io_buffer_len;
                    433:     uint8_t end_transfer_fn_idx;
1.1       root      434:     QEMUTimer *sector_write_timer; /* only used for win2k install hack */
                    435:     uint32_t irq_count; /* counts IRQs when using win2k install hack */
                    436:     /* CF-ATA extended error */
                    437:     uint8_t ext_error;
                    438:     /* CF-ATA metadata storage */
                    439:     uint32_t mdata_size;
                    440:     uint8_t *mdata_storage;
                    441:     int media_changed;
                    442:     int is_read;
                    443:     /* SMART */
                    444:     uint8_t smart_enabled;
                    445:     uint8_t smart_autosave;
                    446:     int smart_errors;
                    447:     uint8_t smart_selftest_count;
                    448:     uint8_t *smart_selftest_data;
1.1.1.5 ! root      449:     /* AHCI */
        !           450:     int ncq_queues;
        !           451: };
        !           452: 
        !           453: struct IDEDMAOps {
        !           454:     DMAStartFunc *start_dma;
        !           455:     DMAFunc *start_transfer;
        !           456:     DMAIntFunc *prepare_buf;
        !           457:     DMAIntFunc *rw_buf;
        !           458:     DMAIntFunc *set_unit;
        !           459:     DMAIntFunc *add_status;
        !           460:     DMAFunc *set_inactive;
        !           461:     DMARestartFunc *restart_cb;
        !           462:     DMAFunc *reset;
        !           463: };
        !           464: 
        !           465: struct IDEDMA {
        !           466:     const struct IDEDMAOps *ops;
        !           467:     struct iovec iov;
        !           468:     QEMUIOVector qiov;
        !           469:     BlockDriverAIOCB *aiocb;
1.1       root      470: };
                    471: 
                    472: struct IDEBus {
                    473:     BusState qbus;
                    474:     IDEDevice *master;
                    475:     IDEDevice *slave;
                    476:     IDEState ifs[2];
1.1.1.5 ! root      477:     int bus_id;
        !           478:     IDEDMA *dma;
1.1       root      479:     uint8_t unit;
                    480:     uint8_t cmd;
                    481:     qemu_irq irq;
                    482: };
                    483: 
                    484: struct IDEDevice {
                    485:     DeviceState qdev;
                    486:     uint32_t unit;
1.1.1.4   root      487:     BlockConf conf;
1.1.1.2   root      488:     char *version;
1.1.1.4   root      489:     char *serial;
1.1       root      490: };
                    491: 
                    492: typedef int (*ide_qdev_initfn)(IDEDevice *dev);
                    493: struct IDEDeviceInfo {
                    494:     DeviceInfo qdev;
                    495:     ide_qdev_initfn init;
                    496: };
                    497: 
                    498: #define BM_STATUS_DMAING 0x01
                    499: #define BM_STATUS_ERROR  0x02
                    500: #define BM_STATUS_INT    0x04
                    501: #define BM_STATUS_DMA_RETRY  0x08
                    502: #define BM_STATUS_PIO_RETRY  0x10
1.1.1.5 ! root      503: #define BM_STATUS_RETRY_READ  0x20
        !           504: #define BM_STATUS_RETRY_FLUSH 0x40
1.1       root      505: 
                    506: #define BM_CMD_START     0x01
                    507: #define BM_CMD_READ      0x08
                    508: 
                    509: static inline IDEState *idebus_active_if(IDEBus *bus)
                    510: {
                    511:     return bus->ifs + bus->unit;
                    512: }
                    513: 
                    514: static inline void ide_set_irq(IDEBus *bus)
                    515: {
                    516:     if (!(bus->cmd & IDE_CMD_DISABLE_IRQ)) {
                    517:         qemu_irq_raise(bus->irq);
                    518:     }
                    519: }
                    520: 
                    521: /* hw/ide/core.c */
                    522: extern const VMStateDescription vmstate_ide_bus;
                    523: 
                    524: #define VMSTATE_IDE_BUS(_field, _state)                          \
                    525:     VMSTATE_STRUCT(_field, _state, 1, vmstate_ide_bus, IDEBus)
                    526: 
                    527: #define VMSTATE_IDE_BUS_ARRAY(_field, _state, _num)              \
                    528:     VMSTATE_STRUCT_ARRAY(_field, _state, _num, 1, vmstate_ide_bus, IDEBus)
                    529: 
                    530: extern const VMStateDescription vmstate_ide_drive;
                    531: 
                    532: #define VMSTATE_IDE_DRIVES(_field, _state) \
                    533:     VMSTATE_STRUCT_ARRAY(_field, _state, 2, 3, vmstate_ide_drive, IDEState)
                    534: 
                    535: void ide_bus_reset(IDEBus *bus);
                    536: int64_t ide_get_sector(IDEState *s);
                    537: void ide_set_sector(IDEState *s, int64_t sector_num);
                    538: 
                    539: void ide_dma_error(IDEState *s);
                    540: 
                    541: void ide_atapi_cmd_ok(IDEState *s);
                    542: void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc);
                    543: void ide_atapi_io_error(IDEState *s, int ret);
                    544: 
                    545: void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val);
                    546: uint32_t ide_ioport_read(void *opaque, uint32_t addr1);
                    547: uint32_t ide_status_read(void *opaque, uint32_t addr);
                    548: void ide_cmd_write(void *opaque, uint32_t addr, uint32_t val);
                    549: void ide_data_writew(void *opaque, uint32_t addr, uint32_t val);
                    550: uint32_t ide_data_readw(void *opaque, uint32_t addr);
                    551: void ide_data_writel(void *opaque, uint32_t addr, uint32_t val);
                    552: uint32_t ide_data_readl(void *opaque, uint32_t addr);
                    553: 
1.1.1.4   root      554: int ide_init_drive(IDEState *s, BlockDriverState *bs,
                    555:                    const char *version, const char *serial);
                    556: void ide_init2(IDEBus *bus, qemu_irq irq);
                    557: void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
                    558:                                     DriveInfo *hd1, qemu_irq irq);
1.1       root      559: void ide_init_ioport(IDEBus *bus, int iobase, int iobase2);
                    560: 
1.1.1.5 ! root      561: void ide_exec_cmd(IDEBus *bus, uint32_t val);
        !           562: void ide_dma_cb(void *opaque, int ret);
        !           563: void ide_sector_write(IDEState *s);
        !           564: void ide_sector_read(IDEState *s);
        !           565: void ide_flush_cache(IDEState *s);
        !           566: 
1.1       root      567: /* hw/ide/qdev.c */
1.1.1.5 ! root      568: void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id);
1.1       root      569: IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive);
                    570: 
                    571: #endif /* HW_IDE_INTERNAL_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.