PatchworkOS
Loading...
Searching...
No Matches
apic.c File Reference
#include <kernel/drivers/apic.h>
#include <kernel/acpi/tables.h>
#include <kernel/cpu/cpu.h>
#include <kernel/cpu/smp.h>
#include <kernel/drivers/hpet.h>
#include <kernel/drivers/pic.h>
#include <kernel/log/log.h>
#include <kernel/log/panic.h>
#include <kernel/mem/vmm.h>
#include <kernel/sched/timer.h>
#include <kernel/utils/utils.h>
#include <assert.h>
#include <kernel/defs.h>

Go to the source code of this file.

Functions

static uint64_t lapic_init (void)
 
static uint64_t ioapic_all_init (void)
 
static uint64_t apic_init (sdt_header_t *table)
 
 ACPI_SDT_HANDLER_REGISTER (MADT_SIGNATURE, apic_init)
 
void apic_timer_one_shot (interrupt_t vector, uint32_t ticks)
 Configure the apic timer in one-shot mode.
 
uint64_t apic_timer_ticks_per_ns (void)
 Apic timer ticks per nanosecond.
 
void lapic_cpu_init (void)
 Initialize the local apic for the current cpu.
 
lapic_id_t lapic_self_id (void)
 Get the lapic id of the current cpu.
 
void lapic_write (lapic_register_t reg, uint32_t value)
 Write to a local apic register.
 
uint32_t lapic_read (lapic_register_t reg)
 Read from a local apic register.
 
void lapic_send_init (lapic_id_t id)
 Send an INIT IPI to a local apic.
 
void lapic_send_sipi (lapic_id_t id, void *entryPoint)
 Send a Startup IPI to a local apic.
 
void lapic_send_ipi (lapic_id_t id, interrupt_t vector)
 Send an Inter-Processor Interrupt (IPI) to a local apic.
 
void lapic_eoi (void)
 Send an End Of Interrupt (EOI) signal to the local apic.
 
uint32_t ioapic_read (ioapic_t *ioapic, ioapic_register_t reg)
 Read from an IOAPIC register.
 
void ioapic_write (ioapic_t *ioapic, ioapic_register_t reg, uint32_t value)
 Write to an IOAPIC register.
 
ioapic_version_t ioapic_get_version (ioapic_t *ioapic)
 Get the IOAPIC version.
 
ioapic_tioapic_from_gsi (ioapic_gsi_t gsi)
 Get the IOAPIC id responsible for a given GSI.
 
void ioapic_set_redirect (interrupt_t vector, ioapic_gsi_t gsi, ioapic_delivery_mode_t deliveryMode, ioapic_polarity_t polarity, ioapic_trigger_mode_t triggerMode, cpu_t *cpu, bool enable)
 Set an IOAPIC redirection entry.
 

Variables

static bool initialized = false
 
static madt_tmadt
 
static uintptr_t lapicBase
 

Function Documentation

◆ ACPI_SDT_HANDLER_REGISTER()

ACPI_SDT_HANDLER_REGISTER ( MADT_SIGNATURE  ,
apic_init   
)

◆ apic_init()

static uint64_t apic_init ( sdt_header_t table)
static

Definition at line 78 of file apic.c.

References ERR, initialized, ioapic_all_init(), lapic_init(), LOG_ERR, and madt.

◆ ioapic_all_init()

◆ lapic_init()

static uint64_t lapic_init ( void  )
static

Variable Documentation

◆ initialized

◆ lapicBase

uintptr_t lapicBase
static

Definition at line 19 of file apic.c.

Referenced by lapic_init(), lapic_read(), and lapic_write().

◆ madt

madt_t* madt
static

Definition at line 18 of file apic.c.

Referenced by apic_init(), ioapic_all_init(), ioapic_from_gsi(), lapic_init(), and smp_others_init().