Merge branch 'master' of github.com:betrusted-io/xous-core

This commit is contained in:
Sean Cross 2020-11-23 19:32:31 +08:00
commit 958fa96fde
8 changed files with 30 additions and 25 deletions

View file

@ -21,7 +21,7 @@ riscv = "0.5.6"
debug-print = [] debug-print = []
print-panics = [] print-panics = []
report-memory = ["stats_alloc"] report-memory = ["stats_alloc"]
# default = ["print-panics", "debug-print"] #default = ["print-panics", "debug-print"]
default = [] default = []
[target.'cfg(any(windows, unix))'.dependencies] [target.'cfg(any(windows, unix))'.dependencies]

View file

@ -8,6 +8,7 @@ use utralib::generated::*;
pub mod debug_print_hardware { pub mod debug_print_hardware {
use crate::debug::*; use crate::debug::*;
pub const SUPERVISOR_UART: Uart = Uart { pub const SUPERVISOR_UART: Uart = Uart {
// the HW device mapping is done in main.rs/init(); the virtuall address has to be in the top 4MiB as it is the only page shared among all processes
base: 0xffcf_0000 as *mut usize, base: 0xffcf_0000 as *mut usize,
}; };

View file

@ -43,24 +43,26 @@ pub const DEFAULT: Uart = Uart {};
impl Uart { impl Uart {
fn map_uart(&self) { fn map_uart(&self) {
/* if cfg!(feature = "debugprint") {
Note: the memory address and interrupt specified here needs to map to a unique hardware /*
UART resource. Modify in this function as necessary. Note: the memory address and interrupt specified here needs to map to a unique hardware
*/ UART resource. Modify in this function as necessary.
let uart = xous::syscall::map_memory( */
xous::MemoryAddress::new(utra::console::HW_CONSOLE_BASE), let uart = xous::syscall::map_memory(
None, xous::MemoryAddress::new(utra::server1::HW_SERVER1_BASE),
4096, None,
xous::MemoryFlags::R | xous::MemoryFlags::W, 4096,
) xous::MemoryFlags::R | xous::MemoryFlags::W,
.expect("couldn't map debug uart"); )
unsafe{ DEFAULT_UART_ADDR = uart.as_mut_ptr() as _; } .expect("couldn't map debug uart");
println!("Mapped UART @ {:08x}", uart.addr.get()); unsafe{ DEFAULT_UART_ADDR = uart.as_mut_ptr() as _; }
// core::mem::forget(uart); println!("Mapped UART @ {:08x}", uart.addr.get());
// core::mem::forget(uart);
println!("Allocating IRQ..."); println!("Allocating IRQ...");
xous::claim_interrupt(utra::console::CONSOLE_IRQ, handle_irq, core::ptr::null_mut::<usize>()).expect("unable to allocate IRQ"); xous::claim_interrupt(utra::server1::HW_SERVER1_BASE, handle_irq, core::ptr::null_mut::<usize>()).expect("unable to allocate IRQ");
self.enable_rx(); self.enable_rx();
}
} }
pub fn putc(&self, c: u8) { pub fn putc(&self, c: u8) {

View file

@ -14,4 +14,5 @@ utralib = { path = "../../utralib"}
[features] [features]
debugprint = [] debugprint = []
default = [] # "debugprint" default = []
#default = ["debugprint"]

View file

@ -6,7 +6,7 @@ use utralib::generated::*;
macro_rules! print macro_rules! print
{ {
($($args:tt)+) => ({ ($($args:tt)+) => ({
use core::fmt::Write; use core::fmt::Write;
let _ = write!(crate::debug::Uart {}, $($args)+); let _ = write!(crate::debug::Uart {}, $($args)+);
}); });
} }

View file

@ -18,4 +18,5 @@ utralib = { path = "../../utralib"}
[features] [features]
debugprint = [] debugprint = []
default = ["debugprint"] # "debugprint" # default = ["debugprint"] # "debugprint"
default = []

View file

@ -232,7 +232,7 @@ fn shell_main() -> ! {
info!("drawing string: {}", string_buffer); info!("drawing string: {}", string_buffer);
graphics_server::draw_string(graphics_conn, &string_buffer).expect("unable to draw string"); graphics_server::draw_string(graphics_conn, &string_buffer).expect("unable to draw string");
ticktimer_server::sleep_ms(ticktimer_conn, 2000).expect("couldn't sleep"); // ticktimer_server::sleep_ms(ticktimer_conn, 500).expect("couldn't sleep");
// draw the ball // draw the ball
bouncyball.update(); bouncyball.update();

View file

@ -113,7 +113,7 @@ mod implementation {
} }
pub fn stop_interrupt(&mut self) -> Option<SleepResponse> { pub fn stop_interrupt(&mut self) -> Option<SleepResponse> {
self.csr.wo(utra::ticktimer::EV_ENABLE, 0); // Disable the timer self.csr.wfo(utra::ticktimer::EV_ENABLE_ALARM, 0); // Disable the timer
let current_value = self.elapsed_ms(); let current_value = self.elapsed_ms();
if let Some(sr) = self.current_response.take() { if let Some(sr) = self.current_response.take() {
Some(SleepResponse { Some(SleepResponse {
@ -137,12 +137,12 @@ mod implementation {
irq_target, irq_target,
self.response_start self.response_start
); );
self.csr.wo(utra::ticktimer::EV_PENDING, 1); // Clear previous interrupt (if any) self.csr.wfo(utra::ticktimer::EV_PENDING_ALARM, 1); // Clear previous interrupt (if any)
self.csr self.csr
.wo(utra::ticktimer::MSLEEP_TARGET1, (irq_target >> 32) as _); .wo(utra::ticktimer::MSLEEP_TARGET1, (irq_target >> 32) as _);
self.csr self.csr
.wo(utra::ticktimer::MSLEEP_TARGET0, irq_target as _); .wo(utra::ticktimer::MSLEEP_TARGET0, irq_target as _);
self.csr.wo(utra::ticktimer::EV_ENABLE, 1); // Enable the interrupt self.csr.wfo(utra::ticktimer::EV_ENABLE_ALARM, 1); // Enable the interrupt
} }
} }
} }