First post, by ardovm
- Rank
- Newbie
Hello All,
I am opening this topic to discuss the generation of serial port related IRQ's as triggered by the OP2 bit in the MCR register.
Short description:
IMHO the ``tri-state logic'' in serialport.cpp around line 785 is flawed. A ``tristated'' IRQ should be disabled, while it is in fact enabled.
Shall I file a bug for this?
Long description:
I was working on a program that works with COM1 and COM3 (they share IRQ 4), and saw that COM1 stopped receiving IRQ's after I shut down COM3 (by setting, among others, its MCR register to zero).
I found out that the IRQ 4 was disabled by the standard IRQ handler in src/bios.cpp, line 966:
static Bitu Default_IRQ_Handler(void)
That function correctly assumes that unhandled IRQ's shall be stopped at the source (i.e. PIC).
The problem is that the IRQ line is raised when the OUT2 bit of MCR is set to zero:
// interrupt logic: if OP2 is 0, the IRQ line is tristated (pulled high)
if((!op2) && temp_op2) {
// irq has been enabled (tristate high -> irq level)
if(!irq_active) PIC_DeActivateIRQ(irq);
} else if(op2 && (!temp_op2)) {
if(!irq_active) PIC_ActivateIRQ(irq); <----------- here
}
If ``tristated'' means ``disabled'', as it should IMHO, the correct code should be as follows:
// interrupt logic: if OP2 is 0, the IRQ line is tristated (disabled)
if((!op2) && temp_op2) {
// irq has been enabled (tristate -> irq level)
if(irq_active) PIC_ActivateIRQ(irq);
} else if(op2 && (!temp_op2)) {
// irq has been disabled (irq level -> tristate)
if(irq_active) PIC_DeActivateIRQ(irq);
}
I looked for the corresponding lines in the QEMU and VirtualBox sources, and if I understood them correctly, they just ignore the OP2 bit of the MCR register: they raise the IRQ only when the IER register requests so.
Shall I file a bug for this? Or is this forum the best place to discuss this?
Thank you in advance!
Arrigo
Arrigo