Skip to content

Commit

Permalink
allocator: import QuickFit allocator from Hypatia
Browse files Browse the repository at this point in the history
This imports the QuickFit allocator from Hypatia, setting
us up to have a rudimentary kernel heap.

Signed-off-by: Dan Cross <[email protected]>
  • Loading branch information
Dan Cross authored and orangecms committed Sep 27, 2024
1 parent d6a0ade commit 4a62db4
Show file tree
Hide file tree
Showing 12 changed files with 549 additions and 57 deletions.
1 change: 0 additions & 1 deletion aarch64/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![cfg_attr(not(any(test)), no_std)]
#![cfg_attr(not(test), no_main)]
#![feature(alloc_error_handler)]
#![feature(asm_const)]
#![feature(core_intrinsics)]
#![feature(strict_provenance)]
#![forbid(unsafe_op_in_unsafe_fn)]
Expand Down
16 changes: 1 addition & 15 deletions aarch64/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate alloc;
use crate::kmem::physaddr_as_virt;
use crate::registers::rpi_mmio;
use crate::uartmini::MiniUart;
use alloc::alloc::{GlobalAlloc, Layout};
use alloc::alloc::Layout;
use core::fmt::Write;
use core::panic::PanicInfo;
use port::devcons::PanicConsole;
Expand Down Expand Up @@ -39,17 +39,3 @@ pub fn panic(info: &PanicInfo) -> ! {
fn oom(_layout: Layout) -> ! {
panic!("oom");
}

struct FakeAlloc;

unsafe impl GlobalAlloc for FakeAlloc {
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
panic!("fake alloc");
}
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {
panic!("fake dealloc");
}
}

#[global_allocator]
static FAKE_ALLOCATOR: FakeAlloc = FakeAlloc {};
4 changes: 2 additions & 2 deletions lib/aarch64-unknown-none-elf.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"arch": "aarch64",
"data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
"data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32",
"disable-redzone": true,
"executables": true,
"features": "+strict-align,+neon,+fp-armv8",
Expand All @@ -16,4 +16,4 @@
"-nostdlib"
]
}
}
}
Loading

0 comments on commit 4a62db4

Please sign in to comment.