Commit 39178965 authored by Colin Finck's avatar Colin Finck
Browse files

Make HermitCore use our own hermit_multiboot crate too instead of the...

Make HermitCore use our own hermit_multiboot crate too instead of the third-party multiboot. Also clean up other crates.
parent de806024
......@@ -6,15 +6,12 @@
path = usr/libomp
url = https://github.com/RWTH-OS/libomp_oss.git
branch = hermit
[submodule "librs/rust"]
path = librs/rust
url = https://github.com/RWTH-OS/rust.git
[submodule "librs/crates/x86"]
path = librs/crates/x86
[submodule "crates/x86"]
path = crates/x86
url = https://github.com/RWTH-OS/rust-x86.git
branch = all-merged
[submodule "librs/crates/raw_cpuid"]
path = librs/crates/raw_cpuid
[submodule "crates/raw_cpuid"]
path = crates/raw_cpuid
url = https://github.com/ColinFinck/rust-cpuid.git
branch = extended-brand-string-fix
[submodule "crates/rlibc"]
......
......@@ -11,18 +11,20 @@ crate-type = ["staticlib"]
[dependencies]
bitflags = "1.0.1"
multiboot = "0.3.0"
spin = "0.4.6"
[dependencies.hermit-multiboot]
path = "../crates/hermit-multiboot"
[dependencies.lazy_static]
version = "0.2.9"
features = ["spin_no_std"]
[dependencies.raw-cpuid]
path = "crates/raw_cpuid"
path = "../crates/raw_cpuid"
[dependencies.x86]
path = "crates/x86"
path = "../crates/x86"
default-features = false
# The development profile, used for `cargo build`.
......
Subproject commit 230a379a452e5a2bcdfd0a956b259e0a1d83b512
......@@ -27,7 +27,8 @@ use arch::x86_64::mm::physicalmem;
use arch::x86_64::processor;
use core::fmt;
use core::marker::PhantomData;
use multiboot;
use hermit_multiboot::Multiboot;
use mm;
use x86::shared::control_regs;
......@@ -37,7 +38,7 @@ extern "C" {
static cmdline: *const u8;
static cmdsize: usize;
static mb_info: multiboot::PAddr;
static mb_info: usize;
}
......@@ -606,12 +607,22 @@ pub fn init() {
if mb_info > 0 {
let page = Page::<BasePageSize>::including_address(mb_info as usize);
assert!(page.address() < mm::kernel_start_address(), "Multiboot information is not below Kernel start address!");
root_pagetable.map_page(page, page.address(), PageTableEntryFlags::EXECUTE_DISABLE);
// Map the "Memory Map" information too.
let mb = Multiboot::new(mb_info);
let page = Page::<BasePageSize>::including_address(
mb.memory_map_address().expect("Could not find a memory map in the Multiboot information")
);
assert!(page.address() < mm::kernel_start_address(), "Multiboot Memory Map is not below Kernel start address!");
root_pagetable.map_page(page, page.address(), PageTableEntryFlags::EXECUTE_DISABLE);
}
if cmdsize > 0 {
let first_page = Page::<BasePageSize>::including_address(cmdline as usize);
let last_page = Page::<BasePageSize>::including_address(cmdline as usize + cmdsize - 1);
assert!(last_page.address() < mm::kernel_start_address(), "Command line is not below Kernel start address!");
let range = Page::<BasePageSize>::range(first_page, last_page);
root_pagetable.map_pages(range, first_page.address(), PageTableEntryFlags::EXECUTE_DISABLE, false);
}
......
......@@ -23,49 +23,42 @@
use arch::x86_64::mm::paging::{BasePageSize, PageSize};
use collections::Node;
use core::{mem, slice};
use hermit_multiboot::Multiboot;
use mm;
use mm::freelist::{FreeList, FreeListEntry};
use multiboot;
extern "C" {
static limit: usize;
static mb_info: multiboot::PAddr;
static mb_info: usize;
}
static mut PHYSICAL_FREE_LIST: FreeList = FreeList::new();
fn paddr_to_slice<'a>(p: multiboot::PAddr, sz: usize) -> Option<&'a [u8]> {
unsafe {
let ptr = mem::transmute(p);
Some(slice::from_raw_parts(ptr, sz))
}
}
fn detect_from_multiboot_info() -> Result<(), ()> {
if unsafe { mb_info } == 0 {
return Err(());
}
let mb = unsafe { multiboot::Multiboot::new(mb_info, paddr_to_slice).unwrap() };
let all_regions = mb.memory_regions().expect("No memory regions supplied by multiboot information!");
let mb = unsafe { Multiboot::new(mb_info) };
let all_regions = mb.memory_map().expect("Could not find a memory map in the Multiboot information");
let ram_regions = all_regions.filter(|m|
m.memory_type() == multiboot::MemoryType::Available &&
m.base_address() + m.length() > mm::kernel_end_address() as u64
m.is_available() &&
m.base_address() + m.length() > mm::kernel_end_address()
);
for m in ram_regions {
let start_address = if m.base_address() <= mm::kernel_start_address() as u64 {
let start_address = if m.base_address() <= mm::kernel_start_address() {
mm::kernel_end_address()
} else {
m.base_address() as usize
m.base_address()
};
let entry = Node::new(
FreeListEntry {
start: start_address,
end: (m.base_address() + m.length()) as usize
end: m.base_address() + m.length()
}
);
unsafe { PHYSICAL_FREE_LIST.list.push(entry); }
......
......@@ -52,10 +52,11 @@ extern crate alloc;
#[macro_use]
extern crate bitflags;
extern crate hermit_multiboot;
#[macro_use]
extern crate lazy_static;
extern crate multiboot;
extern crate raw_cpuid;
extern crate spin;
extern crate x86;
......
......@@ -17,7 +17,7 @@ path = "../crates/rlibc" # Low-level functions like memcpy.
features = ["nightly"]
[dependencies.x86]
path = "../librs/crates/x86"
path = "../crates/x86"
default-features = false
# The release profile, used for `cargo build --release`.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment