~ahs3/+junk/cq-qemu

« back to all changes in this revision

Viewing changes to hw/qdev-addr.c

  • Committer: Al Stone
  • Date: 2012-02-09 01:17:20 UTC
  • Revision ID: albert.stone@canonical.com-20120209011720-tztl7ik3qayz80p4
first commit to bzr for qemu

Show diffs side-by-side

added added

removed removed

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