kernel wip
This commit is contained in:
31
nel_os_bootloader/Cargo.lock
generated
31
nel_os_bootloader/Cargo.lock
generated
@ -8,6 +8,12 @@ version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.9.1"
|
||||
@ -32,6 +38,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"log",
|
||||
"uefi",
|
||||
"x86",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -72,6 +79,15 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raw-cpuid"
|
||||
version = "10.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.104"
|
||||
@ -98,7 +114,7 @@ version = "0.35.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da7569ceafb898907ff764629bac90ac24ba4203c38c33ef79ee88c74aa35b11"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
"cfg-if",
|
||||
"log",
|
||||
"ptr_meta",
|
||||
@ -125,7 +141,7 @@ version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7cad96b8baaf1615d3fdd0f03d04a0b487d857c1b51b19dcbfe05e2e3c447b78"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
"uguid",
|
||||
]
|
||||
|
||||
@ -140,3 +156,14 @@ name = "unicode-ident"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||
|
||||
[[package]]
|
||||
name = "x86"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2781db97787217ad2a2845c396a5efe286f87467a5810836db6d74926e94a385"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"bitflags 1.3.2",
|
||||
"raw-cpuid",
|
||||
]
|
||||
|
@ -6,3 +6,4 @@ edition = "2024"
|
||||
[dependencies]
|
||||
log = "0.4.27"
|
||||
uefi = { version = "0.35.0", features = ["logger", "panic_handler", "alloc"] }
|
||||
x86 = "0.52.0"
|
||||
|
@ -1,3 +1,56 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use core::arch::asm;
|
||||
use core::panic::PanicInfo;
|
||||
use core::ptr::addr_of;
|
||||
|
||||
const STACK_SIZE: usize = 1024 * 1024;
|
||||
|
||||
#[repr(C, align(16))]
|
||||
struct AlignedStack {
|
||||
stack: [u8; STACK_SIZE],
|
||||
}
|
||||
|
||||
#[used]
|
||||
static mut KERNEL_STACK: AlignedStack = AlignedStack {
|
||||
stack: [0; STACK_SIZE],
|
||||
};
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "sysv64" fn asm_main() -> ! {
|
||||
unsafe {
|
||||
let stack_base = addr_of!(KERNEL_STACK.stack) as *const u8;
|
||||
let stack_top = stack_base.add(STACK_SIZE);
|
||||
|
||||
asm!(
|
||||
"mov rsp, {stack_top}",
|
||||
"call {main}",
|
||||
"2:",
|
||||
"hlt",
|
||||
"jmp 2b",
|
||||
stack_top = in(reg) stack_top,
|
||||
main = sym main,
|
||||
options(noreturn)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(_info: &PanicInfo) -> ! {
|
||||
hlt_loop();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn hlt_loop() -> ! {
|
||||
loop {
|
||||
unsafe {
|
||||
asm!("hlt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "sysv64" fn main() {
|
||||
hlt_loop();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"llvm-target": "x86_64-unknown-none",
|
||||
"llvm-target": "x86_64-unknown-none-elf",
|
||||
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
|
||||
"arch": "x86_64",
|
||||
"target-endian": "little",
|
||||
@ -7,10 +7,13 @@
|
||||
"target-c-int-width": "32",
|
||||
"os": "none",
|
||||
"executables": true,
|
||||
"exe-suffix": ".elf",
|
||||
"linker-flavor": "ld.lld",
|
||||
"linker": "rust-lld",
|
||||
"panic-strategy": "abort",
|
||||
"disable-redzone": true,
|
||||
"features": "-mmx,-sse,+soft-float",
|
||||
"rustc-abi": "x86-softfloat"
|
||||
"rustc-abi": "x86-softfloat",
|
||||
"code-model": "kernel",
|
||||
"max-atomic-width": 64
|
||||
}
|
||||
|
Reference in New Issue
Block a user