The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
pic.c File Reference
#include "pic.h"
#include "io.h"

Macros

#define PIC1_COMMAND_PORT   0x20
 PIC I/O port addresses.
#define PIC1_DATA_PORT   0x21
#define PIC2_COMMAND_PORT   0xA0
#define PIC2_DATA_PORT   0xA1

Enumerations

enum  {
  PIC_ICW1_ICW4 = 0x01 , PIC_ICW1_SINGLE = 0x02 , PIC_ICW1_INTERVAL4 = 0x04 , PIC_ICW1_LEVEL = 0x08 ,
  PIC_ICW1_INITIALIZE = 0x10
}
 ICW1 flags. More...
enum  {
  PIC_ICW4_8086 = 0x01 , PIC_ICW4_AUTO_EOI = 0x02 , PIC_ICW4_BUFFER_MASTER = 0x04 , PIC_ICW4_BUFFER_SLAVE = 0x00 ,
  PIC_ICW4_BUFFERED = 0x08 , PIC_ICW4_SFNM = 0x10
}
 ICW4 flags. More...
enum  { PIC_CMD_END_OF_INTERRUPT = 0x20 , PIC_CMD_READ_IRR = 0x0A , PIC_CMD_READ_ISR = 0x0B }
 PIC command bytes. More...

Functions

void pic_configure (uint8_t offset_master, uint8_t offset_slave)
 configure the 8259A PIC.
void pic_send_eoi (int irq)
 send an End-of-Interrupt (EOI) signal to the PIC.
void pic_disable (void)
 disable both PICs by masking all IRQ lines.
void pic_mask (int irq)
 mask (disable) a specific IRQ line.
void pic_unmask (int irq)
 unmask (enable) a specific IRQ line.
uint16_t pic_read_irr (void)
 read the Interrupt Request Register (IRR) from both PICs.
uint16_t pic_read_isr (void)
 read the In-Service Register (ISR) from both PICs.

Macro Definition Documentation

◆ PIC1_COMMAND_PORT

#define PIC1_COMMAND_PORT   0x20

PIC I/O port addresses.

◆ PIC1_DATA_PORT

#define PIC1_DATA_PORT   0x21

◆ PIC2_COMMAND_PORT

#define PIC2_COMMAND_PORT   0xA0

◆ PIC2_DATA_PORT

#define PIC2_DATA_PORT   0xA1

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

ICW1 flags.

(bits 5–7 ignored on x86)

Enumerator
PIC_ICW1_ICW4 
PIC_ICW1_SINGLE 
PIC_ICW1_INTERVAL4 
PIC_ICW1_LEVEL 
PIC_ICW1_INITIALIZE 

◆ anonymous enum

anonymous enum

ICW4 flags.

(bits 5–7 reserved)

Enumerator
PIC_ICW4_8086 
PIC_ICW4_AUTO_EOI 
PIC_ICW4_BUFFER_MASTER 
PIC_ICW4_BUFFER_SLAVE 
PIC_ICW4_BUFFERED 
PIC_ICW4_SFNM 

◆ anonymous enum

anonymous enum

PIC command bytes.

Enumerator
PIC_CMD_END_OF_INTERRUPT 
PIC_CMD_READ_IRR 
PIC_CMD_READ_ISR 

Function Documentation

◆ pic_configure()

void pic_configure ( uint8_t offset_master,
uint8_t offset_slave )

configure the 8259A PIC.

remaps IRQ lines to the specified IDT vector offsets.

Parameters
offset_masterbase vector offset for the master PIC (IRQ 0–7).
offset_slavebase vector offset for the slave PIC (IRQ 8–15).

◆ pic_send_eoi()

void pic_send_eoi ( int irq)

send an End-of-Interrupt (EOI) signal to the PIC.

if the IRQ came from the slave PIC, sends EOI to both slave and master.

Parameters
irqthe IRQ number (0–15).

◆ pic_disable()

void pic_disable ( void )

disable both PICs by masking all IRQ lines.

◆ pic_mask()

void pic_mask ( int irq)

mask (disable) a specific IRQ line.

Parameters
irqthe IRQ number (0–15).

◆ pic_unmask()

void pic_unmask ( int irq)

unmask (enable) a specific IRQ line.

Parameters
irqthe IRQ number (0–15).

◆ pic_read_irr()

uint16_t pic_read_irr ( void )

read the Interrupt Request Register (IRR) from both PICs.

Returns
16-bit value with master in low byte, slave in high byte.

◆ pic_read_isr()

uint16_t pic_read_isr ( void )

read the In-Service Register (ISR) from both PICs.

Returns
16-bit value with master in low byte, slave in high byte.