[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 59/61] ioapic: make irr accept more than 32 pins.
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH 59/61] ioapic: make irr accept more than 32 pins. |
Date: |
Wed, 30 Sep 2009 19:18:35 +0900 |
make irr accept more than 32 pins.
Signed-off-by: Isaku Yamahata <address@hidden>
---
hw/ioapic.c | 44 +++++++++++++++++++++++++++++++++-----------
1 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/hw/ioapic.c b/hw/ioapic.c
index adaef41..2082c4d 100644
--- a/hw/ioapic.c
+++ b/hw/ioapic.c
@@ -33,6 +33,8 @@
#endif
#define IOAPIC_NUM_PINS_DEFAULT 0x18
+#define IOAPIC_NUM_PINS_MIN 16
+#define IOAPIC_NUM_PINS_MAX 240
#define IOAPIC_LVT_MASKED (1<<16)
#define IOAPIC_TRIGGER_EDGE 0
@@ -52,7 +54,7 @@ struct IOAPICState {
uint8_t id;
uint8_t ioregsel;
- uint32_t irr;
+ uint8_t *irr;
uint64_t *ioredtbl;
ioapic_update_fn update_fn;
void *opaque;
@@ -64,21 +66,39 @@ static void ioapic_callback(IOAPICState *s, int reset)
s->update_fn(s->opaque, reset);
}
+static int ioapic_irr_is_set(IOAPICState *s, int vector)
+{
+ return (s->irr[vector / 8] & (1 << (vector % 8)));
+}
+
+static void ioapic_irr_set(IOAPICState *s, int vector)
+{
+ s->irr[vector / 8] |= (1 << (vector % 8));
+}
+
+static void ioapic_irr_clear(IOAPICState *s, int vector)
+{
+ s->irr[vector / 8] &= ~(1 << (vector % 8));
+}
+
+static size_t ioapic_irr_size(int num_pins)
+{
+ return (num_pins + 7) / 8 * sizeof(uint8_t);
+}
+
static void ioapic_service(IOAPICState *s)
{
uint8_t i;
uint8_t trig_mode;
uint8_t vector;
uint8_t delivery_mode;
- uint32_t mask;
uint64_t entry;
uint8_t dest;
uint8_t dest_mode;
uint8_t polarity;
for (i = 0; i < s->num_pins; i++) {
- mask = 1 << i;
- if (s->irr & mask) {
+ if (ioapic_irr_is_set(s, i)) {
entry = s->ioredtbl[i];
if (!(entry & IOAPIC_LVT_MASKED)) {
trig_mode = ((entry >> 15) & 1);
@@ -87,7 +107,7 @@ static void ioapic_service(IOAPICState *s)
delivery_mode = (entry >> 8) & 7;
polarity = (entry >> 13) & 1;
if (trig_mode == IOAPIC_TRIGGER_EDGE)
- s->irr &= ~mask;
+ ioapic_irr_clear(s, i);
if (delivery_mode == IOAPIC_DM_EXTINT)
vector = pic_read_irq(isa_pic);
else
@@ -112,21 +132,20 @@ static void ioapic_set_irq(void *opaque, int vector, int
level)
vector = 2;
if (vector >= 0 && vector < s->num_pins) {
- uint32_t mask = 1 << vector;
uint64_t entry = s->ioredtbl[vector];
if ((entry >> 15) & 1) {
/* level triggered */
if (level) {
- s->irr |= mask;
+ ioapic_irr_set(s, vector);
ioapic_service(s);
} else {
- s->irr &= ~mask;
+ ioapic_irr_clear(s, vector);
}
} else {
/* edge triggered */
if (level) {
- s->irr |= mask;
+ ioapic_irr_set(s, vector);
ioapic_service(s);
}
}
@@ -239,7 +258,7 @@ static void ioapic_reset(void *opaque)
s->id = 0;
s->ioregsel = 0;
- s->irr = 0;
+ memset(s->irr, 0, ioapic_irr_size(s->num_pins));
for(i = 0; i < s->num_pins; i++)
s->ioredtbl[i] = 1 << 16; /* mask LVT */
}
@@ -263,11 +282,14 @@ static void ioapic_init_with_arg(uint8_t num_pins,
IOAPICState *s;
int io_memory;
+ assert(IOAPIC_NUM_PINS_MIN <= num_pins);
+ assert(num_pins <= IOAPIC_NUM_PINS_MAX);
s = qemu_mallocz(sizeof(*s));
*sp = s;
- s->ioredtbl = qemu_mallocz(sizeof(s->ioredtbl[0]) * num_pins);
s->num_pins = num_pins;
+ s->irr = qemu_mallocz(ioapic_irr_size(num_pins));
+ s->ioredtbl = qemu_mallocz(sizeof(s->ioredtbl[0]) * num_pins);
s->update_fn = update_fn;
s->opaque = opaque;
ioapic_reset(s);
--
1.6.0.2
- [Qemu-devel] [PATCH 19/61] pc_piix: initialize ioapic before use., (continued)
- [Qemu-devel] [PATCH 19/61] pc_piix: initialize ioapic before use., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 31/61] pci: pcie host and mmcfg support., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 02/61] acpi: split out apm register emulation from acpi.c, Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 26/61] pci: 64bit bar support., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 04/61] acpi: split acpi.c into the common part and the piix4 part., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 28/61] pci: factor out while(bus) bus->next loop logic into pci_find_bus_from()., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 21/61] pci: introduce constant PCI_NUM_PINS for the number of interrupt pins, 4., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 17/61] pc: split out pci device init from pc_init1() into pc_pci_device_init(), Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 15/61] pc: split out vga initialization from pc_init1() into pc_vga_init()., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 09/61] pc: remove a global variable, floppy_controller., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 59/61] ioapic: make irr accept more than 32 pins.,
Isaku Yamahata <=
- [Qemu-devel] [PATCH 16/61] pc: split out basic device init from pc_init1() into pc_basic_device_init(), Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 14/61] pc: split out memory allocation from pc_init1() into pc_memory_init(), Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 56/61] ioapic: clean up of #ifdef DEBUG_IOAPIC., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 03/61] acpi: add acpi constants from linux header files and use them., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 49/61] pci hot add: pass opaque argument to callback., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 01/61] acpi: split out pc smbus routines from acpi.c into pc_smbus.c, Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 61/61] pc_q35: apic mode for pci interrupt routing., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 11/61] pc: introduce a function to allocate cpu irq., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 51/61] vmstate: add a macro for pointer to struct, VMSTATE_STRUCT_POINTER., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 54/61] pci: add opaque argument to pci_map_irq_fn()., Isaku Yamahata, 2009/09/30