root / hw / qdev-addr.c @ 543fc7b2
History | View | Annotate | Download (826 Bytes)
1 | ee6847d1 | Gerd Hoffmann | #include "qdev.h" |
---|---|---|---|
2 | ee6847d1 | Gerd Hoffmann | #include "qdev-addr.h" |
3 | ee6847d1 | Gerd Hoffmann | #include "targphys.h" |
4 | ee6847d1 | Gerd Hoffmann | |
5 | ee6847d1 | Gerd Hoffmann | /* --- target physical address --- */
|
6 | ee6847d1 | Gerd Hoffmann | |
7 | ee6847d1 | Gerd Hoffmann | static int parse_taddr(DeviceState *dev, Property *prop, const char *str) |
8 | ee6847d1 | Gerd Hoffmann | { |
9 | c227f099 | Anthony Liguori | target_phys_addr_t *ptr = qdev_get_prop_ptr(dev, prop); |
10 | ee6847d1 | Gerd Hoffmann | |
11 | ee6847d1 | Gerd Hoffmann | *ptr = strtoull(str, NULL, 16); |
12 | ee6847d1 | Gerd Hoffmann | return 0; |
13 | ee6847d1 | Gerd Hoffmann | } |
14 | ee6847d1 | Gerd Hoffmann | |
15 | ee6847d1 | Gerd Hoffmann | static int print_taddr(DeviceState *dev, Property *prop, char *dest, size_t len) |
16 | ee6847d1 | Gerd Hoffmann | { |
17 | c227f099 | Anthony Liguori | target_phys_addr_t *ptr = qdev_get_prop_ptr(dev, prop); |
18 | ee6847d1 | Gerd Hoffmann | return snprintf(dest, len, "0x" TARGET_FMT_plx, *ptr); |
19 | ee6847d1 | Gerd Hoffmann | } |
20 | ee6847d1 | Gerd Hoffmann | |
21 | ee6847d1 | Gerd Hoffmann | PropertyInfo qdev_prop_taddr = { |
22 | ee6847d1 | Gerd Hoffmann | .name = "taddr",
|
23 | ee6847d1 | Gerd Hoffmann | .type = PROP_TYPE_TADDR, |
24 | c227f099 | Anthony Liguori | .size = sizeof(target_phys_addr_t),
|
25 | ee6847d1 | Gerd Hoffmann | .parse = parse_taddr, |
26 | ee6847d1 | Gerd Hoffmann | .print = print_taddr, |
27 | ee6847d1 | Gerd Hoffmann | }; |
28 | ee6847d1 | Gerd Hoffmann | |
29 | c227f099 | Anthony Liguori | void qdev_prop_set_taddr(DeviceState *dev, const char *name, target_phys_addr_t value) |
30 | ee6847d1 | Gerd Hoffmann | { |
31 | ee6847d1 | Gerd Hoffmann | qdev_prop_set(dev, name, &value, PROP_TYPE_TADDR); |
32 | ee6847d1 | Gerd Hoffmann | } |