From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: [PATCH 11/16] xen: arm: Add debug keyhandler to dump the physical GIC state. Date: Wed, 20 Nov 2013 14:48:12 +0000 Message-ID: <1384958897-13074-11-git-send-email-ian.campbell@citrix.com> References: <1384958746.6071.64.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1384958746.6071.64.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Ian Campbell , Anup Patel , stefano.stabellini@eu.citrix.com, julien.grall@linaro.org, tim@xen.org, pranavkumar@linaro.org List-Id: xen-devel@lists.xenproject.org Signed-off-by: Ian Campbell --- xen/arch/arm/gic.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index ab49106..185a6b8 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -385,6 +386,77 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize, return 0; } + +static void do_dump_gic(unsigned char key) +{ + int irq; + printk("'%c' pressed -> dumping GIC state\n", key); + + for ( irq = 0; irq < gic.lines; irq++ ) + { + const char *type; + int type_nr, enable, pend, active, priority, target; + struct irq_desc *desc = irq_to_desc(irq); + uint8_t *bytereg; + uint32_t wordreg; + + bytereg = (uint8_t *) (GICD + GICD_ITARGETSR); + target = bytereg[irq]; + + bytereg = (uint8_t *) (GICD + GICD_IPRIORITYR); + priority = bytereg[irq]; + + switch ( irq ) + { + case 0 ... 15: + type = "SGI"; + type_nr = irq; + target = 0x00; /* these are per-CPU */ + break; + case 16 ... 31: + type = "PPI"; + type_nr = irq - 16; + break; + default: + type = "SPI"; + type_nr = irq - 32; + break; + } + + wordreg = GICD[GICD_ISENABLER + irq / 32]; + enable = !!(wordreg & (1u << (irq % 32))); + wordreg = GICD[GICD_ISPENDR + irq / 32]; + pend = !!(wordreg & (1u << (irq % 32))); + wordreg = GICD[GICD_ISACTIVER + irq / 32]; + active = !!(wordreg & (1u << (irq % 32))); + + printk("IRQ%d %s%d: %c%c%c pri:%02x tgt:%02x ", + irq, type, type_nr, + enable ? 'e' : '-', + pend ? 'p' : '-', + active ? 'a' : '-', + priority, target); + + if ( desc->status & IRQ_GUEST ) + { + struct domain *d = desc->action->dev_id; + printk("dom%d %s", d->domain_id, desc->action->name); + } + else + { + printk("Xen"); + } + printk("\n"); + } + +} + +static struct keyhandler dump_gic_keyhandler = { + .irq_callback = 0, + .u.fn = do_dump_gic, + .desc = "dump GIC state" +}; + /* Set up the GIC */ void __init gic_init(void) { @@ -456,6 +528,9 @@ void __init gic_init(void) gic_hyp_init(); spin_unlock(&gic.lock); + + register_keyhandler('G', &dump_gic_keyhandler); + } void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi) -- 1.7.10.4