summaryrefslogtreecommitdiffstats
path: root/hw/qdev-properties.h
diff options
context:
space:
mode:
authorBlue Swirl2013-03-17 18:44:47 +0100
committerBlue Swirl2013-03-17 18:44:47 +0100
commit7fb7377594887db99a2100adcddf3bd6394ef540 (patch)
tree6ead329409c9687ae617eba42f876653c07c315c /hw/qdev-properties.h
parenttarget-mips: fix rndrashift_short_acc and code for EXTR_ instructions (diff)
parentxilinx_spips: QOM styling fixes (diff)
downloadqemu-7fb7377594887db99a2100adcddf3bd6394ef540.tar.gz
qemu-7fb7377594887db99a2100adcddf3bd6394ef540.tar.xz
qemu-7fb7377594887db99a2100adcddf3bd6394ef540.zip
Merge branch 'arm-devs.next' of git://git.linaro.org/people/pmaydell/qemu-arm
* 'arm-devs.next' of git://git.linaro.org/people/pmaydell/qemu-arm: xilinx_spips: QOM styling fixes xilinx_spips: Add missing dual-bus snoop commands xilinx_spips: Fix bus setup conditional check xilinx_spips: Set unused IRQs to NULL xilinx_zynq: added pl330 to machine model pl330: Initial version iov: Factor out hexdumper hw/vexpress: Set reset values for daughterboard oscillators hw/arm_sysctl: Implement SYS_CFG_OSC function hw/vexpress: Pass voltage sensor properties to sysctl device hw/arm_sysctl: Implement SYS_CFG_VOLT qdev: Implement (variable length) array properties hw/arm_sysctl: Convert from qdev init to instance_init hw/arm_sysctl: Implement SYS_CFG_DVIMODE as a no-op hw/arm_sysctl: Implement SYS_CFG_MUXFPGA writes as a no-op hw/arm_sysctl: Handle SYS_CFGCTRL in a more structured way hw/vexpress: Pass proc_id via VEDBoardInfo
Diffstat (limited to 'hw/qdev-properties.h')
-rw-r--r--hw/qdev-properties.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/hw/qdev-properties.h b/hw/qdev-properties.h
index 0b0465c9b3..c9bb246841 100644
--- a/hw/qdev-properties.h
+++ b/hw/qdev-properties.h
@@ -26,6 +26,7 @@ extern PropertyInfo qdev_prop_vlan;
extern PropertyInfo qdev_prop_pci_devfn;
extern PropertyInfo qdev_prop_blocksize;
extern PropertyInfo qdev_prop_pci_host_devaddr;
+extern PropertyInfo qdev_prop_arraylen;
#define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
.name = (_name), \
@@ -51,6 +52,44 @@ extern PropertyInfo qdev_prop_pci_host_devaddr;
.defval = (bool)_defval, \
}
+#define PROP_ARRAY_LEN_PREFIX "len-"
+
+/**
+ * DEFINE_PROP_ARRAY:
+ * @_name: name of the array
+ * @_state: name of the device state structure type
+ * @_field: uint32_t field in @_state to hold the array length
+ * @_arrayfield: field in @_state (of type '@_arraytype *') which
+ * will point to the array
+ * @_arrayprop: PropertyInfo defining what property the array elements have
+ * @_arraytype: C type of the array elements
+ *
+ * Define device properties for a variable-length array _name. A
+ * static property "len-arrayname" is defined. When the device creator
+ * sets this property to the desired length of array, further dynamic
+ * properties "arrayname[0]", "arrayname[1]", ... are defined so the
+ * device creator can set the array element values. Setting the
+ * "len-arrayname" property more than once is an error.
+ *
+ * When the array length is set, the @_field member of the device
+ * struct is set to the array length, and @_arrayfield is set to point
+ * to (zero-initialised) memory allocated for the array. For a zero
+ * length array, @_field will be set to 0 and @_arrayfield to NULL.
+ * It is the responsibility of the device deinit code to free the
+ * @_arrayfield memory.
+ */
+#define DEFINE_PROP_ARRAY(_name, _state, _field, \
+ _arrayfield, _arrayprop, _arraytype) { \
+ .name = (PROP_ARRAY_LEN_PREFIX _name), \
+ .info = &(qdev_prop_arraylen), \
+ .offset = offsetof(_state, _field) \
+ + type_check(uint32_t, typeof_field(_state, _field)), \
+ .qtype = QTYPE_QINT, \
+ .arrayinfo = &(_arrayprop), \
+ .arrayfieldsize = sizeof(_arraytype), \
+ .arrayoffset = offsetof(_state, _arrayfield), \
+ }
+
#define DEFINE_PROP_UINT8(_n, _s, _f, _d) \
DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
#define DEFINE_PROP_UINT16(_n, _s, _f, _d) \