qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: qemu-devel@nongnu.org
Cc: blauwirbel@gmail.com, aurelien@aurel32.net, mst@redhat.com
Subject: [Qemu-devel] [PATCH 04/10] PPC: Make interrupts work
Date: Tue,  9 Feb 2010 17:37:04 +0100	[thread overview]
Message-ID: <1265733430-9656-5-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1265733430-9656-1-git-send-email-agraf@suse.de>

The interrupt code as is didn't really work for me. I couldn't even convince
Linux to take interrupt 9 in an interrupt-map.

So let's do this right. Let's map all PCI interrupts to 0x1b - 0x1e. That way
we're at least a small step closer to what real hardware does.

I also took the interrupt pin to line conversion from OpenBIOS, which at least
assures us we're compatible with our firmware :-).

A dump of the PCI interrupt-map from a U2 (iBook):

00009000 00000000 00000000 00000000 ff97c528 00000034 00000001
0000d800 00000000 00000000 00000000 ff97c528 0000003f 00000001
0000c000 00000000 00000000 00000000 ff97c528 0000001b 00000001
0000c800 00000000 00000000 00000000 ff97c528 0000001c 00000001
0000d000 00000000 00000000 00000000 ff97c528 0000001d 00000001

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/unin_pci.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/hw/unin_pci.c b/hw/unin_pci.c
index 324434f..86fa5ad 100644
--- a/hw/unin_pci.c
+++ b/hw/unin_pci.c
@@ -36,23 +36,31 @@
 #define UNIN_DPRINTF(fmt, ...)
 #endif
 
+static const int unin_irq_line[] = { 0x1b, 0x1c, 0x1d, 0x1e };
+
 typedef struct UNINState {
     SysBusDevice busdev;
     PCIHostState host_state;
     ReadWriteHandler data_handler;
 } UNINState;
 
-/* Don't know if this matches real hardware, but it agrees with OHW.  */
 static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
 {
-    return (irq_num + (pci_dev->devfn >> 3)) & 3;
+    int retval;
+    int devfn = pci_dev->devfn & 0x00FFFFFF;
+ 
+    retval = (((devfn >> 11) & 0x1F) + irq_num) & 3;
+ 
+    return retval;
 }
 
 static void pci_unin_set_irq(void *opaque, int irq_num, int level)
 {
     qemu_irq *pic = opaque;
 
-    qemu_set_irq(pic[irq_num + 8], level);
+    UNIN_DPRINTF("%s: setting INT %d = %d\n", __func__,
+                 unin_irq_line[irq_num], level);
+    qemu_set_irq(pic[unin_irq_line[irq_num]], level);
 }
 
 static void pci_unin_save(QEMUFile* f, void *opaque)
-- 
1.6.0.2

  parent reply	other threads:[~2010-02-09 16:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-09 16:37 [Qemu-devel] [PATCH 00/10] PPC NewWorld fixery v4 Alexander Graf
2010-02-09 16:37 ` [Qemu-devel] [PATCH 01/10] PPC: Uninorth config space accessor Alexander Graf
2010-02-09 16:37 ` [Qemu-devel] [PATCH 02/10] PPC: Use Mac99_U3 type on ppc64 Alexander Graf
2010-02-09 16:37 ` [Qemu-devel] [PATCH 03/10] PPC: Include dump of lspci -nn on real G5 Alexander Graf
2010-02-09 16:37 ` Alexander Graf [this message]
2010-02-09 16:37 ` [Qemu-devel] [PATCH 05/10] PPC: tell the guest about the time base frequency Alexander Graf
2010-02-09 16:37 ` [Qemu-devel] [PATCH 06/10] PPC: Use macio IDE controller for Newworld Alexander Graf
2010-02-09 16:37 ` [Qemu-devel] [PATCH 07/10] PPC: Get rid of segfaults in DBDMA emulation Alexander Graf
2010-02-09 16:37 ` [Qemu-devel] [PATCH 08/10] PPC: Add USB per default on U3 Alexander Graf
2010-02-09 16:37 ` [Qemu-devel] [PATCH 09/10] PPC: Fix large pages Alexander Graf
2010-02-09 16:37 ` [Qemu-devel] [PATCH 10/10] PPC: Add timer when running KVM Alexander Graf
2010-02-09 17:01 ` [Qemu-devel] Re: [PATCH 00/10] PPC NewWorld fixery v4 Michael S. Tsirkin
2010-02-09 18:26   ` Alexander Graf
2010-02-09 20:30     ` Michael S. Tsirkin
2010-02-09 20:37       ` aurelien
2010-02-09 20:39         ` Michael S. Tsirkin
2010-02-09 21:24           ` Alexander Graf
2010-02-09 21:31             ` Michael S. Tsirkin
2010-02-09 21:43 ` Michael S. Tsirkin

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=1265733430-9656-5-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=aurelien@aurel32.net \
    --cc=blauwirbel@gmail.com \
    --cc=mst@redhat.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 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).