mirror of https://gitee.com/openkylin/qemu.git
-----BEGIN PGP SIGNATURE-----
iQIcBAABAgAGBQJYEm6NAAoJEH3vgQaq/DkO+30P/0n5EYgIZQugvUXJvpu0xx7V EDqtgrirRTtKaoApqiY36U3WbWK+1pPdMcdJ2z4bI9+VyYkKxlEisgEeGy2E7S33 qD1kV+L1NabBV8Ee577wxAZz3xl4MBh1pzCIXsySA2VRNg/W6L8hj4rTmjap1U9p ZtbLkmwMpSwTkJxWPG1W+k0klk1tYxmcwsWcCSCuSOTXm/0gBpWdy5gBRuQXVi0l DQFlKS6BDlRiCvR4Qix6n0v8VTQfbRMGS40M6tpr3/QH/HvoKhxfTS/g8P72Bk20 DPNsKF9DBfTY3KCtjcSrPTREaMqFw8VXn5XSw1uE30ALZNHru9PpVS3hbLfGmltB HAVANMbqROFvkQghtGWD7f34Oks/bxzLKxEXPAs9stwvthV46KyJsMHuiSbuzJhv tOUq0MadEquuVvgDqoRYKrwyYrjsRRZ4z5kDDnOr2iGZK+Mrhq7jBuYuKcvHyQi0 apd27X4wwQTx/9tavC+ujeuVxAWBlSSP1EVGSiIenlq21cHLowuZdqrt2swAYkCs VlUyOzdCO/62SJGcrnrRCj3sKWbPTySnmDZQKrHve4rBzcL28IHCRxIfzbXRBkQI kGigceOwIyNW/bnp6rSYoBFKpz1NF2VScr/t5JzknsC8gT/tA0wPDBoIeL/kPVHm T/qOTHLDY/fHUNwXOkTe =tz25 -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging # gpg: Signature made Thu 27 Oct 2016 22:15:57 BST # gpg: using RSA key 0x7DEF8106AAFC390E # gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>" # Primary key fingerprint: FAEB 9711 A12C F475 812F 18F2 88A9 064D 1835 61EB # Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76 CBD0 7DEF 8106 AAFC 390E * remotes/jnsnow/tags/ide-pull-request: qemu-iotests: Test creating floppy drives fdc: Move qdev properties to FloppyDrive fdc: Add a floppy drive qdev fdc: Add a floppy qbus macio: switch over to new byte-aligned DMA helpers dma-helpers: explicitly pass alignment into DMA helpers Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
fd209e4a77
|
@ -73,6 +73,7 @@ typedef struct {
|
|||
AioContext *ctx;
|
||||
BlockAIOCB *acb;
|
||||
QEMUSGList *sg;
|
||||
uint32_t align;
|
||||
uint64_t offset;
|
||||
DMADirection dir;
|
||||
int sg_cur_index;
|
||||
|
@ -160,8 +161,9 @@ static void dma_blk_cb(void *opaque, int ret)
|
|||
return;
|
||||
}
|
||||
|
||||
if (dbs->iov.size & ~BDRV_SECTOR_MASK) {
|
||||
qemu_iovec_discard_back(&dbs->iov, dbs->iov.size & ~BDRV_SECTOR_MASK);
|
||||
if (!QEMU_IS_ALIGNED(dbs->iov.size, dbs->align)) {
|
||||
qemu_iovec_discard_back(&dbs->iov,
|
||||
QEMU_ALIGN_DOWN(dbs->iov.size, dbs->align));
|
||||
}
|
||||
|
||||
dbs->acb = dbs->io_func(dbs->offset, &dbs->iov,
|
||||
|
@ -199,7 +201,7 @@ static const AIOCBInfo dma_aiocb_info = {
|
|||
};
|
||||
|
||||
BlockAIOCB *dma_blk_io(AioContext *ctx,
|
||||
QEMUSGList *sg, uint64_t offset,
|
||||
QEMUSGList *sg, uint64_t offset, uint32_t align,
|
||||
DMAIOFunc *io_func, void *io_func_opaque,
|
||||
BlockCompletionFunc *cb,
|
||||
void *opaque, DMADirection dir)
|
||||
|
@ -212,6 +214,7 @@ BlockAIOCB *dma_blk_io(AioContext *ctx,
|
|||
dbs->sg = sg;
|
||||
dbs->ctx = ctx;
|
||||
dbs->offset = offset;
|
||||
dbs->align = align;
|
||||
dbs->sg_cur_index = 0;
|
||||
dbs->sg_cur_byte = 0;
|
||||
dbs->dir = dir;
|
||||
|
@ -234,11 +237,11 @@ BlockAIOCB *dma_blk_read_io_func(int64_t offset, QEMUIOVector *iov,
|
|||
}
|
||||
|
||||
BlockAIOCB *dma_blk_read(BlockBackend *blk,
|
||||
QEMUSGList *sg, uint64_t offset,
|
||||
QEMUSGList *sg, uint64_t offset, uint32_t align,
|
||||
void (*cb)(void *opaque, int ret), void *opaque)
|
||||
{
|
||||
return dma_blk_io(blk_get_aio_context(blk),
|
||||
sg, offset, dma_blk_read_io_func, blk, cb, opaque,
|
||||
return dma_blk_io(blk_get_aio_context(blk), sg, offset, align,
|
||||
dma_blk_read_io_func, blk, cb, opaque,
|
||||
DMA_DIRECTION_FROM_DEVICE);
|
||||
}
|
||||
|
||||
|
@ -252,11 +255,11 @@ BlockAIOCB *dma_blk_write_io_func(int64_t offset, QEMUIOVector *iov,
|
|||
}
|
||||
|
||||
BlockAIOCB *dma_blk_write(BlockBackend *blk,
|
||||
QEMUSGList *sg, uint64_t offset,
|
||||
QEMUSGList *sg, uint64_t offset, uint32_t align,
|
||||
void (*cb)(void *opaque, int ret), void *opaque)
|
||||
{
|
||||
return dma_blk_io(blk_get_aio_context(blk),
|
||||
sg, offset, dma_blk_write_io_func, blk, cb, opaque,
|
||||
return dma_blk_io(blk_get_aio_context(blk), sg, offset, align,
|
||||
dma_blk_write_io_func, blk, cb, opaque,
|
||||
DMA_DIRECTION_TO_DEVICE);
|
||||
}
|
||||
|
||||
|
|
271
hw/block/fdc.c
271
hw/block/fdc.c
|
@ -35,6 +35,7 @@
|
|||
#include "qemu/timer.h"
|
||||
#include "hw/isa/isa.h"
|
||||
#include "hw/sysbus.h"
|
||||
#include "hw/block/block.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
#include "sysemu/blockdev.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
|
@ -52,6 +53,35 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* qdev floppy bus */
|
||||
|
||||
#define TYPE_FLOPPY_BUS "floppy-bus"
|
||||
#define FLOPPY_BUS(obj) OBJECT_CHECK(FloppyBus, (obj), TYPE_FLOPPY_BUS)
|
||||
|
||||
typedef struct FDCtrl FDCtrl;
|
||||
typedef struct FDrive FDrive;
|
||||
static FDrive *get_drv(FDCtrl *fdctrl, int unit);
|
||||
|
||||
typedef struct FloppyBus {
|
||||
BusState bus;
|
||||
FDCtrl *fdc;
|
||||
} FloppyBus;
|
||||
|
||||
static const TypeInfo floppy_bus_info = {
|
||||
.name = TYPE_FLOPPY_BUS,
|
||||
.parent = TYPE_BUS,
|
||||
.instance_size = sizeof(FloppyBus),
|
||||
};
|
||||
|
||||
static void floppy_bus_create(FDCtrl *fdc, FloppyBus *bus, DeviceState *dev)
|
||||
{
|
||||
qbus_create_inplace(bus, sizeof(FloppyBus), TYPE_FLOPPY_BUS, dev, NULL);
|
||||
bus->fdc = fdc;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* Floppy drive emulation */
|
||||
|
||||
|
@ -148,14 +178,12 @@ static FDriveSize drive_size(FloppyDriveType drive)
|
|||
#define FD_SECTOR_SC 2 /* Sector size code */
|
||||
#define FD_RESET_SENSEI_COUNT 4 /* Number of sense interrupts on RESET */
|
||||
|
||||
typedef struct FDCtrl FDCtrl;
|
||||
|
||||
/* Floppy disk drive emulation */
|
||||
typedef enum FDiskFlags {
|
||||
FDISK_DBL_SIDES = 0x01,
|
||||
} FDiskFlags;
|
||||
|
||||
typedef struct FDrive {
|
||||
struct FDrive {
|
||||
FDCtrl *fdctrl;
|
||||
BlockBackend *blk;
|
||||
/* Drive status */
|
||||
|
@ -176,7 +204,7 @@ typedef struct FDrive {
|
|||
uint8_t media_rate; /* Data rate of medium */
|
||||
|
||||
bool media_validated; /* Have we validated the media? */
|
||||
} FDrive;
|
||||
};
|
||||
|
||||
|
||||
static FloppyDriveType get_fallback_drive_type(FDrive *drv);
|
||||
|
@ -441,6 +469,135 @@ static void fd_revalidate(FDrive *drv)
|
|||
}
|
||||
}
|
||||
|
||||
static void fd_change_cb(void *opaque, bool load)
|
||||
{
|
||||
FDrive *drive = opaque;
|
||||
|
||||
drive->media_changed = 1;
|
||||
drive->media_validated = false;
|
||||
fd_revalidate(drive);
|
||||
}
|
||||
|
||||
static const BlockDevOps fd_block_ops = {
|
||||
.change_media_cb = fd_change_cb,
|
||||
};
|
||||
|
||||
|
||||
#define TYPE_FLOPPY_DRIVE "floppy"
|
||||
#define FLOPPY_DRIVE(obj) \
|
||||
OBJECT_CHECK(FloppyDrive, (obj), TYPE_FLOPPY_DRIVE)
|
||||
|
||||
typedef struct FloppyDrive {
|
||||
DeviceState qdev;
|
||||
uint32_t unit;
|
||||
BlockConf conf;
|
||||
FloppyDriveType type;
|
||||
} FloppyDrive;
|
||||
|
||||
static Property floppy_drive_properties[] = {
|
||||
DEFINE_PROP_UINT32("unit", FloppyDrive, unit, -1),
|
||||
DEFINE_BLOCK_PROPERTIES(FloppyDrive, conf),
|
||||
DEFINE_PROP_DEFAULT("drive-type", FloppyDrive, type,
|
||||
FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
|
||||
FloppyDriveType),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
static int floppy_drive_init(DeviceState *qdev)
|
||||
{
|
||||
FloppyDrive *dev = FLOPPY_DRIVE(qdev);
|
||||
FloppyBus *bus = FLOPPY_BUS(qdev->parent_bus);
|
||||
FDrive *drive;
|
||||
int ret;
|
||||
|
||||
if (dev->unit == -1) {
|
||||
for (dev->unit = 0; dev->unit < MAX_FD; dev->unit++) {
|
||||
drive = get_drv(bus->fdc, dev->unit);
|
||||
if (!drive->blk) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dev->unit >= MAX_FD) {
|
||||
error_report("Can't create floppy unit %d, bus supports only %d units",
|
||||
dev->unit, MAX_FD);
|
||||
return -1;
|
||||
}
|
||||
|
||||
drive = get_drv(bus->fdc, dev->unit);
|
||||
if (drive->blk) {
|
||||
error_report("Floppy unit %d is in use", dev->unit);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!dev->conf.blk) {
|
||||
/* Anonymous BlockBackend for an empty drive */
|
||||
dev->conf.blk = blk_new();
|
||||
ret = blk_attach_dev(dev->conf.blk, qdev);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
blkconf_blocksizes(&dev->conf);
|
||||
if (dev->conf.logical_block_size != 512 ||
|
||||
dev->conf.physical_block_size != 512)
|
||||
{
|
||||
error_report("Physical and logical block size must be 512 for floppy");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* rerror/werror aren't supported by fdc and therefore not even registered
|
||||
* with qdev. So set the defaults manually before they are used in
|
||||
* blkconf_apply_backend_options(). */
|
||||
dev->conf.rerror = BLOCKDEV_ON_ERROR_AUTO;
|
||||
dev->conf.werror = BLOCKDEV_ON_ERROR_AUTO;
|
||||
blkconf_apply_backend_options(&dev->conf);
|
||||
|
||||
/* 'enospc' is the default for -drive, 'report' is what blk_new() gives us
|
||||
* for empty drives. */
|
||||
if (blk_get_on_error(dev->conf.blk, 0) != BLOCKDEV_ON_ERROR_ENOSPC &&
|
||||
blk_get_on_error(dev->conf.blk, 0) != BLOCKDEV_ON_ERROR_REPORT) {
|
||||
error_report("fdc doesn't support drive option werror");
|
||||
return -1;
|
||||
}
|
||||
if (blk_get_on_error(dev->conf.blk, 1) != BLOCKDEV_ON_ERROR_REPORT) {
|
||||
error_report("fdc doesn't support drive option rerror");
|
||||
return -1;
|
||||
}
|
||||
|
||||
drive->blk = dev->conf.blk;
|
||||
drive->fdctrl = bus->fdc;
|
||||
|
||||
fd_init(drive);
|
||||
blk_set_dev_ops(drive->blk, &fd_block_ops, drive);
|
||||
|
||||
/* Keep 'type' qdev property and FDrive->drive in sync */
|
||||
drive->drive = dev->type;
|
||||
pick_drive_type(drive);
|
||||
dev->type = drive->drive;
|
||||
|
||||
fd_revalidate(drive);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void floppy_drive_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *k = DEVICE_CLASS(klass);
|
||||
k->init = floppy_drive_init;
|
||||
set_bit(DEVICE_CATEGORY_STORAGE, k->categories);
|
||||
k->bus_type = TYPE_FLOPPY_BUS;
|
||||
k->props = floppy_drive_properties;
|
||||
k->desc = "virtual floppy drive";
|
||||
}
|
||||
|
||||
static const TypeInfo floppy_drive_info = {
|
||||
.name = TYPE_FLOPPY_DRIVE,
|
||||
.parent = TYPE_DEVICE,
|
||||
.instance_size = sizeof(FloppyDrive),
|
||||
.class_init = floppy_drive_class_init,
|
||||
};
|
||||
|
||||
/********************************************************/
|
||||
/* Intel 82078 floppy disk controller emulation */
|
||||
|
||||
|
@ -684,8 +841,13 @@ struct FDCtrl {
|
|||
/* Power down config (also with status regB access mode */
|
||||
uint8_t pwrd;
|
||||
/* Floppy drives */
|
||||
FloppyBus bus;
|
||||
uint8_t num_floppies;
|
||||
FDrive drives[MAX_FD];
|
||||
struct {
|
||||
BlockBackend *blk;
|
||||
FloppyDriveType type;
|
||||
} qdev_for_drives[MAX_FD];
|
||||
int reset_sensei;
|
||||
uint32_t check_media_rate;
|
||||
FloppyDriveType fallback; /* type=auto failure fallback */
|
||||
|
@ -1159,9 +1321,9 @@ static inline FDrive *drv3(FDCtrl *fdctrl)
|
|||
}
|
||||
#endif
|
||||
|
||||
static FDrive *get_cur_drv(FDCtrl *fdctrl)
|
||||
static FDrive *get_drv(FDCtrl *fdctrl, int unit)
|
||||
{
|
||||
switch (fdctrl->cur_drv) {
|
||||
switch (unit) {
|
||||
case 0: return drv0(fdctrl);
|
||||
case 1: return drv1(fdctrl);
|
||||
#if MAX_FD == 4
|
||||
|
@ -1172,6 +1334,11 @@ static FDrive *get_cur_drv(FDCtrl *fdctrl)
|
|||
}
|
||||
}
|
||||
|
||||
static FDrive *get_cur_drv(FDCtrl *fdctrl)
|
||||
{
|
||||
return get_drv(fdctrl, fdctrl->cur_drv);
|
||||
}
|
||||
|
||||
/* Status A register : 0x00 (read-only) */
|
||||
static uint32_t fdctrl_read_statusA(FDCtrl *fdctrl)
|
||||
{
|
||||
|
@ -2331,46 +2498,49 @@ static void fdctrl_result_timer(void *opaque)
|
|||
}
|
||||
}
|
||||
|
||||
static void fdctrl_change_cb(void *opaque, bool load)
|
||||
{
|
||||
FDrive *drive = opaque;
|
||||
|
||||
drive->media_changed = 1;
|
||||
drive->media_validated = false;
|
||||
fd_revalidate(drive);
|
||||
}
|
||||
|
||||
static const BlockDevOps fdctrl_block_ops = {
|
||||
.change_media_cb = fdctrl_change_cb,
|
||||
};
|
||||
|
||||
/* Init functions */
|
||||
static void fdctrl_connect_drives(FDCtrl *fdctrl, Error **errp)
|
||||
static void fdctrl_connect_drives(FDCtrl *fdctrl, Error **errp,
|
||||
DeviceState *fdc_dev)
|
||||
{
|
||||
unsigned int i;
|
||||
FDrive *drive;
|
||||
DeviceState *dev;
|
||||
BlockBackend *blk;
|
||||
Error *local_err = NULL;
|
||||
|
||||
for (i = 0; i < MAX_FD; i++) {
|
||||
drive = &fdctrl->drives[i];
|
||||
drive->fdctrl = fdctrl;
|
||||
|
||||
if (drive->blk) {
|
||||
if (blk_get_on_error(drive->blk, 0) != BLOCKDEV_ON_ERROR_ENOSPC) {
|
||||
error_setg(errp, "fdc doesn't support drive option werror");
|
||||
return;
|
||||
}
|
||||
if (blk_get_on_error(drive->blk, 1) != BLOCKDEV_ON_ERROR_REPORT) {
|
||||
error_setg(errp, "fdc doesn't support drive option rerror");
|
||||
return;
|
||||
}
|
||||
/* If the drive is not present, we skip creating the qdev device, but
|
||||
* still have to initialise the controller. */
|
||||
blk = fdctrl->qdev_for_drives[i].blk;
|
||||
if (!blk) {
|
||||
fd_init(drive);
|
||||
fd_revalidate(drive);
|
||||
continue;
|
||||
}
|
||||
|
||||
fd_init(drive);
|
||||
if (drive->blk) {
|
||||
blk_set_dev_ops(drive->blk, &fdctrl_block_ops, drive);
|
||||
pick_drive_type(drive);
|
||||
dev = qdev_create(&fdctrl->bus.bus, "floppy");
|
||||
qdev_prop_set_uint32(dev, "unit", i);
|
||||
qdev_prop_set_enum(dev, "drive-type", fdctrl->qdev_for_drives[i].type);
|
||||
|
||||
blk_ref(blk);
|
||||
blk_detach_dev(blk, fdc_dev);
|
||||
fdctrl->qdev_for_drives[i].blk = NULL;
|
||||
qdev_prop_set_drive(dev, "drive", blk, &local_err);
|
||||
blk_unref(blk);
|
||||
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
}
|
||||
|
||||
object_property_set_bool(OBJECT(dev), true, "realized", &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
}
|
||||
fd_revalidate(drive);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2442,7 +2612,8 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,
|
|||
*fdc_tc = qdev_get_gpio_in(dev, 0);
|
||||
}
|
||||
|
||||
static void fdctrl_realize_common(FDCtrl *fdctrl, Error **errp)
|
||||
static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
|
||||
Error **errp)
|
||||
{
|
||||
int i, j;
|
||||
static int command_tables_inited = 0;
|
||||
|
@ -2480,7 +2651,9 @@ static void fdctrl_realize_common(FDCtrl *fdctrl, Error **errp)
|
|||
k->register_channel(fdctrl->dma, fdctrl->dma_chann,
|
||||
&fdctrl_transfer_handler, fdctrl);
|
||||
}
|
||||
fdctrl_connect_drives(fdctrl, errp);
|
||||
|
||||
floppy_bus_create(fdctrl, &fdctrl->bus, dev);
|
||||
fdctrl_connect_drives(fdctrl, errp, dev);
|
||||
}
|
||||
|
||||
static const MemoryRegionPortio fdc_portio_list[] = {
|
||||
|
@ -2508,7 +2681,7 @@ static void isabus_fdc_realize(DeviceState *dev, Error **errp)
|
|||
}
|
||||
|
||||
qdev_set_legacy_instance_id(dev, isa->iobase, 2);
|
||||
fdctrl_realize_common(fdctrl, &err);
|
||||
fdctrl_realize_common(dev, fdctrl, &err);
|
||||
if (err != NULL) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
|
@ -2559,7 +2732,7 @@ static void sysbus_fdc_common_realize(DeviceState *dev, Error **errp)
|
|||
FDCtrlSysBus *sys = SYSBUS_FDC(dev);
|
||||
FDCtrl *fdctrl = &sys->state;
|
||||
|
||||
fdctrl_realize_common(fdctrl, errp);
|
||||
fdctrl_realize_common(dev, fdctrl, errp);
|
||||
}
|
||||
|
||||
FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i)
|
||||
|
@ -2606,14 +2779,14 @@ static Property isa_fdc_properties[] = {
|
|||
DEFINE_PROP_UINT32("iobase", FDCtrlISABus, iobase, 0x3f0),
|
||||
DEFINE_PROP_UINT32("irq", FDCtrlISABus, irq, 6),
|
||||
DEFINE_PROP_UINT32("dma", FDCtrlISABus, dma, 2),
|
||||
DEFINE_PROP_DRIVE("driveA", FDCtrlISABus, state.drives[0].blk),
|
||||
DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.drives[1].blk),
|
||||
DEFINE_PROP_DRIVE("driveA", FDCtrlISABus, state.qdev_for_drives[0].blk),
|
||||
DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.qdev_for_drives[1].blk),
|
||||
DEFINE_PROP_BIT("check_media_rate", FDCtrlISABus, state.check_media_rate,
|
||||
0, true),
|
||||
DEFINE_PROP_DEFAULT("fdtypeA", FDCtrlISABus, state.drives[0].drive,
|
||||
DEFINE_PROP_DEFAULT("fdtypeA", FDCtrlISABus, state.qdev_for_drives[0].type,
|
||||
FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
|
||||
FloppyDriveType),
|
||||
DEFINE_PROP_DEFAULT("fdtypeB", FDCtrlISABus, state.drives[1].drive,
|
||||
DEFINE_PROP_DEFAULT("fdtypeB", FDCtrlISABus, state.qdev_for_drives[1].type,
|
||||
FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
|
||||
FloppyDriveType),
|
||||
DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback,
|
||||
|
@ -2665,12 +2838,12 @@ static const VMStateDescription vmstate_sysbus_fdc ={
|
|||
};
|
||||
|
||||
static Property sysbus_fdc_properties[] = {
|
||||
DEFINE_PROP_DRIVE("driveA", FDCtrlSysBus, state.drives[0].blk),
|
||||
DEFINE_PROP_DRIVE("driveB", FDCtrlSysBus, state.drives[1].blk),
|
||||
DEFINE_PROP_DEFAULT("fdtypeA", FDCtrlSysBus, state.drives[0].drive,
|
||||
DEFINE_PROP_DRIVE("driveA", FDCtrlSysBus, state.qdev_for_drives[0].blk),
|
||||
DEFINE_PROP_DRIVE("driveB", FDCtrlSysBus, state.qdev_for_drives[1].blk),
|
||||
DEFINE_PROP_DEFAULT("fdtypeA", FDCtrlSysBus, state.qdev_for_drives[0].type,
|
||||
FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
|
||||
FloppyDriveType),
|
||||
DEFINE_PROP_DEFAULT("fdtypeB", FDCtrlSysBus, state.drives[1].drive,
|
||||
DEFINE_PROP_DEFAULT("fdtypeB", FDCtrlSysBus, state.qdev_for_drives[1].type,
|
||||
FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
|
||||
FloppyDriveType),
|
||||
DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback,
|
||||
|
@ -2695,8 +2868,8 @@ static const TypeInfo sysbus_fdc_info = {
|
|||
};
|
||||
|
||||
static Property sun4m_fdc_properties[] = {
|
||||
DEFINE_PROP_DRIVE("drive", FDCtrlSysBus, state.drives[0].blk),
|
||||
DEFINE_PROP_DEFAULT("fdtype", FDCtrlSysBus, state.drives[0].drive,
|
||||
DEFINE_PROP_DRIVE("drive", FDCtrlSysBus, state.qdev_for_drives[0].blk),
|
||||
DEFINE_PROP_DEFAULT("fdtype", FDCtrlSysBus, state.qdev_for_drives[0].type,
|
||||
FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
|
||||
FloppyDriveType),
|
||||
DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback,
|
||||
|
@ -2744,6 +2917,8 @@ static void fdc_register_types(void)
|
|||
type_register_static(&sysbus_fdc_type_info);
|
||||
type_register_static(&sysbus_fdc_info);
|
||||
type_register_static(&sun4m_fdc_info);
|
||||
type_register_static(&floppy_bus_info);
|
||||
type_register_static(&floppy_drive_info);
|
||||
}
|
||||
|
||||
type_init(fdc_register_types)
|
||||
|
|
|
@ -258,8 +258,10 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
|
|||
req->has_sg = true;
|
||||
dma_acct_start(n->conf.blk, &req->acct, &req->qsg, acct);
|
||||
req->aiocb = is_write ?
|
||||
dma_blk_write(n->conf.blk, &req->qsg, data_offset, nvme_rw_cb, req) :
|
||||
dma_blk_read(n->conf.blk, &req->qsg, data_offset, nvme_rw_cb, req);
|
||||
dma_blk_write(n->conf.blk, &req->qsg, data_offset, BDRV_SECTOR_SIZE,
|
||||
nvme_rw_cb, req) :
|
||||
dma_blk_read(n->conf.blk, &req->qsg, data_offset, BDRV_SECTOR_SIZE,
|
||||
nvme_rw_cb, req);
|
||||
|
||||
return NVME_NO_COMPLETE;
|
||||
}
|
||||
|
|
|
@ -1009,6 +1009,7 @@ static void execute_ncq_command(NCQTransferState *ncq_tfs)
|
|||
&ncq_tfs->sglist, BLOCK_ACCT_READ);
|
||||
ncq_tfs->aiocb = dma_blk_read(ide_state->blk, &ncq_tfs->sglist,
|
||||
ncq_tfs->lba << BDRV_SECTOR_BITS,
|
||||
BDRV_SECTOR_SIZE,
|
||||
ncq_cb, ncq_tfs);
|
||||
break;
|
||||
case WRITE_FPDMA_QUEUED:
|
||||
|
@ -1022,6 +1023,7 @@ static void execute_ncq_command(NCQTransferState *ncq_tfs)
|
|||
&ncq_tfs->sglist, BLOCK_ACCT_WRITE);
|
||||
ncq_tfs->aiocb = dma_blk_write(ide_state->blk, &ncq_tfs->sglist,
|
||||
ncq_tfs->lba << BDRV_SECTOR_BITS,
|
||||
BDRV_SECTOR_SIZE,
|
||||
ncq_cb, ncq_tfs);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -882,15 +882,15 @@ static void ide_dma_cb(void *opaque, int ret)
|
|||
switch (s->dma_cmd) {
|
||||
case IDE_DMA_READ:
|
||||
s->bus->dma->aiocb = dma_blk_read(s->blk, &s->sg, offset,
|
||||
ide_dma_cb, s);
|
||||
BDRV_SECTOR_SIZE, ide_dma_cb, s);
|
||||
break;
|
||||
case IDE_DMA_WRITE:
|
||||
s->bus->dma->aiocb = dma_blk_write(s->blk, &s->sg, offset,
|
||||
ide_dma_cb, s);
|
||||
BDRV_SECTOR_SIZE, ide_dma_cb, s);
|
||||
break;
|
||||
case IDE_DMA_TRIM:
|
||||
s->bus->dma->aiocb = dma_blk_io(blk_get_aio_context(s->blk),
|
||||
&s->sg, offset,
|
||||
&s->sg, offset, BDRV_SECTOR_SIZE,
|
||||
ide_issue_trim, s->blk, ide_dma_cb, s,
|
||||
DMA_DIRECTION_TO_DEVICE);
|
||||
break;
|
||||
|
|
213
hw/ide/macio.c
213
hw/ide/macio.c
|
@ -52,187 +52,6 @@ static const int debug_macio = 0;
|
|||
|
||||
#define MACIO_PAGE_SIZE 4096
|
||||
|
||||
/*
|
||||
* Unaligned DMA read/write access functions required for OS X/Darwin which
|
||||
* don't perform DMA transactions on sector boundaries. These functions are
|
||||
* modelled on bdrv_co_preadv()/bdrv_co_pwritev() and so should be easy to
|
||||
* remove if the unaligned block APIs are ever exposed.
|
||||
*/
|
||||
|
||||
static void pmac_dma_read(BlockBackend *blk,
|
||||
int64_t offset, unsigned int bytes,
|
||||
void (*cb)(void *opaque, int ret), void *opaque)
|
||||
{
|
||||
DBDMA_io *io = opaque;
|
||||
MACIOIDEState *m = io->opaque;
|
||||
IDEState *s = idebus_active_if(&m->bus);
|
||||
dma_addr_t dma_addr;
|
||||
int64_t sector_num;
|
||||
int nsector;
|
||||
uint64_t align = BDRV_SECTOR_SIZE;
|
||||
size_t head_bytes, tail_bytes;
|
||||
|
||||
qemu_iovec_destroy(&io->iov);
|
||||
qemu_iovec_init(&io->iov, io->len / MACIO_PAGE_SIZE + 1);
|
||||
|
||||
sector_num = (offset >> 9);
|
||||
nsector = (io->len >> 9);
|
||||
|
||||
MACIO_DPRINTF("--- DMA read transfer (0x%" HWADDR_PRIx ",0x%x): "
|
||||
"sector_num: %" PRId64 ", nsector: %d\n", io->addr, io->len,
|
||||
sector_num, nsector);
|
||||
|
||||
dma_addr = io->addr;
|
||||
io->dir = DMA_DIRECTION_FROM_DEVICE;
|
||||
io->dma_len = io->len;
|
||||
io->dma_mem = dma_memory_map(&address_space_memory, dma_addr, &io->dma_len,
|
||||
io->dir);
|
||||
|
||||
if (offset & (align - 1)) {
|
||||
head_bytes = offset & (align - 1);
|
||||
|
||||
MACIO_DPRINTF("--- DMA unaligned head: sector %" PRId64 ", "
|
||||
"discarding %zu bytes\n", sector_num, head_bytes);
|
||||
|
||||
qemu_iovec_add(&io->iov, &io->head_remainder, head_bytes);
|
||||
|
||||
bytes += offset & (align - 1);
|
||||
offset = offset & ~(align - 1);
|
||||
}
|
||||
|
||||
qemu_iovec_add(&io->iov, io->dma_mem, io->len);
|
||||
|
||||
if ((offset + bytes) & (align - 1)) {
|
||||
tail_bytes = (offset + bytes) & (align - 1);
|
||||
|
||||
MACIO_DPRINTF("--- DMA unaligned tail: sector %" PRId64 ", "
|
||||
"discarding bytes %zu\n", sector_num, tail_bytes);
|
||||
|
||||
qemu_iovec_add(&io->iov, &io->tail_remainder, align - tail_bytes);
|
||||
bytes = ROUND_UP(bytes, align);
|
||||
}
|
||||
|
||||
s->io_buffer_size -= io->len;
|
||||
s->io_buffer_index += io->len;
|
||||
|
||||
io->len = 0;
|
||||
|
||||
MACIO_DPRINTF("--- Block read transfer - sector_num: %" PRIx64 " "
|
||||
"nsector: %x\n", (offset >> 9), (bytes >> 9));
|
||||
|
||||
s->bus->dma->aiocb = blk_aio_preadv(blk, offset, &io->iov, 0, cb, io);
|
||||
}
|
||||
|
||||
static void pmac_dma_write(BlockBackend *blk,
|
||||
int64_t offset, int bytes,
|
||||
void (*cb)(void *opaque, int ret), void *opaque)
|
||||
{
|
||||
DBDMA_io *io = opaque;
|
||||
MACIOIDEState *m = io->opaque;
|
||||
IDEState *s = idebus_active_if(&m->bus);
|
||||
dma_addr_t dma_addr;
|
||||
int64_t sector_num;
|
||||
int nsector;
|
||||
uint64_t align = BDRV_SECTOR_SIZE;
|
||||
size_t head_bytes, tail_bytes;
|
||||
bool unaligned_head = false, unaligned_tail = false;
|
||||
|
||||
qemu_iovec_destroy(&io->iov);
|
||||
qemu_iovec_init(&io->iov, io->len / MACIO_PAGE_SIZE + 1);
|
||||
|
||||
sector_num = (offset >> 9);
|
||||
nsector = (io->len >> 9);
|
||||
|
||||
MACIO_DPRINTF("--- DMA write transfer (0x%" HWADDR_PRIx ",0x%x): "
|
||||
"sector_num: %" PRId64 ", nsector: %d\n", io->addr, io->len,
|
||||
sector_num, nsector);
|
||||
|
||||
dma_addr = io->addr;
|
||||
io->dir = DMA_DIRECTION_TO_DEVICE;
|
||||
io->dma_len = io->len;
|
||||
io->dma_mem = dma_memory_map(&address_space_memory, dma_addr, &io->dma_len,
|
||||
io->dir);
|
||||
|
||||
if (offset & (align - 1)) {
|
||||
head_bytes = offset & (align - 1);
|
||||
sector_num = ((offset & ~(align - 1)) >> 9);
|
||||
|
||||
MACIO_DPRINTF("--- DMA unaligned head: pre-reading head sector %"
|
||||
PRId64 "\n", sector_num);
|
||||
|
||||
blk_pread(s->blk, (sector_num << 9), &io->head_remainder, align);
|
||||
|
||||
qemu_iovec_add(&io->iov, &io->head_remainder, head_bytes);
|
||||
qemu_iovec_add(&io->iov, io->dma_mem, io->len);
|
||||
|
||||
bytes += offset & (align - 1);
|
||||
offset = offset & ~(align - 1);
|
||||
|
||||
unaligned_head = true;
|
||||
}
|
||||
|
||||
if ((offset + bytes) & (align - 1)) {
|
||||
tail_bytes = (offset + bytes) & (align - 1);
|
||||
sector_num = (((offset + bytes) & ~(align - 1)) >> 9);
|
||||
|
||||
MACIO_DPRINTF("--- DMA unaligned tail: pre-reading tail sector %"
|
||||
PRId64 "\n", sector_num);
|
||||
|
||||
blk_pread(s->blk, (sector_num << 9), &io->tail_remainder, align);
|
||||
|
||||
if (!unaligned_head) {
|
||||
qemu_iovec_add(&io->iov, io->dma_mem, io->len);
|
||||
}
|
||||
|
||||
qemu_iovec_add(&io->iov, &io->tail_remainder + tail_bytes,
|
||||
align - tail_bytes);
|
||||
|
||||
bytes = ROUND_UP(bytes, align);
|
||||
|
||||
unaligned_tail = true;
|
||||
}
|
||||
|
||||
if (!unaligned_head && !unaligned_tail) {
|
||||
qemu_iovec_add(&io->iov, io->dma_mem, io->len);
|
||||
}
|
||||
|
||||
s->io_buffer_size -= io->len;
|
||||
s->io_buffer_index += io->len;
|
||||
|
||||
io->len = 0;
|
||||
|
||||
MACIO_DPRINTF("--- Block write transfer - sector_num: %" PRIx64 " "
|
||||
"nsector: %x\n", (offset >> 9), (bytes >> 9));
|
||||
|
||||
s->bus->dma->aiocb = blk_aio_pwritev(blk, offset, &io->iov, 0, cb, io);
|
||||
}
|
||||
|
||||
static void pmac_dma_trim(BlockBackend *blk,
|
||||
int64_t offset, int bytes,
|
||||
void (*cb)(void *opaque, int ret), void *opaque)
|
||||
{
|
||||
DBDMA_io *io = opaque;
|
||||
MACIOIDEState *m = io->opaque;
|
||||
IDEState *s = idebus_active_if(&m->bus);
|
||||
dma_addr_t dma_addr;
|
||||
|
||||
qemu_iovec_destroy(&io->iov);
|
||||
qemu_iovec_init(&io->iov, io->len / MACIO_PAGE_SIZE + 1);
|
||||
|
||||
dma_addr = io->addr;
|
||||
io->dir = DMA_DIRECTION_TO_DEVICE;
|
||||
io->dma_len = io->len;
|
||||
io->dma_mem = dma_memory_map(&address_space_memory, dma_addr, &io->dma_len,
|
||||
io->dir);
|
||||
|
||||
qemu_iovec_add(&io->iov, io->dma_mem, io->len);
|
||||
s->io_buffer_size -= io->len;
|
||||
s->io_buffer_index += io->len;
|
||||
io->len = 0;
|
||||
|
||||
s->bus->dma->aiocb = ide_issue_trim(offset, &io->iov, cb, io, blk);
|
||||
}
|
||||
|
||||
static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
|
||||
{
|
||||
DBDMA_io *io = opaque;
|
||||
|
@ -244,6 +63,7 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
|
|||
|
||||
if (ret < 0) {
|
||||
MACIO_DPRINTF("DMA error: %d\n", ret);
|
||||
qemu_sglist_destroy(&s->sg);
|
||||
ide_atapi_io_error(s, ret);
|
||||
goto done;
|
||||
}
|
||||
|
@ -258,6 +78,7 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
|
|||
|
||||
if (s->io_buffer_size <= 0) {
|
||||
MACIO_DPRINTF("End of IDE transfer\n");
|
||||
qemu_sglist_destroy(&s->sg);
|
||||
ide_atapi_cmd_ok(s);
|
||||
m->dma_active = false;
|
||||
goto done;
|
||||
|
@ -282,7 +103,15 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
|
|||
/* Calculate current offset */
|
||||
offset = ((int64_t)s->lba << 11) + s->io_buffer_index;
|
||||
|
||||
pmac_dma_read(s->blk, offset, io->len, pmac_ide_atapi_transfer_cb, io);
|
||||
qemu_sglist_init(&s->sg, DEVICE(m), io->len / MACIO_PAGE_SIZE + 1,
|
||||
&address_space_memory);
|
||||
qemu_sglist_add(&s->sg, io->addr, io->len);
|
||||
s->io_buffer_size -= io->len;
|
||||
s->io_buffer_index += io->len;
|
||||
io->len = 0;
|
||||
|
||||
s->bus->dma->aiocb = dma_blk_read(s->blk, &s->sg, offset, 0x1,
|
||||
pmac_ide_atapi_transfer_cb, io);
|
||||
return;
|
||||
|
||||
done:
|
||||
|
@ -310,6 +139,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
|
|||
|
||||
if (ret < 0) {
|
||||
MACIO_DPRINTF("DMA error: %d\n", ret);
|
||||
qemu_sglist_destroy(&s->sg);
|
||||
ide_dma_error(s);
|
||||
goto done;
|
||||
}
|
||||
|
@ -324,6 +154,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
|
|||
|
||||
if (s->io_buffer_size <= 0) {
|
||||
MACIO_DPRINTF("End of IDE transfer\n");
|
||||
qemu_sglist_destroy(&s->sg);
|
||||
s->status = READY_STAT | SEEK_STAT;
|
||||
ide_set_irq(s->bus);
|
||||
m->dma_active = false;
|
||||
|
@ -338,15 +169,27 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
|
|||
/* Calculate number of sectors */
|
||||
offset = (ide_get_sector(s) << 9) + s->io_buffer_index;
|
||||
|
||||
qemu_sglist_init(&s->sg, DEVICE(m), io->len / MACIO_PAGE_SIZE + 1,
|
||||
&address_space_memory);
|
||||
qemu_sglist_add(&s->sg, io->addr, io->len);
|
||||
s->io_buffer_size -= io->len;
|
||||
s->io_buffer_index += io->len;
|
||||
io->len = 0;
|
||||
|
||||
switch (s->dma_cmd) {
|
||||
case IDE_DMA_READ:
|
||||
pmac_dma_read(s->blk, offset, io->len, pmac_ide_transfer_cb, io);
|
||||
s->bus->dma->aiocb = dma_blk_read(s->blk, &s->sg, offset, 0x1,
|
||||
pmac_ide_atapi_transfer_cb, io);
|
||||
break;
|
||||
case IDE_DMA_WRITE:
|
||||
pmac_dma_write(s->blk, offset, io->len, pmac_ide_transfer_cb, io);
|
||||
s->bus->dma->aiocb = dma_blk_write(s->blk, &s->sg, offset, 0x1,
|
||||
pmac_ide_transfer_cb, io);
|
||||
break;
|
||||
case IDE_DMA_TRIM:
|
||||
pmac_dma_trim(s->blk, offset, io->len, pmac_ide_transfer_cb, io);
|
||||
s->bus->dma->aiocb = dma_blk_io(blk_get_aio_context(s->blk), &s->sg,
|
||||
offset, 0x1, ide_issue_trim, s->blk,
|
||||
pmac_ide_transfer_cb, io,
|
||||
DMA_DIRECTION_TO_DEVICE);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
|
|
|
@ -341,6 +341,7 @@ static void scsi_do_read(SCSIDiskReq *r, int ret)
|
|||
r->req.resid -= r->req.sg->size;
|
||||
r->req.aiocb = dma_blk_io(blk_get_aio_context(s->qdev.conf.blk),
|
||||
r->req.sg, r->sector << BDRV_SECTOR_BITS,
|
||||
BDRV_SECTOR_SIZE,
|
||||
sdc->dma_readv, r, scsi_dma_complete, r,
|
||||
DMA_DIRECTION_FROM_DEVICE);
|
||||
} else {
|
||||
|
@ -539,6 +540,7 @@ static void scsi_write_data(SCSIRequest *req)
|
|||
r->req.resid -= r->req.sg->size;
|
||||
r->req.aiocb = dma_blk_io(blk_get_aio_context(s->qdev.conf.blk),
|
||||
r->req.sg, r->sector << BDRV_SECTOR_BITS,
|
||||
BDRV_SECTOR_SIZE,
|
||||
sdc->dma_writev, r, scsi_dma_complete, r,
|
||||
DMA_DIRECTION_TO_DEVICE);
|
||||
} else {
|
||||
|
|
|
@ -199,14 +199,14 @@ typedef BlockAIOCB *DMAIOFunc(int64_t offset, QEMUIOVector *iov,
|
|||
void *opaque);
|
||||
|
||||
BlockAIOCB *dma_blk_io(AioContext *ctx,
|
||||
QEMUSGList *sg, uint64_t offset,
|
||||
QEMUSGList *sg, uint64_t offset, uint32_t align,
|
||||
DMAIOFunc *io_func, void *io_func_opaque,
|
||||
BlockCompletionFunc *cb, void *opaque, DMADirection dir);
|
||||
BlockAIOCB *dma_blk_read(BlockBackend *blk,
|
||||
QEMUSGList *sg, uint64_t offset,
|
||||
QEMUSGList *sg, uint64_t offset, uint32_t align,
|
||||
BlockCompletionFunc *cb, void *opaque);
|
||||
BlockAIOCB *dma_blk_write(BlockBackend *blk,
|
||||
QEMUSGList *sg, uint64_t offset,
|
||||
QEMUSGList *sg, uint64_t offset, uint32_t align,
|
||||
BlockCompletionFunc *cb, void *opaque);
|
||||
uint64_t dma_buf_read(uint8_t *ptr, int32_t len, QEMUSGList *sg);
|
||||
uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg);
|
||||
|
|
|
@ -0,0 +1,246 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Test floppy configuration
|
||||
#
|
||||
# Copyright (C) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# creator
|
||||
owner=kwolf@redhat.com
|
||||
|
||||
seq=`basename $0`
|
||||
echo "QA output created by $seq"
|
||||
|
||||
here=`pwd`
|
||||
status=1 # failure is the default!
|
||||
|
||||
_cleanup()
|
||||
{
|
||||
_cleanup_test_img
|
||||
}
|
||||
trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||
|
||||
# get standard environment, filters and checks
|
||||
. ./common.rc
|
||||
. ./common.filter
|
||||
|
||||
_supported_fmt qcow2
|
||||
_supported_proto file
|
||||
_supported_os Linux
|
||||
|
||||
if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
|
||||
_notrun "Requires a PC machine"
|
||||
fi
|
||||
|
||||
function do_run_qemu()
|
||||
{
|
||||
(
|
||||
if ! test -t 0; then
|
||||
while read cmd; do
|
||||
echo $cmd
|
||||
done
|
||||
fi
|
||||
echo quit
|
||||
) | $QEMU -nographic -monitor stdio -serial none "$@"
|
||||
echo
|
||||
}
|
||||
|
||||
function check_floppy_qtree()
|
||||
{
|
||||
echo
|
||||
echo Testing: "$@" | _filter_testdir
|
||||
|
||||
# QEMU_OPTIONS contains -nodefaults, we don't want that here because the
|
||||
# defaults are part of what should be checked here.
|
||||
#
|
||||
# Apply the sed filter to stdout only, but keep the stderr output and
|
||||
# filter the qemu program name in it.
|
||||
echo "info qtree" |
|
||||
(QEMU_OPTIONS="" do_run_qemu "$@" |
|
||||
sed -ne '/^ dev: isa-fdc/,/^ dev:/{x;p}' ) 2>&1 |
|
||||
_filter_win32 | _filter_qemu
|
||||
}
|
||||
|
||||
function check_cache_mode()
|
||||
{
|
||||
echo "info block none0" |
|
||||
QEMU_OPTIONS="" do_run_qemu -drive if=none,file="$TEST_IMG" "$@" |
|
||||
_filter_win32 | _filter_qemu | grep "Cache mode"
|
||||
}
|
||||
|
||||
|
||||
size=720k
|
||||
|
||||
_make_test_img $size
|
||||
|
||||
# Default drive semantics:
|
||||
#
|
||||
# By default you get a single empty floppy drive. You can override it with
|
||||
# -drive and using the same index, but if you use -drive to add a floppy to a
|
||||
# different index, you get both of them. However, as soon as you use any
|
||||
# '-device floppy', even to a different slot, the default drive is disabled.
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Default ===
|
||||
|
||||
check_floppy_qtree
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Using -fda/-fdb options ===
|
||||
|
||||
check_floppy_qtree -fda "$TEST_IMG"
|
||||
check_floppy_qtree -fdb "$TEST_IMG"
|
||||
check_floppy_qtree -fda "$TEST_IMG" -fdb "$TEST_IMG"
|
||||
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Using -drive options ===
|
||||
|
||||
check_floppy_qtree -drive if=floppy,file="$TEST_IMG"
|
||||
check_floppy_qtree -drive if=floppy,file="$TEST_IMG",index=1
|
||||
check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=floppy,file="$TEST_IMG",index=1
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Using -drive if=none and -global ===
|
||||
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveA=none0
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveB=none0
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
|
||||
-global isa-fdc.driveA=none0 -global isa-fdc.driveB=none1
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Using -drive if=none and -device ===
|
||||
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
|
||||
-device floppy,drive=none0 -device floppy,drive=none1,unit=1
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Mixing -fdX and -global ===
|
||||
|
||||
# Working
|
||||
check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG" -global isa-fdc.driveB=none0
|
||||
check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG" -global isa-fdc.driveA=none0
|
||||
|
||||
# Conflicting (-fdX wins)
|
||||
check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG" -global isa-fdc.driveA=none0
|
||||
check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG" -global isa-fdc.driveB=none0
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Mixing -fdX and -device ===
|
||||
|
||||
# Working
|
||||
check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0
|
||||
check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1
|
||||
|
||||
check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0
|
||||
check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=0
|
||||
|
||||
# Conflicting
|
||||
check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=0
|
||||
check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Mixing -drive and -device ===
|
||||
|
||||
# Working
|
||||
check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0
|
||||
check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1
|
||||
|
||||
# Conflicting
|
||||
check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=0
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Mixing -global and -device ===
|
||||
|
||||
# Working
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
|
||||
-global isa-fdc.driveA=none0 -device floppy,drive=none1
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
|
||||
-global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=1
|
||||
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
|
||||
-global isa-fdc.driveB=none0 -device floppy,drive=none1
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
|
||||
-global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=0
|
||||
|
||||
# Conflicting
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
|
||||
-global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=0
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
|
||||
-global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=1
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Too many floppy drives ===
|
||||
|
||||
# Working
|
||||
check_floppy_qtree -drive if=floppy,file="$TEST_IMG" \
|
||||
-drive if=none,file="$TEST_IMG" \
|
||||
-drive if=none,file="$TEST_IMG" \
|
||||
-global isa-fdc.driveB=none0 \
|
||||
-device floppy,drive=none1
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Creating an empty drive with anonymous BB ===
|
||||
|
||||
check_floppy_qtree -device floppy
|
||||
check_floppy_qtree -device floppy,drive-type=120
|
||||
check_floppy_qtree -device floppy,drive-type=144
|
||||
check_floppy_qtree -device floppy,drive-type=288
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Try passing different drive size with image ===
|
||||
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=120
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=288
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Try passing different block sizes ===
|
||||
|
||||
# Explicitly setting the default is okay
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=512
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=512
|
||||
|
||||
# Changing it is not
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=4096
|
||||
check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=1024
|
||||
|
||||
echo
|
||||
echo
|
||||
echo === Writethrough caching ===
|
||||
|
||||
check_cache_mode -device floppy,drive=none0
|
||||
check_cache_mode -device floppy,drive=none0,write-cache=on
|
||||
check_cache_mode -device floppy,drive=none0,write-cache=off
|
||||
|
||||
# success, all done
|
||||
echo "*** done"
|
||||
rm -f $seq.full
|
||||
status=0
|
File diff suppressed because it is too large
Load Diff
|
@ -163,3 +163,4 @@
|
|||
160 rw auto quick
|
||||
162 auto quick
|
||||
170 rw auto quick
|
||||
172 auto
|
||||
|
|
1
vl.c
1
vl.c
|
@ -218,6 +218,7 @@ static struct {
|
|||
{ .driver = "isa-serial", .flag = &default_serial },
|
||||
{ .driver = "isa-parallel", .flag = &default_parallel },
|
||||
{ .driver = "isa-fdc", .flag = &default_floppy },
|
||||
{ .driver = "floppy", .flag = &default_floppy },
|
||||
{ .driver = "ide-cd", .flag = &default_cdrom },
|
||||
{ .driver = "ide-hd", .flag = &default_cdrom },
|
||||
{ .driver = "ide-drive", .flag = &default_cdrom },
|
||||
|
|
Loading…
Reference in New Issue