Commit 4a0fb71e67df4774d79eb788f0d1bd7a78801e6d
1 parent
274da6b2
irq statistics code (initial patch by Jocelyn Mayer)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@840 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
34 additions
and
4 deletions
hw/i8259.c
| ... | ... | @@ -27,6 +27,7 @@ |
| 27 | 27 | //#define DEBUG_PIC |
| 28 | 28 | |
| 29 | 29 | //#define DEBUG_IRQ_LATENCY |
| 30 | +//#define DEBUG_IRQ_COUNT | |
| 30 | 31 | |
| 31 | 32 | typedef struct PicState { |
| 32 | 33 | uint8_t last_irr; /* edge detection */ |
| ... | ... | @@ -50,6 +51,13 @@ typedef struct PicState { |
| 50 | 51 | /* 0 is master pic, 1 is slave pic */ |
| 51 | 52 | static PicState pics[2]; |
| 52 | 53 | |
| 54 | +#if defined(DEBUG_PIC) || defined (DEBUG_IRQ_COUNT) | |
| 55 | +static int irq_level[16]; | |
| 56 | +#endif | |
| 57 | +#ifdef DEBUG_IRQ_COUNT | |
| 58 | +static uint64_t irq_count[16]; | |
| 59 | +#endif | |
| 60 | + | |
| 53 | 61 | /* set irq level. If an edge is detected, then the IRR is set to 1 */ |
| 54 | 62 | static inline void pic_set_irq1(PicState *s, int irq, int level) |
| 55 | 63 | { |
| ... | ... | @@ -147,16 +155,19 @@ static void pic_update_irq(void) |
| 147 | 155 | #ifdef DEBUG_IRQ_LATENCY |
| 148 | 156 | int64_t irq_time[16]; |
| 149 | 157 | #endif |
| 150 | -#if defined(DEBUG_PIC) | |
| 151 | -int irq_level[16]; | |
| 152 | -#endif | |
| 153 | 158 | |
| 154 | 159 | void pic_set_irq(int irq, int level) |
| 155 | 160 | { |
| 156 | -#if defined(DEBUG_PIC) | |
| 161 | +#if defined(DEBUG_PIC) || defined(DEBUG_IRQ_COUNT) | |
| 157 | 162 | if (level != irq_level[irq]) { |
| 163 | +#if defined(DEBUG_PIC) | |
| 158 | 164 | printf("pic_set_irq: irq=%d level=%d\n", irq, level); |
| 165 | +#endif | |
| 159 | 166 | irq_level[irq] = level; |
| 167 | +#ifdef DEBUG_IRQ_COUNT | |
| 168 | + if (level == 1) | |
| 169 | + irq_count[irq]++; | |
| 170 | +#endif | |
| 160 | 171 | } |
| 161 | 172 | #endif |
| 162 | 173 | #ifdef DEBUG_IRQ_LATENCY |
| ... | ... | @@ -463,6 +474,22 @@ void pic_info(void) |
| 463 | 474 | } |
| 464 | 475 | } |
| 465 | 476 | |
| 477 | +void irq_info(void) | |
| 478 | +{ | |
| 479 | +#ifndef DEBUG_IRQ_COUNT | |
| 480 | + term_printf("irq statistic code not compiled.\n"); | |
| 481 | +#else | |
| 482 | + int i; | |
| 483 | + int64_t count; | |
| 484 | + | |
| 485 | + term_printf("IRQ statistics:\n"); | |
| 486 | + for (i = 0; i < 16; i++) { | |
| 487 | + count = irq_count[i]; | |
| 488 | + if (count > 0) | |
| 489 | + term_printf("%2d: %lld\n", i, count); | |
| 490 | + } | |
| 491 | +#endif | |
| 492 | +} | |
| 466 | 493 | |
| 467 | 494 | void pic_init(void) |
| 468 | 495 | { | ... | ... |
monitor.c
| ... | ... | @@ -523,6 +523,8 @@ static term_cmd_t info_cmds[] = { |
| 523 | 523 | "", "show the cpu registers" }, |
| 524 | 524 | { "history", "", do_info_history, |
| 525 | 525 | "", "show the command line history", }, |
| 526 | + { "irq", "", irq_info, | |
| 527 | + "", "show the interrupts statistics (if available)", }, | |
| 526 | 528 | { "pic", "", pic_info, |
| 527 | 529 | "", "show i8259 (PIC) state", }, |
| 528 | 530 | { "pci", "", pci_info, | ... | ... |