target-ppc: Extract MPC82xx aliases to *_HiP4
[qemu/agraf.git] / hw / qdev-properties.h
blob20c67f344353d345f591815161b22ec0576fca94
1 #ifndef QEMU_QDEV_PROPERTIES_H
2 #define QEMU_QDEV_PROPERTIES_H
4 #include "qdev-core.h"
6 /*** qdev-properties.c ***/
8 extern PropertyInfo qdev_prop_bit;
9 extern PropertyInfo qdev_prop_uint8;
10 extern PropertyInfo qdev_prop_uint16;
11 extern PropertyInfo qdev_prop_uint32;
12 extern PropertyInfo qdev_prop_int32;
13 extern PropertyInfo qdev_prop_uint64;
14 extern PropertyInfo qdev_prop_hex8;
15 extern PropertyInfo qdev_prop_hex32;
16 extern PropertyInfo qdev_prop_hex64;
17 extern PropertyInfo qdev_prop_string;
18 extern PropertyInfo qdev_prop_chr;
19 extern PropertyInfo qdev_prop_ptr;
20 extern PropertyInfo qdev_prop_macaddr;
21 extern PropertyInfo qdev_prop_losttickpolicy;
22 extern PropertyInfo qdev_prop_bios_chs_trans;
23 extern PropertyInfo qdev_prop_drive;
24 extern PropertyInfo qdev_prop_netdev;
25 extern PropertyInfo qdev_prop_vlan;
26 extern PropertyInfo qdev_prop_pci_devfn;
27 extern PropertyInfo qdev_prop_blocksize;
28 extern PropertyInfo qdev_prop_pci_host_devaddr;
30 #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
31 .name = (_name), \
32 .info = &(_prop), \
33 .offset = offsetof(_state, _field) \
34 + type_check(_type, typeof_field(_state, _field)), \
36 #define DEFINE_PROP_DEFAULT(_name, _state, _field, _defval, _prop, _type) { \
37 .name = (_name), \
38 .info = &(_prop), \
39 .offset = offsetof(_state, _field) \
40 + type_check(_type,typeof_field(_state, _field)), \
41 .qtype = QTYPE_QINT, \
42 .defval = (_type)_defval, \
44 #define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \
45 .name = (_name), \
46 .info = &(qdev_prop_bit), \
47 .bitnr = (_bit), \
48 .offset = offsetof(_state, _field) \
49 + type_check(uint32_t,typeof_field(_state, _field)), \
50 .qtype = QTYPE_QBOOL, \
51 .defval = (bool)_defval, \
54 #define DEFINE_PROP_UINT8(_n, _s, _f, _d) \
55 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
56 #define DEFINE_PROP_UINT16(_n, _s, _f, _d) \
57 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
58 #define DEFINE_PROP_UINT32(_n, _s, _f, _d) \
59 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
60 #define DEFINE_PROP_INT32(_n, _s, _f, _d) \
61 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t)
62 #define DEFINE_PROP_UINT64(_n, _s, _f, _d) \
63 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
64 #define DEFINE_PROP_HEX8(_n, _s, _f, _d) \
65 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex8, uint8_t)
66 #define DEFINE_PROP_HEX32(_n, _s, _f, _d) \
67 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex32, uint32_t)
68 #define DEFINE_PROP_HEX64(_n, _s, _f, _d) \
69 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex64, uint64_t)
70 #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \
71 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
73 #define DEFINE_PROP_PTR(_n, _s, _f) \
74 DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
75 #define DEFINE_PROP_CHR(_n, _s, _f) \
76 DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
77 #define DEFINE_PROP_STRING(_n, _s, _f) \
78 DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)
79 #define DEFINE_PROP_NETDEV(_n, _s, _f) \
80 DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NICPeers)
81 #define DEFINE_PROP_VLAN(_n, _s, _f) \
82 DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, NICPeers)
83 #define DEFINE_PROP_DRIVE(_n, _s, _f) \
84 DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *)
85 #define DEFINE_PROP_MACADDR(_n, _s, _f) \
86 DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr)
87 #define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \
88 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
89 LostTickPolicy)
90 #define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \
91 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
92 #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
93 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
94 #define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
95 DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
97 #define DEFINE_PROP_END_OF_LIST() \
100 /* Set properties between creation and init. */
101 void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
102 int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
103 void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value);
104 void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value);
105 void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value);
106 void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value);
107 void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value);
108 void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
109 void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value);
110 void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
111 void qdev_prop_set_netdev(DeviceState *dev, const char *name, NetClientState *value);
112 int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) QEMU_WARN_UNUSED_RESULT;
113 void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value);
114 void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);
115 void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
116 /* FIXME: Remove opaque pointer properties. */
117 void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
119 void qdev_prop_register_global(GlobalProperty *prop);
120 void qdev_prop_register_global_list(GlobalProperty *props);
121 void qdev_prop_set_globals(DeviceState *dev);
122 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
123 Property *prop, const char *value);
126 * @qdev_property_add_static - add a @Property to a device referencing a
127 * field in a struct.
129 void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp);
131 #endif