StuBS
APIC Namespace Reference

Information about the (extended) Advanced Programmable Interrupt Controller. More...

Enumerations

enum  Device {
  TIMER = 0 ,
  KEYBOARD = 1 ,
  COM1 = 4 ,
  COM2 = 3 ,
  COM3 = 4 ,
  COM4 = 3 ,
  FLOPPY = 6 ,
  LPT1 = 7 ,
  REALTIMECLOCK = 8 ,
  PS2MOUSE = 12 ,
  IDE1 = 14 ,
  IDE2 = 15
}
 Historic order of interrupt lines (PIC) More...
 

Functions

bool init ()
 Executes system detection. More...
 
uint8_t getIOAPICSlot (APIC::Device device)
 Returns the pin number the device is connected to.
 
uintptr_t getIOAPICAddress ()
 Queries the physical I/O-APIC address determined during system boot. More...
 
uint8_t getIOAPICID ()
 Queries of ID of the I/O-APIC determined during system boot. More...
 
uint8_t getLogicalAPICID (uint8_t core)
 Returns the logical ID of the Local APIC passed for core. More...
 
uint8_t getLAPICID (uint8_t core)
 Get the Local APIC ID of a CPU. More...
 

Constants

const uint8_t INVALID_ID = 0xff
 Invalid APIC ID. More...
 

Detailed Description

Information about the (extended) Advanced Programmable Interrupt Controller.

Enumeration Type Documentation

◆ Device

Historic order of interrupt lines (PIC)

Enumerator
TIMER 

Programmable Interrupt Timer (PIT)

KEYBOARD 

Keyboard.

COM1 

First serial interface.

COM2 

Second serial interface.

COM3 

Third serial interface (shared with COM1)

COM4 

Forth serial interface (shared with COM2)

FLOPPY 

Floppy device.

LPT1 

Printer.

REALTIMECLOCK 

Real time clock.

PS2MOUSE 

Mouse.

IDE1 

First hard disk.

IDE2 

Second hard disk.

Function Documentation

◆ init()

bool APIC::init ( )

Executes system detection.

Searches and evaluates the APIC entries in the ACPI table. This function recognizes a possibly existing multicore system. After successful detection, the number of available CPUs (which is equal to the number of local APICs) ) can be queried using the method Core::count().

Note
Called by kernel_init() on BSP
Returns
true if detection of the APIC entries was successful

◆ getIOAPICAddress()

uintptr_t APIC::getIOAPICAddress ( )

Queries the physical I/O-APIC address determined during system boot.

Returns
Base address of the (first & only supported) I/O APIC

◆ getIOAPICID()

uint8_t APIC::getIOAPICID ( )

Queries of ID of the I/O-APIC determined during system boot.

Returns
Identification of the (first & only supported) I/O APIC

◆ getLogicalAPICID()

uint8_t APIC::getLogicalAPICID ( uint8_t  core)

Returns the logical ID of the Local APIC passed for core.

The LAPIC's logical ID is set (by StuBS) during boot such that exactly one bit is set per CPU core. For core 0, bit 0 is set in its ID, while core 1 has bit 1 set, etc.

Parameters
coreThe queried CPU core

◆ getLAPICID()

uint8_t APIC::getLAPICID ( uint8_t  core)

Get the Local APIC ID of a CPU.

Parameters
coreQuery CPU core number
Returns
LAPIC ID of CPU or INVALID_ID if invalid CPU ID

Constant Documentation

◆ INVALID_ID

const uint8_t APIC::INVALID_ID = 0xff

Invalid APIC ID.

The highest address is reserved according to xAPIC specification