mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
handle case where uart is re-allocated by the kernel
this case happens when the loader is instructed to pre-allocate the kernel UART page based on the early-printk feature.
This commit is contained in:
parent
7dc09bbc73
commit
de8ddbf9c2
1 changed files with 16 additions and 10 deletions
|
|
@ -69,16 +69,22 @@ impl SerialRead for Uart {
|
|||
pub fn init() {
|
||||
// Map the UART peripheral.
|
||||
MemoryManager::with_mut(|memory_manager| {
|
||||
memory_manager
|
||||
.map_range(
|
||||
utra::uart::HW_UART_BASE as *mut u8,
|
||||
(UART_ADDR & !4095) as *mut u8,
|
||||
4096,
|
||||
PID::new(1).unwrap(),
|
||||
MemoryFlags::R | MemoryFlags::W,
|
||||
MemoryType::Default,
|
||||
)
|
||||
.expect("unable to map serial port")
|
||||
match memory_manager.map_range(
|
||||
utra::uart::HW_UART_BASE as *mut u8,
|
||||
(UART_ADDR & !4095) as *mut u8,
|
||||
4096,
|
||||
PID::new(1).unwrap(),
|
||||
MemoryFlags::R | MemoryFlags::W,
|
||||
MemoryType::Default,
|
||||
) {
|
||||
Err(xous_kernel::Error::MemoryInUse) => {
|
||||
klog!("Kernel uart already allocated by loader. No need to re-allocate.");
|
||||
}
|
||||
Ok(_) => {}
|
||||
_ => {
|
||||
panic!("Couldn't allocate kernel UART");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let mut uart = Uart::new(UART_ADDR, process_characters);
|
||||
|
|
|
|||
Loading…
Reference in a new issue