Knowing ioapic configuration is very useful for the poor soles how need to debug guest occasionally.
Signed-off-by: Gleb Natapov <g...@redhat.com> diff --git a/hw/ioapic.c b/hw/ioapic.c index b0ad78f..ffbe631 100644 --- a/hw/ioapic.c +++ b/hw/ioapic.c @@ -24,6 +24,7 @@ #include "pc.h" #include "qemu-timer.h" #include "host-utils.h" +#include "monitor.h" //#define DEBUG_IOAPIC @@ -50,6 +51,8 @@ struct IOAPICState { uint64_t ioredtbl[IOAPIC_NUM_PINS]; }; +static struct IOAPICState *ioapic; + static void ioapic_service(IOAPICState *s) { uint8_t i; @@ -232,7 +235,7 @@ qemu_irq *ioapic_init(void) qemu_irq *irq; int io_memory; - s = qemu_mallocz(sizeof(IOAPICState)); + ioapic = s = qemu_mallocz(sizeof(IOAPICState)); ioapic_reset(s); io_memory = cpu_register_io_memory(ioapic_mem_read, @@ -245,3 +248,35 @@ qemu_irq *ioapic_init(void) return irq; } + +static const char *delivery_mode_string[] = {"fixed", "lowprio", "smi", "res", + "nmi", "init", "res", "extint"}; + +void do_info_ioapic(Monitor *mon) +{ + int i; + + if (!ioapic) + return; + for (i = 0; i < IOAPIC_NUM_PINS; i++) { + uint64 e = ioapic->ioredtbl[i]; + monitor_printf(mon, "%2d: ", i); + if (e & IOAPIC_LVT_MASKED) { + monitor_printf(mon, "masked\n"); + } else { + uint8_t vec = e & 0xff; + uint8_t trig_mode = ((e >> 15) & 1); + uint8_t dest = e >> 56; + uint8_t dest_mode = (e >> 11) & 1; + uint8_t delivery_mode = (e >> 8) & 7; + uint8_t polarity = (e >> 13) & 1; + monitor_printf(mon, "vec=%3d %s %s acive-%s %s dest=%d\n", + vec, + delivery_mode_string[delivery_mode], + dest_mode ? "logical":"physical", + polarity ? "low" : "high", + trig_mode ? "level": "edge", + dest); + } + } +} diff --git a/hw/pc.h b/hw/pc.h index 03ffc91..6efb3e8 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -45,6 +45,7 @@ int apic_accept_pic_intr(CPUState *env); void apic_deliver_pic_intr(CPUState *env, int level); int apic_get_interrupt(CPUState *env); qemu_irq *ioapic_init(void); +void do_info_ioapic(Monitor *mon); void ioapic_set_irq(void *opaque, int vector, int level); void apic_reset_irq_delivered(void); int apic_get_irq_delivered(void); diff --git a/monitor.c b/monitor.c index c0dc48e..7848965 100644 --- a/monitor.c +++ b/monitor.c @@ -2625,6 +2625,13 @@ static const mon_cmd_t info_cmds[] = { .mhandler.info = do_info_roms, }, { + .name = "ioapic", + .args_type = "", + .params = "", + .help = "show ioapic config", + .mhandler.info = do_info_ioapic, + }, + { .name = NULL, }, }; -- Gleb.