refactor(userspace): split syscall/fat16/ext4 by concern; trim comments
This commit is contained in:
58
crates/libkos/src/syscall/notify.rs
Normal file
58
crates/libkos/src/syscall/notify.rs
Normal file
@@ -0,0 +1,58 @@
|
||||
//! 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(|_| ())
|
||||
}
|
||||
Reference in New Issue
Block a user