PIC - Programmable Interrupt Controller

Overview

The Programmable Interrupt Controller (PIC) is responsible for handling hardware interrupts in the system. The x86 architecture traditionally uses two cascaded PICs (Master and Slave), which need to be properly initialized and managed.

In BenOS, the PIC driver provides functions to remap, enable/disable, and query the PIC state. It also allows masking or unmasking specific IRQ lines.



Core functions

void pic_send_eoi(uint8_t irq);

Sends an End of Interrupt (EOI) command to the PIC after handling an IRQ.

void pic_remap(int offset1, int offset2);

Remaps the PIC interrupts to new vector offsets to avoid conflicts with CPU exceptions.

void pic_disable();

Disables all IRQs by masking every line.

void irq_set_mask(uint8_t irqline);

Masks (disables) a specific IRQ line.

void irq_clear_mask(uint8_t irqline);

Unmasks (enables) a specific IRQ line.

uint16_t pic_get_irr();

Returns the current value of the Interrupt Request Register (IRR).

uint16_t pic_get_isr();

Returns the current value of the In-Service Register (ISR).