mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Set up allocations
This commit is contained in:
@@ -10,4 +10,4 @@ edition = "2018"
|
|||||||
members = ["disk_image"]
|
members = ["disk_image"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
uefi = "0.8.0"
|
uefi = { version = "0.8.0", features = ["alloc"] }
|
||||||
|
|||||||
25
src/main.rs
25
src/main.rs
@@ -1,8 +1,12 @@
|
|||||||
#![feature(abi_efiapi)]
|
#![feature(abi_efiapi)]
|
||||||
|
#![feature(alloc_error_handler)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
extern crate alloc;
|
||||||
|
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
use core::{alloc::Layout, fmt::Write, panic::PanicInfo};
|
||||||
use uefi::prelude::entry;
|
use uefi::prelude::entry;
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
@@ -10,6 +14,20 @@ fn efi_main(
|
|||||||
image: uefi::Handle,
|
image: uefi::Handle,
|
||||||
system_table: uefi::table::SystemTable<uefi::table::Boot>,
|
system_table: uefi::table::SystemTable<uefi::table::Boot>,
|
||||||
) -> uefi::Status {
|
) -> uefi::Status {
|
||||||
|
let stdout = system_table.stdout();
|
||||||
|
stdout.clear().unwrap().unwrap();
|
||||||
|
writeln!(stdout, "Hello World!").unwrap();
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
uefi::alloc::init(system_table.boot_services());
|
||||||
|
}
|
||||||
|
|
||||||
|
writeln!(stdout, "alloc").unwrap();
|
||||||
|
let mut v: Vec<u32> = Vec::new();
|
||||||
|
v.push(1);
|
||||||
|
v.push(2);
|
||||||
|
writeln!(stdout, "v = {:?}", v).unwrap();
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,3 +35,8 @@ fn efi_main(
|
|||||||
fn panic(_info: &PanicInfo) -> ! {
|
fn panic(_info: &PanicInfo) -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[alloc_error_handler]
|
||||||
|
fn alloc_error(_layout: Layout) -> ! {
|
||||||
|
panic!("out of memory")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user