Use linked_list_allocator crate instead of dummy allocator

This commit is contained in:
Philipp Oppermann
2019-06-26 15:05:57 +02:00
parent 06fc63028a
commit d7484ab48b
4 changed files with 17 additions and 1 deletions

10
Cargo.lock generated
View File

@@ -24,6 +24,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"bootloader 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "bootloader 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"linked_list_allocator 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"pc-keyboard 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "pc-keyboard 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pic8259_simple 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "pic8259_simple 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -99,6 +100,14 @@ name = "libc"
version = "0.2.51" version = "0.2.51"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "linked_list_allocator"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "llvm-tools" name = "llvm-tools"
version = "0.1.1" version = "0.1.1"
@@ -349,6 +358,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797" "checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797"
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917" "checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
"checksum linked_list_allocator 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "47314ec1d29aa869ee7cb5a5be57be9b1055c56567d59c3fb6689926743e0bea"
"checksum llvm-tools 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "955be5d0ca0465caf127165acb47964f911e2bc26073e865deb8be7189302faf" "checksum llvm-tools 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "955be5d0ca0465caf127165acb47964f911e2bc26073e865deb8be7189302faf"
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
"checksum os_bootinfo 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "66481dbeb5e773e7bd85b63cd6042c30786f834338288c5ec4f3742673db360a" "checksum os_bootinfo 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "66481dbeb5e773e7bd85b63cd6042c30786f834338288c5ec4f3742673db360a"

View File

@@ -20,6 +20,7 @@ x86_64 = "0.7.0"
uart_16550 = "0.2.0" uart_16550 = "0.2.0"
pic8259_simple = "0.1.1" pic8259_simple = "0.1.1"
pc-keyboard = "0.3.1" pc-keyboard = "0.3.1"
linked_list_allocator = "0.6.4"
[dependencies.lazy_static] [dependencies.lazy_static]
version = "1.0" version = "1.0"

View File

@@ -30,6 +30,10 @@ pub fn init_heap(
unsafe { mapper.map_to(page, frame, flags, frame_allocator)?.flush() }; unsafe { mapper.map_to(page, frame, flags, frame_allocator)?.flush() };
} }
unsafe {
super::ALLOCATOR.lock().init(HEAP_START, HEAP_SIZE);
}
Ok(()) Ok(())
} }

View File

@@ -9,6 +9,7 @@
extern crate alloc; extern crate alloc;
use core::panic::PanicInfo; use core::panic::PanicInfo;
use linked_list_allocator::LockedHeap;
pub mod allocator; pub mod allocator;
pub mod gdt; pub mod gdt;
@@ -18,7 +19,7 @@ pub mod serial;
pub mod vga_buffer; pub mod vga_buffer;
#[global_allocator] #[global_allocator]
static ALLOCATOR: allocator::Dummy = allocator::Dummy; static ALLOCATOR: LockedHeap = LockedHeap::empty();
pub fn init() { pub fn init() {
gdt::init(); gdt::init();