Revision 538ddf65
b/hw/mpcore.c | ||
---|---|---|
36 | 36 |
|
37 | 37 |
/* Per-CPU private memory mapped IO. */ |
38 | 38 |
|
39 |
static uint64_t mpcore_priv_read(void *opaque, target_phys_addr_t offset,
|
|
40 |
unsigned size)
|
|
39 |
static uint64_t mpcore_scu_read(void *opaque, target_phys_addr_t offset,
|
|
40 |
unsigned size) |
|
41 | 41 |
{ |
42 | 42 |
mpcore_priv_state *s = (mpcore_priv_state *)opaque; |
43 | 43 |
int id; |
44 | 44 |
offset &= 0xff; |
45 |
if (offset < 0x100) { |
|
46 |
/* SCU */ |
|
47 |
switch (offset) { |
|
48 |
case 0x00: /* Control. */ |
|
49 |
return s->scu_control; |
|
50 |
case 0x04: /* Configuration. */ |
|
51 |
id = ((1 << s->num_cpu) - 1) << 4; |
|
52 |
return id | (s->num_cpu - 1); |
|
53 |
case 0x08: /* CPU status. */ |
|
54 |
return 0; |
|
55 |
case 0x0c: /* Invalidate all. */ |
|
56 |
return 0; |
|
57 |
default: |
|
58 |
goto bad_reg; |
|
59 |
} |
|
45 |
/* SCU */ |
|
46 |
switch (offset) { |
|
47 |
case 0x00: /* Control. */ |
|
48 |
return s->scu_control; |
|
49 |
case 0x04: /* Configuration. */ |
|
50 |
id = ((1 << s->num_cpu) - 1) << 4; |
|
51 |
return id | (s->num_cpu - 1); |
|
52 |
case 0x08: /* CPU status. */ |
|
53 |
return 0; |
|
54 |
case 0x0c: /* Invalidate all. */ |
|
55 |
return 0; |
|
56 |
default: |
|
57 |
hw_error("mpcore_priv_read: Bad offset %x\n", (int)offset); |
|
60 | 58 |
} |
61 |
bad_reg: |
|
62 |
hw_error("mpcore_priv_read: Bad offset %x\n", (int)offset); |
|
63 |
return 0; |
|
64 | 59 |
} |
65 | 60 |
|
66 |
static void mpcore_priv_write(void *opaque, target_phys_addr_t offset,
|
|
67 |
uint64_t value, unsigned size)
|
|
61 |
static void mpcore_scu_write(void *opaque, target_phys_addr_t offset,
|
|
62 |
uint64_t value, unsigned size) |
|
68 | 63 |
{ |
69 | 64 |
mpcore_priv_state *s = (mpcore_priv_state *)opaque; |
70 | 65 |
offset &= 0xff; |
71 |
if (offset < 0x100) { |
|
72 |
/* SCU */ |
|
73 |
switch (offset) { |
|
74 |
case 0: /* Control register. */ |
|
75 |
s->scu_control = value & 1; |
|
76 |
break; |
|
77 |
case 0x0c: /* Invalidate all. */ |
|
78 |
/* This is a no-op as cache is not emulated. */ |
|
79 |
break; |
|
80 |
default: |
|
81 |
goto bad_reg; |
|
82 |
} |
|
66 |
/* SCU */ |
|
67 |
switch (offset) { |
|
68 |
case 0: /* Control register. */ |
|
69 |
s->scu_control = value & 1; |
|
70 |
break; |
|
71 |
case 0x0c: /* Invalidate all. */ |
|
72 |
/* This is a no-op as cache is not emulated. */ |
|
73 |
break; |
|
74 |
default: |
|
75 |
hw_error("mpcore_priv_read: Bad offset %x\n", (int)offset); |
|
83 | 76 |
} |
84 |
return; |
|
85 |
bad_reg: |
|
86 |
hw_error("mpcore_priv_read: Bad offset %x\n", (int)offset); |
|
87 | 77 |
} |
88 | 78 |
|
89 |
static const MemoryRegionOps mpcore_priv_ops = {
|
|
90 |
.read = mpcore_priv_read,
|
|
91 |
.write = mpcore_priv_write,
|
|
79 |
static const MemoryRegionOps mpcore_scu_ops = {
|
|
80 |
.read = mpcore_scu_read,
|
|
81 |
.write = mpcore_scu_write,
|
|
92 | 82 |
.endianness = DEVICE_NATIVE_ENDIAN, |
93 | 83 |
}; |
94 | 84 |
|
... | ... | |
106 | 96 |
int i; |
107 | 97 |
SysBusDevice *busdev = sysbus_from_qdev(s->mptimer); |
108 | 98 |
memory_region_init(&s->container, "mpcode-priv-container", 0x2000); |
109 |
memory_region_init_io(&s->iomem, &mpcore_priv_ops, s, "mpcode-priv", |
|
110 |
0x100); |
|
99 |
memory_region_init_io(&s->iomem, &mpcore_scu_ops, s, "mpcore-scu", 0x100); |
|
111 | 100 |
memory_region_add_subregion(&s->container, 0, &s->iomem); |
112 | 101 |
/* GIC CPU interfaces: "current CPU" at 0x100, then specific CPUs |
113 | 102 |
* at 0x200, 0x300... |
Also available in: Unified diff