Statistics
| Branch: | Revision:

root / hw / qdev-properties.h @ d36b66f7

History | View | Annotate | Download (6.6 kB)

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