mirror of
https://github.com/Motorhead1991/qemu.git
synced 2026-02-18 02:12:13 -07:00
Clean-ups: qom-ify serial and remove QDEV_PROP_PTR
Hi, QDEV_PROP_PTR is marked in multiple places as "FIXME/TODO/remove me". In most cases, it can be easily replaced with QDEV_PROP_LINK when the pointer points to an Object. There are a few places where such substitution isn't possible. For those places, it seems reasonable to use a specific setter method instead, and keep the user_creatable = false. In other places, proper usage of qdev or other facilies is the solution. The serial code wasn't converted to qdev, which makes it a bit more archaic to deal with. Let's convert it first, so we can more easily embed it from other devices, and re-export some properties and drop QDEV_PROP_PTR usage. -----BEGIN PGP SIGNATURE----- iQJQBAABCAA6FiEEh6m9kz+HxgbSdvYt2ujhCXWWnOUFAl4UnUYcHG1hcmNhbmRy ZS5sdXJlYXVAcmVkaGF0LmNvbQAKCRDa6OEJdZac5cfYEACcTfXklXdxLDj94Q5/ d6MxYqZWckO+vyMqOwonodl9BS3clpDDxbYzyfTpqwKS2cVg1eUUBPR7/eioX6zT grM0rlgsKWJf9UurJwJWw7Zys7dXZMVJ2BdigLUEZrv9hFF15t344qoKgk4wYmBj 2wC7l7j2WZZ0vtXN7IH4/ZXnaN5/kdoPj6BrF0oNSJaq1AjPByQxmOJhvrxVsm6y gn3la4XbfMIC68qPjcDJAScGXtCWG1Vydw9cFHwRpMfcvPyL70l6FMjIwrLYNQ9b j1AkcEXeev5nWT+gLGxt+TGXB0Sd2ID9uRYxhyZRA4fdjHFtlWfdOwepOOlSlTO+ yfpf9STDLuDQGLTJyNZpYGGDDcm4xsJ8arD/7/Mq/35BQl9ZUT+m6uC1tDhxEHzf +AD/Kh8rMptyAjwtqD2XbqyLoaFJCsPjZbjTj3SY08WaeqClmaAbSD2eaJiNXy4H +rFg9P/eOB+71R1AoMKfiBFzdGV6TG5PLZOJ/oN02yqp0oW8eDWYcETB3j0tIgS1 u2WVCS2cd8IqYa+UQ7COOpoX0UwICmIWV64kxioD7uFQiK/1nQYw4UnPHv29qY6k fTa8jUC5hPiDN1rRYqNpNoVJsstSZfSgpo5jV75sxSyDucupu+SM9qmo3+fBab+q Eol3Ypz4virkNU8IYCYFFiG4Qg== =iYVd -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/elmarco/tags/prop-ptr-pull-request' into staging Clean-ups: qom-ify serial and remove QDEV_PROP_PTR Hi, QDEV_PROP_PTR is marked in multiple places as "FIXME/TODO/remove me". In most cases, it can be easily replaced with QDEV_PROP_LINK when the pointer points to an Object. There are a few places where such substitution isn't possible. For those places, it seems reasonable to use a specific setter method instead, and keep the user_creatable = false. In other places, proper usage of qdev or other facilies is the solution. The serial code wasn't converted to qdev, which makes it a bit more archaic to deal with. Let's convert it first, so we can more easily embed it from other devices, and re-export some properties and drop QDEV_PROP_PTR usage. # gpg: Signature made Tue 07 Jan 2020 15:01:26 GMT # gpg: using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5 # gpg: issuer "marcandre.lureau@redhat.com" # gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>" [full] # gpg: aka "Marc-André Lureau <marcandre.lureau@gmail.com>" [full] # Primary key fingerprint: 87A9 BD93 3F87 C606 D276 F62D DAE8 E109 7596 9CE5 * remotes/elmarco/tags/prop-ptr-pull-request: (37 commits) qdev/qom: remove some TODO limitations now that PROP_PTR is gone qdev: remove QDEV_PROP_PTR qdev: remove PROP_MEMORY_REGION omap-gpio: remove PROP_PTR omap-i2c: remove PROP_PTR omap-intc: remove PROP_PTR smbus-eeprom: remove PROP_PTR cris: improve passing PIC interrupt vector to the CPU mips/cps: fix setting saar property qdev: use g_strcmp0() instead of open-coding it leon3: use qdev gpio facilities for the PIL leon3: use qemu_irq framework instead of callback as property dp8393x: replace PROP_PTR with PROP_LINK etraxfs: remove PROP_PTR usage lance: replace PROP_PTR with PROP_LINK vmmouse: replace PROP_PTR with PROP_LINK sm501: make SerialMM a child, export chardev property mips: use sysbus_mmio_get_region() instead of internal fields mips: use sysbus_add_io() mips: baudbase is 115200 by default ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
1bbd1511b6
47 changed files with 514 additions and 396 deletions
|
|
@ -67,6 +67,58 @@ void omap_clk_setrate(omap_clk clk, int divide, int multiply);
|
|||
int64_t omap_clk_getrate(omap_clk clk);
|
||||
void omap_clk_reparent(omap_clk clk, omap_clk parent);
|
||||
|
||||
/* omap_intc.c */
|
||||
#define TYPE_OMAP_INTC "common-omap-intc"
|
||||
#define OMAP_INTC(obj) \
|
||||
OBJECT_CHECK(omap_intr_handler, (obj), TYPE_OMAP_INTC)
|
||||
|
||||
typedef struct omap_intr_handler_s omap_intr_handler;
|
||||
|
||||
/*
|
||||
* TODO: Ideally we should have a clock framework that
|
||||
* let us wire these clocks up with QOM properties or links.
|
||||
*
|
||||
* qdev should support a generic means of defining a 'port' with
|
||||
* an arbitrary interface for connecting two devices. Then we
|
||||
* could reframe the omap clock API in terms of clock ports,
|
||||
* and get some type safety. For now the best qdev provides is
|
||||
* passing an arbitrary pointer.
|
||||
* (It's not possible to pass in the string which is the clock
|
||||
* name, because this device does not have the necessary information
|
||||
* (ie the struct omap_mpu_state_s*) to do the clockname to pointer
|
||||
* translation.)
|
||||
*/
|
||||
void omap_intc_set_iclk(omap_intr_handler *intc, omap_clk clk);
|
||||
void omap_intc_set_fclk(omap_intr_handler *intc, omap_clk clk);
|
||||
|
||||
/* omap_i2c.c */
|
||||
#define TYPE_OMAP_I2C "omap_i2c"
|
||||
#define OMAP_I2C(obj) OBJECT_CHECK(OMAPI2CState, (obj), TYPE_OMAP_I2C)
|
||||
|
||||
typedef struct OMAPI2CState OMAPI2CState;
|
||||
|
||||
/* TODO: clock framework (see above) */
|
||||
void omap_i2c_set_iclk(OMAPI2CState *i2c, omap_clk clk);
|
||||
void omap_i2c_set_fclk(OMAPI2CState *i2c, omap_clk clk);
|
||||
|
||||
/* omap_gpio.c */
|
||||
#define TYPE_OMAP1_GPIO "omap-gpio"
|
||||
#define OMAP1_GPIO(obj) \
|
||||
OBJECT_CHECK(struct omap_gpif_s, (obj), TYPE_OMAP1_GPIO)
|
||||
|
||||
#define TYPE_OMAP2_GPIO "omap2-gpio"
|
||||
#define OMAP2_GPIO(obj) \
|
||||
OBJECT_CHECK(struct omap2_gpif_s, (obj), TYPE_OMAP2_GPIO)
|
||||
|
||||
typedef struct omap_gpif_s omap_gpif;
|
||||
typedef struct omap2_gpif_s omap2_gpif;
|
||||
|
||||
/* TODO: clock framework (see above) */
|
||||
void omap_gpio_set_clk(omap_gpif *gpio, omap_clk clk);
|
||||
|
||||
void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk);
|
||||
void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk);
|
||||
|
||||
/* OMAP2 l4 Interconnect */
|
||||
struct omap_l4_s;
|
||||
struct omap_l4_region_s {
|
||||
|
|
|
|||
|
|
@ -30,10 +30,13 @@
|
|||
#include "exec/memory.h"
|
||||
#include "qemu/fifo8.h"
|
||||
#include "chardev/char.h"
|
||||
#include "hw/sysbus.h"
|
||||
|
||||
#define UART_FIFO_LENGTH 16 /* 16550A Fifo Length */
|
||||
|
||||
typedef struct SerialState {
|
||||
DeviceState parent;
|
||||
|
||||
uint16_t divider;
|
||||
uint8_t rbr; /* receive register */
|
||||
uint8_t thr; /* transmit holding register */
|
||||
|
|
@ -54,8 +57,7 @@ typedef struct SerialState {
|
|||
qemu_irq irq;
|
||||
CharBackend chr;
|
||||
int last_break_enable;
|
||||
int it_shift;
|
||||
int baudbase;
|
||||
uint32_t baudbase;
|
||||
uint32_t tsr_retry;
|
||||
guint watch_tag;
|
||||
uint32_t wakeup;
|
||||
|
|
@ -77,20 +79,39 @@ typedef struct SerialState {
|
|||
MemoryRegion io;
|
||||
} SerialState;
|
||||
|
||||
typedef struct SerialMM {
|
||||
SysBusDevice parent;
|
||||
|
||||
SerialState serial;
|
||||
|
||||
uint8_t regshift;
|
||||
uint8_t endianness;
|
||||
} SerialMM;
|
||||
|
||||
typedef struct SerialIO {
|
||||
SysBusDevice parent;
|
||||
|
||||
SerialState serial;
|
||||
} SerialIO;
|
||||
|
||||
extern const VMStateDescription vmstate_serial;
|
||||
extern const MemoryRegionOps serial_io_ops;
|
||||
|
||||
void serial_realize_core(SerialState *s, Error **errp);
|
||||
void serial_exit_core(SerialState *s);
|
||||
void serial_set_frequency(SerialState *s, uint32_t frequency);
|
||||
|
||||
/* legacy pre qom */
|
||||
SerialState *serial_init(int base, qemu_irq irq, int baudbase,
|
||||
Chardev *chr, MemoryRegion *system_io);
|
||||
SerialState *serial_mm_init(MemoryRegion *address_space,
|
||||
hwaddr base, int it_shift,
|
||||
qemu_irq irq, int baudbase,
|
||||
Chardev *chr, enum device_endian end);
|
||||
#define TYPE_SERIAL "serial"
|
||||
#define SERIAL(s) OBJECT_CHECK(SerialState, (s), TYPE_SERIAL)
|
||||
|
||||
#define TYPE_SERIAL_MM "serial-mm"
|
||||
#define SERIAL_MM(s) OBJECT_CHECK(SerialMM, (s), TYPE_SERIAL_MM)
|
||||
|
||||
#define TYPE_SERIAL_IO "serial-io"
|
||||
#define SERIAL_IO(s) OBJECT_CHECK(SerialIO, (s), TYPE_SERIAL_IO)
|
||||
|
||||
SerialMM *serial_mm_init(MemoryRegion *address_space,
|
||||
hwaddr base, int regshift,
|
||||
qemu_irq irq, int baudbase,
|
||||
Chardev *chr, enum device_endian end);
|
||||
|
||||
/* serial-isa.c */
|
||||
|
||||
|
|
|
|||
|
|
@ -30,23 +30,9 @@
|
|||
#include "hw/qdev-properties.h"
|
||||
#include "hw/sysbus.h"
|
||||
|
||||
/* Instantiate an ETRAXFS Ethernet MAC. */
|
||||
static inline DeviceState *
|
||||
etraxfs_eth_init(NICInfo *nd, hwaddr base, int phyaddr,
|
||||
void *dma_out, void *dma_in)
|
||||
{
|
||||
DeviceState *dev;
|
||||
qemu_check_nic_model(nd, "fseth");
|
||||
|
||||
dev = qdev_create(NULL, "etraxfs-eth");
|
||||
qdev_set_nic_properties(dev, nd);
|
||||
qdev_prop_set_uint32(dev, "phyaddr", phyaddr);
|
||||
qdev_prop_set_ptr(dev, "dma_out", dma_out);
|
||||
qdev_prop_set_ptr(dev, "dma_in", dma_in);
|
||||
qdev_init_nofail(dev);
|
||||
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
|
||||
return dev;
|
||||
}
|
||||
DeviceState *etraxfs_eth_init(NICInfo *nd, hwaddr base, int phyaddr,
|
||||
struct etraxfs_dma_client *dma_out,
|
||||
struct etraxfs_dma_client *dma_in);
|
||||
|
||||
static inline DeviceState *etraxfs_ser_create(hwaddr addr,
|
||||
qemu_irq irq,
|
||||
|
|
|
|||
|
|
@ -14,10 +14,12 @@
|
|||
|
||||
#define I8042_A20_LINE "a20"
|
||||
|
||||
typedef struct ISAKBDState ISAKBDState;
|
||||
|
||||
void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
|
||||
MemoryRegion *region, ram_addr_t size,
|
||||
hwaddr mask);
|
||||
void i8042_isa_mouse_fake_event(void *opaque);
|
||||
void i8042_isa_mouse_fake_event(ISAKBDState *isa);
|
||||
void i8042_setup_a20_line(ISADevice *dev, qemu_irq a20_out);
|
||||
|
||||
#endif /* HW_INPUT_I8042_H */
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ extern const PropertyInfo qdev_prop_size;
|
|||
extern const PropertyInfo qdev_prop_string;
|
||||
extern const PropertyInfo qdev_prop_chr;
|
||||
extern const PropertyInfo qdev_prop_tpm;
|
||||
extern const PropertyInfo qdev_prop_ptr;
|
||||
extern const PropertyInfo qdev_prop_macaddr;
|
||||
extern const PropertyInfo qdev_prop_on_off_auto;
|
||||
extern const PropertyInfo qdev_prop_losttickpolicy;
|
||||
|
|
@ -171,25 +170,6 @@ extern const PropertyInfo qdev_prop_pcie_link_width;
|
|||
#define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \
|
||||
DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
|
||||
|
||||
/*
|
||||
* Please avoid pointer properties. If you must use them, you must
|
||||
* cover them in their device's class init function as follows:
|
||||
*
|
||||
* - If the property must be set, the device cannot be used with
|
||||
* device_add, so add code like this:
|
||||
* |* Reason: pointer property "NAME-OF-YOUR-PROP" *|
|
||||
* DeviceClass *dc = DEVICE_CLASS(class);
|
||||
* dc->user_creatable = false;
|
||||
*
|
||||
* - If the property may safely remain null, document it like this:
|
||||
* |*
|
||||
* * Note: pointer property "interrupt_vector" may remain null, thus
|
||||
* * no need for dc->user_creatable = false;
|
||||
* *|
|
||||
*/
|
||||
#define DEFINE_PROP_PTR(_n, _s, _f) \
|
||||
DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
|
||||
|
||||
#define DEFINE_PROP_CHR(_n, _s, _f) \
|
||||
DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharBackend)
|
||||
#define DEFINE_PROP_STRING(_n, _s, _f) \
|
||||
|
|
@ -216,8 +196,6 @@ extern const PropertyInfo qdev_prop_pcie_link_width;
|
|||
DEFINE_PROP_UNSIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t)
|
||||
#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
|
||||
DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
|
||||
#define DEFINE_PROP_MEMORY_REGION(_n, _s, _f) \
|
||||
DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, MemoryRegion *)
|
||||
#define DEFINE_PROP_OFF_AUTO_PCIBAR(_n, _s, _f, _d) \
|
||||
DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_off_auto_pcibar, \
|
||||
OffAutoPCIBAR)
|
||||
|
|
@ -264,8 +242,6 @@ void qdev_prop_set_drive(DeviceState *dev, const char *name,
|
|||
void qdev_prop_set_macaddr(DeviceState *dev, const char *name,
|
||||
const uint8_t *value);
|
||||
void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
|
||||
/* FIXME: Remove opaque pointer properties. */
|
||||
void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
|
||||
|
||||
void qdev_prop_register_global(GlobalProperty *prop);
|
||||
int qdev_prop_check_globals(void);
|
||||
|
|
|
|||
|
|
@ -24,10 +24,6 @@ typedef struct SysBusDevice SysBusDevice;
|
|||
|
||||
/**
|
||||
* SysBusDeviceClass:
|
||||
* @init: Callback function invoked when the #DeviceState.realized property
|
||||
* is changed to %true. Deprecated, new types inheriting directly from
|
||||
* TYPE_SYS_BUS_DEVICE should use #DeviceClass.realize instead, new leaf
|
||||
* types should consult their respective parent type.
|
||||
*
|
||||
* SysBusDeviceClass is not overriding #DeviceClass.realize, so derived
|
||||
* classes overriding it are not required to invoke its implementation.
|
||||
|
|
@ -117,8 +113,7 @@ void foreach_dynamic_sysbus_device(FindSysbusDeviceFunc *func, void *opaque);
|
|||
/* Legacy helper function for creating devices. */
|
||||
DeviceState *sysbus_create_varargs(const char *name,
|
||||
hwaddr addr, ...);
|
||||
DeviceState *sysbus_try_create_varargs(const char *name,
|
||||
hwaddr addr, ...);
|
||||
|
||||
static inline DeviceState *sysbus_create_simple(const char *name,
|
||||
hwaddr addr,
|
||||
qemu_irq irq)
|
||||
|
|
@ -126,11 +121,5 @@ static inline DeviceState *sysbus_create_simple(const char *name,
|
|||
return sysbus_create_varargs(name, addr, irq, NULL);
|
||||
}
|
||||
|
||||
static inline DeviceState *sysbus_try_create_simple(const char *name,
|
||||
hwaddr addr,
|
||||
qemu_irq irq)
|
||||
{
|
||||
return sysbus_try_create_varargs(name, addr, irq, NULL);
|
||||
}
|
||||
|
||||
#endif /* HW_SYSBUS_H */
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
typedef enum IdSubSystems {
|
||||
ID_QDEV,
|
||||
ID_BLOCK,
|
||||
ID_CHR,
|
||||
ID_MAX /* last element, used as array size */
|
||||
} IdSubSystems;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue