3 #include "exec/hwaddr.h"
4 #include "qapi/visitor.h"
6 /* --- target physical address --- */
8 static int parse_taddr(DeviceState
*dev
, Property
*prop
, const char *str
)
10 hwaddr
*ptr
= qdev_get_prop_ptr(dev
, prop
);
12 *ptr
= strtoull(str
, NULL
, 16);
16 static int print_taddr(DeviceState
*dev
, Property
*prop
, char *dest
, size_t len
)
18 hwaddr
*ptr
= qdev_get_prop_ptr(dev
, prop
);
19 return snprintf(dest
, len
, "0x" TARGET_FMT_plx
, *ptr
);
22 static void get_taddr(Object
*obj
, Visitor
*v
, void *opaque
,
23 const char *name
, Error
**errp
)
25 DeviceState
*dev
= DEVICE(obj
);
26 Property
*prop
= opaque
;
27 hwaddr
*ptr
= qdev_get_prop_ptr(dev
, prop
);
31 visit_type_int64(v
, &value
, name
, errp
);
34 static void set_taddr(Object
*obj
, Visitor
*v
, void *opaque
,
35 const char *name
, Error
**errp
)
37 DeviceState
*dev
= DEVICE(obj
);
38 Property
*prop
= opaque
;
39 hwaddr
*ptr
= qdev_get_prop_ptr(dev
, prop
);
40 Error
*local_err
= NULL
;
44 error_set(errp
, QERR_PERMISSION_DENIED
);
48 visit_type_int64(v
, &value
, name
, &local_err
);
50 error_propagate(errp
, local_err
);
53 if ((uint64_t)value
<= (uint64_t) ~(hwaddr
)0) {
56 error_set(errp
, QERR_PROPERTY_VALUE_OUT_OF_RANGE
,
57 dev
->id
?:"", name
, value
, (uint64_t) 0,
58 (uint64_t) ~(hwaddr
)0);
63 PropertyInfo qdev_prop_taddr
= {
71 void qdev_prop_set_taddr(DeviceState
*dev
, const char *name
, hwaddr value
)
74 object_property_set_int(OBJECT(dev
), value
, name
, &errp
);