qdev: Add HEX8 property
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
c17725f473
commit
6835678c25
@ -93,6 +93,35 @@ PropertyInfo qdev_prop_uint8 = {
|
|||||||
.print = print_uint8,
|
.print = print_uint8,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* --- 8bit hex value --- */
|
||||||
|
|
||||||
|
static int parse_hex8(DeviceState *dev, Property *prop, const char *str)
|
||||||
|
{
|
||||||
|
uint8_t *ptr = qdev_get_prop_ptr(dev, prop);
|
||||||
|
char *end;
|
||||||
|
|
||||||
|
*ptr = strtoul(str, &end, 16);
|
||||||
|
if ((*end != '\0') || (end == str)) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int print_hex8(DeviceState *dev, Property *prop, char *dest, size_t len)
|
||||||
|
{
|
||||||
|
uint8_t *ptr = qdev_get_prop_ptr(dev, prop);
|
||||||
|
return snprintf(dest, len, "0x%" PRIx8, *ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyInfo qdev_prop_hex8 = {
|
||||||
|
.name = "hex8",
|
||||||
|
.type = PROP_TYPE_UINT8,
|
||||||
|
.size = sizeof(uint8_t),
|
||||||
|
.parse = parse_hex8,
|
||||||
|
.print = print_hex8,
|
||||||
|
};
|
||||||
|
|
||||||
/* --- 16bit integer --- */
|
/* --- 16bit integer --- */
|
||||||
|
|
||||||
static int parse_uint16(DeviceState *dev, Property *prop, const char *str)
|
static int parse_uint16(DeviceState *dev, Property *prop, const char *str)
|
||||||
|
@ -224,6 +224,7 @@ extern PropertyInfo qdev_prop_uint16;
|
|||||||
extern PropertyInfo qdev_prop_uint32;
|
extern PropertyInfo qdev_prop_uint32;
|
||||||
extern PropertyInfo qdev_prop_int32;
|
extern PropertyInfo qdev_prop_int32;
|
||||||
extern PropertyInfo qdev_prop_uint64;
|
extern PropertyInfo qdev_prop_uint64;
|
||||||
|
extern PropertyInfo qdev_prop_hex8;
|
||||||
extern PropertyInfo qdev_prop_hex32;
|
extern PropertyInfo qdev_prop_hex32;
|
||||||
extern PropertyInfo qdev_prop_hex64;
|
extern PropertyInfo qdev_prop_hex64;
|
||||||
extern PropertyInfo qdev_prop_string;
|
extern PropertyInfo qdev_prop_string;
|
||||||
@ -267,6 +268,8 @@ extern PropertyInfo qdev_prop_pci_devfn;
|
|||||||
DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t)
|
DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t)
|
||||||
#define DEFINE_PROP_UINT64(_n, _s, _f, _d) \
|
#define DEFINE_PROP_UINT64(_n, _s, _f, _d) \
|
||||||
DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
|
DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
|
||||||
|
#define DEFINE_PROP_HEX8(_n, _s, _f, _d) \
|
||||||
|
DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex8, uint8_t)
|
||||||
#define DEFINE_PROP_HEX32(_n, _s, _f, _d) \
|
#define DEFINE_PROP_HEX32(_n, _s, _f, _d) \
|
||||||
DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex32, uint32_t)
|
DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex32, uint32_t)
|
||||||
#define DEFINE_PROP_HEX64(_n, _s, _f, _d) \
|
#define DEFINE_PROP_HEX64(_n, _s, _f, _d) \
|
||||||
|
Loading…
Reference in New Issue
Block a user