axhal/
lib.rs

1//! [ArceOS] hardware abstraction layer, provides unified APIs for
2//! platform-specific operations.
3//!
4//! It does the bootstrapping and initialization process for the specified
5//! platform, and provides useful operations on the hardware.
6//!
7//! Currently supported platforms (specify by cargo features):
8//!
9//! - `x86-pc`: Standard PC with x86_64 ISA.
10//! - `riscv64-qemu-virt`: QEMU virt machine with RISC-V ISA.
11//! - `aarch64-qemu-virt`: QEMU virt machine with AArch64 ISA.
12//! - `aarch64-raspi`: Raspberry Pi with AArch64 ISA.
13//! - `dummy`: If none of the above platform is selected, the dummy platform
14//!   will be used. In this platform, most of the operations are no-op or
15//!   `unimplemented!()`. This platform is mainly used for [cargo test].
16//!
17//! # Cargo Features
18//!
19//! - `smp`: Enable SMP (symmetric multiprocessing) support.
20//! - `fp-simd`: Enable floating-point and SIMD support.
21//! - `paging`: Enable page table manipulation.
22//! - `irq`: Enable interrupt handling support.
23//! - `tls`: Enable kernel space thread-local storage support.
24//! - `rtc`: Enable real-time clock support.
25//! - `uspace`: Enable user space support.
26//!
27//! [ArceOS]: https://github.com/arceos-org/arceos
28//! [cargo test]: https://doc.rust-lang.org/cargo/guide/tests.html
29
30#![no_std]
31#![feature(doc_auto_cfg)]
32#![feature(sync_unsafe_cell)]
33
34#[allow(unused_imports)]
35#[macro_use]
36extern crate log;
37
38#[allow(unused_imports)]
39#[macro_use]
40extern crate memory_addr;
41
42mod platform;
43
44pub mod cpu;
45pub mod mem;
46pub mod time;
47
48#[cfg(feature = "tls")]
49pub mod tls;
50
51#[cfg(feature = "irq")]
52pub mod irq;
53
54#[cfg(feature = "paging")]
55pub mod paging;
56
57/// Console input and output.
58pub mod console {
59    pub use super::platform::console::*;
60}
61
62/// Miscellaneous operation, e.g. terminate the system.
63pub mod misc {
64    pub use super::platform::misc::*;
65}
66
67/// Multi-core operations.
68#[cfg(feature = "smp")]
69pub mod mp {
70    pub use super::platform::mp::*;
71}
72
73/// CPU register states for context switching.
74///
75/// There are three types of context:
76///
77/// - [`TaskContext`][axcpu::TaskContext]: The context of a task.
78/// - [`TrapFrame`][axcpu::TrapFrame]: The context of an interrupt or an exception.
79/// - [`UspaceContext`][axcpu::uspace::UspaceContext]: The context for user/kernel mode switching.
80pub mod context {
81    #[cfg(feature = "uspace")]
82    pub use axcpu::uspace::UspaceContext;
83    pub use axcpu::{TaskContext, TrapFrame};
84}
85
86pub use self::platform::platform_init;
87pub use axcpu::{asm, trap};
88
89#[cfg(feature = "smp")]
90pub use self::platform::platform_init_secondary;