20
#include "qemu/osdep.h"
21
#include "hw/arm/omap.h"
24
MemoryRegion *address_space;
27
struct omap_target_agent_s ta[];
30
struct omap_l4_s *omap_l4_init(MemoryRegion *address_space,
31
hwaddr base, int ta_num)
33
struct omap_l4_s *bus = g_malloc0(
34
sizeof(*bus) + ta_num * sizeof(*bus->ta));
36
bus->address_space = address_space;
43
hwaddr omap_l4_region_base(struct omap_target_agent_s *ta,
46
return ta->bus->base + ta->start[region].offset;
49
hwaddr omap_l4_region_size(struct omap_target_agent_s *ta,
52
return ta->start[region].size;
55
static uint64_t omap_l4ta_read(void *opaque, hwaddr addr, unsigned size)
57
struct omap_target_agent_s *s = opaque;
60
return omap_badwidth_read16(opaque, addr);
78
static void omap_l4ta_write(void *opaque, hwaddr addr,
79
uint64_t value, unsigned size)
81
struct omap_target_agent_s *s = opaque;
84
omap_badwidth_write32(opaque, addr, value);
95
s->control = value & 0x01000700;
105
static const MemoryRegionOps omap_l4ta_ops = {
106
.read = omap_l4ta_read,
107
.write = omap_l4ta_write,
108
.endianness = DEVICE_NATIVE_ENDIAN,
111
struct omap_target_agent_s *omap_l4ta_get(struct omap_l4_s *bus,
112
const struct omap_l4_region_s *regions,
113
const struct omap_l4_agent_info_s *agents,
117
struct omap_target_agent_s *ta = NULL;
118
const struct omap_l4_agent_info_s *info = NULL;
120
for (i = 0; i < bus->ta_num; i ++)
121
if (agents[i].ta == cs) {
127
fprintf(stderr, "%s: bad target agent (%i)\n", __func__, cs);
132
ta->start = ®ions[info->region];
133
ta->regions = info->regions;
135
ta->component = ('Q' << 24) | ('E' << 16) | ('M' << 8) | ('U' << 0);
136
ta->status = 0x00000000;
137
ta->control = 0x00000200;
139
memory_region_init_io(&ta->iomem, NULL, &omap_l4ta_ops, ta, "omap.l4ta",
140
omap_l4_region_size(ta, info->ta_region));
141
omap_l4_attach(ta, info->ta_region, &ta->iomem);
146
hwaddr omap_l4_attach(struct omap_target_agent_s *ta,
147
int region, MemoryRegion *mr)
151
if (region < 0 || region >= ta->regions) {
152
fprintf(stderr, "%s: bad io region (%i)\n", __func__, region);
156
base = ta->bus->base + ta->start[region].offset;
158
memory_region_add_subregion(ta->bus->address_space, base, mr);