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,6 +27,7 @@ | ||
| 27 | //#define DEBUG_PIC | 27 | //#define DEBUG_PIC |
| 28 | 28 | ||
| 29 | //#define DEBUG_IRQ_LATENCY | 29 | //#define DEBUG_IRQ_LATENCY |
| 30 | +//#define DEBUG_IRQ_COUNT | ||
| 30 | 31 | ||
| 31 | typedef struct PicState { | 32 | typedef struct PicState { |
| 32 | uint8_t last_irr; /* edge detection */ | 33 | uint8_t last_irr; /* edge detection */ |
| @@ -50,6 +51,13 @@ typedef struct PicState { | @@ -50,6 +51,13 @@ typedef struct PicState { | ||
| 50 | /* 0 is master pic, 1 is slave pic */ | 51 | /* 0 is master pic, 1 is slave pic */ |
| 51 | static PicState pics[2]; | 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 | /* set irq level. If an edge is detected, then the IRR is set to 1 */ | 61 | /* set irq level. If an edge is detected, then the IRR is set to 1 */ |
| 54 | static inline void pic_set_irq1(PicState *s, int irq, int level) | 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,16 +155,19 @@ static void pic_update_irq(void) | ||
| 147 | #ifdef DEBUG_IRQ_LATENCY | 155 | #ifdef DEBUG_IRQ_LATENCY |
| 148 | int64_t irq_time[16]; | 156 | int64_t irq_time[16]; |
| 149 | #endif | 157 | #endif |
| 150 | -#if defined(DEBUG_PIC) | ||
| 151 | -int irq_level[16]; | ||
| 152 | -#endif | ||
| 153 | 158 | ||
| 154 | void pic_set_irq(int irq, int level) | 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 | if (level != irq_level[irq]) { | 162 | if (level != irq_level[irq]) { |
| 163 | +#if defined(DEBUG_PIC) | ||
| 158 | printf("pic_set_irq: irq=%d level=%d\n", irq, level); | 164 | printf("pic_set_irq: irq=%d level=%d\n", irq, level); |
| 165 | +#endif | ||
| 159 | irq_level[irq] = level; | 166 | irq_level[irq] = level; |
| 167 | +#ifdef DEBUG_IRQ_COUNT | ||
| 168 | + if (level == 1) | ||
| 169 | + irq_count[irq]++; | ||
| 170 | +#endif | ||
| 160 | } | 171 | } |
| 161 | #endif | 172 | #endif |
| 162 | #ifdef DEBUG_IRQ_LATENCY | 173 | #ifdef DEBUG_IRQ_LATENCY |
| @@ -463,6 +474,22 @@ void pic_info(void) | @@ -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 | void pic_init(void) | 494 | void pic_init(void) |
| 468 | { | 495 | { |
monitor.c
| @@ -523,6 +523,8 @@ static term_cmd_t info_cmds[] = { | @@ -523,6 +523,8 @@ static term_cmd_t info_cmds[] = { | ||
| 523 | "", "show the cpu registers" }, | 523 | "", "show the cpu registers" }, |
| 524 | { "history", "", do_info_history, | 524 | { "history", "", do_info_history, |
| 525 | "", "show the command line history", }, | 525 | "", "show the command line history", }, |
| 526 | + { "irq", "", irq_info, | ||
| 527 | + "", "show the interrupts statistics (if available)", }, | ||
| 526 | { "pic", "", pic_info, | 528 | { "pic", "", pic_info, |
| 527 | "", "show i8259 (PIC) state", }, | 529 | "", "show i8259 (PIC) state", }, |
| 528 | { "pci", "", pci_info, | 530 | { "pci", "", pci_info, |
vl.h
| @@ -544,6 +544,7 @@ void pic_set_irq(int irq, int level); | @@ -544,6 +544,7 @@ void pic_set_irq(int irq, int level); | ||
| 544 | void pic_init(void); | 544 | void pic_init(void); |
| 545 | uint32_t pic_intack_read(CPUState *env); | 545 | uint32_t pic_intack_read(CPUState *env); |
| 546 | void pic_info(void); | 546 | void pic_info(void); |
| 547 | +void irq_info(void); | ||
| 547 | 548 | ||
| 548 | /* i8254.c */ | 549 | /* i8254.c */ |
| 549 | 550 |