From 0812a0635022227caaf6d4576559878d36a3ddb9 Mon Sep 17 00:00:00 2001 From: 0x35c Date: Wed, 9 Oct 2024 16:22:26 +0200 Subject: [PATCH] core: remove apic.c and unused function in pic.c --- src/interrupt/apic.c | 69 -------------------------------------------- src/interrupt/pic.c | 6 ---- 2 files changed, 75 deletions(-) delete mode 100644 src/interrupt/apic.c diff --git a/src/interrupt/apic.c b/src/interrupt/apic.c deleted file mode 100644 index 930c417..0000000 --- a/src/interrupt/apic.c +++ /dev/null @@ -1,69 +0,0 @@ -#include "apic.h" -#include "cpuid.h" -#include -#include -#include - -#define IA32_APIC_BASE_MSR 0x1B -#define IA32_APIC_BASE_MSR_BSP 0x100 // Processor is a BSP -#define IA32_APIC_BASE_MSR_ENABLE 0x800 - -/** returns a 'true' value if the CPU supports APIC - * and if the local APIC hasn't been disabled in MSRs - * note that this requires CPUID to be supported. - */ -bool check_apic() -{ - static unsigned int eax, edx, unused; - __get_cpuid(1, &eax, &unused, &unused, &edx); - return edx & CPUID_FEAT_EDX_APIC; -} - -/* Set the physical address for local APIC registers */ -static void cpu_set_apic_base(uintptr_t apic) -{ - uint32_t edx = 0; - uint32_t eax = (apic & 0xfffff0000) | IA32_APIC_BASE_MSR_ENABLE; - -#ifdef __PHYSICAL_MEMORY_EXTENSION__ - edx = (apic >> 32) & 0x0f; -#endif - - cpu_set_msr(IA32_APIC_BASE_MSR, eax, edx); -} - -/** - * Get the physical address of the APIC registers page - * make sure you map it to virtual memory ;) - */ -static uintptr_t cpu_get_apic_base(void) -{ - uint32_t eax, edx; - cpu_get_msr(IA32_APIC_BASE_MSR, &eax, &edx); - -#ifdef __PHYSICAL_MEMORY_EXTENSION__ - return (eax & 0xfffff000) | ((edx & 0x0f) << 32); -#else - return (eax & 0xfffff000); -#endif -} - -static uint32_t read_apic_register(uint32_t reg) -{ - return *((volatile uint32_t *)(cpu_get_apic_base()) + reg); -} - -static void write_apic_register(uint32_t reg, uint32_t value) -{ - *((volatile uint32_t *)(cpu_get_apic_base() + reg)) = value; -} - -void enable_apic(void) -{ - /* Hardware enable the Local APIC if it wasn't enabled */ - cpu_set_apic_base(cpu_get_apic_base()); - - /* Set the Spurious Interrupt Vector Register bit 8 to start receiving - * interrupts */ - write_apic_register(0xF0, read_apic_register(0xF0) | 0x100); -} diff --git a/src/interrupt/pic.c b/src/interrupt/pic.c index b5bce4f..3bc5da1 100644 --- a/src/interrupt/pic.c +++ b/src/interrupt/pic.c @@ -56,12 +56,6 @@ void pic_remap(int offset_master, int offset_slave) outb(PIC2_DATA, a2); } -void pic_disable(void) -{ - outb(PIC1_DATA, 0xff); - outb(PIC2_DATA, 0xff); -} - void pic_send_eoi(uint8_t irq) { if (irq >= 8)