mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
move kernel UART to DUART port
using the DUART means we don't get console input on the kernel (because the DUART is incapable of this) but it's a decent compromise I think because the DUART is fast and efficient, and mostly we want it to capture kps? Eventually we'll need an input mode but for now, this will get us moving.
This commit is contained in:
parent
885e877b43
commit
5116d51de5
1 changed files with 26 additions and 5 deletions
|
|
@ -9,15 +9,15 @@ use crate::{
|
|||
debug::shell::process_characters,
|
||||
PID,
|
||||
};
|
||||
#[cfg(feature="cramium-fpga")]
|
||||
use utralib::generated::*;
|
||||
#[cfg(feature="cramium-fpga")]
|
||||
use xous_kernel::{MemoryFlags, MemoryType};
|
||||
|
||||
#[cfg(feature="cramium-soc")]
|
||||
use crate::{
|
||||
io::{SerialWrite, SerialRead},
|
||||
mem::MemoryManager,
|
||||
debug::shell::process_characters,
|
||||
PID,
|
||||
};
|
||||
|
||||
/// UART virtual address.
|
||||
|
|
@ -136,7 +136,21 @@ pub fn init() {
|
|||
|
||||
#[cfg(feature="cramium-soc")]
|
||||
pub fn init() { // there is no kernel UART yet...just a placeholder function
|
||||
let uart = Uart::new(UART_ADDR, IRQ0_ADDR, process_characters);
|
||||
// Map the UART peripheral.
|
||||
MemoryManager::with_mut(|memory_manager| {
|
||||
memory_manager
|
||||
.map_range(
|
||||
utra::duart::HW_DUART_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")
|
||||
});
|
||||
let mut uart = Uart::new(UART_ADDR, IRQ0_ADDR, process_characters);
|
||||
uart.init();
|
||||
unsafe{
|
||||
UART = Some(uart);
|
||||
crate::debug::shell::init(UART.as_mut().unwrap());
|
||||
|
|
@ -145,19 +159,26 @@ pub fn init() { // there is no kernel UART yet...just a placeholder function
|
|||
|
||||
#[cfg(feature="cramium-soc")]
|
||||
pub struct Uart {
|
||||
uart_csr: CSR<u32>,
|
||||
}
|
||||
|
||||
#[cfg(feature="cramium-soc")]
|
||||
impl Uart {
|
||||
pub fn new(_addr: usize, _irq_addr: usize, _callback: fn(&mut Self)) -> Uart {
|
||||
pub fn new(addr: usize, _irq_addr: usize, _callback: fn(&mut Self)) -> Uart {
|
||||
Uart {
|
||||
uart_csr: CSR::new(addr as *mut u32),
|
||||
}
|
||||
}
|
||||
pub fn init(&mut self) {
|
||||
// duart requires no special initializations
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature="cramium-soc")]
|
||||
impl SerialWrite for Uart {
|
||||
fn putc(&mut self, _c: u8) {
|
||||
fn putc(&mut self, c: u8) {
|
||||
while self.uart_csr.r(utra::duart::SFR_SR) != 0 {}
|
||||
self.uart_csr.wo(utra::duart::SFR_TXD, c as u32);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue