strat9_kernel/hal/mod.rs
1//! Hardware Abstraction Layer (HAL) for multi-architecture support.
2//!
3//! This module defines the trait interface that each architecture must implement,
4//! and provides the architecture-specific implementations.
5
6pub mod x86_64;
7
8/// Hardware Abstraction Layer trait.
9///
10/// Each architecture must implement this trait to provide
11/// architecture-specific operations.
12pub trait Hal {
13 /// Initialize the HAL for the current architecture.
14 fn init();
15
16 /// Set up virtual memory paging.
17 fn setup_paging();
18
19 /// Initialize the interrupt controller.
20 fn init_interrupt_controller();
21
22 /// Enable interrupts.
23 fn enable_interrupts();
24
25 /// Disable interrupts.
26 fn disable_interrupts();
27
28 /// Halt the CPU until the next interrupt.
29 fn halt();
30
31 /// Get the current CPU ID (for SMP).
32 fn current_cpu_id() -> u32;
33
34 /// Get the physical address of the kernel text section start.
35 fn kernel_text_start() -> u64;
36
37 /// Get the physical address of the kernel text section end.
38 fn kernel_text_end() -> u64;
39}
40
41/// Initialize the HAL for the current architecture.
42///
43/// This function dispatches to the correct architecture-specific implementation.
44pub fn init_hal() {
45 #[cfg(target_arch = "x86_64")]
46 x86_64::X86_64Hal::init();
47
48 #[cfg(not(target_arch = "x86_64"))]
49 crate::serial_println!("[hal] No HAL implementation for this architecture");
50}