Skip to content

Commit eef7a95

Browse files
committed
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 <[email protected]>
1 parent 32eefb1 commit eef7a95

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
@@ -40,6 +40,7 @@ compile_error!("Missing kernel configuration for conditional compilation");
4040
// Allow proc-macros to refer to `::kernel` inside the `kernel` crate (this crate).
4141
extern crate self as kernel;
4242

43+
pub mod addr;
4344
pub mod alloc;
4445
#[cfg(CONFIG_BLOCK)]
4546
pub mod block;

0 commit comments

Comments
 (0)