summaryrefslogtreecommitdiff
path: root/hw/omap_l4.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2011-11-23 15:17:36 +0200
committerAvi Kivity <avi@redhat.com>2011-11-28 15:38:40 +0200
commitf32261498c83bf434dde74f7832ead98678cb8ae (patch)
tree934f5d89f505aa9d30d1efb31e7724884c08659f /hw/omap_l4.c
parenta56e423c7c39af0fa1515d575fddfda032a02916 (diff)
omap_l4: add memory API variant of omap_l4_attach()
Also add omap_l4_region_size(), since memory API functions need the size during initialization. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'hw/omap_l4.c')
-rw-r--r--hw/omap_l4.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/hw/omap_l4.c b/hw/omap_l4.c
index a19ea702d6..a0bed5cdbc 100644
--- a/hw/omap_l4.c
+++ b/hw/omap_l4.c
@@ -21,16 +21,19 @@
#include "omap.h"
struct omap_l4_s {
+ MemoryRegion *address_space;
target_phys_addr_t base;
int ta_num;
struct omap_target_agent_s ta[0];
};
-struct omap_l4_s *omap_l4_init(target_phys_addr_t base, int ta_num)
+struct omap_l4_s *omap_l4_init(MemoryRegion *address_space,
+ target_phys_addr_t base, int ta_num)
{
struct omap_l4_s *bus = g_malloc0(
sizeof(*bus) + ta_num * sizeof(*bus->ta));
+ bus->address_space = address_space;
bus->ta_num = ta_num;
bus->base = base;
@@ -43,6 +46,12 @@ target_phys_addr_t omap_l4_region_base(struct omap_target_agent_s *ta,
return ta->bus->base + ta->start[region].offset;
}
+target_phys_addr_t omap_l4_region_size(struct omap_target_agent_s *ta,
+ int region)
+{
+ return ta->start[region].size;
+}
+
static uint32_t omap_l4ta_read(void *opaque, target_phys_addr_t addr)
{
struct omap_target_agent_s *s = (struct omap_target_agent_s *) opaque;
@@ -150,3 +159,21 @@ target_phys_addr_t omap_l4_attach(struct omap_target_agent_s *ta, int region,
return base;
}
+
+target_phys_addr_t omap_l4_attach_region(struct omap_target_agent_s *ta,
+ int region, MemoryRegion *mr)
+{
+ target_phys_addr_t base;
+
+ if (region < 0 || region >= ta->regions) {
+ fprintf(stderr, "%s: bad io region (%i)\n", __FUNCTION__, region);
+ exit(-1);
+ }
+
+ base = ta->bus->base + ta->start[region].offset;
+ if (mr) {
+ memory_region_add_subregion(ta->bus->address_space, base, mr);
+ }
+
+ return base;
+}