Commit b118d61e556a1f5cebc991e368af7292ffa1d8f3
1 parent
2f62b397
added PIC debug
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@302 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
30 additions
and
4 deletions
vl.c
... | ... | @@ -536,6 +536,8 @@ void cmos_init(void) |
536 | 536 | /***********************************************************/ |
537 | 537 | /* 8259 pic emulation */ |
538 | 538 | |
539 | +//#define DEBUG_PIC | |
540 | + | |
539 | 541 | typedef struct PicState { |
540 | 542 | uint8_t last_irr; /* edge detection */ |
541 | 543 | uint8_t irr; /* interrupt request register */ |
... | ... | @@ -630,9 +632,18 @@ static void pic_update_irq(void) |
630 | 632 | int64_t irq_time[16]; |
631 | 633 | int64_t cpu_get_ticks(void); |
632 | 634 | #endif |
635 | +#ifdef DEBUG_PIC | |
636 | +int irq_level[16]; | |
637 | +#endif | |
633 | 638 | |
634 | 639 | void pic_set_irq(int irq, int level) |
635 | 640 | { |
641 | +#ifdef DEBUG_PIC | |
642 | + if (level != irq_level[irq]) { | |
643 | + printf("pic_set_irq: irq=%d level=%d\n", irq, level); | |
644 | + irq_level[irq] = level; | |
645 | + } | |
646 | +#endif | |
636 | 647 | #ifdef DEBUG_IRQ_LATENCY |
637 | 648 | if (level) { |
638 | 649 | irq_time[irq] = cpu_get_ticks(); |
... | ... | @@ -651,6 +662,9 @@ int cpu_x86_get_pic_interrupt(CPUX86State *env) |
651 | 662 | #ifdef DEBUG_IRQ_LATENCY |
652 | 663 | printf("IRQ%d latency=%Ld\n", irq, cpu_get_ticks() - irq_time[irq]); |
653 | 664 | #endif |
665 | +#ifdef DEBUG_PIC | |
666 | + printf("pic_interrupt: irq=%d\n", irq); | |
667 | +#endif | |
654 | 668 | |
655 | 669 | if (irq >= 8) { |
656 | 670 | irq2 = irq & 7; |
... | ... | @@ -671,6 +685,9 @@ void pic_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val) |
671 | 685 | PicState *s; |
672 | 686 | int priority; |
673 | 687 | |
688 | +#ifdef DEBUG_PIC | |
689 | + printf("pic_write: addr=0x%02x val=0x%02x\n", addr, val); | |
690 | +#endif | |
674 | 691 | s = &pics[addr >> 7]; |
675 | 692 | addr &= 1; |
676 | 693 | if (addr == 0) { |
... | ... | @@ -743,19 +760,27 @@ void pic_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val) |
743 | 760 | } |
744 | 761 | } |
745 | 762 | |
746 | -uint32_t pic_ioport_read(CPUX86State *env, uint32_t addr) | |
763 | +uint32_t pic_ioport_read(CPUX86State *env, uint32_t addr1) | |
747 | 764 | { |
748 | 765 | PicState *s; |
766 | + unsigned int addr; | |
767 | + int ret; | |
768 | + | |
769 | + addr = addr1; | |
749 | 770 | s = &pics[addr >> 7]; |
750 | 771 | addr &= 1; |
751 | 772 | if (addr == 0) { |
752 | 773 | if (s->read_reg_select) |
753 | - return s->isr; | |
774 | + ret = s->isr; | |
754 | 775 | else |
755 | - return s->irr; | |
776 | + ret = s->irr; | |
756 | 777 | } else { |
757 | - return s->imr; | |
778 | + ret = s->imr; | |
758 | 779 | } |
780 | +#ifdef DEBUG_PIC | |
781 | + printf("pic_read: addr=0x%02x val=0x%02x\n", addr1, ret); | |
782 | +#endif | |
783 | + return ret; | |
759 | 784 | } |
760 | 785 | |
761 | 786 | void pic_init(void) |
... | ... | @@ -2634,6 +2659,7 @@ int main(int argc, char **argv) |
2634 | 2659 | help(); |
2635 | 2660 | |
2636 | 2661 | /* init debug */ |
2662 | + setvbuf(stdout, NULL, _IOLBF, 0); | |
2637 | 2663 | if (loglevel) { |
2638 | 2664 | logfile = fopen(DEBUG_LOGFILE, "w"); |
2639 | 2665 | if (!logfile) { | ... | ... |