mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
fix more UTRA issues; migrate to dual-UART for kernel/console messages
This commit is contained in:
parent
10aacd76c4
commit
cab4c7d4a9
8 changed files with 309 additions and 29 deletions
|
|
@ -18,6 +18,12 @@ fi
|
|||
|
||||
cargo xtask hw-image ../betrusted-soc/build/software/soc.svd
|
||||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "build failed, aborting!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Copying to target..."
|
||||
if [ $# -gt 0 ]
|
||||
then
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ mod log_string;
|
|||
use core::fmt::Write;
|
||||
use log_string::LogString;
|
||||
|
||||
use utralib::generated::*;
|
||||
|
||||
#[cfg(not(target_os = "none"))]
|
||||
mod implementation {
|
||||
use core::fmt::{Error, Write};
|
||||
|
|
@ -105,7 +107,7 @@ mod implementation {
|
|||
|
||||
pub fn init() -> Output {
|
||||
let uart = xous::syscall::map_memory(
|
||||
xous::MemoryAddress::new(0xf000_4000),
|
||||
xous::MemoryAddress::new(utra::uart::HW_UART_BASE),
|
||||
None,
|
||||
4096,
|
||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use core::fmt::{Error, Write};
|
||||
|
||||
use utralib::generated::*;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! print
|
||||
{
|
||||
|
|
@ -39,30 +41,34 @@ pub static mut DEFAULT_UART_ADDR: *mut usize = 0x0000_0000 as *mut usize;
|
|||
pub const DEFAULT: Uart = Uart {};
|
||||
|
||||
impl Uart {
|
||||
pub fn putc(&self, _c: u8) {
|
||||
// unsafe {
|
||||
// if DEFAULT_UART_ADDR as usize == 0 {
|
||||
// let uart = xous::syscall::map_memory(
|
||||
// xous::MemoryAddress::new(0xf000_1000),
|
||||
// None,
|
||||
// 4096,
|
||||
// xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
// )
|
||||
// .expect("couldn't map uart");
|
||||
// DEFAULT_UART_ADDR = uart.as_mut_ptr() as _;
|
||||
// println!("Mapped UART @ {:08x}", uart.addr.get());
|
||||
// // core::mem::forget(uart);
|
||||
pub fn putc(&self, c: u8) {
|
||||
unsafe {
|
||||
if DEFAULT_UART_ADDR as usize == 0 {
|
||||
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 uart");
|
||||
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(2, handle_irq, core::ptr::null_mut::<usize>()).expect("unable to allocate IRQ");
|
||||
// self.enable_rx();
|
||||
// }
|
||||
// let base = DEFAULT_UART_ADDR;
|
||||
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();
|
||||
}
|
||||
let base = DEFAULT_UART_ADDR;
|
||||
let mut uart_csr = CSR::new(DEFAULT_UART_ADDR as *mut u32);
|
||||
|
||||
// // Wait until TXFULL is `0`
|
||||
// while base.add(1).read_volatile() != 0 {}
|
||||
// base.add(0).write_volatile(c as usize)
|
||||
// };
|
||||
// Wait until TXFULL is `0`
|
||||
while uart_csr.r(utra::console::TXFULL) != 0 {}
|
||||
uart_csr.wo(utra::console::RXTX, c as u32);
|
||||
/*
|
||||
while base.add(1).read_volatile() != 0 {}
|
||||
base.add(0).write_volatile(c as usize)*/
|
||||
};
|
||||
}
|
||||
|
||||
pub fn enable_rx(&self) {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ mod timer;
|
|||
// }
|
||||
|
||||
extern crate utralib;
|
||||
use utralib::generated::*;
|
||||
|
||||
fn move_lfsr(mut lfsr: u32) -> u32 {
|
||||
lfsr ^= lfsr >> 7;
|
||||
|
|
@ -67,7 +68,21 @@ fn shell_main() -> ! {
|
|||
let mut lfsr = 0xace1u32;
|
||||
let dark = graphics_server::Color::from(0);
|
||||
let light = graphics_server::Color::from(!0);
|
||||
|
||||
let gpio_base = xous::syscall::map_memory(
|
||||
xous::MemoryAddress::new(utra::gpio::HW_GPIO_BASE),
|
||||
None,
|
||||
4096,
|
||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
)
|
||||
.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, 0);
|
||||
|
||||
loop {
|
||||
//let elapsed_time = ticktimer_server::elapsed_ms(ticktimer_conn).unwrap();
|
||||
//println!("elapsed time: {}ms", elapsed_time);
|
||||
|
||||
// println!("Sending a scalar message with id {}...", counter + 4096);
|
||||
// match xous::syscall::send_message(
|
||||
// log_conn,
|
||||
|
|
@ -93,8 +108,6 @@ fn shell_main() -> ! {
|
|||
// lfsr = move_lfsr(lfsr);
|
||||
|
||||
loop {
|
||||
let elapsed_time = ticktimer_server::elapsed_ms(ticktimer_conn).unwrap();
|
||||
println!("elapsed time: {}ms", elapsed_time);
|
||||
|
||||
match graphics_server::set_style(
|
||||
graphics_conn,
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ pub extern "C" fn init(arg_offset: *const u32, init_offset: *const u32, rpt_offs
|
|||
mem::MemoryManager::with_mut(|memory_manager| {
|
||||
memory_manager
|
||||
.map_range(
|
||||
HW_UART_BASE as *mut u8,
|
||||
utra::uart::HW_UART_BASE as *mut u8,
|
||||
((debug::SUPERVISOR_UART.base as u32) & !4095) as *mut u8,
|
||||
4096,
|
||||
PID::new(1).unwrap(),
|
||||
|
|
@ -76,8 +76,8 @@ pub extern "C" fn init(arg_offset: *const u32, init_offset: *const u32, rpt_offs
|
|||
});
|
||||
println!("KMAIN: Supervisor mode started...");
|
||||
debug::SUPERVISOR_UART.enable_rx();
|
||||
println!("Claiming IRQ 0 via syscall...");
|
||||
xous_kernel::claim_interrupt(0, debug::irq, 0 as *mut usize).expect("Couldn't claim interrupt 0");
|
||||
println!("Claiming IRQ {} via syscall...", utra::uart::UART_IRQ);
|
||||
xous_kernel::claim_interrupt(utra::uart::UART_IRQ, debug::irq, 0 as *mut usize).expect("Couldn't claim debug interrupt");
|
||||
print!("}} ");
|
||||
|
||||
// Print the processed kernel arguments
|
||||
|
|
|
|||
137
loader/Cargo.lock
generated
137
loader/Cargo.lock
generated
|
|
@ -1,11 +1,58 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.33.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"strsim",
|
||||
"textwrap",
|
||||
"unicode-width",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.1.14"
|
||||
|
|
@ -17,6 +64,15 @@ dependencies = [
|
|||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
|
|
@ -35,14 +91,30 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"lazy_static",
|
||||
"rand",
|
||||
"utralib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3d72d5477478f85bd00b6521780dfba1ec6cdaadcf90b8b181c36d7de561f9b"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.7.3"
|
||||
|
|
@ -84,8 +156,73 @@ dependencies = [
|
|||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "svd2utra"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"quick-xml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
|
||||
|
||||
[[package]]
|
||||
name = "utralib"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"svd2utra",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.9.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
|
|
|||
|
|
@ -20,3 +20,6 @@ default = ["debug-print"]
|
|||
codegen-units = 1 # 1 better optimizations
|
||||
debug = true # symbols are nice and they don't increase the size on Flash
|
||||
lto = "fat"
|
||||
|
||||
[target.'cfg(not(any(windows, unix)))'.dependencies]
|
||||
utralib = { path = "../utralib"}
|
||||
|
|
|
|||
115
utralib/Cargo.lock
generated
115
utralib/Cargo.lock
generated
|
|
@ -1,5 +1,67 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.33.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"strsim",
|
||||
"textwrap",
|
||||
"unicode-width",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.3.3"
|
||||
|
|
@ -15,16 +77,67 @@ dependencies = [
|
|||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "svd2utra"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"quick-xml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utra"
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
|
||||
|
||||
[[package]]
|
||||
name = "utralib"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"svd2utra",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
|
|
|||
Loading…
Reference in a new issue