forked from LowLevelDevs/FoundryOS
89 lines
3.2 KiB
Rust
89 lines
3.2 KiB
Rust
#![no_std]
|
|
#![no_main]
|
|
|
|
use core::arch::asm;
|
|
|
|
use lib_serial::{serial_println, serial_read};
|
|
use lib_ascii::{print, println, WRITER};
|
|
|
|
use limine::request::{RequestsEndMarker, RequestsStartMarker};
|
|
use limine::BaseRevision;
|
|
|
|
use lib_framebuffer;
|
|
|
|
/// Sets the base revision to the latest revision supported by the crate.
|
|
/// See specification for further info.
|
|
/// Be sure to mark all limine requests with #[used], otherwise they may be removed by the compiler.
|
|
#[used]
|
|
// The .requests section allows limine to find the requests faster and more safely.
|
|
#[link_section = ".requests"]
|
|
static BASE_REVISION: BaseRevision = BaseRevision::new();
|
|
|
|
/// Define the stand and end markers for Limine requests.
|
|
#[used]
|
|
#[link_section = ".requests_start_marker"]
|
|
static _START_MARKER: RequestsStartMarker = RequestsStartMarker::new();
|
|
#[used]
|
|
#[link_section = ".requests_end_marker"]
|
|
static _END_MARKER: RequestsEndMarker = RequestsEndMarker::new();
|
|
|
|
#[no_mangle]
|
|
unsafe extern "C" fn kmain() -> ! {
|
|
// All limine requests must also be referenced in a called function, otherwise they may be
|
|
// removed by the linker.
|
|
assert!(BASE_REVISION.is_supported());
|
|
|
|
|
|
if let Err(_) = lib_serial::init() {
|
|
loop {}
|
|
}
|
|
|
|
let dimensions = lib_ascii::screensize_chars();
|
|
let dimensions2 = lib_framebuffer::screensize_px();
|
|
println!("Hello World!");
|
|
println!("Dimensions: {}x{} (px)", dimensions2.0, dimensions2.1);
|
|
println!("Dimensions: {}x{} (chars)", dimensions.0, dimensions.1);
|
|
|
|
println!("
|
|
$$$$$$$$\\ $$\\
|
|
$$ _____| $$ |
|
|
$$ | $$$$$$\\ $$\\ $$\\ $$$$$$$\\ $$$$$$$ | $$$$$$\\ $$\\ $$\\
|
|
$$$$$\\ $$ __$$\\ $$ | $$ |$$ __$$\\ $$ __$$ |$$ __$$\\ $$ | $$ |
|
|
$$ __|$$ / $$ |$$ | $$ |$$ | $$ |$$ / $$ |$$ | \\__|$$ | $$ |
|
|
$$ | $$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ | $$ |
|
|
$$ | \\$$$$$$ |\\$$$$$$ |$$ | $$ |\\$$$$$$$ |$$ | \\$$$$$$$ |
|
|
\\__| \\______/ \\______/ \\__| \\__| \\_______|\\__| \\____$$ |
|
|
$$$$$$\\ $$$$$$\\ $$\\ $$\\ $$\\ $$\\ $$ |
|
|
$$ __$$\\ $$ __$$\\ $$ | $$ |$$$$ | \\$$$$$$ |
|
|
$$ / $$ |$$ / \\__| $$ | $$ |\\_$$ | \\______/
|
|
$$ | $$ |\\$$$$$$\\ \\$$\\ $$ | $$ |
|
|
$$ | $$ | \\____$$\\ \\$$\\$$ / $$ |
|
|
$$ | $$ |$$\\ $$ | \\$$$ / $$ |
|
|
$$$$$$ |\\$$$$$$ | \\$ / $$$$$$\\
|
|
\\______/ \\______/ \\_/ \\______|
|
|
");
|
|
|
|
for i in 0u8..128 {
|
|
print!("{}", i as char);
|
|
}
|
|
|
|
hcf();
|
|
}
|
|
|
|
#[panic_handler]
|
|
fn rust_panic(_info: &core::panic::PanicInfo) -> ! {
|
|
hcf();
|
|
}
|
|
|
|
fn hcf() -> ! {
|
|
loop {
|
|
unsafe {
|
|
#[cfg(target_arch = "x86_64")]
|
|
asm!("hlt");
|
|
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
|
|
asm!("wfi");
|
|
#[cfg(target_arch = "loongarch64")]
|
|
asm!("idle 0");
|
|
}
|
|
}
|
|
} |