We're currently working on a monolithic operating system (x86) in Rust. Our cargo workspace looks roughly like this:
Code: Select all
|--src (contains all kernel related code, omitted here)
| |--main.rs
| |--...
|
|--user
| |--arch
| | |--link.ld
| |--bin
| |--app1.rs
| |--app2.rs
|
|--Cargo.toml
|--build.rs
Code: Select all
objcopy -O binary --set-section-flags .bss=alloc,load,contents <app> <flat binary>
Now we want to use different heap allocators for the userspace applications and the kernel. We created a heap allocator for our kernel within our kernelspace (<32MiB):
Code: Select all
#[global_allocator]
static ALLOCATOR: LockedHeap = LockedHeap::empty();
// Later initialised in main
Code: Select all
#![no_std]
#![no_main]
extern crate alloc;
use os::syscall;
#[global_allocator]
static ALLOCATOR: LockedHeap = LockedHeap::empty();
#[no_mangle]
pub extern "C" fn start() -> ! {
let mem_size = 3 * Page::SIZE;
let mem = syscall::mmap(mem_size);
unsafe {
ALLOCATOR.lock().init(mem, mem_size);
}
let v = vec![1, 2, 3];
syscall::serial!("{:?}", v);
syscall::exit();
}
So how do we need to change our setup/code to enable the user space applications to use a different heap so they can make use of the alloc crate?
We've tried compiling the user applications in a completely different workspace, under the assumption that the combined workspace was the root of this problem, but this didn't help.
We've also explored the option of using the new 'https://github.com/rust-lang/wg-allocators/issues/7' feature, but this isn't really an option since its still a WIP and even if you only use 'new_in(...)' and friends you still need to at least declare a global_allocator.
Help would be greatly appreciated :).