From: Andre Beckus <mikemail98-qemu@yahoo.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, Andre Beckus <mikemail98-qemu@yahoo.com>
Subject: [Qemu-devel] [PATCH 1/2] hw/armv7m_nvic: Implement byte read/write for NVIC SCB_SHPRx registers
Date: Tue, 9 Oct 2012 18:29:15 -0400 [thread overview]
Message-ID: <1349821756-23125-1-git-send-email-mikemail98-qemu@yahoo.com> (raw)
Adds nvic_writeb and nvic_readb functions.
Implements byte read/write for the NVIC SCB_SHPRx (System Handler
Priority Registers). Currently, only double word access is implemented.
The ARM CMSIS library maps these registers to a byte array, which requires
that byte access be implemented.
Note that because the NVIC ID register read handles both byte and word reads,
it is left as-is, and not moved into the new nvic_readb function.
Signed-off-by: Andre Beckus <mikemail98-qemu@yahoo.com>
---
hw/armv7m_nvic.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/hw/armv7m_nvic.c b/hw/armv7m_nvic.c
index 5c09116..10b5954 100644
--- a/hw/armv7m_nvic.c
+++ b/hw/armv7m_nvic.c
@@ -138,6 +138,26 @@ void armv7m_nvic_complete_irq(void *opaque, int irq)
gic_complete_irq(&s->gic, 0, irq);
}
+static uint32_t nvic_readb(void *opaque, uint32_t offset)
+{
+ nvic_state *s = (nvic_state *)opaque;
+ uint32_t val;
+ int irq;
+
+ if (offset < 0xd18) {
+ goto bad_reg;
+ } else if (offset < 0xd24) {
+ irq = offset - 0xd14;
+ val = s->gic.priority1[irq][0];
+ } else {
+ goto bad_reg;
+ }
+ return val;
+bad_reg:
+ hw_error("NVIC: Bad read offset 0x%x\n", offset);
+ return 0;
+}
+
static uint32_t nvic_readl(void *opaque, uint32_t offset)
{
nvic_state *s = (nvic_state *)opaque;
@@ -285,6 +305,25 @@ static uint32_t nvic_readl(void *opaque, uint32_t offset)
}
}
+static void nvic_writeb(void *opaque, uint32_t offset, uint32_t value)
+{
+ nvic_state *s = (nvic_state *)opaque;
+ int irq;
+
+ if (offset < 0xd18) {
+ goto bad_reg;
+ } else if (offset < 0xd24) {
+ irq = offset - 0xd14;
+ s->gic.priority1[irq][0] = value;
+ gic_update(&s->gic);
+ } else {
+ goto bad_reg;
+ }
+ return;
+bad_reg:
+ hw_error("NVIC: Bad read offset 0x%x\n", offset);
+}
+
static void nvic_writel(void *opaque, uint32_t offset, uint32_t value)
{
nvic_state *s = (nvic_state *)opaque;
@@ -408,6 +447,8 @@ static uint64_t nvic_sysreg_read(void *opaque, target_phys_addr_t addr,
}
if (size == 4) {
return nvic_readl(opaque, offset);
+ } else if (size == 1) {
+ return nvic_readb(opaque, offset);
}
hw_error("NVIC: Bad read of size %d at offset 0x%x\n", size, offset);
}
@@ -419,6 +460,9 @@ static void nvic_sysreg_write(void *opaque, target_phys_addr_t addr,
if (size == 4) {
nvic_writel(opaque, offset, value);
return;
+ } else if (size == 1) {
+ nvic_writeb(opaque, offset, value);
+ return;
}
hw_error("NVIC: Bad write of size %d at offset 0x%x\n", size, offset);
}
--
1.7.9.5
next reply other threads:[~2012-10-09 22:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-09 22:29 Andre Beckus [this message]
2012-10-09 22:29 ` [Qemu-devel] [PATCH 2/2] hw/armv7m_nvic: Add global variable for SysTick external reference clock Andre Beckus
2012-10-10 12:03 ` Peter Maydell
2012-10-12 6:53 ` Andre Beckus
2012-10-12 8:36 ` Peter Maydell
2012-10-10 11:32 ` [Qemu-devel] [PATCH 1/2] hw/armv7m_nvic: Implement byte read/write for NVIC SCB_SHPRx registers Peter Maydell
2012-10-12 5:43 ` Andre Beckus
2012-10-12 8:31 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1349821756-23125-1-git-send-email-mikemail98-qemu@yahoo.com \
--to=mikemail98-qemu@yahoo.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).