[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/28] hw/armv7m_nvic: Implement byte/halfword acces
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PATCH 01/28] hw/armv7m_nvic: Implement byte/halfword access for NVIC SCB_SHPRx registers |
Date: |
Tue, 30 Oct 2012 08:43:57 +0000 |
From: Andre Beckus <address@hidden>
Implement byte/halfword read and write for the NVIC SCB_SHPRx
(System Handler Priority Registers). Do this by removing SHPR word access
from nvic_readl/writel and adding common code to hande all access
sizes in nvic_sysreg_read/write.
Because the "nvic_state *s" variable now needs to be declared in
nvic_sysreg_read/write, the "void *opaque" parameter of
nvic_readl/writel is changed to "nvic_state *s".
Signed-off-by: Andre Beckus <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>
---
hw/armv7m_nvic.c | 58 ++++++++++++++++++++++++++----------------------------
1 file changed, 28 insertions(+), 30 deletions(-)
diff --git a/hw/armv7m_nvic.c b/hw/armv7m_nvic.c
index 35c1aa6..8d8d0a4 100644
--- a/hw/armv7m_nvic.c
+++ b/hw/armv7m_nvic.c
@@ -138,9 +138,8 @@ void armv7m_nvic_complete_irq(void *opaque, int irq)
gic_complete_irq(&s->gic, 0, irq);
}
-static uint32_t nvic_readl(void *opaque, uint32_t offset)
+static uint32_t nvic_readl(nvic_state *s, uint32_t offset)
{
- nvic_state *s = (nvic_state *)opaque;
uint32_t val;
int irq;
@@ -216,14 +215,6 @@ static uint32_t nvic_readl(void *opaque, uint32_t offset)
case 0xd14: /* Configuration Control. */
/* TODO: Implement Configuration Control bits. */
return 0;
- case 0xd18: case 0xd1c: case 0xd20: /* System Handler Priority. */
- irq = offset - 0xd14;
- val = 0;
- val |= s->gic.priority1[irq++][0];
- val |= s->gic.priority1[irq++][0] << 8;
- val |= s->gic.priority1[irq++][0] << 16;
- val |= s->gic.priority1[irq][0] << 24;
- return val;
case 0xd24: /* System Handler Status. */
val = 0;
if (s->gic.irq_state[ARMV7M_EXCP_MEM].active) val |= (1 << 0);
@@ -285,9 +276,8 @@ static uint32_t nvic_readl(void *opaque, uint32_t offset)
}
}
-static void nvic_writel(void *opaque, uint32_t offset, uint32_t value)
+static void nvic_writel(nvic_state *s, uint32_t offset, uint32_t value)
{
- nvic_state *s = (nvic_state *)opaque;
uint32_t oldval;
switch (offset) {
case 0x10: /* SysTick Control and Status. */
@@ -356,17 +346,6 @@ static void nvic_writel(void *opaque, uint32_t offset,
uint32_t value)
case 0xd14: /* Configuration Control. */
/* TODO: Implement control registers. */
goto bad_reg;
- case 0xd18: case 0xd1c: case 0xd20: /* System Handler Priority. */
- {
- int irq;
- irq = offset - 0xd14;
- s->gic.priority1[irq++][0] = value & 0xff;
- s->gic.priority1[irq++][0] = (value >> 8) & 0xff;
- s->gic.priority1[irq++][0] = (value >> 16) & 0xff;
- s->gic.priority1[irq][0] = (value >> 24) & 0xff;
- gic_update(&s->gic);
- }
- break;
case 0xd24: /* System Handler Control. */
/* TODO: Real hardware allows you to set/clear the active bits
under some circumstances. We don't implement this. */
@@ -395,19 +374,26 @@ static void nvic_writel(void *opaque, uint32_t offset,
uint32_t value)
static uint64_t nvic_sysreg_read(void *opaque, hwaddr addr,
unsigned size)
{
- /* At the moment we only support the ID registers for byte/word access.
- * This is not strictly correct as a few of the other registers also
- * allow byte access.
- */
+ nvic_state *s = (nvic_state *)opaque;
uint32_t offset = addr;
- if (offset >= 0xfe0) {
+ int i;
+ uint32_t val;
+
+ switch (offset) {
+ case 0xd18 ... 0xd23: /* System Handler Priority. */
+ val = 0;
+ for (i = 0; i < size; i++) {
+ val |= s->gic.priority1[(offset - 0xd14) + i][0] << (i * 8);
+ }
+ return val;
+ case 0xfe0 ... 0xfff: /* ID. */
if (offset & 3) {
return 0;
}
return nvic_id[(offset - 0xfe0) >> 2];
}
if (size == 4) {
- return nvic_readl(opaque, offset);
+ return nvic_readl(s, offset);
}
hw_error("NVIC: Bad read of size %d at offset 0x%x\n", size, offset);
}
@@ -415,9 +401,21 @@ static uint64_t nvic_sysreg_read(void *opaque, hwaddr addr,
static void nvic_sysreg_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
+ nvic_state *s = (nvic_state *)opaque;
uint32_t offset = addr;
+ int i;
+
+ switch (offset) {
+ case 0xd18 ... 0xd23: /* System Handler Priority. */
+ for (i = 0; i < size; i++) {
+ s->gic.priority1[(offset - 0xd14) + i][0] =
+ (value >> (i * 8)) & 0xff;
+ }
+ gic_update(&s->gic);
+ return;
+ }
if (size == 4) {
- nvic_writel(opaque, offset, value);
+ nvic_writel(s, offset, value);
return;
}
hw_error("NVIC: Bad write of size %d at offset 0x%x\n", size, offset);
--
1.7.9.5
- [Qemu-devel] [PATCH 15/28] hw/arm11mpcore: Use LOG_GUEST_ERROR rather than hw_error(), (continued)
- [Qemu-devel] [PATCH 15/28] hw/arm11mpcore: Use LOG_GUEST_ERROR rather than hw_error(), Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 12/28] hw/pl080: Use LOG_GUEST_ERROR and LOG_UNIMP, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 06/28] hw/omap_sx1: Don't prematurely explode QEMUMachineInitArgs, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 02/28] hw/vexpress.c: Don't prematurely explode QEMUMachineInitArgs, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 22/28] pflash_cfi0x: remove unused base field, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 14/28] hw/pl190: Use LOG_UNIMP rather than hw_error(), Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 19/28] hw/arm_sysctl: Use LOG_GUEST_ERROR, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 09/28] hw/exynos4_boards: Don't prematurely explode QEMUMachineInitArgs, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 27/28] vmstate: Add support for saving/loading bitmaps, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 04/28] hw/versatilepb: Don't prematurely explode QEMUMachineInitArgs, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 01/28] hw/armv7m_nvic: Implement byte/halfword access for NVIC SCB_SHPRx registers,
Peter Maydell <=
- [Qemu-devel] [PATCH 28/28] hw/sd.c: add SD card save/load support, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 20/28] hw/arm_l2x0: Use LOG_GUEST_ERROR, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 13/28] hw/pl110: Use LOG_GUEST_ERROR rather than hw_error(), Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 21/28] hw/versatile_i2c: Use LOG_GUEST_ERROR, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 23/28] pflash_cfi01: remove unused total_len field, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 08/28] hw/mainstone: Don't prematurely explode QEMUMachineInitArgs, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 03/28] hw/realview.c: Don't prematurely explode QEMUMachineInitArgs, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 24/28] pflash_cfi0x: QOMified, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 17/28] hw/arm_timer: Use LOG_GUEST_ERROR and LOG_UNIMP, Peter Maydell, 2012/10/30
- [Qemu-devel] [PATCH 05/28] hw/spitz: Don't prematurely explode QEMUMachineInitArgs, Peter Maydell, 2012/10/30