ide: move cmd+irq from IDEState to IDEBus.

These variables are per bus, not per drive.  Lets move them and
cleanup things a bit.  And fix the cmd migration bug for real.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Gerd Hoffmann 2009-08-28 16:37:42 +02:00 committed by Anthony Liguori
parent f455e98cf4
commit 9cdd03a791
3 changed files with 55 additions and 63 deletions

View File

@ -381,7 +381,7 @@ void ide_set_sector(IDEState *s, int64_t sector_num)
static void ide_rw_error(IDEState *s) { static void ide_rw_error(IDEState *s) {
ide_abort_command(s); ide_abort_command(s);
ide_set_irq(s); ide_set_irq(s->bus);
} }
static void ide_sector_read(IDEState *s) static void ide_sector_read(IDEState *s)
@ -408,7 +408,7 @@ static void ide_sector_read(IDEState *s)
return; return;
} }
ide_transfer_start(s, s->io_buffer, 512 * n, ide_sector_read); ide_transfer_start(s, s->io_buffer, 512 * n, ide_sector_read);
ide_set_irq(s); ide_set_irq(s->bus);
ide_set_sector(s, sector_num + n); ide_set_sector(s, sector_num + n);
s->nsector -= n; s->nsector -= n;
} }
@ -465,7 +465,7 @@ void ide_dma_error(IDEState *s)
ide_transfer_stop(s); ide_transfer_stop(s);
s->error = ABRT_ERR; s->error = ABRT_ERR;
s->status = READY_STAT | ERR_STAT; s->status = READY_STAT | ERR_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
} }
static int ide_handle_write_error(IDEState *s, int error, int op) static int ide_handle_write_error(IDEState *s, int error, int op)
@ -565,7 +565,7 @@ static void ide_read_dma_cb(void *opaque, int ret)
/* end of transfer ? */ /* end of transfer ? */
if (s->nsector == 0) { if (s->nsector == 0) {
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
eot: eot:
bm->status &= ~BM_STATUS_DMAING; bm->status &= ~BM_STATUS_DMAING;
bm->status |= BM_STATUS_INT; bm->status |= BM_STATUS_INT;
@ -600,7 +600,7 @@ static void ide_sector_read_dma(IDEState *s)
static void ide_sector_write_timer_cb(void *opaque) static void ide_sector_write_timer_cb(void *opaque)
{ {
IDEState *s = opaque; IDEState *s = opaque;
ide_set_irq(s); ide_set_irq(s->bus);
} }
static void ide_sector_write(IDEState *s) static void ide_sector_write(IDEState *s)
@ -648,7 +648,7 @@ static void ide_sector_write(IDEState *s)
} else } else
#endif #endif
{ {
ide_set_irq(s); ide_set_irq(s->bus);
} }
} }
@ -705,7 +705,7 @@ static void ide_write_dma_cb(void *opaque, int ret)
/* end of transfer ? */ /* end of transfer ? */
if (s->nsector == 0) { if (s->nsector == 0) {
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
eot: eot:
bm->status &= ~BM_STATUS_DMAING; bm->status &= ~BM_STATUS_DMAING;
bm->status |= BM_STATUS_INT; bm->status |= BM_STATUS_INT;
@ -741,7 +741,7 @@ void ide_atapi_cmd_ok(IDEState *s)
s->error = 0; s->error = 0;
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD; s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
ide_set_irq(s); ide_set_irq(s->bus);
} }
void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc) void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc)
@ -754,7 +754,7 @@ void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc)
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD; s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
s->sense_key = sense_key; s->sense_key = sense_key;
s->asc = asc; s->asc = asc;
ide_set_irq(s); ide_set_irq(s->bus);
} }
static void ide_atapi_cmd_check_status(IDEState *s) static void ide_atapi_cmd_check_status(IDEState *s)
@ -765,7 +765,7 @@ static void ide_atapi_cmd_check_status(IDEState *s)
s->error = MC_ERR | (SENSE_UNIT_ATTENTION << 4); s->error = MC_ERR | (SENSE_UNIT_ATTENTION << 4);
s->status = ERR_STAT; s->status = ERR_STAT;
s->nsector = 0; s->nsector = 0;
ide_set_irq(s); ide_set_irq(s->bus);
} }
static inline void cpu_to_ube16(uint8_t *buf, int val) static inline void cpu_to_ube16(uint8_t *buf, int val)
@ -866,7 +866,7 @@ static void ide_atapi_cmd_reply_end(IDEState *s)
ide_transfer_stop(s); ide_transfer_stop(s);
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD; s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
ide_set_irq(s); ide_set_irq(s->bus);
#ifdef DEBUG_IDE_ATAPI #ifdef DEBUG_IDE_ATAPI
printf("status=0x%x\n", s->status); printf("status=0x%x\n", s->status);
#endif #endif
@ -922,7 +922,7 @@ static void ide_atapi_cmd_reply_end(IDEState *s)
s->packet_transfer_size -= size; s->packet_transfer_size -= size;
s->elementary_transfer_size -= size; s->elementary_transfer_size -= size;
s->io_buffer_index += size; s->io_buffer_index += size;
ide_set_irq(s); ide_set_irq(s->bus);
#ifdef DEBUG_IDE_ATAPI #ifdef DEBUG_IDE_ATAPI
printf("status=0x%x\n", s->status); printf("status=0x%x\n", s->status);
#endif #endif
@ -1003,7 +1003,7 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret)
if (s->packet_transfer_size <= 0) { if (s->packet_transfer_size <= 0) {
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD; s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
ide_set_irq(s); ide_set_irq(s->bus);
eot: eot:
bm->status &= ~BM_STATUS_DMAING; bm->status &= ~BM_STATUS_DMAING;
bm->status |= BM_STATUS_INT; bm->status |= BM_STATUS_INT;
@ -1666,7 +1666,7 @@ static void cdrom_change_cb(void *opaque)
s->sense_key = SENSE_UNIT_ATTENTION; s->sense_key = SENSE_UNIT_ATTENTION;
s->asc = ASC_MEDIUM_MAY_HAVE_CHANGED; s->asc = ASC_MEDIUM_MAY_HAVE_CHANGED;
s->cdrom_changed = 1; s->cdrom_changed = 1;
ide_set_irq(s); ide_set_irq(s->bus);
} }
static void ide_cmd_lba48_transform(IDEState *s, int lba48) static void ide_cmd_lba48_transform(IDEState *s, int lba48)
@ -1792,13 +1792,13 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
} }
ide_abort_command(s); ide_abort_command(s);
} }
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case WIN_SPECIFY: case WIN_SPECIFY:
case WIN_RECAL: case WIN_RECAL:
s->error = 0; s->error = 0;
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case WIN_SETMULT: case WIN_SETMULT:
if (s->is_cf && s->nsector == 0) { if (s->is_cf && s->nsector == 0) {
@ -1813,7 +1813,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->mult_sectors = s->nsector & 0xff; s->mult_sectors = s->nsector & 0xff;
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
} }
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case WIN_VERIFY_EXT: case WIN_VERIFY_EXT:
lba48 = 1; lba48 = 1;
@ -1822,7 +1822,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
/* do sector number check ? */ /* do sector number check ? */
ide_cmd_lba48_transform(s, lba48); ide_cmd_lba48_transform(s, lba48);
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case WIN_READ_EXT: case WIN_READ_EXT:
lba48 = 1; lba48 = 1;
@ -1897,13 +1897,13 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
ide_cmd_lba48_transform(s, lba48); ide_cmd_lba48_transform(s, lba48);
ide_set_sector(s, s->nb_sectors - 1); ide_set_sector(s, s->nb_sectors - 1);
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case WIN_CHECKPOWERMODE1: case WIN_CHECKPOWERMODE1:
case WIN_CHECKPOWERMODE2: case WIN_CHECKPOWERMODE2:
s->nsector = 0xff; /* device active or idle */ s->nsector = 0xff; /* device active or idle */
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case WIN_SETFEATURES: case WIN_SETFEATURES:
if (!s->bs) if (!s->bs)
@ -1925,7 +1925,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
case 0x42: /* enable Automatic Acoustic Mode */ case 0x42: /* enable Automatic Acoustic Mode */
case 0xc2: /* disable Automatic Acoustic Mode */ case 0xc2: /* disable Automatic Acoustic Mode */
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case 0x03: { /* set transfer mode */ case 0x03: { /* set transfer mode */
uint8_t val = s->nsector & 0x07; uint8_t val = s->nsector & 0x07;
@ -1956,7 +1956,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
goto abort_cmd; goto abort_cmd;
} }
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
} }
default: default:
@ -1968,7 +1968,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
if (s->bs) if (s->bs)
bdrv_flush(s->bs); bdrv_flush(s->bs);
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case WIN_STANDBY: case WIN_STANDBY:
case WIN_STANDBY2: case WIN_STANDBY2:
@ -1981,14 +1981,14 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
case WIN_SLEEPNOW1: case WIN_SLEEPNOW1:
case WIN_SLEEPNOW2: case WIN_SLEEPNOW2:
s->status = READY_STAT; s->status = READY_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case WIN_SEEK: case WIN_SEEK:
if(s->is_cdrom) if(s->is_cdrom)
goto abort_cmd; goto abort_cmd;
/* XXX: Check that seek is within bounds */ /* XXX: Check that seek is within bounds */
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
/* ATAPI commands */ /* ATAPI commands */
case WIN_PIDENTIFY: case WIN_PIDENTIFY:
@ -1999,7 +1999,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
} else { } else {
ide_abort_command(s); ide_abort_command(s);
} }
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case WIN_DIAGNOSE: case WIN_DIAGNOSE:
ide_set_signature(s); ide_set_signature(s);
@ -2012,7 +2012,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->error = 0x01; /* Device 0 passed, Device 1 passed or not s->error = 0x01; /* Device 0 passed, Device 1 passed or not
* present. * present.
*/ */
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case WIN_SRST: case WIN_SRST:
if (!s->is_cdrom) if (!s->is_cdrom)
@ -2039,7 +2039,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
goto abort_cmd; goto abort_cmd;
s->error = 0x09; /* miscellaneous error */ s->error = 0x09; /* miscellaneous error */
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case CFA_ERASE_SECTORS: case CFA_ERASE_SECTORS:
case CFA_WEAR_LEVEL: case CFA_WEAR_LEVEL:
@ -2051,7 +2051,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->media_changed = 1; s->media_changed = 1;
s->error = 0x00; s->error = 0x00;
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case CFA_TRANSLATE_SECTOR: case CFA_TRANSLATE_SECTOR:
if (!s->is_cf) if (!s->is_cf)
@ -2071,7 +2071,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->io_buffer[0x19] = 0x00; /* Hot count */ s->io_buffer[0x19] = 0x00; /* Hot count */
s->io_buffer[0x1a] = 0x01; /* Hot count */ s->io_buffer[0x1a] = 0x01; /* Hot count */
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop); ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case CFA_ACCESS_METADATA_STORAGE: case CFA_ACCESS_METADATA_STORAGE:
if (!s->is_cf) if (!s->is_cf)
@ -2091,7 +2091,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
} }
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop); ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
s->status = 0x00; /* NOTE: READY is _not_ set */ s->status = 0x00; /* NOTE: READY is _not_ set */
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case IBM_SENSE_CONDITION: case IBM_SENSE_CONDITION:
if (!s->is_cf) if (!s->is_cf)
@ -2104,7 +2104,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
goto abort_cmd; goto abort_cmd;
} }
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case WIN_SMART: case WIN_SMART:
@ -2118,12 +2118,12 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
case SMART_DISABLE: case SMART_DISABLE:
s->smart_enabled = 0; s->smart_enabled = 0;
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case SMART_ENABLE: case SMART_ENABLE:
s->smart_enabled = 1; s->smart_enabled = 1;
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case SMART_ATTR_AUTOSAVE: case SMART_ATTR_AUTOSAVE:
switch (s->sector) { switch (s->sector) {
@ -2137,7 +2137,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
goto abort_cmd; goto abort_cmd;
} }
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case SMART_STATUS: case SMART_STATUS:
if (!s->smart_errors) { if (!s->smart_errors) {
@ -2148,7 +2148,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->lcyl = 0xf4; s->lcyl = 0xf4;
} }
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case SMART_READ_THRESH: case SMART_READ_THRESH:
memset(s->io_buffer, 0, 0x200); memset(s->io_buffer, 0, 0x200);
@ -2164,7 +2164,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->io_buffer[511] = 0x100 - s->io_buffer[511]; s->io_buffer[511] = 0x100 - s->io_buffer[511];
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop); ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case SMART_READ_DATA: case SMART_READ_DATA:
memset(s->io_buffer, 0, 0x200); memset(s->io_buffer, 0, 0x200);
@ -2202,7 +2202,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->io_buffer[511] = 0x100 - s->io_buffer[511]; s->io_buffer[511] = 0x100 - s->io_buffer[511];
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop); ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case SMART_READ_LOG: case SMART_READ_LOG:
switch (s->sector) { switch (s->sector) {
@ -2236,7 +2236,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
} }
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop); ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
case SMART_EXECUTE_OFFLINE: case SMART_EXECUTE_OFFLINE:
switch (s->sector) { switch (s->sector) {
@ -2252,7 +2252,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->smart_selftest_data[n+2] = 0x34; /* hour count lsb */ s->smart_selftest_data[n+2] = 0x34; /* hour count lsb */
s->smart_selftest_data[n+3] = 0x12; /* hour count msb */ s->smart_selftest_data[n+3] = 0x12; /* hour count msb */
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
default: default:
goto abort_cmd; goto abort_cmd;
@ -2265,7 +2265,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
default: default:
abort_cmd: abort_cmd:
ide_abort_command(s); ide_abort_command(s);
ide_set_irq(s); ide_set_irq(s->bus);
break; break;
} }
} }
@ -2340,7 +2340,7 @@ uint32_t ide_ioport_read(void *opaque, uint32_t addr1)
ret = 0; ret = 0;
else else
ret = s->status; ret = s->status;
qemu_irq_lower(s->irq); qemu_irq_lower(bus->irq);
break; break;
} }
#ifdef DEBUG_IDE #ifdef DEBUG_IDE
@ -2376,7 +2376,7 @@ void ide_cmd_write(void *opaque, uint32_t addr, uint32_t val)
printf("ide: write control addr=0x%x val=%02x\n", addr, val); printf("ide: write control addr=0x%x val=%02x\n", addr, val);
#endif #endif
/* common for both drives */ /* common for both drives */
if (!(bus->ifs[0].cmd & IDE_CMD_RESET) && if (!(bus->cmd & IDE_CMD_RESET) &&
(val & IDE_CMD_RESET)) { (val & IDE_CMD_RESET)) {
/* reset low to high */ /* reset low to high */
for(i = 0;i < 2; i++) { for(i = 0;i < 2; i++) {
@ -2384,7 +2384,7 @@ void ide_cmd_write(void *opaque, uint32_t addr, uint32_t val)
s->status = BUSY_STAT | SEEK_STAT; s->status = BUSY_STAT | SEEK_STAT;
s->error = 0x01; s->error = 0x01;
} }
} else if ((bus->ifs[0].cmd & IDE_CMD_RESET) && } else if ((bus->cmd & IDE_CMD_RESET) &&
!(val & IDE_CMD_RESET)) { !(val & IDE_CMD_RESET)) {
/* high to low */ /* high to low */
for(i = 0;i < 2; i++) { for(i = 0;i < 2; i++) {
@ -2397,8 +2397,7 @@ void ide_cmd_write(void *opaque, uint32_t addr, uint32_t val)
} }
} }
bus->ifs[0].cmd = val; bus->cmd = val;
bus->ifs[1].cmd = val;
} }
void ide_data_writew(void *opaque, uint32_t addr, uint32_t val) void ide_data_writew(void *opaque, uint32_t addr, uint32_t val)
@ -2548,11 +2547,11 @@ void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1,
if (strlen(s->drive_serial_str) == 0) if (strlen(s->drive_serial_str) == 0)
snprintf(s->drive_serial_str, sizeof(s->drive_serial_str), snprintf(s->drive_serial_str, sizeof(s->drive_serial_str),
"QM%05d", s->drive_serial); "QM%05d", s->drive_serial);
s->irq = irq;
s->sector_write_timer = qemu_new_timer(vm_clock, s->sector_write_timer = qemu_new_timer(vm_clock,
ide_sector_write_timer_cb, s); ide_sector_write_timer_cb, s);
ide_reset(s); ide_reset(s);
} }
bus->irq = irq;
} }
void ide_init_ioport(IDEBus *bus, int iobase, int iobase2) void ide_init_ioport(IDEBus *bus, int iobase, int iobase2)
@ -2637,20 +2636,14 @@ void ide_load(QEMUFile* f, IDEState *s, int version_id)
void idebus_save(QEMUFile* f, IDEBus *bus) void idebus_save(QEMUFile* f, IDEBus *bus)
{ {
IDEState *s = idebus_active_if(bus); qemu_put_8s(f, &bus->cmd);
qemu_put_8s(f, &s->cmd);
qemu_put_8s(f, &bus->unit); qemu_put_8s(f, &bus->unit);
} }
void idebus_load(QEMUFile* f, IDEBus *bus, int version_id) void idebus_load(QEMUFile* f, IDEBus *bus, int version_id)
{ {
IDEState *s; qemu_get_8s(f, &bus->cmd);
uint8_t cmd;
qemu_get_8s(f, &cmd);
qemu_get_8s(f, &bus->unit); qemu_get_8s(f, &bus->unit);
s = idebus_active_if(bus);
s->cmd = cmd;
} }
/***********************************************************/ /***********************************************************/

View File

@ -379,7 +379,6 @@ struct IDEState {
int mult_sectors; int mult_sectors;
int identify_set; int identify_set;
uint16_t identify_data[256]; uint16_t identify_data[256];
qemu_irq irq;
int drive_serial; int drive_serial;
char drive_serial_str[21]; char drive_serial_str[21];
/* ide regs */ /* ide regs */
@ -399,8 +398,6 @@ struct IDEState {
uint8_t select; uint8_t select;
uint8_t status; uint8_t status;
/* 0x3f6 command, only meaningful for drive 0 */
uint8_t cmd;
/* set for lba48 access */ /* set for lba48 access */
uint8_t lba48; uint8_t lba48;
BlockDriverState *bs; BlockDriverState *bs;
@ -446,6 +443,8 @@ struct IDEBus {
BMDMAState *bmdma; BMDMAState *bmdma;
IDEState ifs[2]; IDEState ifs[2];
uint8_t unit; uint8_t unit;
uint8_t cmd;
qemu_irq irq;
}; };
#define BM_STATUS_DMAING 0x01 #define BM_STATUS_DMAING 0x01
@ -490,14 +489,14 @@ static inline IDEState *bmdma_active_if(BMDMAState *bmdma)
return bmdma->bus->ifs + bmdma->unit; return bmdma->bus->ifs + bmdma->unit;
} }
static inline void ide_set_irq(IDEState *s) static inline void ide_set_irq(IDEBus *bus)
{ {
BMDMAState *bm = s->bus->bmdma; BMDMAState *bm = bus->bmdma;
if (!(s->cmd & IDE_CMD_DISABLE_IRQ)) { if (!(bus->cmd & IDE_CMD_DISABLE_IRQ)) {
if (bm) { if (bm) {
bm->status |= BM_STATUS_INT; bm->status |= BM_STATUS_INT;
} }
qemu_irq_raise(s->irq); qemu_irq_raise(bus->irq);
} }
} }

View File

@ -124,7 +124,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
/* end of transfer ? */ /* end of transfer ? */
if (s->nsector == 0) { if (s->nsector == 0) {
s->status = READY_STAT | SEEK_STAT; s->status = READY_STAT | SEEK_STAT;
ide_set_irq(s); ide_set_irq(s->bus);
} }
/* end of DMA ? */ /* end of DMA ? */