Skip to main content

kernel/arch/x86_64/interrupts/irqs/pic/
irq7_spurious.rs

1// SPDX-License-Identifier: GPL-3.0-only
2//! Spurious PIC interrupt handler
3//!
4//! Authors: MarioS271
5
6use crate::arch::x86_64::interrupts::pic;
7use x86_64::instructions::port::Port;
8use x86_64::structures::idt::InterruptStackFrame;
9
10/// Check whether IRQ7 is spurious; send EOI only if the ISR bit 7 is set (real IRQ)
11pub extern "x86-interrupt" fn handler(
12    _: InterruptStackFrame
13) {
14    let mut port: Port<u8> = Port::new(pic::PIC_MASTER_CMD_PORT);
15    let isr;
16
17    // Safety:
18    // - The port at PIC_MASTER_CMD_PORT is the correct PIC command port per x86_64 standards
19    // - 0x0B is the OCW3 command to be able to read the ISR register
20    unsafe {
21        port.write(0x0B);
22         isr = port.read();
23    }
24
25    if isr & (1 << 7) == 0 {
26        return;
27    }
28
29    pic::end_of_interrupt(pic::PIC_MASTER_OFFSET + 7);
30}