IBNOS
Functions | Variables
Programmable Interrupt Controller

Functions

void picInit (uint32_t interruptOffset)
 Initializes the programmable interrupt controller. More...
 
bool picReserveIRQ (uint32_t irq, irq_callback callback)
 Assign a callback function to an IRQ. More...
 
void picFreeIRQ (uint32_t irq)
 Release an IRQ. More...
 

Variables

uint32_t irqBase = 0
 
irq_callback irqTable [IRQ_COUNT]
 

IRQ Ports

#define IRQ_PIT   0
 
#define IRQ_KEYBOARD   1
 
#define IRQ_SLAVE   2
 
#define IRQ_COM2   3
 
#define IRQ_COM1   4
 
#define IRQ_LPT2   5
 
#define IRQ_FLOPPY   6
 
#define IRQ_LPT1   7
 
#define IRQ_CMOS_CLOCK   8
 
#define IRQ_PS2_MOUSE   12
 
#define IRQ_FPU   13
 
#define IRQ_ATA1   14
 
#define IRQ_ATA2   15
 

Detailed Description

The Programmable Interrupt Controller (PIC) can be used to control hardware interrupts / IRQs. A device driver can set an IRQ handler through picReserveIRQ() and free it again with picFreeIRQ().

For more information about IRQs and Interrupts take a look at http://wiki.osdev.org/IRQ

Macro Definition Documentation

◆ IRQ_ATA1

#define IRQ_ATA1   14

First ATA device (Hard disk or CD)

Definition at line 76 of file pic.h.

◆ IRQ_ATA2

#define IRQ_ATA2   15

Second ATA device (Hard disk or CD)

Definition at line 77 of file pic.h.

◆ IRQ_CMOS_CLOCK

#define IRQ_CMOS_CLOCK   8

The CMOS clock was just updated

Definition at line 73 of file pic.h.

◆ IRQ_COM1

#define IRQ_COM1   4

The COM Port 1 received data

Definition at line 69 of file pic.h.

◆ IRQ_COM2

#define IRQ_COM2   3

The COM Port 2 received data

Definition at line 68 of file pic.h.

◆ IRQ_FLOPPY

#define IRQ_FLOPPY   6

The floppy driver has read some data

Definition at line 71 of file pic.h.

◆ IRQ_FPU

#define IRQ_FPU   13

Not used in modern CPUs

Definition at line 75 of file pic.h.

◆ IRQ_KEYBOARD

#define IRQ_KEYBOARD   1

A key was pressed on the Keyboard

Definition at line 66 of file pic.h.

◆ IRQ_LPT1

#define IRQ_LPT1   7

The LPT Port 1 received data

Definition at line 72 of file pic.h.

◆ IRQ_LPT2

#define IRQ_LPT2   5

The LPT Port 2 received data

Definition at line 70 of file pic.h.

◆ IRQ_PIT

#define IRQ_PIT   0

Programmable Intervall Timer

Definition at line 65 of file pic.h.

◆ IRQ_PS2_MOUSE

#define IRQ_PS2_MOUSE   12

The mouse was moved or clicked

Definition at line 74 of file pic.h.

◆ IRQ_SLAVE

#define IRQ_SLAVE   2

The slave PIC received an IRQ

Definition at line 67 of file pic.h.

Function Documentation

◆ picFreeIRQ()

void picFreeIRQ ( uint32_t  irq)

Release an IRQ.

Call this function if you do not longer need to listen for this IRQ.

Parameters
irqThe previously requested IRQ

Definition at line 186 of file pic.c.

◆ picInit()

void picInit ( uint32_t  interruptOffset)

Initializes the programmable interrupt controller.

The PIC is required to handle hardware interrupts / IRQs. There are (theoretically) 16 hardware IRQs which can be mapped to interrupts.

Parameters
interruptOffsetThe first interrupt which should handle the IRQs

Definition at line 103 of file pic.c.

◆ picReserveIRQ()

bool picReserveIRQ ( uint32_t  irq,
irq_callback  callback 
)

Assign a callback function to an IRQ.

This function allows a device driver to get notified on an IRQ by executing a callback. The function can then handle the input and return the control back to the user program.

Parameters
irqThe irq which should be assigned
callbackThe function which should be called on the irq
Returns
True, if the interrupt is not taken yet, false otherwise.

Definition at line 151 of file pic.c.

Variable Documentation

◆ irqBase

uint32_t irqBase = 0

Definition at line 45 of file pic.c.

◆ irqTable

Definition at line 47 of file pic.c.