diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2022-11-30 13:03:19 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2023-01-06 00:50:32 +0100 |
commit | cec79db38df72ce74d0296b831e90547111bc13c (patch) | |
tree | 9039f99370cf10909fa1a796faf8df9f9f5d633c /hw/ide/qdev.c | |
parent | 1ea17d228e582b1cfbf6f61e9da5fafef4063be8 (diff) | |
download | qemu-cec79db38df72ce74d0296b831e90547111bc13c.zip qemu-cec79db38df72ce74d0296b831e90547111bc13c.tar.gz qemu-cec79db38df72ce74d0296b831e90547111bc13c.tar.bz2 |
ide: Add "ide-cf" driver, a CompactFlash card
This allows attaching IDE_CFATA device to an IDE bus. Behaves like a
CompactFlash card in True IDE mode.
Tested with:
qemu-system-i386 \
-device driver=ide-cf,drive=cf,bus=ide.0 \
-drive id=cf,index=0,format=raw,if=none,file=cf.img
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Message-Id: <20221130120319.706885-1-lkundrak@v3.sk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/ide/qdev.c')
-rw-r--r-- | hw/ide/qdev.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 618045b..6f6c746 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -283,6 +283,11 @@ static void ide_cd_realize(IDEDevice *dev, Error **errp) ide_dev_initfn(dev, IDE_CD, errp); } +static void ide_cf_realize(IDEDevice *dev, Error **errp) +{ + ide_dev_initfn(dev, IDE_CFATA, errp); +} + #define DEFINE_IDE_DEV_PROPERTIES() \ DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf), \ DEFINE_BLOCK_ERROR_PROPERTIES(IDEDrive, dev.conf), \ @@ -341,6 +346,32 @@ static const TypeInfo ide_cd_info = { .class_init = ide_cd_class_init, }; +static Property ide_cf_properties[] = { + DEFINE_IDE_DEV_PROPERTIES(), + DEFINE_BLOCK_CHS_PROPERTIES(IDEDrive, dev.conf), + DEFINE_PROP_BIOS_CHS_TRANS("bios-chs-trans", + IDEDrive, dev.chs_trans, BIOS_ATA_TRANSLATION_AUTO), + DEFINE_PROP_END_OF_LIST(), +}; + +static void ide_cf_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + IDEDeviceClass *k = IDE_DEVICE_CLASS(klass); + + k->realize = ide_cf_realize; + dc->fw_name = "drive"; + dc->desc = "virtual CompactFlash card"; + device_class_set_props(dc, ide_cf_properties); +} + +static const TypeInfo ide_cf_info = { + .name = "ide-cf", + .parent = TYPE_IDE_DEVICE, + .instance_size = sizeof(IDEDrive), + .class_init = ide_cf_class_init, +}; + static void ide_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); @@ -365,6 +396,7 @@ static void ide_register_types(void) type_register_static(&ide_bus_info); type_register_static(&ide_hd_info); type_register_static(&ide_cd_info); + type_register_static(&ide_cf_info); type_register_static(&ide_device_type_info); } |