From fbc1c60164b77cb3f82cab9e2423b9ef4f8b86c8 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 11 Apr 2016 22:17:58 +0200 Subject: [PATCH] Ensure that memory::init is only called once --- Cargo.toml | 1 + src/lib.rs | 2 ++ src/memory/mod.rs | 2 ++ 3 files changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index e7f18f4f..7b7403e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ authors = ["Philipp Oppermann "] crate-type = ["staticlib"] [dependencies] +once = "0.2.1" rlibc = "0.1.4" spin = "0.3.4" bump_allocator = {path="libs/bump_allocator"} diff --git a/src/lib.rs b/src/lib.rs index f72da1c7..1a77ad80 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,6 +18,8 @@ extern crate multiboot2; #[macro_use] extern crate bitflags; extern crate x86; +#[macro_use] +extern crate once; extern crate bump_allocator; extern crate alloc; diff --git a/src/memory/mod.rs b/src/memory/mod.rs index f4905c03..d29928f1 100644 --- a/src/memory/mod.rs +++ b/src/memory/mod.rs @@ -18,6 +18,8 @@ mod paging; pub const PAGE_SIZE: usize = 4096; pub fn init(boot_info: &BootInformation) { + assert_has_not_been_called!("memory::init must be called only once"); + let memory_map_tag = boot_info.memory_map_tag().expect( "Memory map tag required"); let elf_sections_tag = boot_info.elf_sections_tag().expect(