Wait for a message to be received
(handle: &CommHandle)
| 235 | |
| 236 | /// Wait for a message to be received |
| 237 | pub fn receive(handle: &CommHandle) -> Result<Message, SyscallError> { |
| 238 | let ctrl: u64; |
| 239 | let (data1, data2, data3): (u64, u64, u64); |
| 240 | unsafe { |
| 241 | asm!("syscall", |
| 242 | in("rax") SYSCALL_RECEIVE, |
| 243 | in("rdi") handle.0, |
| 244 | lateout("rax") ctrl, |
| 245 | lateout("rdi") data1, |
| 246 | lateout("rsi") data2, |
| 247 | lateout("rdx") data3, |
| 248 | out("rcx") _, |
| 249 | out("r11") _); |
| 250 | } |
| 251 | let err = ctrl & 0xFF; |
| 252 | if err == 0 { |
| 253 | return Ok(Message::from_values(ctrl, data1, data2, data3)); |
| 254 | } |
| 255 | Err(SyscallError(err)) |
| 256 | } |
| 257 | |
| 258 | /// Send a message and wait for it to be received |
| 259 | /// |
no test coverage detected