Skip to content

fix(pic): unmask cascade IRQ2 when enabling a slave IRQ - #106

Merged
im-nymii merged 1 commit into
Auri-OS:developfrom
kudasaixc:fix/pic-cascade-unmask
Jul 24, 2026
Merged

fix(pic): unmask cascade IRQ2 when enabling a slave IRQ#106
im-nymii merged 1 commit into
Auri-OS:developfrom
kudasaixc:fix/pic-cascade-unmask

Conversation

@kudasaixc

Copy link
Copy Markdown
Contributor

pic_remap() masks every IRQ line (0xFF) including IRQ2, the cascade input for the slave PIC, and nothing ever unmasks it. Any IRQ in the 8-15 range (RTC, PS/2 mouse, ATA, ...) could therefore never be delivered, even after calling pic_unmask_irq() for it. This unmasks the cascade line on the master whenever a slave IRQ is enabled.

pic_remap() masks every IRQ line (0xFF) including IRQ2, the cascade
input for the slave PIC, and nothing ever unmasks it. Any IRQ in the
8-15 range (RTC, PS/2 mouse, ATA, ...) could therefore never be
delivered, even after calling pic_unmask_irq() for it. Unmask the
cascade line on the master whenever a slave IRQ is enabled.
@kudasaixc

kudasaixc commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

PoC

pic_remap() ends by masking everything:

outb(PIC1_DATA, 0xFF);
outb(PIC2_DATA, 0xFF);

That includes IRQ2 on the master : the line the slave PIC is cascaded onto : and nothing ever clears it. So no slave interrupt (IRQ 8–15) can reach the CPU, even after you "enable" it:

// try to enable the RTC (IRQ 8)
irq_register_handler(8, rtc_callback);
pic_unmask_irq(8);           // clears IRQ8 in the SLAVE mask only
// rtc_callback never fires: IRQ2 on the master is still masked,
// so the slave's output is blocked before it reaches the CPU

pic_unmask_irq(8) computes port = PIC2_DATA and clears bit 0 of the slave mask, but the master never learns it should listen on IRQ2. Any future driver on IRQ 8–15 (RTC, PS/2 mouse @ IRQ12, ATA @ IRQ14/15) is silently dead. Fix clears IRQ2 on the master whenever a slave line is unmasked.

@im-nymii

Copy link
Copy Markdown
Member

LGTM

@im-nymii
im-nymii merged commit 42e7eb7 into Auri-OS:develop Jul 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants