78 lines
2.2 KiB
Rust
78 lines
2.2 KiB
Rust
//! Notifications and interrupts.
|
|
|
|
use super::{call0, raw, slot_of, Result};
|
|
use types::bounded::CapSlot;
|
|
use types::syscall_abi::*;
|
|
|
|
// ---- notifications and interrupts ----
|
|
|
|
pub fn create_notification() -> Result<CapSlot> {
|
|
slot_of(call0(SYS_CREATE_NOTIFICATION))
|
|
}
|
|
|
|
pub fn signal(notification: CapSlot) -> Result<()> {
|
|
raw(SYS_SIGNAL, [notification.value() as usize, 0, 0, 0, 0, 0]).map(|_| ())
|
|
}
|
|
|
|
/// Blocks until the notification has bits, then returns and clears them.
|
|
pub fn wait(notification: CapSlot) -> Result<usize> {
|
|
raw(SYS_WAIT, [notification.value() as usize, 0, 0, 0, 0, 0]).map(|r| r[1])
|
|
}
|
|
|
|
/// Returns and clears the bits without blocking.
|
|
pub fn poll(notification: CapSlot) -> Result<usize> {
|
|
raw(SYS_POLL, [notification.value() as usize, 0, 0, 0, 0, 0]).map(|r| r[1])
|
|
}
|
|
|
|
/// After this, `receive` also returns when the notification is signalled.
|
|
pub fn bind_notification(notification: CapSlot) -> Result<()> {
|
|
raw(
|
|
SYS_BIND_NOTIFICATION,
|
|
[notification.value() as usize, 0, 0, 0, 0, 0],
|
|
)
|
|
.map(|_| ())
|
|
}
|
|
|
|
/// Delivers interrupt `irq` as a signal on `notification`.
|
|
pub fn set_irq_notification(irq: CapSlot, notification: CapSlot) -> Result<()> {
|
|
raw(
|
|
SYS_SET_IRQ_NOTIFICATION,
|
|
[
|
|
irq.value() as usize,
|
|
notification.value() as usize,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
],
|
|
)
|
|
.map(|_| ())
|
|
}
|
|
|
|
pub fn ack_interrupt(irq: CapSlot) -> Result<()> {
|
|
raw(
|
|
SYS_ACKNOWLEDGE_INTERRUPT,
|
|
[irq.value() as usize, 0, 0, 0, 0, 0],
|
|
)
|
|
.map(|_| ())
|
|
}
|
|
|
|
/// Signals `notification` when the process behind `process` dies.
|
|
pub fn watch_death(process: CapSlot, notification: CapSlot) -> Result<()> {
|
|
raw(
|
|
SYS_WATCH_DEATH,
|
|
[process.value() as usize, notification.value() as usize, 0, 0, 0, 0],
|
|
)
|
|
.map(|_| ())
|
|
}
|
|
|
|
/// Signals `notification` once `get_time()` reaches `deadline`; replaces
|
|
/// this process's timer. A zero deadline cancels it.
|
|
pub fn set_timer(notification: CapSlot, deadline: types::time::Ticks) -> Result<()> {
|
|
raw(
|
|
SYS_SET_TIMER,
|
|
[notification.value() as usize, deadline.raw() as usize, 0, 0, 0, 0],
|
|
)
|
|
.map(|_| ())
|
|
}
|