mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
remove arg page list, replace with set of 8 usize
this makes calls more efficient and avoids the double-shared page
This commit is contained in:
parent
d6cfb13e4f
commit
167cd04f06
1 changed files with 9 additions and 45 deletions
|
|
@ -26,15 +26,9 @@ static mut SWAP: Swap = Swap {
|
||||||
pc: 0,
|
pc: 0,
|
||||||
prev_op: None,
|
prev_op: None,
|
||||||
swapper_state: 0,
|
swapper_state: 0,
|
||||||
swapper_args_pid2_vaddr: 0,
|
swapper_args: [0usize; 8],
|
||||||
mappable_args: SwapperArgs { data: [0u32; 1024] },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[repr(C, align(4096))]
|
|
||||||
struct SwapperArgs {
|
|
||||||
data: [u32; 1024],
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Swap {
|
pub struct Swap {
|
||||||
/// Pointer to the swap page table base
|
/// Pointer to the swap page table base
|
||||||
spt_ptr: usize,
|
spt_ptr: usize,
|
||||||
|
|
@ -52,10 +46,8 @@ pub struct Swap {
|
||||||
prev_op: Option<BlockingSwapOp>,
|
prev_op: Option<BlockingSwapOp>,
|
||||||
/// state for the swapper. this is a PID-2 local virtual address, passed from the swapper on registration
|
/// state for the swapper. this is a PID-2 local virtual address, passed from the swapper on registration
|
||||||
swapper_state: usize,
|
swapper_state: usize,
|
||||||
/// virtual address of the below arg block in PID2 space
|
|
||||||
swapper_args_pid2_vaddr: usize,
|
|
||||||
/// storage for args
|
/// storage for args
|
||||||
mappable_args: SwapperArgs,
|
swapper_args: [usize; 8],
|
||||||
}
|
}
|
||||||
impl Swap {
|
impl Swap {
|
||||||
/// Calls the provided function with the current inner process state.
|
/// Calls the provided function with the current inner process state.
|
||||||
|
|
@ -113,33 +105,6 @@ impl Swap {
|
||||||
if self.sid == SID::from_u32(0, 0, 0, 0) {
|
if self.sid == SID::from_u32(0, 0, 0, 0) {
|
||||||
self.sid = SID::from_u32(s0, s1, s2, s3);
|
self.sid = SID::from_u32(s0, s1, s2, s3);
|
||||||
self.pc = handler;
|
self.pc = handler;
|
||||||
// map the arguments into the swapper's space, without unmapping it from the kernel space
|
|
||||||
let args_phys_addr =
|
|
||||||
crate::arch::mem::virt_to_phys(&self.mappable_args as *const SwapperArgs as usize).unwrap();
|
|
||||||
SystemServices::with_mut(|system_services| {
|
|
||||||
let swapper_map = system_services.get_process(swapper_pid).unwrap().mapping;
|
|
||||||
// map the argument block into the swapper
|
|
||||||
let args_virt = MemoryManager::with_mut(|mm| {
|
|
||||||
let args_virt = mm
|
|
||||||
.find_virtual_address(
|
|
||||||
core::ptr::null_mut(),
|
|
||||||
PAGE_SIZE,
|
|
||||||
xous_kernel::MemoryType::Messages,
|
|
||||||
)
|
|
||||||
.expect("couldn't map swapper args into swapper space")
|
|
||||||
as usize;
|
|
||||||
let _result = crate::arch::mem::map_page_inner(
|
|
||||||
mm,
|
|
||||||
swapper_pid,
|
|
||||||
args_phys_addr,
|
|
||||||
args_virt,
|
|
||||||
MemoryFlags::R | MemoryFlags::W,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
args_virt
|
|
||||||
});
|
|
||||||
self.swapper_args_pid2_vaddr = args_virt;
|
|
||||||
});
|
|
||||||
self.swapper_state = state;
|
self.swapper_state = state;
|
||||||
Ok(xous_kernel::Result::Ok)
|
Ok(xous_kernel::Result::Ok)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -205,11 +170,12 @@ impl Swap {
|
||||||
// setup the argument block
|
// setup the argument block
|
||||||
match op {
|
match op {
|
||||||
BlockingSwapOp::WriteToSwap(pid, phys_addr, virt_addr) => {
|
BlockingSwapOp::WriteToSwap(pid, phys_addr, virt_addr) => {
|
||||||
self.mappable_args.data[0] = self.swapper_state as u32;
|
self.swapper_args[0] = self.swapper_state;
|
||||||
self.mappable_args.data[1] = 0; // WriteToSwap opcode
|
self.swapper_args[1] = 0; // WriteToSwap opcode
|
||||||
self.mappable_args.data[2] = pid.get() as u32;
|
self.swapper_args[2] = payload_ptr;
|
||||||
self.mappable_args.data[3] = phys_addr as u32;
|
self.swapper_args[3] = pid.get() as usize;
|
||||||
self.mappable_args.data[4] = virt_addr as u32;
|
self.swapper_args[4] = phys_addr;
|
||||||
|
self.swapper_args[5] = virt_addr;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
todo!()
|
todo!()
|
||||||
|
|
@ -224,9 +190,7 @@ impl Swap {
|
||||||
ss.make_callback_to(
|
ss.make_callback_to(
|
||||||
swapper_pid,
|
swapper_pid,
|
||||||
self.pc as *const usize,
|
self.pc as *const usize,
|
||||||
self.swapper_args_pid2_vaddr,
|
crate::services::CallbackType::Swap(self.swapper_args),
|
||||||
payload_ptr as *mut usize,
|
|
||||||
crate::arch::process::RETURN_FROM_EXCEPTION_HANDLER,
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.expect("couldn't switch to handler");
|
.expect("couldn't switch to handler");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue