Avoid PHYS_OFFSET in dtb/serial.rs

This commit is contained in:
bjorn3
2026-04-04 21:53:34 +02:00
parent d029ccfe20
commit b7456d5bcc
4 changed files with 7 additions and 4 deletions
-1
View File
@@ -93,7 +93,6 @@ bitflags! {
}
}
#[allow(dead_code)]
pub struct SerialPort {
base: usize,
data_reg: u8,
+4 -2
View File
@@ -11,6 +11,7 @@ use fdt::{
standard_nodes::MemoryRegion,
Fdt,
};
use rmm::PhysicalAddress;
use spin::once::Once;
/// Represents the in-memory DTB (DeviceTree) binary.
@@ -146,6 +147,7 @@ pub fn register_dev_memory_ranges(dt: &Fdt) {
}
}
// FIXME return PhysicalAddress
pub fn get_mmio_address(fdt: &Fdt, _device: &FdtNode, region: &MemoryRegion) -> Option<usize> {
/* DT spec 2.3.8 "ranges":
* The ranges property provides a means of defining a mapping or translation between
@@ -206,7 +208,7 @@ pub fn get_interrupt(fdt: &Fdt, node: &FdtNode, idx: usize) -> Option<IrqCell> {
}
}
pub fn diag_uart_range<'a>(dtb: &'a Fdt) -> Option<(usize, usize, bool, bool, &'a str)> {
pub fn diag_uart_range<'a>(dtb: &'a Fdt) -> Option<(PhysicalAddress, usize, bool, bool, &'a str)> {
let stdout_path = dtb.chosen().stdout()?;
let uart_node = stdout_path.node();
let skip_init = uart_node.property("skip-init").is_some();
@@ -220,7 +222,7 @@ pub fn diag_uart_range<'a>(dtb: &'a Fdt) -> Option<(usize, usize, bool, bool, &'
let address = get_mmio_address(dtb, &uart_node, &memory)?;
Some((
address,
PhysicalAddress::new(address),
memory.size?,
skip_init,
cts_event_walkaround,
+2 -1
View File
@@ -5,6 +5,7 @@ use syscall::Mmio;
use crate::{
devices::{serial::SerialKind, uart_16550, uart_pl011},
dtb::diag_uart_range,
memory::{RmmA, RmmArch},
};
pub static COM1: Mutex<SerialKind> = Mutex::new(SerialKind::NotPresent);
@@ -18,7 +19,7 @@ pub unsafe fn init_early(dtb: &Fdt) {
}
if let Some((phys, size, skip_init, cts, compatible)) = diag_uart_range(dtb) {
let virt = crate::PHYS_OFFSET + phys;
let virt = RmmA::phys_to_virt(phys).data();
let serial_opt = if compatible.contains("arm,pl011") {
let mut serial_port = uart_pl011::SerialPort::new(virt, cts);
if !skip_init {
+1
View File
@@ -40,6 +40,7 @@ mod macros;
mod arch;
use crate::arch::*;
/// Offset of physmap
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), expect(dead_code))]
const PHYS_OFFSET: usize = <arch::CurrentRmmArch as ::rmm::Arch>::PHYS_OFFSET;
/// Heap allocators