Skip to content
Snippets Groups Projects
Verified Commit 0c6398ab authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Do not require allocation in static_init

parent ebb17654
No related branches found
No related tags found
No related merge requests found
use core::{mem, ptr};
use goblin::elf::program_header::{self, program_header32, program_header64, ProgramHeader};
use self::tcb::{Master, Tcb};
......@@ -11,6 +12,13 @@ mod library;
pub mod linker;
pub mod start;
pub mod tcb;
static mut STATIC_TCB_MASTER: Master = Master {
ptr: ptr::null_mut(),
len: 0,
offset: 0,
};
pub fn static_init(sp: &'static Stack) {
let mut phdr_opt = None;
let mut phent_opt = None;
......@@ -61,15 +69,14 @@ pub fn static_init(sp: &'static Stack) {
ph.p_memsz
} as usize;
let tcb_master = Master {
ptr: ph.p_vaddr as usize as *const u8,
len: ph.p_filesz as usize,
offset: vsize - valign,
};
unsafe {
STATIC_TCB_MASTER.ptr = ph.p_vaddr as usize as *const u8;
STATIC_TCB_MASTER.len = ph.p_filesz as usize;
STATIC_TCB_MASTER.offset = vsize - valign;
let tcb = Tcb::new(vsize).expect("failed to allocate TCB");
tcb.set_masters(vec![tcb_master].into_boxed_slice());
tcb.masters_ptr = &mut STATIC_TCB_MASTER;
tcb.masters_len = mem::size_of::<Master>();
tcb.copy_masters().expect("failed to copy TLS master data");
tcb.activate();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment