[PATCH 3/6] device assignment: introduce functions to correlate pin number and irq

muli
2008-10-28T10:06:56Z

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
---
qemu/hw/pc.h | 3 +++
qemu/hw/piix_pci.c | 19 +++++++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/qemu/hw/pc.h b/qemu/hw/pc.h
index 1f63678..3edf62f 100644
--- a/qemu/hw/pc.h
+++ b/qemu/hw/pc.h
@@ -112,6 +112,9 @@ void i440fx_init_memory_mappings(PCIDevice *d);

int piix4_init(PCIBus *bus, int devfn);

+int piix3_get_pin(int pic_irq);
+int piix_get_irq(int pin);
+
/* vga.c */
enum vga_retrace_method {
VGA_RETRACE_DUMB,
diff --git a/qemu/hw/piix_pci.c b/qemu/hw/piix_pci.c
index 6fbf47b..dc12c8a 100644
--- a/qemu/hw/piix_pci.c
+++ b/qemu/hw/piix_pci.c
@@ -243,6 +243,25 @@ static void piix3_set_irq(qemu_irq *pic, int irq_num, int level)
}
}

+int piix3_get_pin(int pic_irq)
+{
+ int i;
+ for (i = 0; i < 4; i++)
+ if (piix3_dev->config[0x60+i] == pic_irq)
+ return i;
+ return -1;
+}
+
+int piix_get_irq(int pin)
+{
+ if (piix3_dev)
+ return piix3_dev->config[0x60+pin];
+ if (piix4_dev)
+ return piix4_dev->config[0x60+pin];
+
+ return 0;
+}
+
static void piix3_reset(PCIDevice *d)
{
uint8_t *pci_conf = d->config;
--
1.5.6.5