All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jia Liu <proljc@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v5 09/16] target-or32: Add PIC support
Date: Mon, 18 Jun 2012 09:02:57 +0800	[thread overview]
Message-ID: <1339981384-9117-10-git-send-email-proljc@gmail.com> (raw)
In-Reply-To: <1339981384-9117-1-git-send-email-proljc@gmail.com>

Add OpenRISC Programmable Interrupt Controller.

Signed-off-by: Jia Liu <proljc@gmail.com>
---
 hw/openrisc_pic.c |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/hw/openrisc_pic.c b/hw/openrisc_pic.c
index 0d14bbe..76bd792 100644
--- a/hw/openrisc_pic.c
+++ b/hw/openrisc_pic.c
@@ -28,3 +28,51 @@ void cpu_openrisc_pic_reset(CPUOpenRISCState *env)
     env->picmr = 0x00000000;
     env->picsr = 0x00000000;
 }
+
+/* OpenRISC pic handler */
+static void openrisc_pic_cpu_handler(void *opaque, int irq, int level)
+{
+    CPUOpenRISCState *env = (CPUOpenRISCState *)opaque;
+    int i;
+    uint32_t irq_bit = 1 << irq;
+
+    if (irq > 31 || irq < 0) {
+        return;
+    }
+
+    if (level) {
+        env->picsr |= irq_bit;
+    } else {
+        env->picsr &= ~irq_bit;
+    }
+
+    for (i = 0; i < 32; i++) {
+        if ((env->picsr && (1 << i)) && (env->picmr && (1 << i))) {
+            cpu_interrupt(env, CPU_INTERRUPT_HARD);
+        } else {
+            cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
+            env->picsr &= ~(1 << i);
+        }
+    }
+}
+
+void cpu_openrisc_pic_init(CPUOpenRISCState *env)
+{
+    int i;
+    qemu_irq *qi;
+    qi = qemu_allocate_irqs(openrisc_pic_cpu_handler, env, NR_IRQS);
+
+    for (i = 0; i < NR_IRQS; i++) {
+        env->irq[i] = qi[i];
+    }
+}
+
+void cpu_openrisc_store_picmr(CPUOpenRISCState *env, uint32_t value)
+{
+    env->picmr |= value;
+}
+
+void cpu_openrisc_store_picsr(CPUOpenRISCState *env, uint32_t value)
+{
+    env->picsr &= ~value;
+}
-- 
1.7.9.5

  parent reply	other threads:[~2012-06-18  1:04 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-18  1:02 [Qemu-devel] [PATCH v5 00/16] QEMU OpenRISC support Jia Liu
2012-06-18  1:02 ` [Qemu-devel] [PATCH v5 01/16] target-or32: Add target stubs and cpu support Jia Liu
2012-06-18 18:28   ` Blue Swirl
2012-06-20  7:14     ` Jia Liu
2012-06-21 17:30       ` Blue Swirl
2012-06-18  1:02 ` [Qemu-devel] [PATCH v5 02/16] target-or32: Add target machine Jia Liu
2012-06-18 18:24   ` Blue Swirl
2012-06-20  7:19     ` Jia Liu
2012-06-18  1:02 ` [Qemu-devel] [PATCH v5 03/16] target-or32: Add MMU support Jia Liu
2012-06-18  1:02 ` [Qemu-devel] [PATCH v5 04/16] target-or32: Add interrupt support Jia Liu
2012-06-18  1:02 ` [Qemu-devel] [PATCH v5 05/16] target-or32: Add exception support Jia Liu
2012-06-18  1:02 ` [Qemu-devel] [PATCH v5 06/16] target-or32: Add int instruction helpers Jia Liu
2012-06-18  1:02 ` [Qemu-devel] [PATCH v5 07/16] target-or32: Add float " Jia Liu
2012-06-18  1:02 ` [Qemu-devel] [PATCH v5 08/16] target-or32: Add translation routines Jia Liu
2012-06-18 18:40   ` Blue Swirl
2012-06-19  8:05     ` Jia Liu
2012-06-19 18:33       ` Blue Swirl
2012-06-19 23:11         ` Jia Liu
2012-06-18  1:02 ` Jia Liu [this message]
2012-06-18  1:02 ` [Qemu-devel] [PATCH v5 10/16] target-or32: Add timer support Jia Liu
2012-06-18  1:02 ` [Qemu-devel] [PATCH v5 11/16] target-or32: Add a IIS dummy board Jia Liu
2012-06-20  6:29   ` Max Filippov
2012-06-20  9:42     ` Jia Liu
2012-06-20 12:57       ` Max Filippov
2012-06-20 16:41         ` Jia Liu
2012-06-20 20:07           ` Max Filippov
2012-06-20 20:10             ` [Qemu-devel] [PATCH] target-or32: replace NE2000 with OpenCores 10/100 ethernet adapter Max Filippov
2012-06-21  1:54               ` Jia Liu
2012-06-18  1:03 ` [Qemu-devel] [PATCH v5 12/16] target-or32: Add system instructions Jia Liu
2012-06-18 18:58   ` Blue Swirl
2012-06-19  8:02     ` Jia Liu
2012-06-19 18:25       ` Blue Swirl
2012-06-20  0:17         ` Jia Liu
2012-06-18  1:03 ` [Qemu-devel] [PATCH v5 13/16] target-or32: Add gdb stub support Jia Liu
2012-06-18  1:03 ` [Qemu-devel] [PATCH v5 14/16] target-or32: Add linux syscall, signal and termbits Jia Liu
2012-06-18  1:03 ` [Qemu-devel] [PATCH v5 15/16] target-or32: Add linux user support Jia Liu
2012-06-18  1:03 ` [Qemu-devel] [PATCH v5 16/16] target-or32: Add testcases Jia Liu
2012-06-18 19:11 ` [Qemu-devel] [PATCH v5 00/16] QEMU OpenRISC support Blue Swirl
2012-06-20  7:10   ` Jia Liu
2012-06-21 17:24     ` Blue Swirl
2012-06-21 17:28       ` Peter Maydell
2012-06-22  3:16         ` 陳韋任 (Wei-Ren Chen)

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=1339981384-9117-10-git-send-email-proljc@gmail.com \
    --to=proljc@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.