mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
examples: shell: get shell working on baremetal
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
4b58e5108e
commit
45bd670138
4 changed files with 36 additions and 31 deletions
3
examples/shell/.vscode/settings.json
vendored
3
examples/shell/.vscode/settings.json
vendored
|
|
@ -37,5 +37,6 @@
|
|||
"vmim",
|
||||
"vmip",
|
||||
"xous"
|
||||
]
|
||||
],
|
||||
"git.ignoreLimitWarning": true
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ pub unsafe extern "C" fn start_rust() -> ! {
|
|||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
)
|
||||
.expect("couldn't map uart");
|
||||
unsafe { crate::debug::DEFAULT_UART_ADDR = uart.as_mut_ptr() };
|
||||
crate::debug::DEFAULT_UART_ADDR = uart.as_mut_ptr() as _;
|
||||
println!("Mapped UART @ {:08x}", uart.addr.get());
|
||||
|
||||
xous::syscall::map_memory(
|
||||
|
|
@ -51,11 +51,12 @@ pub unsafe extern "C" fn start_rust() -> ! {
|
|||
|
||||
crate::debug::DEFAULT.enable_rx();
|
||||
println!("Allocating IRQ...");
|
||||
xous::rsyscall(xous::SysCall::ClaimInterrupt(
|
||||
2,
|
||||
handle_irq as *mut usize,
|
||||
core::ptr::null_mut::<usize>(),
|
||||
))
|
||||
xous::claim_interrupt(2, handle_irq, core::ptr::null_mut::<usize>())
|
||||
// xous::rsyscall(xous::SysCall::ClaimInterrupt(
|
||||
// 2,
|
||||
// handle_irq as *mut usize,
|
||||
// core::ptr::null_mut::<usize>(),
|
||||
// ))
|
||||
.expect("couldn't claim interrupt");
|
||||
|
||||
main();
|
||||
|
|
|
|||
|
|
@ -11,9 +11,6 @@ mod baremetal;
|
|||
mod timer;
|
||||
// mod logstr;
|
||||
|
||||
#[cfg(baremetal)]
|
||||
use core::fmt::Write;
|
||||
|
||||
// fn print_and_yield(index: *mut usize) -> ! {
|
||||
// let num = index as usize;
|
||||
// loop {
|
||||
|
|
@ -25,6 +22,7 @@ use core::fmt::Write;
|
|||
#[cfg_attr(baremetal, no_mangle)]
|
||||
fn main() {
|
||||
println!("Starting to initialize the timer");
|
||||
#[cfg(not(baremetal))]
|
||||
xous::arch::ensure_connection().unwrap();
|
||||
timer::init();
|
||||
|
||||
|
|
@ -62,6 +60,8 @@ fn main() {
|
|||
println!("Loop {}", counter);
|
||||
}
|
||||
counter += 1;
|
||||
|
||||
#[cfg(not(baremetal))]
|
||||
std::thread::sleep(std::time::Duration::from_millis(500));
|
||||
// if counter & 2 == 0 {
|
||||
// xous::syscall::yield_slice();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ fn timer_tick(_irq_no: usize, _arg: *mut usize) {
|
|||
println!(">>> Timer tick");
|
||||
let ptr = TIMER_BASE as *mut usize;
|
||||
|
||||
xous::rsyscall(xous::SysCall::ReturnToParentI(0, 0)).expect("couldn't return to parent");
|
||||
xous::rsyscall(xous::SysCall::ReturnToParentI(xous::PID::new(1).unwrap(), 0)).expect("couldn't return to parent");
|
||||
|
||||
// acknowledge the timer
|
||||
unsafe { ptr.add(6).write_volatile(1) };
|
||||
|
|
@ -49,25 +49,28 @@ pub fn init() {
|
|||
#[cfg(not(baremetal))]
|
||||
pub fn init() {}
|
||||
|
||||
// pub fn load(value: u32) {
|
||||
// let ptr = TIMER_BASE as *mut usize;
|
||||
// unsafe {
|
||||
// ptr.add(0).write_volatile(value as usize);
|
||||
// }
|
||||
// }
|
||||
#[cfg(baremetal)]
|
||||
pub fn load(value: u32) {
|
||||
let ptr = TIMER_BASE as *mut usize;
|
||||
unsafe {
|
||||
ptr.add(0).write_volatile(value as usize);
|
||||
}
|
||||
}
|
||||
|
||||
// pub fn reload(value: u32) {
|
||||
// let ptr = TIMER_BASE as *mut usize;
|
||||
// unsafe {
|
||||
// ptr.add(1).write_volatile(value as usize);
|
||||
// }
|
||||
// }
|
||||
#[cfg(baremetal)]
|
||||
pub fn reload(value: u32) {
|
||||
let ptr = TIMER_BASE as *mut usize;
|
||||
unsafe {
|
||||
ptr.add(1).write_volatile(value as usize);
|
||||
}
|
||||
}
|
||||
|
||||
// pub fn en(en: bool) {
|
||||
// let ptr = TIMER_BASE as *mut usize;
|
||||
// if en {
|
||||
// unsafe { ptr.add(2).write_volatile(1) };
|
||||
// } else {
|
||||
// unsafe { ptr.add(2).write_volatile(0) };
|
||||
// }
|
||||
// }
|
||||
#[cfg(baremetal)]
|
||||
pub fn en(en: bool) {
|
||||
let ptr = TIMER_BASE as *mut usize;
|
||||
if en {
|
||||
unsafe { ptr.add(2).write_volatile(1) };
|
||||
} else {
|
||||
unsafe { ptr.add(2).write_volatile(0) };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue