Next Generation WASM Microkernel Operating System
1// Copyright 2025 Jonas Kruckenberg
2//
3// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5// http://opensource.org/licenses/MIT>, at your option. This file may not be
6// copied, modified, or distributed except according to those terms.
7
8//! Architecture-specific code
9//!
10//! This module contains different submodules for each supported architecture (RISC-V, AArch64, x86_64).
11//! and reexports them based on the compilation target. Each submodule has to adhere to roughly the
12//! same interface:
13//! - `call_with_setjmp`, `setjmp`, `longjmp`, `JumpBuf`, `JumpBufStruct` for setjmp/longjmp functionality
14//! - `init`, `per_cpu_init_early`, `per_cpu_init_late` for initialization
15//! - `cpu_park`, `cpu_park_timeout` for parking a CPU
16//! - `with_user_memory_access` for temporarily enabling kernel access to userspace memory
17//! - `mb`, `rmb`, `wmb` for memory barriers
18//! - `set_thread_ptr`, `get_stack_pointer`, `get_next_older_pc_from_fp`, `assert_fp_is_aligned` for
19//! WASM stack support
20//! - `device::cpu::init`, `device::cpu::with_cpu_info` for CPU initialization
21//! - `invalidate_range`, `is_kernel_address`, `AddressSpace`, `KERNEL_ASPACE_BASE`,
22//! `USER_ASPACE_BASE`, `PAGE_SHIFT`, `CANONICAL_ADDRESS_MASK`, `PAGE_SIZE`, `DEFAULT_ASID` to
23//! support the virtual memory subsystem
24
25cfg_if::cfg_if! {
26 if #[cfg(target_arch = "riscv64")] {
27 mod riscv64;
28 pub use riscv64::*;
29 pub use riscv::*;
30 } else if #[cfg(target_arch = "aarch64")] {
31 mod aarch64;
32 pub use aarch64::*;
33 } else if #[cfg(target_arch = "x86_64")] {
34 mod x86_64;
35 pub use x86_64::*;
36 } else {
37 compile_error!("Unsupported target architecture");
38 }
39}