pub trait SentryExchangeable {
// Required methods
fn to_kernel(&self) -> Result<Status, Status>;
fn from_kernel(&mut self) -> Result<Status, Status>;
}Expand description
Sentry exchangeable opaque trait, only defined for systypes defined types
This trait is declared in order to allow the attribute checking but is not exported as no upper layer type needs to implement it Trait of kernel-user exchangeable objects
This trait written in order to support the notion of “kernel-exchangeable” type. Any type that do support this trait can be delivered to (and/or received from) the kernel.
The effective implementation of this trait public functions are kept private, and can’t be implemented out of this very crate in order to ensure that only this crate’s declared types are exchangeable. To ensure such a restriction, this trait is hosted by the current, crate-private, module.
As a consequence, don’t try to implement that trait in any of the upper layers.
Required Methods§
Sourcefn to_kernel(&self) -> Result<Status, Status>
fn to_kernel(&self) -> Result<Status, Status>
Copy the current object to the kernel exchagne zone
Sourcefn from_kernel(&mut self) -> Result<Status, Status>
fn from_kernel(&mut self) -> Result<Status, Status>
set the current object using the data delivered by the kernel in the exchange zone
Implementations on Foreign Types§
Source§impl SentryExchangeable for &[u8]
impl SentryExchangeable for &[u8]
Source§impl SentryExchangeable for &mut [u8]
impl SentryExchangeable for &mut [u8]
Source§impl SentryExchangeable for u8
impl SentryExchangeable for u8
Source§impl SentryExchangeable for u16
impl SentryExchangeable for u16
Source§impl SentryExchangeable for u32
impl SentryExchangeable for u32
Source§impl SentryExchangeable for u64
impl SentryExchangeable for u64
Source§impl SentryExchangeable for usize
impl SentryExchangeable for usize
Implementors§
impl SentryExchangeable for GpdmaStreamConfig
SentryExchangeable trait implementation for dma::GpdmaStreamConfig. dma::GpdmaStreamConfig is a typical structure which is returned by the kernel to the userspace in order to delivers various DMA stream-related information to a given task that is using the corresponding DMA handle.
In test mode only, this structure can be written back to the Exchange Area. In production mode, the application can’t write such a content to the exchange as the kernel as strictly no use of it.
impl SentryExchangeable for ShmInfo
SentryExchangeable trait implementation for ShmInfo. Shminfo is a typical structure which is returned by the kernel to the userspace in order to delivers various SHM-related information to a given task that is using the corresponding SHM.
In test mode only, this structure can be written back to the Exchange Area. In production mode, the application can’t write such a content to the exchange as the kernel as strictly no use of it.
impl SentryExchangeable for Event<'_>
Event SentryExchangeable trait implementation
Events are objects that are used to hold event ifnormation that need to be delivered or received from the kernel.
Events are received from the kernel and hold a header and an associated data bloc. The SentryExchangeable trait only support, in nominal mode, the from_kernel() usage for any event, and to_kernel when emitting IPC
This trait allows to easily receive or deliver properly formatted events, including the event header forged by the kernel and associated data.
§Example
let mut my_event = uapi::systypes::Event {
header: uapi::systypes::ExchangeHeader {
peer: 0,
event: uapi::systypes::EventType::None.into(),
length: 0,
magic: 0,
},
data: &mut[0; 12],
};
// wait for kernel events of type IRQ or IPC
let _ = uapi::syscall::wait_for_event(
uapi::systypes::EventType::IRQ.into() | uapi::systypes::EventType::Ipc.into(),
0;
);
// get back event data from kernel
let _ = my_event.from_kernel();
// handle event
if !my_event.header.is_valid() {
return Err(),
}
match my_event.header.event {
EventType::Irq => treat_irq(&my_event.data, my_event.length),
EventType::IPC => treat_ipc(&my_event.data, my_event.length),
any_other => Err(),
}