added PIC debug

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@302 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
bellard 2003-06-30 23:36:21 +00:00
parent 2f62b397b5
commit b118d61e55
1 changed files with 30 additions and 4 deletions

34
vl.c
View File

@ -536,6 +536,8 @@ void cmos_init(void)
/***********************************************************/
/* 8259 pic emulation */
//#define DEBUG_PIC
typedef struct PicState {
uint8_t last_irr; /* edge detection */
uint8_t irr; /* interrupt request register */
@ -630,9 +632,18 @@ static void pic_update_irq(void)
int64_t irq_time[16];
int64_t cpu_get_ticks(void);
#endif
#ifdef DEBUG_PIC
int irq_level[16];
#endif
void pic_set_irq(int irq, int level)
{
#ifdef DEBUG_PIC
if (level != irq_level[irq]) {
printf("pic_set_irq: irq=%d level=%d\n", irq, level);
irq_level[irq] = level;
}
#endif
#ifdef DEBUG_IRQ_LATENCY
if (level) {
irq_time[irq] = cpu_get_ticks();
@ -651,6 +662,9 @@ int cpu_x86_get_pic_interrupt(CPUX86State *env)
#ifdef DEBUG_IRQ_LATENCY
printf("IRQ%d latency=%Ld\n", irq, cpu_get_ticks() - irq_time[irq]);
#endif
#ifdef DEBUG_PIC
printf("pic_interrupt: irq=%d\n", irq);
#endif
if (irq >= 8) {
irq2 = irq & 7;
@ -671,6 +685,9 @@ void pic_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val)
PicState *s;
int priority;
#ifdef DEBUG_PIC
printf("pic_write: addr=0x%02x val=0x%02x\n", addr, val);
#endif
s = &pics[addr >> 7];
addr &= 1;
if (addr == 0) {
@ -743,19 +760,27 @@ void pic_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val)
}
}
uint32_t pic_ioport_read(CPUX86State *env, uint32_t addr)
uint32_t pic_ioport_read(CPUX86State *env, uint32_t addr1)
{
PicState *s;
unsigned int addr;
int ret;
addr = addr1;
s = &pics[addr >> 7];
addr &= 1;
if (addr == 0) {
if (s->read_reg_select)
return s->isr;
ret = s->isr;
else
return s->irr;
ret = s->irr;
} else {
return s->imr;
ret = s->imr;
}
#ifdef DEBUG_PIC
printf("pic_read: addr=0x%02x val=0x%02x\n", addr1, ret);
#endif
return ret;
}
void pic_init(void)
@ -2634,6 +2659,7 @@ int main(int argc, char **argv)
help();
/* init debug */
setvbuf(stdout, NULL, _IOLBF, 0);
if (loglevel) {
logfile = fopen(DEBUG_LOGFILE, "w");
if (!logfile) {