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 = []
print-panics = []
report-memory = ["stats_alloc"]
# default = ["print-panics", "debug-print"]
#default = ["print-panics", "debug-print"]
default = []
[target.'cfg(any(windows, unix))'.dependencies]

View file

@ -8,6 +8,7 @@ use utralib::generated::*;
pub mod debug_print_hardware {
use crate::debug::*;
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,
};

View file

@ -43,24 +43,26 @@ pub const DEFAULT: Uart = Uart {};
impl Uart {
fn map_uart(&self) {
/*
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),
None,
4096,
xous::MemoryFlags::R | xous::MemoryFlags::W,
)
.expect("couldn't map debug uart");
unsafe{ DEFAULT_UART_ADDR = uart.as_mut_ptr() as _; }
println!("Mapped UART @ {:08x}", uart.addr.get());
// core::mem::forget(uart);
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.
*/
let uart = xous::syscall::map_memory(
xous::MemoryAddress::new(utra::server1::HW_SERVER1_BASE),
None,
4096,
xous::MemoryFlags::R | xous::MemoryFlags::W,
)
.expect("couldn't map debug uart");
unsafe{ DEFAULT_UART_ADDR = uart.as_mut_ptr() as _; }
println!("Mapped UART @ {:08x}", uart.addr.get());
// core::mem::forget(uart);
println!("Allocating IRQ...");
xous::claim_interrupt(utra::console::CONSOLE_IRQ, handle_irq, core::ptr::null_mut::<usize>()).expect("unable to allocate IRQ");
self.enable_rx();
println!("Allocating IRQ...");
xous::claim_interrupt(utra::server1::HW_SERVER1_BASE, handle_irq, core::ptr::null_mut::<usize>()).expect("unable to allocate IRQ");
self.enable_rx();
}
}
pub fn putc(&self, c: u8) {

View file

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

View file

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

View file

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

View file

@ -232,7 +232,7 @@ fn shell_main() -> ! {
info!("drawing string: {}", string_buffer);
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
bouncyball.update();

View file

@ -113,7 +113,7 @@ mod implementation {
}
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();
if let Some(sr) = self.current_response.take() {
Some(SleepResponse {
@ -137,12 +137,12 @@ mod implementation {
irq_target,
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
.wo(utra::ticktimer::MSLEEP_TARGET1, (irq_target >> 32) as _);
self.csr
.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
}
}
}