From patchwork Thu Dec 24 15:02:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 41780 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 73E75B7BF2 for ; Fri, 25 Dec 2009 02:03:31 +1100 (EST) Received: from localhost ([127.0.0.1]:59609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNpDs-0001Md-Ij for incoming@patchwork.ozlabs.org; Thu, 24 Dec 2009 10:03:28 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NNpDG-0001L8-Ve for qemu-devel@nongnu.org; Thu, 24 Dec 2009 10:02:50 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NNpDC-0001JM-K0 for qemu-devel@nongnu.org; Thu, 24 Dec 2009 10:02:50 -0500 Received: from [199.232.76.173] (port=33242 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NNpDC-0001JH-B6 for qemu-devel@nongnu.org; Thu, 24 Dec 2009 10:02:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3485) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NNpDB-0004cq-Ln for qemu-devel@nongnu.org; Thu, 24 Dec 2009 10:02:45 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBOF2id2024611 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Dec 2009 10:02:44 -0500 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBOF2hsN001903 for ; Thu, 24 Dec 2009 10:02:43 -0500 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id D9A671336CD; Thu, 24 Dec 2009 17:02:42 +0200 (IST) Date: Thu, 24 Dec 2009 17:02:42 +0200 From: Gleb Natapov To: qemu-devel@nongnu.org Message-ID: <20091224150242.GD5691@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH] add "info ioapic" monitor command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Knowing ioapic configuration is very useful for the poor soles how need to debug guest occasionally. Signed-off-by: Gleb Natapov --- Gleb. 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, }, };