Skip to main content

strat9_kernel/hal/x86_64/
mod.rs

1//! x86_64 Hardware Abstraction Layer implementation.
2
3use super::Hal;
4
5/// x86_64 HAL implementation
6pub struct X86_64Hal;
7
8impl Hal for X86_64Hal {
9    fn init() {
10        crate::serial_println!("[hal] x86_64 HAL initialized");
11    }
12
13    fn setup_paging() {
14        // x86_64 paging is handled by the memory subsystem
15        crate::serial_println!("[hal] x86_64 paging setup delegated to memory subsystem");
16    }
17
18    fn init_interrupt_controller() {
19        // x86_64 uses APIC/IOAPIC
20        crate::serial_println!("[hal] x86_64 interrupt controller (APIC) init delegated");
21    }
22
23    fn enable_interrupts() {
24        unsafe {
25            core::arch::asm!("sti");
26        }
27    }
28
29    fn disable_interrupts() {
30        unsafe {
31            core::arch::asm!("cli");
32        }
33    }
34
35    fn halt() {
36        unsafe {
37            core::arch::asm!("hlt");
38        }
39    }
40
41    fn current_cpu_id() -> u32 {
42        // For now, return 0 (BSP)
43        // TODO: Use CPUID or APIC ID for SMP
44        0
45    }
46
47    fn kernel_text_start() -> u64 {
48        // This would be filled by the linker script symbol
49        0xFFFFFFFF80000000
50    }
51
52    fn kernel_text_end() -> u64 {
53        // This would be filled by the linker script symbol
54        0xFFFFFFFF80000000
55    }
56}