|
ginnOS
The reference: libc, the libraries and the kernel
|
the local APIC and the I/O APIC. More...
#include "common/stdint.h"Go to the source code of this file.
Macros | |
| #define | LOCAL_TIMER_VECTOR 0xEC |
| the vector of the local APIC timer on the cores other than the boot core (as in Linux) | |
| #define | TLB_FLUSH_VECTOR 0xFC |
| the vector of the IPI that asks a core to flush its TLB (Linux's CALL_FUNCTION_VECTOR) | |
| #define | RESCHEDULE_VECTOR 0xFD |
| the vector of the IPI that wakes a core to run a process or act on a signal (as in Linux) | |
Functions | |
| bool | apic_init (uint32_t timer_hz) |
| change from the 8259 PICs to the APICs. | |
| bool | apic_active (void) |
| true after a successful apic_init. | |
| void | apic_eoi (void) |
| end of interrupt to the local APIC. | |
| void | apic_set_irq_masked (uint32_t irq, bool masked) |
| mask or unmask the I/O APIC entry of an ISA IRQ (0 to 15). | |
| uint8_t | apic_id (void) |
| the id of the local APIC of the boot core, for the destination of MSI messages and the I/O APIC entries. | |
| void | apic_set_irq_level (uint32_t irq) |
| make the I/O APIC entry of an ISA IRQ level-triggered (a PCI interrupt line routed to it). | |
| bool | apic_set_irq_dest (uint32_t irq, uint8_t lapic_id) |
| send the I/O APIC entry of an ISA IRQ to a local APIC (physical destination mode). | |
| bool | apic_init_ap (void) |
| set up the local APIC of a core other than the boot core: turn it on, mask LINT0, LINT1 and the error interrupt, and start its timer on LOCAL_TIMER_VECTOR at the rate the boot core measured (if the boot core uses its timer). | |
| bool | apic_send_init (uint8_t target) |
| send INIT to a core: it stops and waits for a startup IPI. | |
| bool | apic_send_startup (uint8_t target, uint32_t page_address) |
| send a startup IPI (SIPI) to a core that waits after INIT. | |
| void | apic_send_ipi (uint8_t target, uint8_t vector) |
| send an interrupt to another core (an IPI) on a vector, with fixed delivery. | |
| void | apic_send_nmi (uint8_t target) |
| send a non-maskable interrupt (NMI, vector 2) to another core. | |
the local APIC and the I/O APIC.
the kernel starts with the 8259 PICs. apic_init changes to the APICs if the ACPI MADT describes them: the 8259s are masked, the I/O APIC sends the ISA IRQs to the same vectors as before (PIC_REMAP_OFFSET + irq), and the local APIC timer gives the scheduler tick on the vector of IRQ 0. without a MADT the kernel stays on the 8259s.
| #define LOCAL_TIMER_VECTOR 0xEC |
the vector of the local APIC timer on the cores other than the boot core (as in Linux)
| #define TLB_FLUSH_VECTOR 0xFC |
the vector of the IPI that asks a core to flush its TLB (Linux's CALL_FUNCTION_VECTOR)
| #define RESCHEDULE_VECTOR 0xFD |
the vector of the IPI that wakes a core to run a process or act on a signal (as in Linux)
change from the 8259 PICs to the APICs.
call with interrupts off, after acpi_init (it needs the MADT) and mmio_init.
| timer_hz | the tick rate for the local APIC timer. |
| bool apic_active | ( | void | ) |
true after a successful apic_init.
| void apic_eoi | ( | void | ) |
end of interrupt to the local APIC.
mask or unmask the I/O APIC entry of an ISA IRQ (0 to 15).
| uint8_t apic_id | ( | void | ) |
the id of the local APIC of the boot core, for the destination of MSI messages and the I/O APIC entries.
| void apic_set_irq_level | ( | uint32_t | irq | ) |
make the I/O APIC entry of an ISA IRQ level-triggered (a PCI interrupt line routed to it).
the polarity stays as the MADT gives it.
send the I/O APIC entry of an ISA IRQ to a local APIC (physical destination mode).
| irq | the ISA IRQ (0 to 15). |
| lapic_id | the id of the local APIC of the core. |
| bool apic_init_ap | ( | void | ) |
set up the local APIC of a core other than the boot core: turn it on, mask LINT0, LINT1 and the error interrupt, and start its timer on LOCAL_TIMER_VECTOR at the rate the boot core measured (if the boot core uses its timer).
call it on that core, after apic_init on the boot core.
send INIT to a core: it stops and waits for a startup IPI.
| target | the local APIC id of the core. |
send a startup IPI (SIPI) to a core that waits after INIT.
the core starts in real mode at page_address (CS = page_address / 16, IP = 0).
| target | the local APIC id of the core. |
| page_address | a page-aligned physical address below 1 MiB. |
send an interrupt to another core (an IPI) on a vector, with fixed delivery.
interrupts are off on this core while the IPI goes out.
| target | the local APIC id of the core. |
| vector | the vector the core receives. |
| void apic_send_nmi | ( | uint8_t | target | ) |
send a non-maskable interrupt (NMI, vector 2) to another core.
it comes also when interrupts are off on that core.
| target | the local APIC id of the core. |