pvmfw: helpers: Represent addresses as usize
Use the more natural type to represent "pointers as integers".
Test: -
Change-Id: I9bedfb1aad80769f5b3beaf18e896226c09ba758
diff --git a/pvmfw/src/exceptions.rs b/pvmfw/src/exceptions.rs
index 0fb2911..03fc220 100644
--- a/pvmfw/src/exceptions.rs
+++ b/pvmfw/src/exceptions.rs
@@ -20,14 +20,14 @@
use vmbase::{console::emergency_write_str, eprintln, power::reboot};
const ESR_32BIT_EXT_DABT: u64 = 0x96000010;
-const UART_PAGE: u64 = page_4kb_of(console::BASE_ADDRESS as u64);
+const UART_PAGE: usize = page_4kb_of(console::BASE_ADDRESS);
#[no_mangle]
extern "C" fn sync_exception_current(_elr: u64, _spsr: u64) {
let esr = read_esr();
let far = read_far();
// Don't print to the UART if we're handling the exception it could raise.
- if esr != ESR_32BIT_EXT_DABT || page_4kb_of(far) != UART_PAGE {
+ if esr != ESR_32BIT_EXT_DABT || page_4kb_of(far as usize) != UART_PAGE {
emergency_write_str("sync_exception_current\n");
print_esr(esr);
}
diff --git a/pvmfw/src/helpers.rs b/pvmfw/src/helpers.rs
index 781c1ac..bcace14 100644
--- a/pvmfw/src/helpers.rs
+++ b/pvmfw/src/helpers.rs
@@ -15,12 +15,12 @@
//! Miscellaneous helper functions.
/// Computes the address of the page containing a given address.
-pub const fn page_of(addr: u64, page_size: u64) -> u64 {
+pub const fn page_of(addr: usize, page_size: usize) -> usize {
addr & !(page_size - 1)
}
/// Validates a page size and computes the address of the page containing a given address.
-pub const fn checked_page_of(addr: u64, page_size: u64) -> Option<u64> {
+pub const fn checked_page_of(addr: usize, page_size: usize) -> Option<usize> {
if page_size.is_power_of_two() {
Some(page_of(addr, page_size))
} else {
@@ -29,8 +29,8 @@
}
/// Computes the address of the 4KiB page containing a given address.
-pub const fn page_4kb_of(addr: u64) -> u64 {
- const PAGE_SIZE: u64 = 4 << 10;
+pub const fn page_4kb_of(addr: usize) -> usize {
+ const PAGE_SIZE: usize = 4 << 10;
page_of(addr, PAGE_SIZE)
}
diff --git a/pvmfw/src/main.rs b/pvmfw/src/main.rs
index eb97961..b9b01c8 100644
--- a/pvmfw/src/main.rs
+++ b/pvmfw/src/main.rs
@@ -43,10 +43,10 @@
fn main(fdt_address: u64, payload_start: u64, payload_size: u64, arg3: u64) -> Result<(), Error> {
// We need to inform the hypervisor that the MMIO page containing the UART may be shared back.
- let uart = console::BASE_ADDRESS as u64;
let mmio_granule = smccc::mmio_guard_info().map_err(|_| Error::FailedUartSetup)?;
- let uart_page = checked_page_of(uart, mmio_granule).ok_or(Error::FailedUartSetup)?;
- smccc::mmio_guard_map(uart_page).map_err(|_| Error::FailedUartSetup)?;
+ let uart_page = checked_page_of(console::BASE_ADDRESS, mmio_granule as usize)
+ .ok_or(Error::FailedUartSetup)?;
+ smccc::mmio_guard_map(uart_page as u64).map_err(|_| Error::FailedUartSetup)?;
println!("pVM firmware");
println!(