2 #include "hw/qdev-addr.h"
3 #include "exec/hwaddr.h"
4 #include "qapi/qmp/qerror.h"
5 #include "qapi/visitor.h"
7 /* --- target physical address --- */
9 static int parse_taddr(DeviceState
*dev
, Property
*prop
, const char *str
)
11 hwaddr
*ptr
= qdev_get_prop_ptr(dev
, prop
);
13 *ptr
= strtoull(str
, NULL
, 16);
17 static int print_taddr(DeviceState
*dev
, Property
*prop
, char *dest
, size_t len
)
19 hwaddr
*ptr
= qdev_get_prop_ptr(dev
, prop
);
20 return snprintf(dest
, len
, "0x" TARGET_FMT_plx
, *ptr
);
23 static void get_taddr(Object
*obj
, Visitor
*v
, void *opaque
,
24 const char *name
, Error
**errp
)
26 DeviceState
*dev
= DEVICE(obj
);
27 Property
*prop
= opaque
;
28 hwaddr
*ptr
= qdev_get_prop_ptr(dev
, prop
);
32 visit_type_int64(v
, &value
, name
, errp
);
35 static void set_taddr(Object
*obj
, Visitor
*v
, void *opaque
,
36 const char *name
, Error
**errp
)
38 DeviceState
*dev
= DEVICE(obj
);
39 Property
*prop
= opaque
;
40 hwaddr
*ptr
= qdev_get_prop_ptr(dev
, prop
);
41 Error
*local_err
= NULL
;
45 qdev_prop_set_after_realize(dev
, name
, errp
);
49 visit_type_int64(v
, &value
, name
, &local_err
);
51 error_propagate(errp
, local_err
);
54 if ((uint64_t)value
<= (uint64_t) ~(hwaddr
)0) {
57 error_set(errp
, QERR_PROPERTY_VALUE_OUT_OF_RANGE
,
58 dev
->id
?:"", name
, value
, (uint64_t) 0,
59 (uint64_t) ~(hwaddr
)0);
64 PropertyInfo qdev_prop_taddr
= {
72 void qdev_prop_set_taddr(DeviceState
*dev
, const char *name
, hwaddr value
)
75 object_property_set_int(OBJECT(dev
), value
, name
, &errp
);