mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +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() {
|
pub fn init() {
|
||||||
// Map the UART peripheral.
|
// Map the UART peripheral.
|
||||||
MemoryManager::with_mut(|memory_manager| {
|
MemoryManager::with_mut(|memory_manager| {
|
||||||
memory_manager
|
match memory_manager.map_range(
|
||||||
.map_range(
|
utra::uart::HW_UART_BASE as *mut u8,
|
||||||
utra::uart::HW_UART_BASE as *mut u8,
|
(UART_ADDR & !4095) as *mut u8,
|
||||||
(UART_ADDR & !4095) as *mut u8,
|
4096,
|
||||||
4096,
|
PID::new(1).unwrap(),
|
||||||
PID::new(1).unwrap(),
|
MemoryFlags::R | MemoryFlags::W,
|
||||||
MemoryFlags::R | MemoryFlags::W,
|
MemoryType::Default,
|
||||||
MemoryType::Default,
|
) {
|
||||||
)
|
Err(xous_kernel::Error::MemoryInUse) => {
|
||||||
.expect("unable to map serial port")
|
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);
|
let mut uart = Uart::new(UART_ADDR, process_characters);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue