mirror of
https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials.git
synced 2024-11-11 07:10:59 +00:00
31 lines
937 B
Rust
31 lines
937 B
Rust
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||
|
//
|
||
|
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
||
|
|
||
|
//! BSP console facilities.
|
||
|
|
||
|
use super::{super::device_driver, memory::map};
|
||
|
use crate::console;
|
||
|
use core::fmt;
|
||
|
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
|
// Public Code
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
||
|
/// In case of a panic, the panic handler uses this function to take a last shot at printing
|
||
|
/// something before the system is halted.
|
||
|
///
|
||
|
/// # Safety
|
||
|
///
|
||
|
/// - Use only for printing during a panic.
|
||
|
pub unsafe fn panic_console_out() -> impl fmt::Write {
|
||
|
let mut uart = device_driver::PanicUart::new(map::mmio::PL011_UART_BASE);
|
||
|
uart.init();
|
||
|
uart
|
||
|
}
|
||
|
|
||
|
/// Return a reference to the console.
|
||
|
pub fn console() -> &'static impl console::interface::All {
|
||
|
&super::PL011_UART
|
||
|
}
|