public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: minyard@acm.org
To: kvm@vger.kernel.org
Cc: Corey Minyard <cminyard@mvista.com>
Subject: [PATCH 3/9] isa: Add a way to query for a free interrupt
Date: Mon, 02 Jul 2012 14:44:35 -0500	[thread overview]
Message-ID: <1341258281-9283-4-git-send-email-minyard@acm.org> (raw)
In-Reply-To: <1341258281-9283-1-git-send-email-minyard@acm.org>

From: Corey Minyard <cminyard@mvista.com>

This lets devices that don't care about their interrupt number, like
IPMI, just grab any unused interrupt.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 hw/isa-bus.c |   13 +++++++++++++
 hw/isa.h     |    2 ++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 5a43f03..f561f21 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -71,6 +71,7 @@ qemu_irq isa_get_irq(ISADevice *dev, int isairq)
     if (isairq < 0 || isairq > 15) {
         hw_error("isa irq %d invalid", isairq);
     }
+    isabus->irq_inuse[isairq] = 1;
     return isabus->irqs[isairq];
 }
 
@@ -82,6 +83,18 @@ void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq)
     dev->nirqs++;
 }
 
+int isa_find_free_irq(ISABus *bus)
+{
+    unsigned int i;
+
+    /* 0 and 1 are called for, 2 is the chain interrupt */
+    for (i = 3; i < ISA_NUM_IRQS; i++) {
+	if (!bus->irq_inuse[i])
+	    return i;
+    }
+    return 0;
+}
+
 static inline void isa_init_ioport(ISADevice *dev, uint16_t ioport)
 {
     if (dev && (dev->ioport_id == 0 || ioport < dev->ioport_id)) {
diff --git a/hw/isa.h b/hw/isa.h
index f7bc4b5..9447296 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -28,6 +28,7 @@ struct ISABus {
     BusState qbus;
     MemoryRegion *address_space_io;
     qemu_irq *irqs;
+    int irq_inuse[ISA_NUM_IRQS];
 };
 
 struct ISADevice {
@@ -41,6 +42,7 @@ ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
 void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
 qemu_irq isa_get_irq(ISADevice *dev, int isairq);
 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
+int isa_find_free_irq(ISABus *bus);
 MemoryRegion *isa_address_space(ISADevice *dev);
 ISADevice *isa_create(ISABus *bus, const char *name);
 ISADevice *isa_try_create(ISABus *bus, const char *name);
-- 
1.7.4.1


  parent reply	other threads:[~2012-07-02 20:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-02 19:44 First shot at adding IPMI to qemu minyard
2012-07-02 19:44 ` [PATCH 1/9] smbios: Add a function to directly add an entry minyard
2012-07-02 19:44 ` [PATCH 2/9] pc: move SMBIOS setup to after device init minyard
2012-07-02 19:44 ` minyard [this message]
2012-07-02 19:44 ` [PATCH 4/9] Add a base IPMI interface minyard
2012-07-02 19:44 ` [PATCH 5/9] IPMI: Add a PC ISA type structure minyard
2012-07-02 19:44 ` [PATCH 6/9] IPMI: Add a KCS low-level interface minyard
2012-07-02 19:44 ` [PATCH 7/9] IPMI: Add a BT " minyard
2012-07-02 19:44 ` [PATCH 8/9] IPMI: Add a local BMC simulation minyard
2012-07-02 19:44 ` [PATCH 9/9] IPMI: Add an external connection simulation interface minyard
2012-07-09 13:23 ` First shot at adding IPMI to qemu Corey Minyard
2012-07-09 14:05   ` Daniel P. Berrange

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=1341258281-9283-4-git-send-email-minyard@acm.org \
    --to=minyard@acm.org \
    --cc=cminyard@mvista.com \
    --cc=kvm@vger.kernel.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