From 1aa01fdf5d55379a0244051f66d1b3817b62a010 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 23 Nov 2020 19:02:02 +0800 Subject: [PATCH] confirm sleep works, some minor fixup to UTRA style usage --- kernel/Cargo.toml | 2 +- kernel/src/debug.rs | 1 + services/graphics-server/src/debug.rs | 36 ++++++++++++++------------- services/log-server/Cargo.toml | 3 ++- services/log-server/src/debug.rs | 2 +- services/shell/Cargo.toml | 3 ++- services/shell/src/main.rs | 2 +- services/ticktimer-server/src/main.rs | 6 ++--- 8 files changed, 30 insertions(+), 25 deletions(-) diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index cace83385..6bb7cc32f 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -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] diff --git a/kernel/src/debug.rs b/kernel/src/debug.rs index 605cfd8a5..eb5c5e94a 100644 --- a/kernel/src/debug.rs +++ b/kernel/src/debug.rs @@ -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, }; diff --git a/services/graphics-server/src/debug.rs b/services/graphics-server/src/debug.rs index 65b20fb87..a5eced533 100644 --- a/services/graphics-server/src/debug.rs +++ b/services/graphics-server/src/debug.rs @@ -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::()).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::()).expect("unable to allocate IRQ"); + self.enable_rx(); + } } pub fn putc(&self, c: u8) { diff --git a/services/log-server/Cargo.toml b/services/log-server/Cargo.toml index 8882815c7..9341019dc 100644 --- a/services/log-server/Cargo.toml +++ b/services/log-server/Cargo.toml @@ -14,4 +14,5 @@ utralib = { path = "../../utralib"} [features] debugprint = [] -default = [] # "debugprint" +default = [] +#default = ["debugprint"] diff --git a/services/log-server/src/debug.rs b/services/log-server/src/debug.rs index e19adef3a..2aa8d51f1 100644 --- a/services/log-server/src/debug.rs +++ b/services/log-server/src/debug.rs @@ -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)+); }); } diff --git a/services/shell/Cargo.toml b/services/shell/Cargo.toml index c17a2b410..78743eeda 100644 --- a/services/shell/Cargo.toml +++ b/services/shell/Cargo.toml @@ -18,4 +18,5 @@ utralib = { path = "../../utralib"} [features] debugprint = [] -default = ["debugprint"] # "debugprint" +# default = ["debugprint"] # "debugprint" +default = [] diff --git a/services/shell/src/main.rs b/services/shell/src/main.rs index 6e7114b79..be9f78f54 100644 --- a/services/shell/src/main.rs +++ b/services/shell/src/main.rs @@ -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(); diff --git a/services/ticktimer-server/src/main.rs b/services/ticktimer-server/src/main.rs index 9fbf47d92..228b8da25 100644 --- a/services/ticktimer-server/src/main.rs +++ b/services/ticktimer-server/src/main.rs @@ -113,7 +113,7 @@ mod implementation { } pub fn stop_interrupt(&mut self) -> Option { - 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 } } }