ax-cpu 0.5.3

Privileged instruction and structure abstractions for various CPU architectures
Documentation
//! Helper functions to initialize the CPU states on systems bootstrapping.

/// Initializes the per-CPU data structures.
///
/// It calls the initialization function of the [`ax-percpu`] crate. It (or other
/// alternative initialization) should be called before [`init_trap`].
///
/// [`ax-percpu`]: https://docs.rs/ax-percpu/latest/ax_percpu/index.html
pub fn init_percpu(cpu_id: usize) {
    ax_percpu::init();
    ax_percpu::init_percpu_reg(cpu_id);
}

/// Initializes trap handling on the current CPU.
///
/// In detail, it initializes the GDT, IDT on x86_64 platforms. If the `uspace`
/// feature is enabled, it also initializes relevant model-specific registers to
/// configure the handler for `syscall` instruction.
///
/// # Notes
/// Before calling this function, the initialization function of the [`ax-percpu`]
/// crate should have been invoked to ensure that the per-CPU data structures
/// are set up correctly (i.e., by calling [`init_percpu`]).
///
/// [`ax-percpu`]: https://docs.rs/ax-percpu/latest/ax_percpu/index.html
pub fn init_trap() {
    #[cfg(feature = "uspace")]
    crate::uspace_common::init_exception_table();
    super::gdt::init();
    super::idt::init();
    #[cfg(feature = "uspace")]
    super::uspace::init_syscall();
}