Skip to content

Commit b0bc7c5

Browse files
committed
syscalls/ipc: Wrap enough syscalls for aero_shell
Signed-off-by: Dennis Bonke <[email protected]>
1 parent 8c3caec commit b0bc7c5

File tree

1 file changed

+9
-7
lines changed
  • src/aero_kernel/src/syscall

1 file changed

+9
-7
lines changed

src/aero_kernel/src/syscall/ipc.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* along with Aero. If not, see <https://www.gnu.org/licenses/>.
1818
*/
1919

20+
use crate::arch::controlregs;
2021
use crate::userland::scheduler::get_scheduler;
2122
use crate::userland::task::TaskId;
2223

@@ -60,11 +61,10 @@ fn handle_recieve(
6061
let output =
6162
validate_slice_mut(message_ptr as *mut u8, message_size).ok_or(AeroSyscallError::EINVAL)?;
6263

63-
output[0..msg.data.len()].copy_from_slice(&msg.data);
64-
65-
unsafe {
64+
controlregs::with_userspace_access(||unsafe {
65+
output[0..msg.data.len()].copy_from_slice(&msg.data);
6666
pid_ptr.write(msg.from);
67-
}
67+
});
6868

6969
Ok(msg.data.len())
7070
}
@@ -82,9 +82,11 @@ pub fn send(pid: usize, message: usize, message_size: usize) -> Result<usize, Ae
8282
let mut queue = message_queue.queue.lock();
8383

8484
// Push the message to the message queue of the provided task.
85-
queue.push_back(Message {
86-
from: get_scheduler().current_task().pid().as_usize(),
87-
data: payload.to_vec(),
85+
controlregs::with_userspace_access(|| {
86+
queue.push_back(Message {
87+
from: get_scheduler().current_task().pid().as_usize(),
88+
data: payload.to_vec(),
89+
})
8890
});
8991

9092
// Notify the task that it has a new message if its awaiting for one!

0 commit comments

Comments
 (0)