1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
/* Copyright (c) [2023] [Syswonder Community]
* [Rukos] is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
//! [ArceOS] hardware abstraction layer, provides unified APIs for
//! platform-specific operations.
//!
//! It does the bootstrapping and initialization process for the specified
//! platform, and provides useful operations on the hardware.
//!
//! Currently supported platforms (specify by cargo features):
//!
//! - `x86-pc`: Standard PC with x86_64 ISA.
//! - `riscv64-qemu-virt`: QEMU virt machine with RISC-V ISA.
//! - `aarch64-qemu-virt`: QEMU virt machine with AArch64 ISA.
//! - `aarch64-raspi`: Raspberry Pi with AArch64 ISA.
//! - `dummy`: If none of the above platform is selected, the dummy platform
//! will be used. In this platform, most of the operations are no-op or
//! `unimplemented!()`. This platform is mainly used for [cargo test].
//!
//! # Cargo Features
//!
//! - `smp`: Enable SMP (symmetric multiprocessing) support.
//! - `fp_simd`: Enable floating-point and SIMD support.
//! - `paging`: Enable page table manipulation.
//! - `irq`: Enable interrupt handling support.
//!
//! [ArceOS]: https://github.com/rcore-os/arceos
//! [cargo test]: https://doc.rust-lang.org/cargo/guide/tests.html
#![no_std]
#![feature(asm_const)]
#![feature(naked_functions)]
#![feature(const_maybe_uninit_zeroed)]
#![feature(const_option)]
#![feature(doc_auto_cfg)]
#[allow(unused_imports)]
#[macro_use]
extern crate log;
mod platform;
pub mod arch;
pub mod cpu;
pub mod mem;
pub mod time;
pub mod trap;
#[cfg(feature = "tls")]
pub mod tls;
#[cfg(feature = "irq")]
pub mod irq;
#[cfg(feature = "paging")]
pub mod paging;
/// Console input and output.
pub mod console {
pub use super::platform::console::*;
/// Write a slice of bytes to the console.
pub fn write_bytes(bytes: &[u8]) {
for c in bytes {
putchar(*c);
}
}
}
/// Miscellaneous operation, e.g. terminate the system.
pub mod misc {
pub use super::platform::misc::*;
}
/// Multi-core operations.
#[cfg(feature = "smp")]
pub mod mp {
pub use super::platform::mp::*;
}
pub use self::platform::platform_init;
#[cfg(feature = "smp")]
pub use self::platform::platform_init_secondary;
/// A cmdline buf for x86_64
///
/// The Multiboot information structure may be placed anywhere in memory by the boot loader,
/// so we should save cmdline in a buf before this memory is set free
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub static mut COMLINE_BUF: [u8; 256] = [0; 256];