shell: fix build for hosted

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-10-28 11:14:09 +08:00
parent f9af2322f7
commit 4334e7c23e
2 changed files with 28 additions and 23 deletions

View file

@ -5,8 +5,8 @@
#[macro_use] #[macro_use]
mod debug; mod debug;
mod timer;
mod logstr; mod logstr;
mod timer;
use core::fmt::Write; use core::fmt::Write;
// fn print_and_yield(index: *mut usize) -> ! { // fn print_and_yield(index: *mut usize) -> ! {
@ -17,7 +17,7 @@ use core::fmt::Write;
// } // }
// } // }
extern crate utralib; #[cfg(baremetal)]
use utralib::generated::*; use utralib::generated::*;
fn move_lfsr(mut lfsr: u32) -> u32 { fn move_lfsr(mut lfsr: u32) -> u32 {
@ -71,22 +71,25 @@ fn shell_main() -> ! {
let dark = graphics_server::Color::from(0); let dark = graphics_server::Color::from(0);
let light = graphics_server::Color::from(!0); let light = graphics_server::Color::from(!0);
let gpio_base = xous::syscall::map_memory( #[cfg(baremetal)]
xous::MemoryAddress::new(utra::gpio::HW_GPIO_BASE), {
None, let gpio_base = xous::syscall::map_memory(
4096, xous::MemoryAddress::new(utra::gpio::HW_GPIO_BASE),
xous::MemoryFlags::R | xous::MemoryFlags::W, None,
) 4096,
.expect("couldn't map GPIO CSR range"); xous::MemoryFlags::R | xous::MemoryFlags::W,
let mut gpio = CSR::new(gpio_base.as_mut_ptr() as *mut u32); )
gpio.wfo(utra::gpio::UARTSEL_UARTSEL, 2); .expect("couldn't map GPIO CSR range");
let mut gpio = CSR::new(gpio_base.as_mut_ptr() as *mut u32);
gpio.wfo(utra::gpio::UARTSEL_UARTSEL, 2);
}
let mut last_time: u64 = 0; let mut last_time: u64 = 0;
loop { loop {
// a message passing demo -- checking time // a message passing demo -- checking time
if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) { if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) {
println!("SHELL: {}ms", elapsed_time); println!("SHELL: {}ms", elapsed_time);
if elapsed_time - last_time > 4000 { if elapsed_time - last_time > 40 {
last_time = elapsed_time; last_time = elapsed_time;
/* /*
xous::try_send_message(log_conn, xous::try_send_message(log_conn,
@ -95,18 +98,22 @@ fn shell_main() -> ! {
println!("Preparing a mutable borrow message"); println!("Preparing a mutable borrow message");
ls.clear(); ls.clear();
write!(ls, "Hello, Server! This memory is borrowed from another process. Elapsed: {}", elapsed_time as usize).expect("couldn't send hello message"); write!(
ls,
"Hello, Server! This memory is borrowed from another process. Elapsed: {}",
elapsed_time as usize
)
.expect("couldn't send hello message");
let mm = ls.as_memory_message(0) let mm = ls
.expect("couldn't form memory message"); .as_memory_message(0)
.expect("couldn't form memory message");
println!("Sending a mutable borrow message"); println!("Sending a mutable borrow message");
let response = xous::syscall::try_send_message( let response =
log_conn, xous::syscall::try_send_message(log_conn, xous::Message::MutableBorrow(mm))
xous::Message::MutableBorrow(mm), .expect("couldn't send memory message");
)
.expect("couldn't send memory message");
//unsafe { ls.set_len(response.0)}; //unsafe { ls.set_len(response.0)};
//println!("Message came back with args ({}, {}) as: {}", response.0, response.1, ls); //println!("Message came back with args ({}, {}) as: {}", response.0, response.1, ls);
} }
@ -114,7 +121,6 @@ fn shell_main() -> ! {
println!("error requesting ticktimer!") println!("error requesting ticktimer!")
} }
// println!("Sending a scalar message with id {}...", counter + 4096); // println!("Sending a scalar message with id {}...", counter + 4096);
// match xous::syscall::send_message( // match xous::syscall::send_message(
// log_conn, // log_conn,
@ -140,7 +146,6 @@ fn shell_main() -> ! {
// lfsr = move_lfsr(lfsr); // lfsr = move_lfsr(lfsr);
loop { loop {
match graphics_server::set_style( match graphics_server::set_style(
graphics_conn, graphics_conn,
5, 5,
@ -209,6 +214,5 @@ fn shell_main() -> ! {
// if counter & 2 == 0 { // if counter & 2 == 0 {
// xous::syscall::yield_slice(); // xous::syscall::yield_slice();
// } // }
} }
} }

View file

@ -1,3 +1,4 @@
#[cfg(baremetal)]
use utralib::generated::*; use utralib::generated::*;
#[cfg(baremetal)] #[cfg(baremetal)]