mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
hosted: fix hosted mode after CreateProcess addition
Hosted mode spawns processes very differently, and this difference was not reflected after changes were made to native mode. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
1d3cf25518
commit
75e855cc4d
3 changed files with 23 additions and 8 deletions
|
|
@ -40,6 +40,11 @@ impl MemoryMapping {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Does nothing in hosted mode.
|
||||
pub unsafe fn allocate(&mut self, _pid: PID) -> Result<(), xous_kernel::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn reserve_address(
|
||||
&mut self,
|
||||
_mm: &mut MemoryManager,
|
||||
|
|
|
|||
|
|
@ -337,7 +337,11 @@ impl Process {
|
|||
/// Initialize this process with the given memory space. THIS DOES NOT
|
||||
/// INITIALIZE A MAIN THREAD. You must call `setup_thread()` in order to
|
||||
/// select a main thread.
|
||||
pub fn create(pid: PID, init_data: ProcessInit) -> ProcessStartup {
|
||||
pub fn create(
|
||||
pid: PID,
|
||||
init_data: ProcessInit,
|
||||
_services: &mut crate::SystemServices,
|
||||
) -> Result<ProcessStartup, xous_kernel::Error> {
|
||||
PROCESS_TABLE.with(|process_table| {
|
||||
let mut process_table = process_table.borrow_mut();
|
||||
let pid_idx = (pid.get() - 1) as usize;
|
||||
|
|
@ -359,7 +363,7 @@ impl Process {
|
|||
} else {
|
||||
panic!("pid already allocated!");
|
||||
}
|
||||
ProcessStartup::new(pid)
|
||||
Ok(ProcessStartup::new(pid))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -421,12 +421,15 @@ impl SystemServices {
|
|||
let new_pid = new_pid.unwrap();
|
||||
let startup = arch::process::Process::create(new_pid, init_process, self).unwrap();
|
||||
|
||||
let mut entry = &mut self.processes[entry_idx.unwrap()];
|
||||
// The `Process::create()` call above set up the process so that it will
|
||||
// be ready to run right away, meaning we will not need to first set
|
||||
// the state to `ProcessState::Allocated` and we can go straight to running
|
||||
// this process.
|
||||
entry.state = ProcessState::Ready(1 << INITIAL_TID);
|
||||
#[cfg(baremetal)]
|
||||
{
|
||||
let mut entry = &mut self.processes[entry_idx.unwrap()];
|
||||
// The `Process::create()` call above set up the process so that it will
|
||||
// be ready to run right away, meaning we will not need to first set
|
||||
// the state to `ProcessState::Allocated` and we can go straight to running
|
||||
// this process.
|
||||
entry.state = ProcessState::Ready(1 << INITIAL_TID);
|
||||
}
|
||||
// entry.ppid = _ppid;
|
||||
klog!("created new process for PID {} with PPID {}", new_pid, ppid);
|
||||
return Ok(startup);
|
||||
|
|
@ -1210,6 +1213,9 @@ impl SystemServices {
|
|||
if dest_virt as usize & 0xfff != 0 {
|
||||
return Err(xous_kernel::Error::BadAddress);
|
||||
}
|
||||
if (dest_virt as usize) + len > crate::arch::mem::USER_AREA_END {
|
||||
return Err(xous_kernel::Error::BadAddress);
|
||||
}
|
||||
|
||||
let current_pid = self.current_pid();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue