I recently added a part to an application of mine which is meant to allow it to operate with an IRQ belonging to the secondary PIC. In particular, the interrupt handler needs to signal an End Of Interrupt condition to both PICs then instead of only the primary one. This is my code:
push cs
pop ds
mov al, 20h ; acknowledge interrupt
cmp byte [serial_use_irqmask + 1], 0
je @F
out 0A0h, al ; to secondary PIC
@@:
out 20h, al ; to primary PIC
Now, while adding this part I considered whether to signal the EOI to the secondary PIC first, or to the primary PIC. Searching for that did not yield any statements either way. However, I found that some examples seem to choose the order I ended up implementing; that is the secondary PIC first, then the primary.
My question is, does this matter at all? Is there an actual reason to prefer either order?
Examples of secondary PIC first
bootlib interrupt handlers:
movb $0x20, %al # end of interrupt command
outb %al, $0xA0 # PIC2 command port
outb %al, $0x20 # PIC1 command port
osdev.org wiki's article on Interrupts:
mov al, 20h
out A0h, al
out 20h, al
Pure64 interrupt handlers:
mov al, 0x20 ; Acknowledge the IRQ
out 0xA0, al
out 0x20, al
Dos64-stub interrupt handlers:
Irq0007_1:
mov al,20h
out 20h,al
pop rax
swint:
iretq
;--- IRQs 8-F
Irq080F:
push rax
mov al,20h
out 0A0h,al
jmp Irq0007_1
Example of primary PIC first
Example in the German Wikipedia article "Softwarebremse" ("Bremse" means "Brake"):
mov al, 20h
out 020h, al
out 0a0h, al
sti