blob: 305c2d37b06afc881dbd27a18d7d0e73dd82ec94 [file] [log] [blame]
Gerd Hoffmannee6847d2009-07-15 13:43:31 +02001#include "qdev.h"
2#include "qdev-addr.h"
3#include "targphys.h"
4
5/* --- target physical address --- */
6
7static int parse_taddr(DeviceState *dev, Property *prop, const char *str)
8{
Anthony Liguoric227f092009-10-01 16:12:16 -05009 target_phys_addr_t *ptr = qdev_get_prop_ptr(dev, prop);
Gerd Hoffmannee6847d2009-07-15 13:43:31 +020010
11 *ptr = strtoull(str, NULL, 16);
12 return 0;
13}
14
15static int print_taddr(DeviceState *dev, Property *prop, char *dest, size_t len)
16{
Anthony Liguoric227f092009-10-01 16:12:16 -050017 target_phys_addr_t *ptr = qdev_get_prop_ptr(dev, prop);
Gerd Hoffmannee6847d2009-07-15 13:43:31 +020018 return snprintf(dest, len, "0x" TARGET_FMT_plx, *ptr);
19}
20
21PropertyInfo qdev_prop_taddr = {
22 .name = "taddr",
23 .type = PROP_TYPE_TADDR,
Anthony Liguoric227f092009-10-01 16:12:16 -050024 .size = sizeof(target_phys_addr_t),
Gerd Hoffmannee6847d2009-07-15 13:43:31 +020025 .parse = parse_taddr,
26 .print = print_taddr,
27};
28
Anthony Liguoric227f092009-10-01 16:12:16 -050029void qdev_prop_set_taddr(DeviceState *dev, const char *name, target_phys_addr_t value)
Gerd Hoffmannee6847d2009-07-15 13:43:31 +020030{
31 qdev_prop_set(dev, name, &value, PROP_TYPE_TADDR);
32}