summaryrefslogtreecommitdiffstats
path: root/hw/ide
diff options
context:
space:
mode:
Diffstat (limited to 'hw/ide')
-rw-r--r--hw/ide/ahci.c31
-rw-r--r--hw/ide/atapi.c33
-rw-r--r--hw/ide/cmd646.c2
-rw-r--r--hw/ide/core.c182
-rw-r--r--hw/ide/ich.c2
-rw-r--r--hw/ide/internal.h6
-rw-r--r--hw/ide/isa.c2
-rw-r--r--hw/ide/macio.c48
-rw-r--r--hw/ide/microdrive.c4
-rw-r--r--hw/ide/mmio.c2
-rw-r--r--hw/ide/pci.c4
-rw-r--r--hw/ide/piix.c8
-rw-r--r--hw/ide/qdev.c11
-rw-r--r--hw/ide/via.c2
14 files changed, 173 insertions, 164 deletions
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index f3d4e70..70958e3 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -28,6 +28,7 @@
#include <hw/sysbus.h>
#include "monitor/monitor.h"
+#include "sysemu/block-backend.h"
#include "sysemu/dma.h"
#include "internal.h"
#include <hw/ide/pci.h>
@@ -84,7 +85,7 @@ static uint32_t ahci_port_read(AHCIState *s, int port, int offset)
val = pr->sig;
break;
case PORT_SCR_STAT:
- if (s->dev[port].port.ifs[0].bs) {
+ if (s->dev[port].port.ifs[0].blk) {
val = SATA_SCR_SSTATUS_DET_DEV_PRESENT_PHY_UP |
SATA_SCR_SSTATUS_SPD_GEN1 | SATA_SCR_SSTATUS_IPM_ACTIVE;
} else {
@@ -501,7 +502,7 @@ static void ahci_reset_port(AHCIState *s, int port)
d->init_d2h_sent = false;
ide_state = &s->dev[port].port.ifs[0];
- if (!ide_state->bs) {
+ if (!ide_state->blk) {
return;
}
@@ -513,11 +514,11 @@ static void ahci_reset_port(AHCIState *s, int port)
}
if (ncq_tfs->aiocb) {
- bdrv_aio_cancel(ncq_tfs->aiocb);
+ blk_aio_cancel(ncq_tfs->aiocb);
ncq_tfs->aiocb = NULL;
}
- /* Maybe we just finished the request thanks to bdrv_aio_cancel() */
+ /* Maybe we just finished the request thanks to blk_aio_cancel() */
if (!ncq_tfs->used) {
continue;
}
@@ -527,7 +528,7 @@ static void ahci_reset_port(AHCIState *s, int port)
}
s->dev[port].port_state = STATE_RUN;
- if (!ide_state->bs) {
+ if (!ide_state->blk) {
pr->sig = 0;
ide_state->status = SEEK_STAT | WRERR_STAT;
} else if (ide_state->drive_kind == IDE_CD) {
@@ -826,7 +827,7 @@ static void ncq_cb(void *opaque, int ret)
DPRINTF(ncq_tfs->drive->port_no, "NCQ transfer tag %d finished\n",
ncq_tfs->tag);
- block_acct_done(bdrv_get_stats(ncq_tfs->drive->port.ifs[0].bs),
+ block_acct_done(blk_get_stats(ncq_tfs->drive->port.ifs[0].blk),
&ncq_tfs->acct);
qemu_sglist_destroy(&ncq_tfs->sglist);
ncq_tfs->used = 0;
@@ -877,11 +878,11 @@ static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis,
DPRINTF(port, "tag %d aio read %"PRId64"\n",
ncq_tfs->tag, ncq_tfs->lba);
- dma_acct_start(ncq_tfs->drive->port.ifs[0].bs, &ncq_tfs->acct,
+ dma_acct_start(ncq_tfs->drive->port.ifs[0].blk, &ncq_tfs->acct,
&ncq_tfs->sglist, BLOCK_ACCT_READ);
- ncq_tfs->aiocb = dma_bdrv_read(ncq_tfs->drive->port.ifs[0].bs,
- &ncq_tfs->sglist, ncq_tfs->lba,
- ncq_cb, ncq_tfs);
+ ncq_tfs->aiocb = dma_blk_read(ncq_tfs->drive->port.ifs[0].blk,
+ &ncq_tfs->sglist, ncq_tfs->lba,
+ ncq_cb, ncq_tfs);
break;
case WRITE_FPDMA_QUEUED:
DPRINTF(port, "NCQ writing %d sectors to LBA %"PRId64", tag %d\n",
@@ -890,11 +891,11 @@ static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis,
DPRINTF(port, "tag %d aio write %"PRId64"\n",
ncq_tfs->tag, ncq_tfs->lba);
- dma_acct_start(ncq_tfs->drive->port.ifs[0].bs, &ncq_tfs->acct,
+ dma_acct_start(ncq_tfs->drive->port.ifs[0].blk, &ncq_tfs->acct,
&ncq_tfs->sglist, BLOCK_ACCT_WRITE);
- ncq_tfs->aiocb = dma_bdrv_write(ncq_tfs->drive->port.ifs[0].bs,
- &ncq_tfs->sglist, ncq_tfs->lba,
- ncq_cb, ncq_tfs);
+ ncq_tfs->aiocb = dma_blk_write(ncq_tfs->drive->port.ifs[0].blk,
+ &ncq_tfs->sglist, ncq_tfs->lba,
+ ncq_cb, ncq_tfs);
break;
default:
DPRINTF(port, "error: tried to process non-NCQ command as NCQ\n");
@@ -943,7 +944,7 @@ static int handle_cmd(AHCIState *s, int port, int slot)
/* The device we are working for */
ide_state = &s->dev[port].port.ifs[0];
- if (!ide_state->bs) {
+ if (!ide_state->blk) {
DPRINTF(port, "error: guest accessed unused port");
goto out;
}
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index 10218df..c63b7e5 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -25,6 +25,7 @@
#include "hw/ide/internal.h"
#include "hw/scsi/scsi.h"
+#include "sysemu/block-backend.h"
static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret);
@@ -110,16 +111,16 @@ static int cd_read_sector(IDEState *s, int lba, uint8_t *buf, int sector_size)
switch(sector_size) {
case 2048:
- block_acct_start(bdrv_get_stats(s->bs), &s->acct,
+ block_acct_start(blk_get_stats(s->blk), &s->acct,
4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
- ret = bdrv_read(s->bs, (int64_t)lba << 2, buf, 4);
- block_acct_done(bdrv_get_stats(s->bs), &s->acct);
+ ret = blk_read(s->blk, (int64_t)lba << 2, buf, 4);
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
break;
case 2352:
- block_acct_start(bdrv_get_stats(s->bs), &s->acct,
+ block_acct_start(blk_get_stats(s->blk), &s->acct,
4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
- ret = bdrv_read(s->bs, (int64_t)lba << 2, buf + 16, 4);
- block_acct_done(bdrv_get_stats(s->bs), &s->acct);
+ ret = blk_read(s->blk, (int64_t)lba << 2, buf + 16, 4);
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
if (ret < 0)
return ret;
cd_data_to_raw(buf, lba);
@@ -254,7 +255,7 @@ static void ide_atapi_cmd_reply(IDEState *s, int size, int max_size)
s->io_buffer_index = 0;
if (s->atapi_dma) {
- block_acct_start(bdrv_get_stats(s->bs), &s->acct, size,
+ block_acct_start(blk_get_stats(s->blk), &s->acct, size,
BLOCK_ACCT_READ);
s->status = READY_STAT | SEEK_STAT | DRQ_STAT;
ide_start_dma(s, ide_atapi_cmd_read_dma_cb);
@@ -350,13 +351,13 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret)
s->bus->dma->iov.iov_len = n * 4 * 512;
qemu_iovec_init_external(&s->bus->dma->qiov, &s->bus->dma->iov, 1);
- s->bus->dma->aiocb = bdrv_aio_readv(s->bs, (int64_t)s->lba << 2,
+ s->bus->dma->aiocb = blk_aio_readv(s->blk, (int64_t)s->lba << 2,
&s->bus->dma->qiov, n * 4,
ide_atapi_cmd_read_dma_cb, s);
return;
eot:
- block_acct_done(bdrv_get_stats(s->bs), &s->acct);
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
ide_set_inactive(s, false);
}
@@ -371,7 +372,7 @@ static void ide_atapi_cmd_read_dma(IDEState *s, int lba, int nb_sectors,
s->io_buffer_size = 0;
s->cd_sector_size = sector_size;
- block_acct_start(bdrv_get_stats(s->bs), &s->acct, s->packet_transfer_size,
+ block_acct_start(blk_get_stats(s->blk), &s->acct, s->packet_transfer_size,
BLOCK_ACCT_READ);
/* XXX: check if BUSY_STAT should be set */
@@ -504,7 +505,7 @@ static unsigned int event_status_media(IDEState *s,
media_status = 0;
if (s->tray_open) {
media_status = MS_TRAY_OPEN;
- } else if (bdrv_is_inserted(s->bs)) {
+ } else if (blk_is_inserted(s->blk)) {
media_status = MS_MEDIA_PRESENT;
}
@@ -800,7 +801,7 @@ static void cmd_test_unit_ready(IDEState *s, uint8_t *buf)
static void cmd_prevent_allow_medium_removal(IDEState *s, uint8_t* buf)
{
s->tray_locked = buf[4] & 1;
- bdrv_lock_medium(s->bs, buf[4] & 1);
+ blk_lock_medium(s->blk, buf[4] & 1);
ide_atapi_cmd_ok(s);
}
@@ -884,14 +885,14 @@ static void cmd_start_stop_unit(IDEState *s, uint8_t* buf)
if (loej) {
if (!start && !s->tray_open && s->tray_locked) {
- sense = bdrv_is_inserted(s->bs)
+ sense = blk_is_inserted(s->blk)
? NOT_READY : ILLEGAL_REQUEST;
ide_atapi_cmd_error(s, sense, ASC_MEDIA_REMOVAL_PREVENTED);
return;
}
if (s->tray_open != !start) {
- bdrv_eject(s->bs, !start);
+ blk_eject(s->blk, !start);
s->tray_open = !start;
}
}
@@ -1125,7 +1126,7 @@ void ide_atapi_cmd(IDEState *s)
* states rely on this behavior.
*/
if (!(atapi_cmd_table[s->io_buffer[0]].flags & ALLOW_UA) &&
- !s->tray_open && bdrv_is_inserted(s->bs) && s->cdrom_changed) {
+ !s->tray_open && blk_is_inserted(s->blk) && s->cdrom_changed) {
if (s->cdrom_changed == 1) {
ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT);
@@ -1140,7 +1141,7 @@ void ide_atapi_cmd(IDEState *s)
/* Report a Not Ready condition if appropriate for the command */
if ((atapi_cmd_table[s->io_buffer[0]].flags & CHECK_READY) &&
- (!media_present(s) || !bdrv_is_inserted(s->bs)))
+ (!media_present(s) || !blk_is_inserted(s->blk)))
{
ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT);
return;
diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index 91048f2..c8b0322 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -26,7 +26,7 @@
#include <hw/i386/pc.h>
#include <hw/pci/pci.h>
#include <hw/isa/isa.h>
-#include "block/block.h"
+#include "sysemu/block-backend.h"
#include "sysemu/sysemu.h"
#include "sysemu/dma.h"
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 0505c45..a5c4698 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -31,7 +31,7 @@
#include "sysemu/sysemu.h"
#include "sysemu/dma.h"
#include "hw/block/block.h"
-#include "sysemu/blockdev.h"
+#include "sysemu/block-backend.h"
#include <hw/ide/internal.h>
@@ -158,10 +158,11 @@ static void ide_identify(IDEState *s)
put_le16(p + 84, (1 << 14) | 0);
}
/* 14 = NOP supported, 5=WCACHE enabled, 0=SMART feature set enabled */
- if (bdrv_enable_write_cache(s->bs))
- put_le16(p + 85, (1 << 14) | (1 << 5) | 1);
- else
- put_le16(p + 85, (1 << 14) | 1);
+ if (blk_enable_write_cache(s->blk)) {
+ put_le16(p + 85, (1 << 14) | (1 << 5) | 1);
+ } else {
+ put_le16(p + 85, (1 << 14) | 1);
+ }
/* 13=flush_cache_ext,12=flush_cache,10=lba48 */
put_le16(p + 86, (1 << 13) | (1 <<12) | (1 << 10));
/* 14=set to 1, 8=has WWN, 1=SMART self test, 0=SMART error logging */
@@ -350,7 +351,7 @@ static void ide_set_signature(IDEState *s)
if (s->drive_kind == IDE_CD) {
s->lcyl = 0x14;
s->hcyl = 0xeb;
- } else if (s->bs) {
+ } else if (s->blk) {
s->lcyl = 0;
s->hcyl = 0;
} else {
@@ -379,7 +380,7 @@ static void trim_aio_cancel(BlockAIOCB *acb)
iocb->ret = -ECANCELED;
if (iocb->aiocb) {
- bdrv_aio_cancel_async(iocb->aiocb);
+ blk_aio_cancel_async(iocb->aiocb);
iocb->aiocb = NULL;
}
}
@@ -438,13 +439,13 @@ static void ide_issue_trim_cb(void *opaque, int ret)
}
}
-BlockAIOCB *ide_issue_trim(BlockDriverState *bs,
+BlockAIOCB *ide_issue_trim(BlockBackend *blk,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockCompletionFunc *cb, void *opaque)
{
TrimAIOCB *iocb;
- iocb = qemu_aio_get(&trim_aiocb_info, bs, cb, opaque);
+ iocb = blk_aio_get(&trim_aiocb_info, blk, cb, opaque);
iocb->bh = qemu_bh_new(ide_trim_bh_cb, iocb);
iocb->ret = 0;
iocb->qiov = qiov;
@@ -551,7 +552,7 @@ static bool ide_sect_range_ok(IDEState *s,
{
uint64_t total_sectors;
- bdrv_get_geometry(s->bs, &total_sectors);
+ blk_get_geometry(s->blk, &total_sectors);
if (sector > total_sectors || nb_sectors > total_sectors - sector) {
return false;
}
@@ -569,7 +570,7 @@ static void ide_sector_read_cb(void *opaque, int ret)
if (ret == -ECANCELED) {
return;
}
- block_acct_done(bdrv_get_stats(s->bs), &s->acct);
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
if (ret != 0) {
if (ide_handle_rw_error(s, -ret, IDE_RETRY_PIO |
IDE_RETRY_READ)) {
@@ -625,10 +626,10 @@ void ide_sector_read(IDEState *s)
s->iov.iov_len = n * BDRV_SECTOR_SIZE;
qemu_iovec_init_external(&s->qiov, &s->iov, 1);
- block_acct_start(bdrv_get_stats(s->bs), &s->acct,
+ block_acct_start(blk_get_stats(s->blk), &s->acct,
n * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
- s->pio_aiocb = bdrv_aio_readv(s->bs, sector_num, &s->qiov, n,
- ide_sector_read_cb, s);
+ s->pio_aiocb = blk_aio_readv(s->blk, sector_num, &s->qiov, n,
+ ide_sector_read_cb, s);
}
static void dma_buf_commit(IDEState *s)
@@ -655,7 +656,7 @@ void ide_dma_error(IDEState *s)
static int ide_handle_rw_error(IDEState *s, int error, int op)
{
bool is_read = (op & IDE_RETRY_READ) != 0;
- BlockErrorAction action = bdrv_get_error_action(s->bs, is_read, error);
+ BlockErrorAction action = blk_get_error_action(s->blk, is_read, error);
if (action == BLOCK_ERROR_ACTION_STOP) {
s->bus->dma->ops->set_unit(s->bus->dma, s->unit);
@@ -668,7 +669,7 @@ static int ide_handle_rw_error(IDEState *s, int error, int op)
ide_rw_error(s);
}
}
- bdrv_error_action(s->bs, action, is_read, error);
+ blk_error_action(s->blk, action, is_read, error);
return action != BLOCK_ERROR_ACTION_IGNORE;
}
@@ -744,24 +745,24 @@ void ide_dma_cb(void *opaque, int ret)
switch (s->dma_cmd) {
case IDE_DMA_READ:
- s->bus->dma->aiocb = dma_bdrv_read(s->bs, &s->sg, sector_num,
- ide_dma_cb, s);
+ s->bus->dma->aiocb = dma_blk_read(s->blk, &s->sg, sector_num,
+ ide_dma_cb, s);
break;
case IDE_DMA_WRITE:
- s->bus->dma->aiocb = dma_bdrv_write(s->bs, &s->sg, sector_num,
- ide_dma_cb, s);
+ s->bus->dma->aiocb = dma_blk_write(s->blk, &s->sg, sector_num,
+ ide_dma_cb, s);
break;
case IDE_DMA_TRIM:
- s->bus->dma->aiocb = dma_bdrv_io(s->bs, &s->sg, sector_num,
- ide_issue_trim, ide_dma_cb, s,
- DMA_DIRECTION_TO_DEVICE);
+ s->bus->dma->aiocb = dma_blk_io(s->blk, &s->sg, sector_num,
+ ide_issue_trim, ide_dma_cb, s,
+ DMA_DIRECTION_TO_DEVICE);
break;
}
return;
eot:
if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) {
- block_acct_done(bdrv_get_stats(s->bs), &s->acct);
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
}
ide_set_inactive(s, stay_active);
}
@@ -775,11 +776,11 @@ static void ide_sector_start_dma(IDEState *s, enum ide_dma_cmd dma_cmd)
switch (dma_cmd) {
case IDE_DMA_READ:
- block_acct_start(bdrv_get_stats(s->bs), &s->acct,
+ block_acct_start(blk_get_stats(s->blk), &s->acct,
s->nsector * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
break;
case IDE_DMA_WRITE:
- block_acct_start(bdrv_get_stats(s->bs), &s->acct,
+ block_acct_start(blk_get_stats(s->blk), &s->acct,
s->nsector * BDRV_SECTOR_SIZE, BLOCK_ACCT_WRITE);
break;
default:
@@ -810,7 +811,7 @@ static void ide_sector_write_cb(void *opaque, int ret)
if (ret == -ECANCELED) {
return;
}
- block_acct_done(bdrv_get_stats(s->bs), &s->acct);
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
s->pio_aiocb = NULL;
s->status &= ~BUSY_STAT;
@@ -877,10 +878,10 @@ void ide_sector_write(IDEState *s)
s->iov.iov_len = n * BDRV_SECTOR_SIZE;
qemu_iovec_init_external(&s->qiov, &s->iov, 1);
- block_acct_start(bdrv_get_stats(s->bs), &s->acct,
+ block_acct_start(blk_get_stats(s->blk), &s->acct,
n * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
- s->pio_aiocb = bdrv_aio_writev(s->bs, sector_num, &s->qiov, n,
- ide_sector_write_cb, s);
+ s->pio_aiocb = blk_aio_writev(s->blk, sector_num, &s->qiov, n,
+ ide_sector_write_cb, s);
}
static void ide_flush_cb(void *opaque, int ret)
@@ -899,8 +900,8 @@ static void ide_flush_cb(void *opaque, int ret)
}
}
- if (s->bs) {
- block_acct_done(bdrv_get_stats(s->bs), &s->acct);
+ if (s->blk) {
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
}
s->status = READY_STAT | SEEK_STAT;
ide_cmd_done(s);
@@ -909,14 +910,14 @@ static void ide_flush_cb(void *opaque, int ret)
void ide_flush_cache(IDEState *s)
{
- if (s->bs == NULL) {
+ if (s->blk == NULL) {
ide_flush_cb(s, 0);
return;
}
s->status |= BUSY_STAT;
- block_acct_start(bdrv_get_stats(s->bs), &s->acct, 0, BLOCK_ACCT_FLUSH);
- s->pio_aiocb = bdrv_aio_flush(s->bs, ide_flush_cb, s);
+ block_acct_start(blk_get_stats(s->blk), &s->acct, 0, BLOCK_ACCT_FLUSH);
+ s->pio_aiocb = blk_aio_flush(s->blk, ide_flush_cb, s);
}
static void ide_cfata_metadata_inquiry(IDEState *s)
@@ -979,7 +980,7 @@ static void ide_cd_change_cb(void *opaque, bool load)
uint64_t nb_sectors;
s->tray_open = !load;
- bdrv_get_geometry(s->bs, &nb_sectors);
+ blk_get_geometry(s->blk, &nb_sectors);
s->nb_sectors = nb_sectors;
/*
@@ -1113,7 +1114,7 @@ static bool cmd_data_set_management(IDEState *s, uint8_t cmd)
{
switch (s->feature) {
case DSM_TRIM:
- if (s->bs) {
+ if (s->blk) {
ide_sector_start_dma(s, IDE_DMA_TRIM);
return false;
}
@@ -1126,7 +1127,7 @@ static bool cmd_data_set_management(IDEState *s, uint8_t cmd)
static bool cmd_identify(IDEState *s, uint8_t cmd)
{
- if (s->bs && s->drive_kind != IDE_CD) {
+ if (s->blk && s->drive_kind != IDE_CD) {
if (s->drive_kind != IDE_CFATA) {
ide_identify(s);
} else {
@@ -1176,7 +1177,7 @@ static bool cmd_read_multiple(IDEState *s, uint8_t cmd)
{
bool lba48 = (cmd == WIN_MULTREAD_EXT);
- if (!s->bs || !s->mult_sectors) {
+ if (!s->blk || !s->mult_sectors) {
ide_abort_command(s);
return true;
}
@@ -1192,7 +1193,7 @@ static bool cmd_write_multiple(IDEState *s, uint8_t cmd)
bool lba48 = (cmd == WIN_MULTWRITE_EXT);
int n;
- if (!s->bs || !s->mult_sectors) {
+ if (!s->blk || !s->mult_sectors) {
ide_abort_command(s);
return true;
}
@@ -1220,7 +1221,7 @@ static bool cmd_read_pio(IDEState *s, uint8_t cmd)
return true;
}
- if (!s->bs) {
+ if (!s->blk) {
ide_abort_command(s);
return true;
}
@@ -1236,7 +1237,7 @@ static bool cmd_write_pio(IDEState *s, uint8_t cmd)
{
bool lba48 = (cmd == WIN_WRITE_EXT);
- if (!s->bs) {
+ if (!s->blk) {
ide_abort_command(s);
return true;
}
@@ -1256,7 +1257,7 @@ static bool cmd_read_dma(IDEState *s, uint8_t cmd)
{
bool lba48 = (cmd == WIN_READDMA_EXT);
- if (!s->bs) {
+ if (!s->blk) {
ide_abort_command(s);
return true;
}
@@ -1271,7 +1272,7 @@ static bool cmd_write_dma(IDEState *s, uint8_t cmd)
{
bool lba48 = (cmd == WIN_WRITEDMA_EXT);
- if (!s->bs) {
+ if (!s->blk) {
ide_abort_command(s);
return true;
}
@@ -1322,7 +1323,7 @@ static bool cmd_set_features(IDEState *s, uint8_t cmd)
{
uint16_t *identify_data;
- if (!s->bs) {
+ if (!s->blk) {
ide_abort_command(s);
return true;
}
@@ -1330,12 +1331,12 @@ static bool cmd_set_features(IDEState *s, uint8_t cmd)
/* XXX: valid for CDROM ? */
switch (s->feature) {
case 0x02: /* write cache enable */
- bdrv_set_enable_write_cache(s->bs, true);
+ blk_set_enable_write_cache(s->blk, true);
identify_data = (uint16_t *)s->identify_data;
put_le16(identify_data + 85, (1 << 14) | (1 << 5) | 1);
return true;
case 0x82: /* write cache disable */
- bdrv_set_enable_write_cache(s->bs, false);
+ blk_set_enable_write_cache(s->blk, false);
identify_data = (uint16_t *)s->identify_data;
put_le16(identify_data + 85, (1 << 14) | 1);
ide_flush_cache(s);
@@ -1802,8 +1803,9 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val)
#endif
s = idebus_active_if(bus);
/* ignore commands to non existent slave */
- if (s != bus->ifs && !s->bs)
+ if (s != bus->ifs && !s->blk) {
return;
+ }
/* Only DEVICE RESET is allowed while BSY or/and DRQ are set */
if ((s->status & (BUSY_STAT|DRQ_STAT)) && val != WIN_DEVICE_RESET)
@@ -1848,59 +1850,66 @@ uint32_t ide_ioport_read(void *opaque, uint32_t addr1)
ret = 0xff;
break;
case 1:
- if ((!bus->ifs[0].bs && !bus->ifs[1].bs) ||
- (s != bus->ifs && !s->bs))
+ if ((!bus->ifs[0].blk && !bus->ifs[1].blk) ||
+ (s != bus->ifs && !s->blk)) {
ret = 0;
- else if (!hob)
+ } else if (!hob) {
ret = s->error;
- else
+ } else {
ret = s->hob_feature;
+ }
break;
case 2:
- if (!bus->ifs[0].bs && !bus->ifs[1].bs)
+ if (!bus->ifs[0].blk && !bus->ifs[1].blk) {
ret = 0;
- else if (!hob)
+ } else if (!hob) {
ret = s->nsector & 0xff;
- else
+ } else {
ret = s->hob_nsector;
+ }
break;
case 3:
- if (!bus->ifs[0].bs && !bus->ifs[1].bs)
+ if (!bus->ifs[0].blk && !bus->ifs[1].blk) {
ret = 0;
- else if (!hob)
+ } else if (!hob) {
ret = s->sector;
- else
+ } else {
ret = s->hob_sector;
+ }
break;
case 4:
- if (!bus->ifs[0].bs && !bus->ifs[1].bs)
+ if (!bus->ifs[0].blk && !bus->ifs[1].blk) {
ret = 0;
- else if (!hob)
+ } else if (!hob) {
ret = s->lcyl;
- else
+ } else {
ret = s->hob_lcyl;
+ }
break;
case 5:
- if (!bus->ifs[0].bs && !bus->ifs[1].bs)
+ if (!bus->ifs[0].blk && !bus->ifs[1].blk) {
ret = 0;
- else if (!hob)
+ } else if (!hob) {
ret = s->hcyl;
- else
+ } else {
ret = s->hob_hcyl;
+ }
break;
case 6:
- if (!bus->ifs[0].bs && !bus->ifs[1].bs)
+ if (!bus->ifs[0].blk && !bus->ifs[1].blk) {
ret = 0;
- else
+ } else {
ret = s->select;
+ }
break;
default:
case 7:
- if ((!bus->ifs[0].bs && !bus->ifs[1].bs) ||
- (s != bus->ifs && !s->bs))
+ if ((!bus->ifs[0].blk && !bus->ifs[1].blk) ||
+ (s != bus->ifs && !s->blk)) {
ret = 0;
- else
+ } else {
ret = s->status;
+ }
qemu_irq_lower(bus->irq);
break;
}
@@ -1916,11 +1925,12 @@ uint32_t ide_status_read(void *opaque, uint32_t addr)
IDEState *s = idebus_active_if(bus);
int ret;
- if ((!bus->ifs[0].bs && !bus->ifs[1].bs) ||
- (s != bus->ifs && !s->bs))
+ if ((!bus->ifs[0].blk && !bus->ifs[1].blk) ||
+ (s != bus->ifs && !s->blk)) {
ret = 0;
- else
+ } else {
ret = s->status;
+ }
#ifdef DEBUG_IDE
printf("ide: read status addr=0x%x val=%02x\n", addr, ret);
#endif
@@ -2081,7 +2091,7 @@ static void ide_reset(IDEState *s)
#endif
if (s->pio_aiocb) {
- bdrv_aio_cancel(s->pio_aiocb);
+ blk_aio_cancel(s->pio_aiocb);
s->pio_aiocb = NULL;
}
@@ -2145,7 +2155,7 @@ void ide_bus_reset(IDEBus *bus)
#ifdef DEBUG_AIO
printf("aio_cancel\n");
#endif
- bdrv_aio_cancel(bus->dma->aiocb);
+ blk_aio_cancel(bus->dma->aiocb);
bus->dma->aiocb = NULL;
}
@@ -2174,7 +2184,7 @@ static void ide_resize_cb(void *opaque)
return;
}
- bdrv_get_geometry(s->bs, &nb_sectors);
+ blk_get_geometry(s->blk, &nb_sectors);
s->nb_sectors = nb_sectors;
/* Update the identify data buffer. */
@@ -2198,7 +2208,7 @@ static const BlockDevOps ide_hd_block_ops = {
.resize_cb = ide_resize_cb,
};
-int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
+int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind,
const char *version, const char *serial, const char *model,
uint64_t wwn,
uint32_t cylinders, uint32_t heads, uint32_t secs,
@@ -2206,10 +2216,10 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
{
uint64_t nb_sectors;
- s->bs = bs;
+ s->blk = blk;
s->drive_kind = kind;
- bdrv_get_geometry(bs, &nb_sectors);
+ blk_get_geometry(blk, &nb_sectors);
s->cylinders = cylinders;
s->heads = heads;
s->sectors = secs;
@@ -2223,18 +2233,18 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
s->smart_errors = 0;
s->smart_selftest_count = 0;
if (kind == IDE_CD) {
- bdrv_set_dev_ops(bs, &ide_cd_block_ops, s);
- bdrv_set_guest_block_size(bs, 2048);
+ blk_set_dev_ops(blk, &ide_cd_block_ops, s);
+ blk_set_guest_block_size(blk, 2048);
} else {
- if (!bdrv_is_inserted(s->bs)) {
+ if (!blk_is_inserted(s->blk)) {
error_report("Device needs media, but drive is empty");
return -1;
}
- if (bdrv_is_read_only(bs)) {
+ if (blk_is_read_only(blk)) {
error_report("Can't use a read-only drive");
return -1;
}
- bdrv_set_dev_ops(bs, &ide_hd_block_ops, s);
+ blk_set_dev_ops(blk, &ide_hd_block_ops, s);
}
if (serial) {
pstrcpy(s->drive_serial_str, sizeof(s->drive_serial_str), serial);
@@ -2265,7 +2275,7 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
}
ide_reset(s);
- bdrv_iostatus_enable(bs);
+ blk_iostatus_enable(blk);
return 0;
}
@@ -2282,7 +2292,7 @@ static void ide_init1(IDEBus *bus, int unit)
s->io_buffer = qemu_memalign(2048, s->io_buffer_total_len);
memset(s->io_buffer, 0, s->io_buffer_total_len);
- s->smart_selftest_data = qemu_blockalign(s->bs, 512);
+ s->smart_selftest_data = blk_blockalign(s->blk, 512);
memset(s->smart_selftest_data, 0, 512);
s->sector_write_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
@@ -2377,7 +2387,7 @@ static int ide_drive_post_load(void *opaque, int version_id)
IDEState *s = opaque;
if (s->identify_set) {
- bdrv_set_enable_write_cache(s->bs, !!(s->identify_data[85] & (1 << 5)));
+ blk_set_enable_write_cache(s->blk, !!(s->identify_data[85] & (1 << 5)));
}
return 0;
}
diff --git a/hw/ide/ich.c b/hw/ide/ich.c
index 8eb77a1..fb1d095 100644
--- a/hw/ide/ich.c
+++ b/hw/ide/ich.c
@@ -65,7 +65,7 @@
#include <hw/i386/pc.h>
#include <hw/pci/pci.h>
#include <hw/isa/isa.h>
-#include "block/block.h"
+#include "sysemu/block-backend.h"
#include "sysemu/dma.h"
#include <hw/ide/pci.h>
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index 9314c80..68ac610 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -373,7 +373,7 @@ struct IDEState {
/* set for lba48 access */
uint8_t lba48;
- BlockDriverState *bs;
+ BlockBackend *blk;
char version[9];
/* ATAPI specific */
struct unreported_events events;
@@ -537,7 +537,7 @@ uint32_t ide_data_readw(void *opaque, uint32_t addr);
void ide_data_writel(void *opaque, uint32_t addr, uint32_t val);
uint32_t ide_data_readl(void *opaque, uint32_t addr);
-int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
+int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind,
const char *version, const char *serial, const char *model,
uint64_t wwn,
uint32_t cylinders, uint32_t heads, uint32_t secs,
@@ -555,7 +555,7 @@ void ide_transfer_start(IDEState *s, uint8_t *buf, int size,
EndTransferFunc *end_transfer_func);
void ide_transfer_stop(IDEState *s);
void ide_set_inactive(IDEState *s, bool more);
-BlockAIOCB *ide_issue_trim(BlockDriverState *bs,
+BlockAIOCB *ide_issue_trim(BlockBackend *blk,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockCompletionFunc *cb, void *opaque);
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index 4cbcb1c..b084162 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -25,7 +25,7 @@
#include <hw/hw.h>
#include <hw/i386/pc.h>
#include <hw/isa/isa.h>
-#include "block/block.h"
+#include "sysemu/block-backend.h"
#include "sysemu/dma.h"
#include <hw/ide/internal.h>
diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index 6b5cce5..9a55407 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -25,7 +25,7 @@
#include "hw/hw.h"
#include "hw/ppc/mac.h"
#include "hw/ppc/mac_dbdma.h"
-#include "block/block.h"
+#include "sysemu/block-backend.h"
#include "sysemu/dma.h"
#include <hw/ide/internal.h>
@@ -134,7 +134,7 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
MACIO_DPRINTF("precopying unaligned %d bytes to %#" HWADDR_PRIx "\n",
unaligned, io->addr + io->len - unaligned);
- bdrv_read(s->bs, sector_num + nsector, io->remainder, 1);
+ blk_read(s->blk, sector_num + nsector, io->remainder, 1);
cpu_physical_memory_write(io->addr + io->len - unaligned,
io->remainder, unaligned);
@@ -164,14 +164,14 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
(s->lba << 2) + (s->io_buffer_index >> 9),
s->packet_transfer_size, s->dma_cmd);
- m->aiocb = dma_bdrv_read(s->bs, &s->sg,
- (int64_t)(s->lba << 2) + (s->io_buffer_index >> 9),
- pmac_ide_atapi_transfer_cb, io);
+ m->aiocb = dma_blk_read(s->blk, &s->sg,
+ (int64_t)(s->lba << 2) + (s->io_buffer_index >> 9),
+ pmac_ide_atapi_transfer_cb, io);
return;
done:
MACIO_DPRINTF("done DMA\n");
- block_acct_done(bdrv_get_stats(s->bs), &s->acct);
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
io->dma_end(opaque);
}
@@ -254,8 +254,8 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
qemu_iovec_reset(&io->iov);
qemu_iovec_add(&io->iov, io->remainder, 0x200);
- m->aiocb = bdrv_aio_writev(s->bs, sector_num - 1, &io->iov, 1,
- pmac_ide_transfer_cb, io);
+ m->aiocb = blk_aio_writev(s->blk, sector_num - 1, &io->iov, 1,
+ pmac_ide_transfer_cb, io);
}
}
@@ -294,8 +294,8 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
qemu_iovec_reset(&io->iov);
qemu_iovec_add(&io->iov, io->remainder, 0x200);
- m->aiocb = bdrv_aio_readv(s->bs, sector_num + nsector, &io->iov, 1,
- pmac_ide_transfer_cb, io);
+ m->aiocb = blk_aio_readv(s->blk, sector_num + nsector, &io->iov, 1,
+ pmac_ide_transfer_cb, io);
break;
case IDE_DMA_WRITE:
/* cache the contents in our io struct */
@@ -333,17 +333,17 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
switch (s->dma_cmd) {
case IDE_DMA_READ:
- m->aiocb = dma_bdrv_read(s->bs, &s->sg, sector_num,
- pmac_ide_transfer_cb, io);
+ m->aiocb = dma_blk_read(s->blk, &s->sg, sector_num,
+ pmac_ide_transfer_cb, io);
break;
case IDE_DMA_WRITE:
- m->aiocb = dma_bdrv_write(s->bs, &s->sg, sector_num,
- pmac_ide_transfer_cb, io);
+ m->aiocb = dma_blk_write(s->blk, &s->sg, sector_num,
+ pmac_ide_transfer_cb, io);
break;
case IDE_DMA_TRIM:
- m->aiocb = dma_bdrv_io(s->bs, &s->sg, sector_num,
- ide_issue_trim, pmac_ide_transfer_cb, io,
- DMA_DIRECTION_TO_DEVICE);
+ m->aiocb = dma_blk_io(s->blk, &s->sg, sector_num,
+ ide_issue_trim, pmac_ide_transfer_cb, io,
+ DMA_DIRECTION_TO_DEVICE);
break;
}
@@ -352,7 +352,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
done:
if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) {
- block_acct_done(bdrv_get_stats(s->bs), &s->acct);
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
}
io->dma_end(io);
}
@@ -370,7 +370,7 @@ static void pmac_ide_transfer(DBDMA_io *io)
/* Handle non-block ATAPI DMA transfers */
if (s->lba == -1) {
s->io_buffer_size = MIN(io->len, s->packet_transfer_size);
- block_acct_start(bdrv_get_stats(s->bs), &s->acct, s->io_buffer_size,
+ block_acct_start(blk_get_stats(s->blk), &s->acct, s->io_buffer_size,
BLOCK_ACCT_READ);
MACIO_DPRINTF("non-block ATAPI DMA transfer size: %d\n",
s->io_buffer_size);
@@ -382,12 +382,12 @@ static void pmac_ide_transfer(DBDMA_io *io)
m->dma_active = false;
MACIO_DPRINTF("end of non-block ATAPI DMA transfer\n");
- block_acct_done(bdrv_get_stats(s->bs), &s->acct);
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
io->dma_end(io);
return;
}
- block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len,
+ block_acct_start(blk_get_stats(s->blk), &s->acct, io->len,
BLOCK_ACCT_READ);
pmac_ide_atapi_transfer_cb(io, 0);
return;
@@ -395,11 +395,11 @@ static void pmac_ide_transfer(DBDMA_io *io)
switch (s->dma_cmd) {
case IDE_DMA_READ:
- block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len,
+ block_acct_start(blk_get_stats(s->blk), &s->acct, io->len,
BLOCK_ACCT_READ);
break;
case IDE_DMA_WRITE:
- block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len,
+ block_acct_start(blk_get_stats(s->blk), &s->acct, io->len,
BLOCK_ACCT_WRITE);
break;
default:
@@ -415,7 +415,7 @@ static void pmac_ide_flush(DBDMA_io *io)
MACIOIDEState *m = io->opaque;
if (m->aiocb) {
- bdrv_drain_all();
+ blk_drain_all();
}
}
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
index 15671b8..ed85185 100644
--- a/hw/ide/microdrive.c
+++ b/hw/ide/microdrive.c
@@ -25,7 +25,7 @@
#include <hw/hw.h>
#include <hw/i386/pc.h>
#include <hw/pcmcia.h>
-#include "block/block.h"
+#include "sysemu/block-backend.h"
#include "sysemu/dma.h"
#include <hw/ide/internal.h>
@@ -247,7 +247,7 @@ static uint16_t md_common_read(PCMCIACardState *card, uint32_t at)
return ide_ioport_read(&s->bus, 0x1);
case 0xe: /* Alternate Status */
ifs = idebus_active_if(&s->bus);
- if (ifs->bs) {
+ if (ifs->blk) {
return ifs->status;
} else {
return 0;
diff --git a/hw/ide/mmio.c b/hw/ide/mmio.c
index 334c8cc..b6ce62a 100644
--- a/hw/ide/mmio.c
+++ b/hw/ide/mmio.c
@@ -24,7 +24,7 @@
*/
#include "hw/hw.h"
#include "hw/sysbus.h"
-#include "block/block.h"
+#include "sysemu/block-backend.h"
#include "sysemu/dma.h"
#include <hw/ide/internal.h>
diff --git a/hw/ide/pci.c b/hw/ide/pci.c
index 6ff1c58..2dad50e 100644
--- a/hw/ide/pci.c
+++ b/hw/ide/pci.c
@@ -26,7 +26,7 @@
#include <hw/i386/pc.h>
#include <hw/pci/pci.h>
#include <hw/isa/isa.h>
-#include "block/block.h"
+#include "sysemu/block-backend.h"
#include "sysemu/dma.h"
#include <hw/ide/pci.h>
@@ -302,7 +302,7 @@ void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val)
* aio operation with preadv/pwritev.
*/
if (bm->bus->dma->aiocb) {
- bdrv_drain_all();
+ blk_drain_all();
assert(bm->bus->dma->aiocb == NULL);
}
bm->status &= ~BM_STATUS_DMAING;
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index 0e87e51..574b9c1 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -28,7 +28,6 @@
#include <hw/pci/pci.h>
#include <hw/isa/isa.h>
#include "sysemu/block-backend.h"
-#include "sysemu/blockdev.h"
#include "sysemu/sysemu.h"
#include "sysemu/dma.h"
@@ -180,12 +179,11 @@ int pci_piix3_xen_ide_unplug(DeviceState *dev)
di = drive_get_by_index(IF_IDE, i);
if (di != NULL && !di->media_cd) {
BlockBackend *blk = blk_by_legacy_dinfo(di);
- BlockDriverState *bs = blk_bs(blk);
- DeviceState *ds = bdrv_get_attached_dev(bs);
+ DeviceState *ds = blk_get_attached_dev(blk);
if (ds) {
- bdrv_detach_dev(bs, ds);
+ blk_detach_dev(blk, ds);
}
- pci_ide->bus[di->bus].ifs[di->unit].bs = NULL;
+ pci_ide->bus[di->bus].ifs[di->unit].blk = NULL;
blk_unref(blk);
}
}
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 816167b..600e67c 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -73,7 +73,7 @@ static int ide_qdev_init(DeviceState *qdev)
IDEDeviceClass *dc = IDE_DEVICE_GET_CLASS(dev);
IDEBus *bus = DO_UPCAST(IDEBus, qbus, qdev->parent_bus);
- if (!dev->conf.bs) {
+ if (!dev->conf.blk) {
error_report("No drive specified");
goto err;
}
@@ -118,8 +118,7 @@ IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive)
dev = qdev_create(&bus->qbus, drive->media_cd ? "ide-cd" : "ide-hd");
qdev_prop_set_uint32(dev, "unit", unit);
- qdev_prop_set_drive_nofail(dev, "drive",
- blk_bs(blk_by_legacy_dinfo(drive)));
+ qdev_prop_set_drive_nofail(dev, "drive", blk_by_legacy_dinfo(drive));
qdev_init_nofail(dev);
return DO_UPCAST(IDEDevice, qdev, dev);
}
@@ -129,7 +128,7 @@ int ide_get_geometry(BusState *bus, int unit,
{
IDEState *s = &DO_UPCAST(IDEBus, qbus, bus)->ifs[unit];
- if (s->drive_kind != IDE_HD || !s->bs) {
+ if (s->drive_kind != IDE_HD || !s->blk) {
return -1;
}
@@ -174,7 +173,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
}
}
- if (ide_init_drive(s, dev->conf.bs, kind,
+ if (ide_init_drive(s, dev->conf.blk, kind,
dev->version, dev->serial, dev->model, dev->wwn,
dev->conf.cyls, dev->conf.heads, dev->conf.secs,
dev->chs_trans) < 0) {
@@ -251,7 +250,7 @@ static int ide_cd_initfn(IDEDevice *dev)
static int ide_drive_initfn(IDEDevice *dev)
{
- DriveInfo *dinfo = drive_get_by_blockdev(dev->conf.bs);
+ DriveInfo *dinfo = blk_legacy_dinfo(dev->conf.blk);
return ide_dev_initfn(dev, dinfo->media_cd ? IDE_CD : IDE_HD);
}
diff --git a/hw/ide/via.c b/hw/ide/via.c
index 89d27b4..4d8089d 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -27,7 +27,7 @@
#include <hw/i386/pc.h>
#include <hw/pci/pci.h>
#include <hw/isa/isa.h>
-#include "block/block.h"
+#include "sysemu/block-backend.h"
#include "sysemu/sysemu.h"
#include "sysemu/dma.h"
OpenPOWER on IntegriCloud