Skip to main content

dma_write

Macro dma_write 

Source
macro_rules! dma_write {
    (@parse [$dma:expr] [$($proj:tt)*] [, $val:expr]) => { ... };
    (@parse [$dma:expr] [$($proj:tt)*] [.$field:tt $($rest:tt)*]) => { ... };
    (@parse [$dma:expr] [$($proj:tt)*] [[$index:expr]? $($rest:tt)*]) => { ... };
    (@parse [$dma:expr] [$($proj:tt)*] [[$index:expr] $($rest:tt)*]) => { ... };
    ($dma:expr, $($rest:tt)*) => { ... };
}
Expand description

Writes to a field of an item from an allocated region of structs.

The syntax is of the form kernel::dma_write!(dma, proj, val) where dma is an expression evaluating to a CoherentAllocation, proj is a projection specification, and val is the value to be written to the projected location.

ยงExamples

use kernel::device::Device;
use kernel::dma::{attrs::*, CoherentAllocation};

struct MyStruct { member: u32, }

// SAFETY: All bit patterns are acceptable values for `MyStruct`.
unsafe impl kernel::transmute::FromBytes for MyStruct{};
// SAFETY: Instances of `MyStruct` have no uninitialized portions.
unsafe impl kernel::transmute::AsBytes for MyStruct{};

kernel::dma_write!(alloc, [2]?.member, 0xf);
kernel::dma_write!(alloc, [1]?, MyStruct { member: 0xf });