mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
kernel: support receiving process arguments
Support passing process arguments in register 2 as part of arguments to a process. This requires updating the `InitialProcess` struct that is received from the loader, and so requires modeifications to be made in tandem. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
d8c6881554
commit
60f2a17649
2 changed files with 16 additions and 14 deletions
|
|
@ -127,6 +127,9 @@ pub struct InitialProcess {
|
||||||
|
|
||||||
/// Address of the top of the stack
|
/// Address of the top of the stack
|
||||||
pub sp: usize,
|
pub sp: usize,
|
||||||
|
|
||||||
|
/// Address of the environment block
|
||||||
|
pub env: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InitialProcess {
|
impl InitialProcess {
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,6 @@ const MINIELF_FLG_NC: u8 = 2;
|
||||||
const MINIELF_FLG_X: u8 = 4;
|
const MINIELF_FLG_X: u8 = 4;
|
||||||
#[cfg(baremetal)]
|
#[cfg(baremetal)]
|
||||||
const MINIELF_FLG_EHF: u8 = 8;
|
const MINIELF_FLG_EHF: u8 = 8;
|
||||||
#[cfg(baremetal)]
|
|
||||||
const MINIELF_FLG_EHH: u8 = 0x10;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub struct ExceptionHandler {
|
pub struct ExceptionHandler {
|
||||||
|
|
@ -414,25 +412,26 @@ impl SystemServices {
|
||||||
// - Process #1 is the kernel
|
// - Process #1 is the kernel
|
||||||
// Any changes to this will break this code!
|
// Any changes to this will break this code!
|
||||||
let mut eh_frame = 0;
|
let mut eh_frame = 0;
|
||||||
let mut eh_frame_size = 0;
|
|
||||||
let mut eh_frame_header = 0;
|
|
||||||
let mut eh_frame_header_size = 0;
|
|
||||||
if let Some(arg) = arg_iter.next() {
|
if let Some(arg) = arg_iter.next() {
|
||||||
for section in arg.data.chunks_exact(2) {
|
for section in arg.data.chunks_exact(2) {
|
||||||
let flags = (section[1] >> 24) as u8;
|
let flags = (section[1] >> 24) as u8;
|
||||||
if flags & MINIELF_FLG_EHF != 0 {
|
if flags & MINIELF_FLG_EHF != 0 {
|
||||||
eh_frame = section[0];
|
eh_frame = section[0];
|
||||||
eh_frame_size = section[1] & 0xFF_FFFF;
|
|
||||||
} else if flags & MINIELF_FLG_EHH != 0 {
|
|
||||||
eh_frame_header = section[0];
|
|
||||||
eh_frame_header_size = section[1] & 0xFF_FFFF;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let arg0 = eh_frame as _;
|
||||||
|
#[cfg(target_arch = "riscv32")]
|
||||||
|
let arg1 = init.env as _;
|
||||||
|
#[cfg(not(target_arch = "riscv32"))]
|
||||||
|
let arg1 = 0;
|
||||||
|
let arg2 = 0;
|
||||||
|
let arg3 = 0;
|
||||||
|
|
||||||
// end of assumption area
|
// end of assumption area
|
||||||
process.state = ProcessState::Setup(ThreadInit::new(
|
process.state = ProcessState::Setup(ThreadInit::new(
|
||||||
unsafe { core::mem::transmute::<usize, _>(init.entrypoint) },
|
init.entrypoint as _,
|
||||||
unsafe {
|
unsafe {
|
||||||
MemoryRange::new(
|
MemoryRange::new(
|
||||||
init.sp - crate::arch::process::DEFAULT_STACK_SIZE,
|
init.sp - crate::arch::process::DEFAULT_STACK_SIZE,
|
||||||
|
|
@ -440,10 +439,10 @@ impl SystemServices {
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
},
|
},
|
||||||
eh_frame as _,
|
arg0,
|
||||||
eh_frame_size as _,
|
arg1,
|
||||||
eh_frame_header as _,
|
arg2,
|
||||||
eh_frame_header_size as _,
|
arg3,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
// log_process_update(file!(), line!(), process, old_state);
|
// log_process_update(file!(), line!(), process, old_state);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue