Skip to content

Commit 8bae89f

Browse files
hoshinolinajannau
authored andcommitted
rust: addr: Add a module to declare core address types
Encapsulates the core physical/DMA address types, so they can be used by Rust abstractions. Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent bdc90f7 commit 8bae89f

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

rust/kernel/addr.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
//! Kernel core address types.
4+
5+
use bindings;
6+
use core::ffi;
7+
8+
/// A physical memory address (which may be wider than the CPU pointer size)
9+
pub type PhysicalAddr = bindings::phys_addr_t;
10+
/// A DMA memory address (which may be narrower than `PhysicalAddr` on some systems)
11+
pub type DmaAddr = bindings::dma_addr_t;
12+
/// A physical resource size, typically the same width as `PhysicalAddr`
13+
pub type ResourceSize = bindings::resource_size_t;
14+
/// A raw page frame number, not to be confused with the C `pfn_t` which also encodes flags.
15+
pub type Pfn = ffi::c_ulong;

rust/kernel/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ extern crate self as kernel;
6262

6363
pub use ffi;
6464

65+
pub mod addr;
6566
pub mod alloc;
6667
#[cfg(CONFIG_AUXILIARY_BUS)]
6768
pub mod auxiliary;

0 commit comments

Comments
 (0)