Commit d1b75db3 authored by Stefan Lankes's avatar Stefan Lankes
Browse files

add feature to support a C-based runtime

parent 003d0490
......@@ -5,7 +5,7 @@ set(HERMIT_RS "${CMAKE_BINARY_DIR}/hermit_rs/${HERMIT_ARCH}-unknown-hermit-kerne
add_custom_target(hermit_rs
COMMAND
${CMAKE_COMMAND} -E env CARGO_TARGET_DIR=${CMAKE_BINARY_DIR}/hermit_rs RUST_TARGET_PATH=${HERMIT_ROOT}/librs
cargo xbuild ${CARGO_BUILDTYPE_PARAMETER} --target ${HERMIT_ARCH}-unknown-hermit-kernel
cargo xbuild ${CARGO_BUILDTYPE_PARAMETER} --target ${HERMIT_ARCH}-unknown-hermit-kernel --features newlib
WORKING_DIRECTORY
${CMAKE_CURRENT_LIST_DIR})
......
......@@ -22,10 +22,12 @@ crate-type = ["staticlib"]
#default = ["network"]
vga = []
network = ["smoltcp"]
newlib = []
[dependencies]
bitflags = "1.0.*"
spin = "0.5"
#cfg-if = "0.1"
#byteorder = { version = "1.0", default-features = false }
[dependencies.log]
......
......@@ -7,7 +7,6 @@
use arch::x86_64::mm::paging::{BasePageSize, PageSize};
use collections::Node;
use environment;
use mm;
use mm::freelist::{FreeList, FreeListEntry};
use synch::spinlock::*;
......@@ -124,17 +123,20 @@ pub fn print_information() {
/// End of the virtual memory address space reserved for kernel memory.
/// This also marks the start of the virtual memory address space reserved for the task heap.
/// In case of pure rust applications, we don't have a task heap.
#[cfg(not(feature = "newlib"))]
#[inline]
pub fn kernel_heap_end() -> usize {
if !environment::is_pure_rust() {
0x1_0000_0000
} else {
0x8000_0000_0000
}
pub const fn kernel_heap_end() -> usize {
0x8000_0000_0000
}
#[cfg(feature = "newlib")]
#[inline]
pub const fn kernel_heap_end() -> usize {
0x1_0000_0000
}
#[inline]
pub fn task_heap_start() -> usize {
pub const fn task_heap_start() -> usize {
kernel_heap_end()
}
......
......@@ -99,10 +99,14 @@ pub fn init() {
}
}
let (mut map_addr, mut map_size) = if !environment::is_pure_rust() {
let mut map_addr: usize;
let mut map_size: usize;
#[cfg(feature = "newlib")]
{
info!("An application with a C-based runtime is running on top of HermitCore!");
let size: usize = 2 * LargePageSize::SIZE;
let size = 2 * LargePageSize::SIZE;
unsafe {
let addr = allocate(size, true);
::ALLOCATOR.lock().init(addr, size);
......@@ -115,8 +119,12 @@ pub fn init() {
);
info!("User-space heap size: {} MB", user_heap_size >> 20);
(arch::mm::virtualmem::task_heap_start(), user_heap_size)
} else {
map_addr = arch::mm::virtualmem::task_heap_start();
map_size = user_heap_size;
}
#[cfg(not(feature = "newlib"))]
{
info!("A pure Rust application is running on top of HermitCore!");
// At first, we map only a small part into the heap.
......@@ -156,8 +164,9 @@ pub fn init() {
::ALLOCATOR.lock().init(virt_addr, virt_size);
}
(virt_addr + counter, virt_size - counter)
};
map_addr = virt_addr + counter;
map_size = virt_size - counter;
}
if has_1gib_pages
&& map_size > HugePageSize::SIZE
......
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