Skip to content

Commit

Permalink
rust: addr: Add a module to declare core address types
Browse files Browse the repository at this point in the history
Encapsulates the core physical/DMA address types, so they can be used by
Rust abstractions.

Signed-off-by: Asahi Lina <[email protected]>
  • Loading branch information
asahilina committed Dec 9, 2024
1 parent 32eefb1 commit eef7a95
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions rust/kernel/addr.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: GPL-2.0

//! Kernel core address types.
use bindings;
use core::ffi;

/// A physical memory address (which may be wider than the CPU pointer size)
pub type PhysicalAddr = bindings::phys_addr_t;
/// A DMA memory address (which may be narrower than `PhysicalAddr` on some systems)
pub type DmaAddr = bindings::dma_addr_t;
/// A physical resource size, typically the same width as `PhysicalAddr`
pub type ResourceSize = bindings::resource_size_t;
/// A raw page frame number, not to be confused with the C `pfn_t` which also encodes flags.
pub type Pfn = ffi::c_ulong;
1 change: 1 addition & 0 deletions rust/kernel/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ compile_error!("Missing kernel configuration for conditional compilation");
// Allow proc-macros to refer to `::kernel` inside the `kernel` crate (this crate).
extern crate self as kernel;

pub mod addr;
pub mod alloc;
#[cfg(CONFIG_BLOCK)]
pub mod block;
Expand Down

0 comments on commit eef7a95

Please sign in to comment.