totally didn't import an allocator...

This commit is contained in:
2025-02-22 21:02:29 +00:00
parent 36cb118933
commit 361c67764d
4 changed files with 36 additions and 4 deletions
Generated
+22
View File
@@ -57,6 +57,10 @@ dependencies = [
[[package]] [[package]]
name = "lib_alloc" name = "lib_alloc"
version = "0.1.0" version = "0.1.0"
dependencies = [
"linked_list_allocator",
"x86_64",
]
[[package]] [[package]]
name = "lib_application" name = "lib_application"
@@ -101,6 +105,15 @@ dependencies = [
"bitflags", "bitflags",
] ]
[[package]]
name = "linked_list_allocator"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286"
dependencies = [
"spinning_top",
]
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.12" version = "0.4.12"
@@ -153,6 +166,15 @@ dependencies = [
"lock_api", "lock_api",
] ]
[[package]]
name = "spinning_top"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0"
dependencies = [
"lock_api",
]
[[package]] [[package]]
name = "volatile" name = "volatile"
version = "0.4.6" version = "0.4.6"
-3
View File
@@ -9,9 +9,6 @@ use x86_64::{
PhysAddr, VirtAddr, PhysAddr, VirtAddr,
}; };
#[global_allocator]
static ALLOCATOR: FoundryAllocator = FoundryAllocator;
/// Returns a mutable reference to the current level 4 page table. /// Returns a mutable reference to the current level 4 page table.
/// ///
/// # Safety /// # Safety
+4 -1
View File
@@ -4,6 +4,7 @@
extern crate alloc; extern crate alloc;
use core::arch::asm; use core::arch::asm;
use lib_alloc::allocator::init_heap;
use limine::request::{RequestsEndMarker, RequestsStartMarker}; use limine::request::{RequestsEndMarker, RequestsStartMarker};
use limine::BaseRevision; use limine::BaseRevision;
@@ -67,7 +68,9 @@ pub fn boot() -> Result<(), &'static str> {
x86_64::instructions::interrupts::enable(); x86_64::instructions::interrupts::enable();
let physical_memory_offset = VirtAddr::new(*memmap::PHYSICAL_MEMORY_OFFSET); let physical_memory_offset = VirtAddr::new(*memmap::PHYSICAL_MEMORY_OFFSET);
let l4_table = unsafe { memory::init(physical_memory_offset) }; let mut l4_table = unsafe { memory::init(physical_memory_offset) };
init_heap(&mut l4_table, &mut frame_allocator);
Ok(()) Ok(())
} }
+10
View File
@@ -1,6 +1,10 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
extern crate alloc;
use alloc::vec::Vec;
use foundry_os::{println, println_log}; use foundry_os::{println, println_log};
#[no_mangle] #[no_mangle]
@@ -40,5 +44,11 @@ unsafe extern "C" fn kmain() -> ! {
" "
); );
let mut vec = Vec::new();
for i in 0..100 {
vec.push(i);
}
println!("{:?}", vec);
loop {} loop {}
} }