Add alloc

This commit is contained in:
Mathieu Strypsteen 2024-06-29 21:10:38 +02:00
parent 856ea613eb
commit 026b2df25a
3 changed files with 25 additions and 2 deletions

16
loader/Cargo.lock generated
View file

@ -2,6 +2,12 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "alloc-traits"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b2d54853319fd101b8dd81de382bcbf3e03410a64d8928bbee85a3e7dcde483"
[[package]]
name = "bit_field"
version = "0.10.2"
@ -48,6 +54,7 @@ dependencies = [
"com_logger",
"elf",
"log",
"static-alloc",
"uefi",
"x86_64",
]
@ -111,6 +118,15 @@ version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6"
[[package]]
name = "static-alloc"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b2975e035ce16539eecee08d7c6e5626ca26f299c6e90af343b302c6dd2e61e"
dependencies = [
"alloc-traits",
]
[[package]]
name = "syn"
version = "1.0.109"

View file

@ -7,5 +7,6 @@ edition = "2021"
com_logger = { git = "https://git.strypsteen.com/mathieu/com_logger", version = "0.1.1" }
elf = {version = "0.7.4", default-features = false}
log = "0.4.22"
static-alloc = "0.2.5"
uefi = {version = "0.28.0"}
x86_64 = {version = "0.15.1", default-features = false}
x86_64 = {version = "0.15.1", default-features = false, features = ["instructions"]}

View file

@ -1,10 +1,13 @@
#![no_main]
#![no_std]
extern crate alloc;
use core::panic::PanicInfo;
use elf::load_kernel;
use log::{error, info};
use static_alloc::Bump;
use uefi::{
entry,
table::{boot::MemoryType, Boot, SystemTable},
@ -13,13 +16,16 @@ use uefi::{
mod elf;
#[global_allocator]
static A: Bump<[u8; 8 * 1024 * 1024]> = Bump::uninit();
const KERNEL: &[u8] = include_bytes!("../../kernel/target/x86_64-unknown-none/release/kernel");
#[entry]
fn main(image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
com_logger::init();
uefi::helpers::init(&mut system_table).unwrap();
info!("Starting bootloader...");
uefi::helpers::init(&mut system_table).unwrap();
load_kernel(KERNEL, &system_table);
let _memory_map = system_table.exit_boot_services(MemoryType::LOADER_DATA).1;
loop {}