Commit 4a0fb71e authored by bellard's avatar bellard
Browse files

irq statistics code (initial patch by Jocelyn Mayer)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@840 c046a42c-6fe2-441c-8c8c-71466251a162
parent 274da6b2
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
//#define DEBUG_PIC //#define DEBUG_PIC
//#define DEBUG_IRQ_LATENCY //#define DEBUG_IRQ_LATENCY
//#define DEBUG_IRQ_COUNT
typedef struct PicState { typedef struct PicState {
uint8_t last_irr; /* edge detection */ uint8_t last_irr; /* edge detection */
...@@ -50,6 +51,13 @@ typedef struct PicState { ...@@ -50,6 +51,13 @@ typedef struct PicState {
/* 0 is master pic, 1 is slave pic */ /* 0 is master pic, 1 is slave pic */
static PicState pics[2]; static PicState pics[2];
#if defined(DEBUG_PIC) || defined (DEBUG_IRQ_COUNT)
static int irq_level[16];
#endif
#ifdef DEBUG_IRQ_COUNT
static uint64_t irq_count[16];
#endif
/* set irq level. If an edge is detected, then the IRR is set to 1 */ /* set irq level. If an edge is detected, then the IRR is set to 1 */
static inline void pic_set_irq1(PicState *s, int irq, int level) static inline void pic_set_irq1(PicState *s, int irq, int level)
{ {
...@@ -147,16 +155,19 @@ static void pic_update_irq(void) ...@@ -147,16 +155,19 @@ static void pic_update_irq(void)
#ifdef DEBUG_IRQ_LATENCY #ifdef DEBUG_IRQ_LATENCY
int64_t irq_time[16]; int64_t irq_time[16];
#endif #endif
#if defined(DEBUG_PIC)
int irq_level[16];
#endif
void pic_set_irq(int irq, int level) void pic_set_irq(int irq, int level)
{ {
#if defined(DEBUG_PIC) #if defined(DEBUG_PIC) || defined(DEBUG_IRQ_COUNT)
if (level != irq_level[irq]) { if (level != irq_level[irq]) {
#if defined(DEBUG_PIC)
printf("pic_set_irq: irq=%d level=%d\n", irq, level); printf("pic_set_irq: irq=%d level=%d\n", irq, level);
#endif
irq_level[irq] = level; irq_level[irq] = level;
#ifdef DEBUG_IRQ_COUNT
if (level == 1)
irq_count[irq]++;
#endif
} }
#endif #endif
#ifdef DEBUG_IRQ_LATENCY #ifdef DEBUG_IRQ_LATENCY
...@@ -463,6 +474,22 @@ void pic_info(void) ...@@ -463,6 +474,22 @@ void pic_info(void)
} }
} }
void irq_info(void)
{
#ifndef DEBUG_IRQ_COUNT
term_printf("irq statistic code not compiled.\n");
#else
int i;
int64_t count;
term_printf("IRQ statistics:\n");
for (i = 0; i < 16; i++) {
count = irq_count[i];
if (count > 0)
term_printf("%2d: %lld\n", i, count);
}
#endif
}
void pic_init(void) void pic_init(void)
{ {
......
...@@ -523,6 +523,8 @@ static term_cmd_t info_cmds[] = { ...@@ -523,6 +523,8 @@ static term_cmd_t info_cmds[] = {
"", "show the cpu registers" }, "", "show the cpu registers" },
{ "history", "", do_info_history, { "history", "", do_info_history,
"", "show the command line history", }, "", "show the command line history", },
{ "irq", "", irq_info,
"", "show the interrupts statistics (if available)", },
{ "pic", "", pic_info, { "pic", "", pic_info,
"", "show i8259 (PIC) state", }, "", "show i8259 (PIC) state", },
{ "pci", "", pci_info, { "pci", "", pci_info,
......
...@@ -544,6 +544,7 @@ void pic_set_irq(int irq, int level); ...@@ -544,6 +544,7 @@ void pic_set_irq(int irq, int level);
void pic_init(void); void pic_init(void);
uint32_t pic_intack_read(CPUState *env); uint32_t pic_intack_read(CPUState *env);
void pic_info(void); void pic_info(void);
void irq_info(void);
/* i8254.c */ /* i8254.c */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment