floppy: build as modules.
cover floppy: build as modules.
Some code shuffling needed beforehand due to floppy being part of several platforms. While being at it also make floppy optional in pc machine type.
Gerd Hoffmann (7):
floppy: move isa_fdc_get_drive_type to separate source file.
floppy: move isa_fdc_init_drives + fdctrl_init_drives
floppy: move fdctrl_init_sysbus
floppy: move sun4m_fdctrl_init
floppy: move cmos_get_fd_drive_type
floppy: build as modules.
pc: add floppy=OnOffAuto
hw/block/fdc-internal.h | 31 ++++++++++ include/hw/i386/pc.h | 2 + hw/block/fdc-isa.c | 54 +---------------- hw/block/fdc-module.c | 125 ++++++++++++++++++++++++++++++++++++++++ hw/block/fdc-sysbus.c | 54 ++--------------- hw/block/fdc.c | 19 +----- hw/i386/pc.c | 23 ++++++++ hw/i386/pc_piix.c | 8 ++- hw/block/meson.build | 18 +++++- 9 files changed, 211 insertions(+), 123 deletions(-) create mode 100644 hw/block/fdc-module.c
Signature · 1 line
2.31.1
PATCH 1/7 floppy: move isa_fdc_get_drive_type to separate source file.
isa_fdc_get_drive_type() is needed by pc machine types when setting up the cmos.
Move to separate source file so we can keep it in core qemu when building floppy as module.
--- hw/block/fdc-internal.h | 16 ++++++++++++++++ hw/block/fdc-isa.c | 22 ---------------------- hw/block/fdc-module.c | 39 +++++++++++++++++++++++++++++++++++++++ hw/block/meson.build | 1 + 4 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 hw/block/fdc-module.c
hw/block/fdc-internal.h +16 -0
@@ -29,6 +29,7 @@#include "exec/ioport.h" #include "hw/block/block.h" #include "hw/block/fdc.h" +#include "hw/isa/isa.h" #include "qapi/qapi-types-block.h" typedef struct FDCtrl FDCtrl ;
@@ -143,6 +144,21 @@ struct FDCtrl {PortioList portio_list; }; +OBJECT_DECLARE_SIMPLE_TYPE(FDCtrlISABus, ISA_FDC) + +struct FDCtrlISABus { +/*< private >*/ +ISADevice parent_obj; +/*< public >*/ + +uint32_t iobase; +uint32_t irq; +uint32_t dma; +struct FDCtrl state; +int32_t bootindexA; +int32_t bootindexB; +}; +extern const FDFormat fd_formats[];extern const VMStateDescription vmstate_fdc;
hw/block/fdc-isa.c +0 -22
@@ -49,21 +49,6 @@#include "qom/object.h" #include "fdc-internal.h" -OBJECT_DECLARE_SIMPLE_TYPE(FDCtrlISABus, ISA_FDC) - -struct FDCtrlISABus { -/*< private >*/ -ISADevice parent_obj; -/*< public >*/ - -uint32_t iobase; -uint32_t irq; -uint32_t dma; -struct FDCtrl state; -int32_t bootindexA; -int32_t bootindexB; -}; -static void fdctrl_external_reset_isa (DeviceState *d) {FDCtrlISABus *isa =ISA_FDC (d);
@@ -117,13 +102,6 @@ static void isabus_fdc_realize(DeviceState *dev, Error **errp) } } -FloppyDriveType isa_fdc_get_drive_type (ISADevice *fdc,int i) -{ -FDCtrlISABus *isa =ISA_FDC (fdc); - -return isa->state.drives[i].drive; -} -static void isa_fdc_get_drive_max_chs (FloppyDriveType type,uint8_t *maxc,uint8_t *maxh,uint8_t *maxs) {
hw/block/fdc-module.c new file +39 -0
@@ -0,0 +1,39 @@ +/* +* QEMU Floppy disk emulator (Intel 82078) +* +* Some small helper functions which must be built into core qemu when +* building floppy as module. +* +* Copyright (c) 2003, 2007 Jocelyn Mayer +* Copyright (c) 2008 Hervé Poussineau +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include "qemu/osdep.h" +#include "hw/isa/isa.h" +#include "hw/block/fdc.h" +#include "fdc-internal.h" + +FloppyDriveType isa_fdc_get_drive_type (ISADevice *fdc,int i) +{ +FDCtrlISABus *isa =ISA_FDC (fdc); + +return isa->state.drives[i].drive; +}
hw/block/meson.build +1 -0
@@ -4,6 +4,7 @@ softmmu_ss.add(files( 'hd-geometry.c' )) softmmu_ss.add(when: 'CONFIG_ECC', if_true: files('ecc.c')) +softmmu_ss.add(when: 'CONFIG_FDC', if_true: files('fdc-module.c')) softmmu_ss.add(when: 'CONFIG_FDC', if_true: files('fdc.c')) softmmu_ss.add(when: 'CONFIG_FDC_ISA', if_true: files('fdc-isa.c')) softmmu_ss.add(when: 'CONFIG_FDC_SYSBUS', if_true: files('fdc-sysbus.c'))
Signature · 1 line
2.31.1
PATCH 2/7 floppy: move isa_fdc_init_drives + fdctrl_init_drives
In reply to Gerd Hoffmannisa_fdc_init_drives() is called by pc machine setup, and it depends on fdctrl_init_drives().
Move both functions to separate source file so we can keep them in core qemu when building floppy as module.
--- hw/block/fdc-isa.c | 5 ----- hw/block/fdc-module.c | 24 ++++++++++++++++++++++++ hw/block/fdc.c | 17 ----------------- 3 files changed, 24 insertions(+), 22 deletions(-)
hw/block/fdc-isa.c +0 -5
@@ -57,11 +57,6 @@ static void fdctrl_external_reset_isa(DeviceState *d)fdctrl_reset (s,0 ); } -void isa_fdc_init_drives (ISADevice *fdc,DriveInfo **fds) -{ -fdctrl_init_drives (&ISA_FDC (fdc)->state.bus, fds); -} -static const MemoryRegionPortio fdc_portio_list[] = { {1 ,5 ,1 , .read = fdctrl_read, .write = fdctrl_write }, {7 ,1 ,1 , .read = fdctrl_read, .write = fdctrl_write },
hw/block/fdc-module.c +24 -0
@@ -29,8 +29,32 @@#include "qemu/osdep.h" #include "hw/isa/isa.h" #include "hw/block/fdc.h" +#include "qapi/error.h" +#include "sysemu/blockdev.h" #include "fdc-internal.h" +void fdctrl_init_drives (FloppyBus *bus,DriveInfo **fds) +{ +DeviceState *dev; +int i; + +for (i =0 ; i <MAX_FD ; i++) { +if (fds[i]) { + dev =qdev_new ("floppy" ); +qdev_prop_set_uint32 (dev,"unit" , i); +qdev_prop_set_enum (dev,"drive-type" ,FLOPPY_DRIVE_TYPE_AUTO ); +qdev_prop_set_drive_err (dev,"drive" ,blk_by_legacy_dinfo (fds[i]), + &error_fatal); +qdev_realize_and_unref (dev, &bus->bus, &error_fatal); + } + } +} + +void isa_fdc_init_drives (ISADevice *fdc,DriveInfo **fds) +{ +fdctrl_init_drives (&ISA_FDC (fdc)->state.bus, fds); +} +FloppyDriveType isa_fdc_get_drive_type (ISADevice *fdc,int i) {FDCtrlISABus *isa =ISA_FDC (fdc);
hw/block/fdc.c +0 -17
@@ -2297,23 +2297,6 @@ static void fdctrl_result_timer(void *opaque)/* Init functions */ -void fdctrl_init_drives (FloppyBus *bus,DriveInfo **fds) -{ -DeviceState *dev; -int i; - -for (i =0 ; i <MAX_FD ; i++) { -if (fds[i]) { - dev =qdev_new ("floppy" ); -qdev_prop_set_uint32 (dev,"unit" , i); -qdev_prop_set_enum (dev,"drive-type" ,FLOPPY_DRIVE_TYPE_AUTO ); -qdev_prop_set_drive_err (dev,"drive" ,blk_by_legacy_dinfo (fds[i]), - &error_fatal); -qdev_realize_and_unref (dev, &bus->bus, &error_fatal); - } - } -} -void fdctrl_realize_common (DeviceState *dev,FDCtrl *fdctrl,Error **errp) {int i, j;
Signature · 1 line
2.31.1
PATCH 3/7 floppy: move fdctrl_init_sysbus
In reply to Gerd HoffmannNeeded by mips machine init.
Move to separate source file so we can keep it in core qemu when building floppy as module.
--- hw/block/fdc-internal.h | 15 +++++++++++++++ hw/block/fdc-module.c | 21 +++++++++++++++++++++ hw/block/fdc-sysbus.c | 34 ---------------------------------- 3 files changed, 36 insertions(+), 34 deletions(-)
hw/block/fdc-internal.h +15 -0
@@ -30,6 +30,7 @@#include "hw/block/block.h" #include "hw/block/fdc.h" #include "hw/isa/isa.h" +#include "hw/sysbus.h" #include "qapi/qapi-types-block.h" typedef struct FDCtrl FDCtrl ;
@@ -159,6 +160,20 @@ struct FDCtrlISABus {int32_t bootindexB; }; +#define TYPE_SYSBUS_FDC "base-sysbus-fdc" +typedef struct FDCtrlSysBusClass FDCtrlSysBusClass ; +typedef struct FDCtrlSysBus FDCtrlSysBus ; +DECLARE_OBJ_CHECKERS (FDCtrlSysBus, FDCtrlSysBusClass, + SYSBUS_FDC, TYPE_SYSBUS_FDC) + +struct FDCtrlSysBus { +/*< private >*/ +SysBusDevice parent_obj; +/*< public >*/ + +struct FDCtrl state; +}; +extern const FDFormat fd_formats[];extern const VMStateDescription vmstate_fdc;
hw/block/fdc-module.c +21 -0
@@ -29,10 +29,31 @@#include "qemu/osdep.h" #include "hw/isa/isa.h" #include "hw/block/fdc.h" +#include "hw/sysbus.h" #include "qapi/error.h" #include "sysemu/blockdev.h" #include "fdc-internal.h" +void fdctrl_init_sysbus (qemu_irq irq,int dma_chann, +hwaddr mmio_base,DriveInfo **fds) +{ +FDCtrl *fdctrl; +DeviceState *dev; +SysBusDevice *sbd; +FDCtrlSysBus *sys; + + dev =qdev_new ("sysbus-fdc" ); + sys =SYSBUS_FDC (dev); + fdctrl = &sys->state; + fdctrl->dma_chann = dma_chann;/* FIXME */ + sbd =SYS_BUS_DEVICE (dev); +sysbus_realize_and_unref (sbd, &error_fatal); +sysbus_connect_irq (sbd,0 , irq); +sysbus_mmio_map (sbd,0 , mmio_base); + +fdctrl_init_drives (&sys->state.bus, fds); +} +void fdctrl_init_drives (FloppyBus *bus,DriveInfo **fds) {DeviceState *dev;
hw/block/fdc-sysbus.c +0 -34
@@ -32,12 +32,6 @@#include "fdc-internal.h" #include "trace.h" -#define TYPE_SYSBUS_FDC "base-sysbus-fdc" -typedef struct FDCtrlSysBusClass FDCtrlSysBusClass ; -typedef struct FDCtrlSysBus FDCtrlSysBus ; -DECLARE_OBJ_CHECKERS (FDCtrlSysBus, FDCtrlSysBusClass, - SYSBUS_FDC, TYPE_SYSBUS_FDC) -struct FDCtrlSysBusClass {/*< private >*/ SysBusDeviceClass parent_class;
@@ -46,14 +40,6 @@ struct FDCtrlSysBusClass {bool use_strict_io; }; -struct FDCtrlSysBus { -/*< private >*/ -SysBusDevice parent_obj; -/*< public >*/ - -struct FDCtrl state; -}; -static uint64_t fdctrl_read_mem (void *opaque,hwaddr reg,unsigned ize) {return fdctrl_read (opaque, (uint32_t )reg);
@@ -94,26 +80,6 @@ static void fdctrl_handle_tc(void *opaque, int irq, int level)trace_fdctrl_tc_pulse (level); } -void fdctrl_init_sysbus (qemu_irq irq,int dma_chann, -hwaddr mmio_base,DriveInfo **fds) -{ -FDCtrl *fdctrl; -DeviceState *dev; -SysBusDevice *sbd; -FDCtrlSysBus *sys; - - dev =qdev_new ("sysbus-fdc" ); - sys =SYSBUS_FDC (dev); - fdctrl = &sys->state; - fdctrl->dma_chann = dma_chann;/* FIXME */ - sbd =SYS_BUS_DEVICE (dev); -sysbus_realize_and_unref (sbd, &error_fatal); -sysbus_connect_irq (sbd,0 , irq); -sysbus_mmio_map (sbd,0 , mmio_base); - -fdctrl_init_drives (&sys->state.bus, fds); -} -void sun4m_fdctrl_init (qemu_irq irq,hwaddr io_base,DriveInfo **fds,qemu_irq *fdc_tc) {
Signature · 1 line
2.31.1
PATCH 4/7 floppy: move sun4m_fdctrl_init
In reply to Gerd HoffmannNeeded by sparc machine init.
Move to separate source file so we can keep it in core qemu when building floppy as module.
--- hw/block/fdc-module.c | 16 ++++++++++++++++ hw/block/fdc-sysbus.c | 16 ---------------- 2 files changed, 16 insertions(+), 16 deletions(-)
hw/block/fdc-module.c +16 -0
@@ -54,6 +54,22 @@ void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,fdctrl_init_drives (&sys->state.bus, fds); } +void sun4m_fdctrl_init (qemu_irq irq,hwaddr io_base, +DriveInfo **fds,qemu_irq *fdc_tc) +{ +DeviceState *dev; +FDCtrlSysBus *sys; + + dev =qdev_new ("sun-fdtwo" ); +sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); + sys =SYSBUS_FDC (dev); +sysbus_connect_irq (SYS_BUS_DEVICE (sys),0 , irq); +sysbus_mmio_map (SYS_BUS_DEVICE (sys),0 , io_base); + *fdc_tc =qdev_get_gpio_in (dev,0 ); + +fdctrl_init_drives (&sys->state.bus, fds); +} +void fdctrl_init_drives (FloppyBus *bus,DriveInfo **fds) {DeviceState *dev;
hw/block/fdc-sysbus.c +0 -16
@@ -80,22 +80,6 @@ static void fdctrl_handle_tc(void *opaque, int irq, int level)trace_fdctrl_tc_pulse (level); } -void sun4m_fdctrl_init (qemu_irq irq,hwaddr io_base, -DriveInfo **fds,qemu_irq *fdc_tc) -{ -DeviceState *dev; -FDCtrlSysBus *sys; - - dev =qdev_new ("sun-fdtwo" ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); - sys =SYSBUS_FDC (dev); -sysbus_connect_irq (SYS_BUS_DEVICE (sys),0 , irq); -sysbus_mmio_map (SYS_BUS_DEVICE (sys),0 , io_base); - *fdc_tc =qdev_get_gpio_in (dev,0 ); - -fdctrl_init_drives (&sys->state.bus, fds); -} -static void sysbus_fdc_common_instance_init (Object *obj) {DeviceState *dev =DEVICE (obj);
Signature · 1 line
2.31.1
PATCH 5/7 floppy: move cmos_get_fd_drive_type
In reply to Gerd HoffmannNeeded by pc machine init.
Move to separate source file so we can keep it in core qemu when building floppy as module.
--- hw/block/fdc-isa.c | 25 ------------------------- hw/block/fdc-module.c | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 25 deletions(-)
hw/block/fdc-isa.c +0 -25
@@ -162,31 +162,6 @@ static Aml *build_fdinfo_aml(int idx, FloppyDriveType type)return dev; } -int cmos_get_fd_drive_type (FloppyDriveType fd0) -{ -int val; - -switch (fd0) { -case FLOPPY_DRIVE_TYPE_144 : -/* 1.44 Mb 3"5 drive */ - val =4 ; -break ; -case FLOPPY_DRIVE_TYPE_288 : -/* 2.88 Mb 3"5 drive */ - val =5 ; -break ; -case FLOPPY_DRIVE_TYPE_120 : -/* 1.2 Mb 5"5 drive */ - val =2 ; -break ; -case FLOPPY_DRIVE_TYPE_NONE : -default : - val =0 ; -break ; - } -return val; -} -static void fdc_isa_build_aml (ISADevice *isadev,Aml *scope) {Aml *dev;
hw/block/fdc-module.c +25 -0
@@ -98,3 +98,28 @@ FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i)return isa->state.drives[i].drive; } + +int cmos_get_fd_drive_type (FloppyDriveType fd0) +{ +int val; + +switch (fd0) { +case FLOPPY_DRIVE_TYPE_144 : +/* 1.44 Mb 3"5 drive */ + val =4 ; +break ; +case FLOPPY_DRIVE_TYPE_288 : +/* 2.88 Mb 3"5 drive */ + val =5 ; +break ; +case FLOPPY_DRIVE_TYPE_120 : +/* 1.2 Mb 5"5 drive */ + val =2 ; +break ; +case FLOPPY_DRIVE_TYPE_NONE : +default : + val =0 ; +break ; + } +return val; +}
Signature · 1 line
2.31.1
PATCH 6/7 floppy: build as modules.
In reply to Gerd HoffmannAdd module_obj() annotations, update meson build rules.
--- hw/block/fdc-isa.c | 2 ++ hw/block/fdc-sysbus.c | 4 ++++ hw/block/fdc.c | 2 ++ hw/block/meson.build | 17 ++++++++++++++--- 4 files changed, 22 insertions(+), 3 deletions(-)
hw/block/fdc-isa.c +2 -0
@@ -259,6 +259,7 @@ static const TypeInfo isa_fdc_info = { .class_init = isabus_fdc_class_init, .instance_init = isabus_fdc_instance_init, }; +module_obj (TYPE_ISA_FDC );static void isa_fdc_register_types (void ) {
@@ -266,3 +267,4 @@ static void isa_fdc_register_types(void) } type_init(isa_fdc_register_types) +module_dep("hw-block-fdc");
hw/block/fdc-sysbus.c +4 -0
@@ -137,6 +137,7 @@ static const TypeInfo sysbus_fdc_common_typeinfo = { .class_init = sysbus_fdc_common_class_init, .class_size = sizeof(FDCtrlSysBusClass), }; +module_obj (TYPE_SYSBUS_FDC );static Property sysbus_fdc_properties[] = { DEFINE_PROP_SIGNED("fdtypeA", FDCtrlSysBus, state.qdev_for_drives[0].type,
@@ -164,6 +165,7 @@ static const TypeInfo sysbus_fdc_typeinfo = { .parent = TYPE_SYSBUS_FDC, .class_init = sysbus_fdc_class_init, }; +module_obj ("sysbus-fdc" );static Property sun4m_fdc_properties[] = { DEFINE_PROP_SIGNED("fdtype", FDCtrlSysBus, state.qdev_for_drives[0].type,
@@ -190,6 +192,7 @@ static const TypeInfo sun4m_fdc_typeinfo = { .parent = TYPE_SYSBUS_FDC, .class_init = sun4m_fdc_class_init, }; +module_obj ("sun-fdtwo" );static void sysbus_fdc_register_types (void ) {
@@ -199,3 +202,4 @@ static void sysbus_fdc_register_types(void) } type_init(sysbus_fdc_register_types) +module_dep("hw-block-fdc");
hw/block/fdc.c +2 -0
@@ -74,6 +74,7 @@ static const TypeInfo floppy_bus_info = { .parent = TYPE_BUS, .instance_size = sizeof(FloppyBus), }; +module_obj (TYPE_FLOPPY_BUS );static void floppy_bus_create (FDCtrl *fdc,FloppyBus *bus,DeviceState *dev) {
@@ -564,6 +565,7 @@ static const TypeInfo floppy_drive_info = { .instance_size = sizeof(FloppyDrive), .class_init = floppy_drive_class_init, }; +module_obj (TYPE_FLOPPY_DRIVE );/********************************************************/ /* Intel 82078 floppy disk controller emulation */
hw/block/meson.build +14 -3
@@ -1,3 +1,5 @@ +hw_block_modules = {} + softmmu_ss.add(files( 'block.c', 'cdrom.c',
@@ -5,9 +7,6 @@ softmmu_ss.add(files( )) softmmu_ss.add(when: 'CONFIG_ECC', if_true: files('ecc.c')) softmmu_ss.add(when: 'CONFIG_FDC', if_true: files('fdc-module.c')) -softmmu_ss.add(when: 'CONFIG_FDC', if_true: files('fdc.c')) -softmmu_ss.add(when: 'CONFIG_FDC_ISA', if_true: files('fdc-isa.c')) -softmmu_ss.add(when: 'CONFIG_FDC_SYSBUS', if_true: files('fdc-sysbus.c')) softmmu_ss.add(when: 'CONFIG_NAND', if_true: files('nand.c')) softmmu_ss.add(when: 'CONFIG_ONENAND', if_true: files('onenand.c')) softmmu_ss.add(when: 'CONFIG_PFLASH_CFI01', if_true: files('pflash_cfi01.c'))
@@ -20,4 +19,16 @@ softmmu_ss.add(when: 'CONFIG_TC58128', if_true: files('tc58128.c')) specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c')) specific_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk.c')) +fdc_ss = ss.source_set() +fdc_isa_ss = ss.source_set() +fdc_sysbus_ss = ss.source_set() +fdc_ss.add(when: 'CONFIG_FDC', if_true: files('fdc.c')) +fdc_isa_ss.add(when: 'CONFIG_FDC_ISA', if_true: files('fdc-isa.c')) +fdc_sysbus_ss.add(when: 'CONFIG_FDC_SYSBUS', if_true: files('fdc-sysbus.c')) +hw_block_modules += {'fdc': fdc_ss, + 'fdc-isa' : fdc_isa_ss, + 'fdc-sysbus' : fdc_sysbus_ss } + subdir('dataplane') + +modules += { 'hw-block': hw_block_modules }
Signature · 1 line
2.31.1
PATCH 7/7 pc: add floppy=OnOffAuto
In reply to Gerd HoffmannAllows to enable/disable the floppy controller. Default depends on MachineClass->no_floppy. It's ON for now, but we can flip the default for 6.2+ machine types.
NOTE: This requires -nodefaults or no_floppy=1 to actually have an effect. Otherwise the default floppy drive created by qemu will auto-enable the floppy controller. Not sure how to deal with that best. IMHO we should simply stop creating a default floppy, unfortunaly that will break live migration.
--- include/hw/i386/pc.h | 2 ++ hw/i386/pc.c | 23 +++++++++++++++++++++++ hw/i386/pc_piix.c | 8 +++++++- 3 files changed, 32 insertions(+), 1 deletion(-)
include/hw/i386/pc.h +2 -0
@@ -38,6 +38,7 @@ typedef struct PCMachineState {/* Configuration options: */ uint64_t max_ram_below_4g;OnOffAuto vmport; +OnOffAuto floppy;bool acpi_build_enabled;bool smbus_enabled;
@@ -59,6 +60,7 @@ typedef struct PCMachineState {#define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g"#define PC_MACHINE_DEVMEM_REGION_SIZE "device-memory-region-size"#define PC_MACHINE_VMPORT "vmport" +#define PC_MACHINE_FLOPPY "floppy"#define PC_MACHINE_SMBUS "smbus"#define PC_MACHINE_SATA "sata"#define PC_MACHINE_PIT "pit"
hw/i386/pc.c +23 -0
@@ -1468,6 +1468,23 @@ static void pc_machine_set_vmport(Object *obj, Visitor *v, const char *name,visit_type_OnOffAuto (v, name, &pcms->vmport, errp); } +static void pc_machine_get_floppy (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +PCMachineState *pcms =PC_MACHINE (obj); +OnOffAuto floppy = pcms->floppy; + +visit_type_OnOffAuto (v, name, &floppy, errp); +} + +static void pc_machine_set_floppy (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +PCMachineState *pcms =PC_MACHINE (obj); + +visit_type_OnOffAuto (v, name, &pcms->floppy, errp); +} +static bool pc_machine_get_smbus (Object *obj,Error **errp) {PCMachineState *pcms =PC_MACHINE (obj);
@@ -1751,6 +1768,12 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)object_class_property_set_description (oc,PC_MACHINE_VMPORT ,"Enable vmport (pc & q35)" ); +object_class_property_add (oc,PC_MACHINE_FLOPPY ,"OnOffAuto" , + pc_machine_get_floppy, pc_machine_set_floppy, +NULL ,NULL ); +object_class_property_set_description (oc,PC_MACHINE_FLOPPY , +"Enable floppy (pc only)" ); +object_class_property_add_bool (oc,PC_MACHINE_SMBUS , pc_machine_get_smbus, pc_machine_set_smbus);
hw/i386/pc_piix.c +7 -1
@@ -235,8 +235,14 @@ static void pc_init1(MachineState *machine, pcms->vmport =xen_enabled () ?ON_OFF_AUTO_OFF :ON_OFF_AUTO_ON ; } +if (pcms->floppy ==ON_OFF_AUTO_AUTO ) { + pcms->floppy =MACHINE_CLASS (pcmc)->no_floppy + ?ON_OFF_AUTO_OFF :ON_OFF_AUTO_ON ; + } +/* init basic PC hardware */ -pc_basic_device_init (pcms, isa_bus, x86ms->gsi, &rtc_state, true, +pc_basic_device_init (pcms, isa_bus, x86ms->gsi, &rtc_state, + pcms->floppy ==ON_OFF_AUTO_ON ,0x4 );pc_nic_init (pcmc, isa_bus, pci_bus);
Signature · 1 line
2.31.1
+Mark
Quoted 6 lines · Gerd Hoffmann
Some code shuffling needed beforehand due to floppy being part of several platforms. While being at it also make floppy optional in pc machine type.
floppy: move
fdctrl_init_sysbus
floppy: movesun4m_fdctrl_init
https://www.mail-archive.com/[email protected]/msg84008.html
Mark suggested:
You may be able to simplify this further by removing the global legacy init functions fdctrl_init_sysbus() and sun4m_fdctrl_init(): from what I can see fdctrl_init_sysbus() is only used in hw/mips/jazz.c and sun4m_fdctrl_init() is only used in hw/sparc/sun4m.c so you might as well inline them or move the functions to the relevant files.
I did it and plan to send during 6.2. Sounds simpler than module. You could easily rebase your series on top (or I can include your patches while sending).
Quoted 21 lines · Philippe Mathieu-Daudé
+Mark
Quoted 6 lines · Gerd Hoffmann
Some code shuffling needed beforehand due to floppy being part of several platforms. While being at it also make floppy optional in pc machine type.
floppy: move
fdctrl_init_sysbus
floppy: movesun4m_fdctrl_inithttps://www.mail-archive.com/[email protected]/msg84008.html
Mark suggested:
You may be able to simplify this further by removing the global legacy init functions
fdctrl_init_sysbus()andsun4m_fdctrl_init(): from what I can seefdctrl_init_sysbus()is only used inhw/mips/jazz.candsun4m_fdctrl_init()is only used inhw/sparc/sun4m.cso you might as well inline them or move the functions to the relevant files.
Quoted 3 lines
I did it and plan to send during 6.2. Sounds simpler than module. You could easily rebase your series on top (or I can include your patches while sending).
Feel free to include them. But I can also rebase when your patches landed upstream. Your choice ;)
take care,
Gerd
Quoted 26 lines · Gerd Hoffmann
Quoted 21 lines · Philippe Mathieu-Daudé
+Mark
Quoted 6 lines · Gerd Hoffmann
Some code shuffling needed beforehand due to floppy being part of several platforms. While being at it also make floppy optional in pc machine type.
floppy: move
fdctrl_init_sysbus
floppy: movesun4m_fdctrl_inithttps://www.mail-archive.com/[email protected]/msg84008.html
Mark suggested:
You may be able to simplify this further by removing the global legacy init functions
fdctrl_init_sysbus()andsun4m_fdctrl_init(): from what I can seefdctrl_init_sysbus()is only used inhw/mips/jazz.candsun4m_fdctrl_init()is only used inhw/sparc/sun4m.cso you might as well inline them or move the functions to the relevant files.Quoted 3 lines
I did it and plan to send during 6.2. Sounds simpler than module. You could easily rebase your series on top (or I can include your patches while sending).
Quoted 7 lines
Feel free to include them. But I can also rebase when your patches landed upstream. Your choice ;)
take care,
Gerd
What's the plan here, what are we trying to solve with this series *exactly*?
If Phil sends his cleanups, do we still want/need the modularization here?
For now I'm gonna shuffle these off of my review queue and I assume I'll see a respin/rebase from either you or phil during the 6.2 window, let me know if this is wrong.
Thanks,
--js
Hi John,
Quoted 30 lines · John Snow
On Thu, Aug 5, 2021 at 3:12 AM Gerd Hoffmann <[email protected] <mailto:[email protected]>> wrote:
On Wed, Aug 04, 2021 at 05:19:02PM +0200, Philippe Mathieu-Daudé wrote:
> +Mark
>
> On 8/4/21 4:27 PM, Gerd Hoffmann wrote:
> > Some code shuffling needed beforehand due to floppy being part of > > several platforms. While being at it also make floppy optional > > in pc machine type.
>
> > floppy: movefdctrl_init_sysbus
> > floppy: movesun4m_fdctrl_init
>
> https://www.mail-archive.com/[email protected]/msg84008.html
<https://www.mail-archive.com/[email protected]/msg84008.html>
>
> Mark suggested:
>
> You may be able to simplify this further by removing the > global legacy init functionsfdctrl_init_sysbus()and
> sun4m_fdctrl_init(): from what I can seefdctrl_init_sysbus()> is only used inhw/mips/jazz.candsun4m_fdctrl_init()is only > used inhw/sparc/sun4m.cso you might as well inline them or > move the functions to the relevant files.
>
> I did it and plan to send during 6.2. Sounds simpler than module. > You could easily rebase your series on top (or I can include your > patches while sending).
Quoted 6 lines
Feel free to include them. But I can also rebase when your patches landed upstream. Your choice ;)
What's the plan here, what are we trying to solve with this series *exactly*?
If Phil sends his cleanups, do we still want/need the modularization here?
Both series are orthogonal, but if my cleanups get merged first, there is less floppy code to modularize.
Quoted 3 lines
For now I'm gonna shuffle these off of my review queue and I assume I'll see a respin/rebase from either you or phil during the 6.2 window, let me know if this is wrong.
This is OK. Probably easier for everybody if I can rebase/include Gerd's patches along. I'm still not convinced FDC modularization is the right way to go; but the PC machine is one of machines I know the less, and has inherited a lot of odd things, so I need to carefully audit few more things.
I'd rather have faithful chipsets modelled. Long term I don't think FDC are going away from QEMU, as they are used by happy hobbyist running old DOS programs from the 80's. But being able to build QEMU without FDC would be nice indeed.
Quoted 55 lines · Philippe Mathieu-Daudé
Hi John,
Quoted 4 lines · John Snow
On Thu, Aug 5, 2021 at 3:12 AM Gerd Hoffmann <[email protected] <mailto:[email protected]>> wrote:
On Wed, Aug 04, 2021 at 05:19:02PM +0200, Philippe Mathieu-DaudéQuoted 26 lines · wrote:
Quoted 11 lines
+Mark
Quoted 6 lines · Gerd Hoffmann
Some code shuffling needed beforehand due to floppy being part of several platforms. While being at it also make floppy optional in pc machine type.
floppy: move
fdctrl_init_sysbus
floppy: movesun4m_fdctrl_inithttps://www.mail-archive.com/[email protected]/msg84008.html
<https://www.mail-archive.com/[email protected]/msg84008.html>
>
> Mark suggested:
>
> You may be able to simplify this further by removing the
> global legacy init functionsfdctrl_init_sysbus()and
>sun4m_fdctrl_init(): from what I can seefdctrl_init_sysbus()
> is only used inhw/mips/jazz.candsun4m_fdctrl_init()is only
> used inhw/sparc/sun4m.cso you might as well inline them or
> move the functions to the relevant files.
>
> I did it and plan to send during 6.2. Sounds simpler than module. > You could easily rebase your series on top (or I can include your > patches while sending).Quoted 6 lines
Feel free to include them. But I can also rebase when your patches landed upstream. Your choice ;)
What's the plan here, what are we trying to solve with this series *exactly*?
If Phil sends his cleanups, do we still want/need the modularizationhere?
Both series are orthogonal, but if my cleanups get merged first, there is less floppy code to modularize.
Quoted 3 lines
For now I'm gonna shuffle these off of my review queue and I assume I'll see a respin/rebase from either you or phil during the 6.2 window, let me know if this is wrong.
This is OK. Probably easier for everybody if I can rebase/include Gerd's patches along. I'm still not convinced FDC modularization is the right way to go; but the PC machine is one of machines I know the less, and has inherited a lot of odd things, so I need to carefully audit few more things.
Quoted 6 lines
I'd rather have faithful chipsets modelled. Long term I don't think FDC are going away from QEMU, as they are used by happy hobbyist running old DOS programs from the 80's. But being able to build QEMU without FDC would be nice indeed.
OK, Understood -- And you're right, upstream the FDC needs a bit of work and love, because they are used and important. I just ... as you can tell, don't have much time to give them that love myself.
*cough* *cough* *nudge* *wink*
I'll be sending a patch when 6.2 opens indicating my desire to step down from the device.
--js