added PIC debug
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@302 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/vl.c b/vl.c
index 23a4b59..53f475a 100644
--- a/vl.c
+++ b/vl.c
@@ -536,6 +536,8 @@
/***********************************************************/
/* 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 @@
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 @@
#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 @@
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 @@
}
}
-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 @@
help();
/* init debug */
+ setvbuf(stdout, NULL, _IOLBF, 0);
if (loglevel) {
logfile = fopen(DEBUG_LOGFILE, "w");
if (!logfile) {