mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
Merge pull request #43 from betrusted-io/hardware
GAM initial abstractions laid down, warnings cleaned up.
This commit is contained in:
commit
f7543f2c2a
39 changed files with 1110 additions and 127 deletions
38
Cargo.lock
generated
38
Cargo.lock
generated
|
|
@ -390,6 +390,7 @@ dependencies = [
|
||||||
"com",
|
"com",
|
||||||
"graphics-server",
|
"graphics-server",
|
||||||
"heapless",
|
"heapless",
|
||||||
|
"ime-frontend",
|
||||||
"keyboard",
|
"keyboard",
|
||||||
"log",
|
"log",
|
||||||
"log-server",
|
"log-server",
|
||||||
|
|
@ -525,12 +526,49 @@ version = "2.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ime-frontend"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"graphics-server",
|
||||||
|
"heapless",
|
||||||
|
"log",
|
||||||
|
"log-server",
|
||||||
|
"rkyv",
|
||||||
|
"ticktimer-server",
|
||||||
|
"utralib",
|
||||||
|
"xous",
|
||||||
|
"xous-names",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ime-plugin-shell"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"heapless",
|
||||||
|
"log",
|
||||||
|
"log-server",
|
||||||
|
"rkyv",
|
||||||
|
"ticktimer-server",
|
||||||
|
"utralib",
|
||||||
|
"xous",
|
||||||
|
"xous-names",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "0.4.7"
|
version = "0.4.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "kernel-test"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"utralib",
|
||||||
|
"xous",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "keyboard"
|
name = "keyboard"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,13 @@ members = [
|
||||||
"services/fcc-agent",
|
"services/fcc-agent",
|
||||||
"services/xous-names",
|
"services/xous-names",
|
||||||
"services/keyboard",
|
"services/keyboard",
|
||||||
|
"services/kernel-test",
|
||||||
"services/trng",
|
"services/trng",
|
||||||
"services/gam",
|
"services/gam",
|
||||||
"services/benchmark",
|
"services/benchmark",
|
||||||
"services/benchmark-target",
|
"services/benchmark-target",
|
||||||
|
"services/ime-frontend",
|
||||||
|
"services/ime-plugin-shell",
|
||||||
"svd2utra",
|
"svd2utra",
|
||||||
"xtask",
|
"xtask",
|
||||||
"imports/blitstr-ref",
|
"imports/blitstr-ref",
|
||||||
|
|
@ -40,6 +43,8 @@ default-members = [
|
||||||
"imports/com_rs-ref",
|
"imports/com_rs-ref",
|
||||||
"services/benchmark",
|
"services/benchmark",
|
||||||
"services/benchmark-target",
|
"services/benchmark-target",
|
||||||
|
"services/ime-frontend",
|
||||||
|
"services/ime-plugin-shell",
|
||||||
]
|
]
|
||||||
|
|
||||||
# These packages have custom RUSTFLAGS, so if they
|
# These packages have custom RUSTFLAGS, so if they
|
||||||
|
|
|
||||||
|
|
@ -593,6 +593,12 @@ pub fn virt_to_phys(virt: usize) -> Result<usize, xous_kernel::Error> {
|
||||||
|
|
||||||
// Ensure the entry hasn't already been mapped.
|
// Ensure the entry hasn't already been mapped.
|
||||||
if l0_pt.entries[vpn0] & MMUFlags::VALID.bits() == 0 {
|
if l0_pt.entries[vpn0] & MMUFlags::VALID.bits() == 0 {
|
||||||
|
// The memory has been reserved, but isn't pointing anywhere yet.
|
||||||
|
if l0_pt.entries[vpn0] != 0 {
|
||||||
|
return Err(xous_kernel::Error::MemoryInUse);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The address hasn't been allocated
|
||||||
return Err(xous_kernel::Error::BadAddress);
|
return Err(xous_kernel::Error::BadAddress);
|
||||||
}
|
}
|
||||||
Ok((l0_pt.entries[vpn0] >> 10) << 12)
|
Ok((l0_pt.entries[vpn0] >> 10) << 12)
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ use core::fmt::{Error, Write};
|
||||||
#[cfg(baremetal)]
|
#[cfg(baremetal)]
|
||||||
use utralib::generated::*;
|
use utralib::generated::*;
|
||||||
|
|
||||||
|
#[allow(dead_code)] // this is unused in hosted mode, kill the warning
|
||||||
|
static mut INITIALIZED: bool = false;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
not(test),
|
not(test),
|
||||||
|
|
@ -67,12 +70,17 @@ pub struct Uart {
|
||||||
#[cfg(baremetal)]
|
#[cfg(baremetal)]
|
||||||
impl Uart {
|
impl Uart {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn enable_rx(self) {
|
pub fn init(self) {
|
||||||
|
unsafe { INITIALIZED = true };
|
||||||
let mut uart_csr = CSR::new(0xffcf_0000 as *mut u32);
|
let mut uart_csr = CSR::new(0xffcf_0000 as *mut u32);
|
||||||
uart_csr.rmwf(utra::uart::EV_ENABLE_RX, 1);
|
uart_csr.rmwf(utra::uart::EV_ENABLE_RX, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn putc(&self, c: u8) {
|
pub fn putc(&self, c: u8) {
|
||||||
|
if unsafe { INITIALIZED != true } {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let mut uart_csr = CSR::new(0xffcf_0000 as *mut u32);
|
let mut uart_csr = CSR::new(0xffcf_0000 as *mut u32);
|
||||||
// Wait until TXFULL is `0`
|
// Wait until TXFULL is `0`
|
||||||
while uart_csr.r(utra::uart::TXFULL) != 0 {
|
while uart_csr.r(utra::uart::TXFULL) != 0 {
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,8 @@ pub extern "C" fn init(arg_offset: *const u32, init_offset: *const u32, rpt_offs
|
||||||
)
|
)
|
||||||
.expect("unable to map serial port")
|
.expect("unable to map serial port")
|
||||||
});
|
});
|
||||||
|
debug::Uart{}.init();
|
||||||
println!("KMAIN: Supervisor mode started...");
|
println!("KMAIN: Supervisor mode started...");
|
||||||
debug::Uart{}.enable_rx();
|
|
||||||
println!("Claiming IRQ {} via syscall...", utra::uart::UART_IRQ);
|
println!("Claiming IRQ {} via syscall...", utra::uart::UART_IRQ);
|
||||||
xous_kernel::claim_interrupt(utra::uart::UART_IRQ, debug::irq, 0 as *mut usize)
|
xous_kernel::claim_interrupt(utra::uart::UART_IRQ, debug::irq, 0 as *mut usize)
|
||||||
.expect("Couldn't claim debug interrupt");
|
.expect("Couldn't claim debug interrupt");
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,6 @@ impl MemoryManager {
|
||||||
|
|
||||||
// Look for a sequence of `size` pages that are free.
|
// Look for a sequence of `size` pages that are free.
|
||||||
for potential_start in (initial..end - size).step_by(PAGE_SIZE) {
|
for potential_start in (initial..end - size).step_by(PAGE_SIZE) {
|
||||||
// println!(" Checking {:08x}...", potential_start);
|
|
||||||
let mut all_free = true;
|
let mut all_free = true;
|
||||||
for check_page in (potential_start..potential_start + size).step_by(PAGE_SIZE) {
|
for check_page in (potential_start..potential_start + size).step_by(PAGE_SIZE) {
|
||||||
if !crate::arch::mem::address_available(check_page) {
|
if !crate::arch::mem::address_available(check_page) {
|
||||||
|
|
@ -313,7 +312,6 @@ impl MemoryManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
for potential_start in (start..initial).step_by(PAGE_SIZE) {
|
for potential_start in (start..initial).step_by(PAGE_SIZE) {
|
||||||
// println!(" Checking {:08x}...", potential_start);
|
|
||||||
let mut all_free = true;
|
let mut all_free = true;
|
||||||
for check_page in (potential_start..potential_start + size).step_by(PAGE_SIZE) {
|
for check_page in (potential_start..potential_start + size).step_by(PAGE_SIZE) {
|
||||||
if !crate::arch::mem::address_available(check_page) {
|
if !crate::arch::mem::address_available(check_page) {
|
||||||
|
|
@ -334,7 +332,6 @@ impl MemoryManager {
|
||||||
return Ok(potential_start as *mut u8);
|
return Ok(potential_start as *mut u8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// println!("Couldn't find virtual address");
|
|
||||||
Err(xous_kernel::Error::BadAddress)
|
Err(xous_kernel::Error::BadAddress)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ pub struct SystemServices {
|
||||||
_syscall_depth: usize,
|
_syscall_depth: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub enum ProcessState {
|
pub enum ProcessState {
|
||||||
/// This is an unallocated, free process
|
/// This is an unallocated, free process
|
||||||
Free,
|
Free,
|
||||||
|
|
@ -62,6 +62,20 @@ pub enum ProcessState {
|
||||||
Sleeping,
|
Sleeping,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl core::fmt::Debug for ProcessState {
|
||||||
|
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::result::Result<(), core::fmt::Error> {
|
||||||
|
use ProcessState::*;
|
||||||
|
match *self {
|
||||||
|
Free => write!(fmt, "Free"),
|
||||||
|
Allocated => write!(fmt, "Allocated"),
|
||||||
|
Setup(ti) => write!(fmt, "Setup({:?})", ti),
|
||||||
|
Ready(rt) => write!(fmt, "Ready({:b})", rt),
|
||||||
|
Running(rt) => write!(fmt, "Running({:b})", rt),
|
||||||
|
Sleeping => write!(fmt, "Sleeping"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for ProcessState {
|
impl Default for ProcessState {
|
||||||
fn default() -> ProcessState {
|
fn default() -> ProcessState {
|
||||||
ProcessState::Free
|
ProcessState::Free
|
||||||
|
|
@ -541,7 +555,6 @@ impl SystemServices {
|
||||||
/// Mark the specified context as ready to run. If the thread is Sleeping, mark
|
/// Mark the specified context as ready to run. If the thread is Sleeping, mark
|
||||||
/// it as Ready.
|
/// it as Ready.
|
||||||
pub fn ready_thread(&mut self, pid: PID, tid: TID) -> Result<(), xous_kernel::Error> {
|
pub fn ready_thread(&mut self, pid: PID, tid: TID) -> Result<(), xous_kernel::Error> {
|
||||||
// assert!(tid == INITIAL_TID);
|
|
||||||
let process = self.get_process_mut(pid)?;
|
let process = self.get_process_mut(pid)?;
|
||||||
process.state = match process.state {
|
process.state = match process.state {
|
||||||
ProcessState::Free => {
|
ProcessState::Free => {
|
||||||
|
|
@ -684,10 +697,13 @@ impl SystemServices {
|
||||||
ProcessState::Running(new_mask)
|
ProcessState::Running(new_mask)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// println!(
|
// println!(
|
||||||
// "switch_to_thread({}:{:?}): New state is {:?}",
|
// "switch_to_thread({}:{:?}): New state is {:?} Thread is ",
|
||||||
// pid, tid, process.state
|
// pid, tid, process.state
|
||||||
// );
|
// );
|
||||||
|
// ArchProcess::with_current(|current| current.print_thread());
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -705,6 +721,8 @@ impl SystemServices {
|
||||||
// "switch_from_thread({}:{}): Old state was {:?}",
|
// "switch_from_thread({}:{}): Old state was {:?}",
|
||||||
// pid, tid, process.state
|
// pid, tid, process.state
|
||||||
// );
|
// );
|
||||||
|
// ArchProcess::with_current(|current| current.print_thread());
|
||||||
|
|
||||||
process.state = match process.state {
|
process.state = match process.state {
|
||||||
ProcessState::Running(x) if x & (1 << tid) != 0 => panic!(
|
ProcessState::Running(x) if x & (1 << tid) != 0 => panic!(
|
||||||
"PID {} thread {} was already queued for running when `switch_from_thread()` was called",
|
"PID {} thread {} was already queued for running when `switch_from_thread()` was called",
|
||||||
|
|
@ -798,6 +816,7 @@ impl SystemServices {
|
||||||
"\n\r KERNEL({},{}): Activating process {} thread {}",
|
"\n\r KERNEL({},{}): Activating process {} thread {}",
|
||||||
previous_pid, previous_tid, new_pid, new_tid
|
previous_pid, previous_tid, new_pid, new_tid
|
||||||
);
|
);
|
||||||
|
//ArchProcess::with_current(|current| current.print_thread());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save state if the PID has changed. This will activate the new memory
|
// Save state if the PID has changed. This will activate the new memory
|
||||||
|
|
@ -823,11 +842,6 @@ impl SystemServices {
|
||||||
new.state
|
new.state
|
||||||
);
|
);
|
||||||
if new_tid == 0 {
|
if new_tid == 0 {
|
||||||
print!(
|
|
||||||
"PID {}: Looking for a valid context in the mask {:08b}",
|
|
||||||
new_pid, x,
|
|
||||||
);
|
|
||||||
//new_tid = 0;
|
|
||||||
new_tid = (new.current_thread + 1) as usize;
|
new_tid = (new.current_thread + 1) as usize;
|
||||||
while x & (1 << new_tid) == 0 {
|
while x & (1 << new_tid) == 0 {
|
||||||
new_tid += 1;
|
new_tid += 1;
|
||||||
|
|
@ -835,22 +849,22 @@ impl SystemServices {
|
||||||
new_tid = 0;
|
new_tid = 0;
|
||||||
} else if new_tid == (new.current_thread + 1) as usize {
|
} else if new_tid == (new.current_thread + 1) as usize {
|
||||||
// If we've looped around, return an error.
|
// If we've looped around, return an error.
|
||||||
println!("Looked through all contexts and couldn't find one that was ready");
|
// println!("Looked through all contexts and couldn't find one that was ready");
|
||||||
return Err(xous_kernel::Error::ProcessNotFound);
|
return Err(xous_kernel::Error::ProcessNotFound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new.current_thread = new_tid as _;
|
new.current_thread = new_tid as _;
|
||||||
println!(" -- picked thread {}", new_tid);
|
// println!(" -- picked thread {}", new_tid);
|
||||||
} else if x & (1 << new_tid) == 0 {
|
} else if x & (1 << new_tid) == 0 {
|
||||||
println!(
|
// println!(
|
||||||
"thread is {:?}, which is not valid for new thread {}",
|
// "thread is {:?}, which is not valid for new thread {}",
|
||||||
new.state, new_tid
|
// new.state, new_tid
|
||||||
);
|
// );
|
||||||
return Err(xous_kernel::Error::ProcessNotFound);
|
return Err(xous_kernel::Error::ProcessNotFound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProcessState::Sleeping => {
|
ProcessState::Sleeping => {
|
||||||
println!("PID {} was sleeping", new_pid);
|
// println!("PID {} was sleeping", new_pid);
|
||||||
return Err(xous_kernel::Error::ProcessNotFound);
|
return Err(xous_kernel::Error::ProcessNotFound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -928,50 +942,53 @@ impl SystemServices {
|
||||||
// previous_pid, previous.state, can_resume
|
// previous_pid, previous.state, can_resume
|
||||||
// );
|
// );
|
||||||
} else {
|
} else {
|
||||||
// if self.current_thread(previous_pid) == new_tid {
|
let new = self.get_process_mut(new_pid)?;
|
||||||
// if !can_resume {
|
|
||||||
// panic!("tried to switch to our own context without resume");
|
|
||||||
// }
|
|
||||||
// return Ok(new_tid);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// we can get here if we're activating a new thread in the same process
|
// If we wanted to switch to a "new" thread, and it's the same
|
||||||
//return Ok(new_tid);
|
// as the one we just switched from, do nothing.
|
||||||
|
if new.current_thread == new_tid {
|
||||||
|
if !can_resume {
|
||||||
|
panic!("tried to switch to our own context without resume");
|
||||||
|
}
|
||||||
|
return Ok(new_tid);
|
||||||
|
}
|
||||||
|
|
||||||
let new = self.get_process_mut(new_pid)?; /*
|
// Transition to the new state.
|
||||||
new.state = match new.state {
|
new.state = if let ProcessState::Running(x) = new.state {
|
||||||
ProcessState::Running(x) if (x & 1 << new_tid) == 0 => {
|
let previous_tid = new.current_thread;
|
||||||
return Err(xous_kernel::Error::ProcessNotFound)
|
// If no new thread is specified, take the previous
|
||||||
}
|
// thread. If that is not runnable, do a round-robin
|
||||||
// ProcessState::Running(x) => {
|
// search for the next available thread.
|
||||||
// if can_resume {
|
if new_tid == 0 {
|
||||||
// ProcessState::Running((x | (1 << previous_tid)) & !(1 << new_tid))
|
new_tid = (new.current_thread + 1) as usize;
|
||||||
// } else {
|
while x & (1 << new_tid) == 0 {
|
||||||
// ProcessState::Running(x | (1 << previous_tid))
|
new_tid += 1;
|
||||||
// }
|
if new_tid > arch::process::MAX_THREAD {
|
||||||
// }
|
new_tid = 0;
|
||||||
other => */
|
} else if new_tid == (new.current_thread + 1) as usize {
|
||||||
panic!(
|
// If we've looped around, return an error.
|
||||||
"PID {} invalid process state (not Running): {:?}",
|
return Err(xous_kernel::Error::ProcessNotFound);
|
||||||
previous_pid, new.state
|
}
|
||||||
) /*,
|
}
|
||||||
}*/
|
new.current_thread = new_tid as _;
|
||||||
;
|
} else if x & (1 << new_tid) == 0 {
|
||||||
// if advance_thread {
|
return Err(xous_kernel::Error::ProcessNotFound);
|
||||||
// new.current_thread += 1;
|
}
|
||||||
// if new.current_thread as TID > arch::process::MAX_CONTEXT {
|
// Mark the previous TID as being runnable, and remove the new TID
|
||||||
// new.current_thread = 0;
|
// from the list of threads that can be run.
|
||||||
// }
|
ProcessState::Running(x & !(1 << new_tid) | if can_resume { 1 << previous_tid } else { 0 })
|
||||||
// }
|
} else {
|
||||||
|
panic!(
|
||||||
|
"PID {} invalid process state (not Running): {:?}",
|
||||||
|
previous_pid, new.state
|
||||||
|
)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
// self.pid = new_pid;
|
|
||||||
|
|
||||||
let mut process = crate::arch::process::Process::current();
|
let mut process = crate::arch::process::Process::current();
|
||||||
|
|
||||||
// Restore the previous context, if one exists.
|
// Restore the previous thread, if one exists.
|
||||||
process.set_thread(new_tid)?;
|
process.set_thread(new_tid)?;
|
||||||
// self.processes[new_pid.get() as usize - 1].current_thread = new_tid as u8;
|
|
||||||
// let _ctx = process.current_context();
|
|
||||||
|
|
||||||
Ok(new_tid)
|
Ok(new_tid)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -578,8 +578,6 @@ pub fn handle(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallResult
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallResult {
|
pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallResult {
|
||||||
// let pid = arch::current_pid();
|
|
||||||
|
|
||||||
match call {
|
match call {
|
||||||
SysCall::MapMemory(phys, virt, size, req_flags) => {
|
SysCall::MapMemory(phys, virt, size, req_flags) => {
|
||||||
MemoryManager::with_mut(|mm| {
|
MemoryManager::with_mut(|mm| {
|
||||||
|
|
|
||||||
|
|
@ -178,9 +178,8 @@ mod implementation {
|
||||||
use crate::WorkRequest;
|
use crate::WorkRequest;
|
||||||
use com_rs_ref as com_rs;
|
use com_rs_ref as com_rs;
|
||||||
use com_rs::*;
|
use com_rs::*;
|
||||||
use log::{error, info};
|
use log::error;
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
use heapless::Vec;
|
use heapless::Vec;
|
||||||
use heapless::consts::*;
|
use heapless::consts::*;
|
||||||
|
|
||||||
|
|
@ -201,7 +200,7 @@ mod implementation {
|
||||||
0xDEAD as u16
|
0xDEAD as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wait_txrx(&mut self, tx: u16, timeout: Option<u32>) -> u16 {
|
pub fn wait_txrx(&mut self, _tx: u16, _timeout: Option<u32>) -> u16 {
|
||||||
0xDEAD as u16
|
0xDEAD as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ heapless = "0.5"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
com = { path = "../com"}
|
com = { path = "../com"}
|
||||||
blitstr-ref = { path = "../../imports/blitstr-ref" }
|
blitstr-ref = { path = "../../imports/blitstr-ref" }
|
||||||
|
ime-frontend = {path="../ime-frontend"}
|
||||||
|
|
||||||
|
|
||||||
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use xous::{Message, ScalarMessage};
|
use xous::{Message, ScalarMessage};
|
||||||
use graphics_server::api::{Point, Rectangle, TextView, TextViewResult, Gid, Line, RoundedRectangle, Circle};
|
use graphics_server::api::{Rectangle, TextView, Gid, Line, RoundedRectangle, Circle};
|
||||||
use blitstr_ref as blitstr;
|
|
||||||
use blitstr::{GlyphStyle, Cursor};
|
|
||||||
|
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Unarchive, Copy, Clone)]
|
#[derive(Debug, rkyv::Archive, rkyv::Unarchive, Copy, Clone)]
|
||||||
pub enum GamObjectType {
|
pub enum GamObjectType {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
use core::cmp::Ordering;
|
use core::cmp::Ordering;
|
||||||
use heapless::binary_heap::{BinaryHeap, Max};
|
use heapless::binary_heap::{BinaryHeap, Max};
|
||||||
use heapless::FnvIndexMap;
|
use heapless::FnvIndexMap;
|
||||||
use heapless::Vec;
|
|
||||||
use heapless::consts::*;
|
use heapless::consts::*;
|
||||||
use graphics_server::*;
|
use graphics_server::*;
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
|
|
||||||
use crate::api::*;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||||
pub enum CanvasState {
|
pub enum CanvasState {
|
||||||
// the initial state of every Canvas. Not drawable.
|
// the initial state of every Canvas. Not drawable.
|
||||||
|
|
@ -41,6 +38,8 @@ pub struct Canvas {
|
||||||
// enables scroll/pan of objects within a region
|
// enables scroll/pan of objects within a region
|
||||||
pan_offset: Point,
|
pan_offset: Point,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl Canvas {
|
impl Canvas {
|
||||||
pub fn new(clip_rect: Rectangle, trust_level: u8,
|
pub fn new(clip_rect: Rectangle, trust_level: u8,
|
||||||
trng_conn: xous::CID, pan_offset: Option<Point>) -> Result<Canvas, xous::Error> {
|
trng_conn: xous::CID, pan_offset: Option<Point>) -> Result<Canvas, xous::Error> {
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,17 @@ use api::*;
|
||||||
|
|
||||||
use rkyv::Write;
|
use rkyv::Write;
|
||||||
use rkyv::Unarchive;
|
use rkyv::Unarchive;
|
||||||
use graphics_server::api::{TextOp, TextView, TextViewResult};
|
use graphics_server::api::{TextOp, TextView};
|
||||||
|
|
||||||
use graphics_server::api::{Rectangle, Point, Gid, TextBounds, Line};
|
use graphics_server::api::{Point, Gid, Line};
|
||||||
use log::{error, info};
|
use log::info;
|
||||||
|
|
||||||
/// this "posts" a textview -- it's not a "draw" as the update is neither guaranteed nor instantaneous
|
/// this "posts" a textview -- it's not a "draw" as the update is neither guaranteed nor instantaneous
|
||||||
/// the GAM first has to check that the textview is allowed to be updated, and then it will decide when
|
/// the GAM first has to check that the textview is allowed to be updated, and then it will decide when
|
||||||
/// the actual screen update is allowed
|
/// the actual screen update is allowed
|
||||||
pub fn post_textview(gam_cid: xous::CID, tv: &mut TextView) -> Result<(), xous::Error> {
|
pub fn post_textview(gam_cid: xous::CID, tv: &mut TextView) -> Result<(), xous::Error> {
|
||||||
tv.set_op(TextOp::Render);
|
tv.set_op(TextOp::Render);
|
||||||
let mut rkyv_tv = api::Opcode::RenderTextView(*tv);
|
let rkyv_tv = api::Opcode::RenderTextView(*tv);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&rkyv_tv).expect("GAM_API: couldn't archive textview");
|
let pos = writer.archive(&rkyv_tv).expect("GAM_API: couldn't archive textview");
|
||||||
let mut xous_buffer = writer.into_inner();
|
let mut xous_buffer = writer.into_inner();
|
||||||
|
|
@ -39,14 +39,14 @@ pub fn post_textview(gam_cid: xous::CID, tv: &mut TextView) -> Result<(), xous::
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_line(gam_cid: xous::CID, gid: Gid, line: Line) -> Result<(), xous::Error> {
|
pub fn draw_line(gam_cid: xous::CID, gid: Gid, line: Line) -> Result<(), xous::Error> {
|
||||||
let mut rkyv_tv = api::Opcode::RenderObject(
|
let rkyv_tv = api::Opcode::RenderObject(
|
||||||
GamObject {
|
GamObject {
|
||||||
canvas: gid,
|
canvas: gid,
|
||||||
obj: GamObjectType::Line(line),
|
obj: GamObjectType::Line(line),
|
||||||
});
|
});
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&rkyv_tv).expect("GAM_API: couldn't archive GamObject");
|
let pos = writer.archive(&rkyv_tv).expect("GAM_API: couldn't archive GamObject");
|
||||||
let mut xous_buffer = writer.into_inner();
|
let xous_buffer = writer.into_inner();
|
||||||
|
|
||||||
xous_buffer.lend(gam_cid, pos as u32).expect("GAM_API: GamObject operation failure");
|
xous_buffer.lend(gam_cid, pos as u32).expect("GAM_API: GamObject operation failure");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,13 @@ mod canvas;
|
||||||
use canvas::*;
|
use canvas::*;
|
||||||
|
|
||||||
use blitstr_ref as blitstr;
|
use blitstr_ref as blitstr;
|
||||||
use blitstr::{Cursor, GlyphStyle};
|
use blitstr::GlyphStyle;
|
||||||
use com::*;
|
|
||||||
use graphics_server::*;
|
use graphics_server::*;
|
||||||
|
|
||||||
use log::{error, info};
|
use log::info;
|
||||||
use xous::String;
|
|
||||||
|
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
|
|
||||||
use heapless::binary_heap::{BinaryHeap, Max};
|
|
||||||
use heapless::FnvIndexMap;
|
use heapless::FnvIndexMap;
|
||||||
use heapless::consts::*;
|
use heapless::consts::*;
|
||||||
|
|
||||||
|
|
@ -138,13 +135,18 @@ fn xmain() -> ! {
|
||||||
// the status bar is a trusted element managed by the OS, and we are chosing to domicile this in the GAM process for now
|
// the status bar is a trusted element managed by the OS, and we are chosing to domicile this in the GAM process for now
|
||||||
xous::create_thread_simple(status_thread, chatlayout.status.gid()).expect("GAM: couldn't create status thread");
|
xous::create_thread_simple(status_thread, chatlayout.status.gid()).expect("GAM: couldn't create status thread");
|
||||||
|
|
||||||
|
// connect to the IME front end, and set its canvas
|
||||||
|
/*
|
||||||
|
info!("GAM: acquiring connection to IMEF...");
|
||||||
|
let imef_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_IME_FRONT).expect("GAM: can't connect to the IME front end");
|
||||||
|
ime_frontend::set_canvas(imef_conn, chatlayout.input).expect("GAM: couldn't set IMEF canvas");
|
||||||
|
*/
|
||||||
let mut last_time: u64 = ticktimer_server::elapsed_ms(ticktimer_conn).unwrap();
|
let mut last_time: u64 = ticktimer_server::elapsed_ms(ticktimer_conn).unwrap();
|
||||||
info!("GAM: entering main loop");
|
info!("GAM: entering main loop");
|
||||||
loop {
|
loop {
|
||||||
// /*
|
|
||||||
let maybe_env = xous::try_receive_message(gam_sid).unwrap();
|
let maybe_env = xous::try_receive_message(gam_sid).unwrap();
|
||||||
match maybe_env {
|
match maybe_env {
|
||||||
Some(envelope) => { // */
|
Some(envelope) => {
|
||||||
// let envelope = xous::receive_message(gam_sid).unwrap();
|
// let envelope = xous::receive_message(gam_sid).unwrap();
|
||||||
if debug1 {info!("GAM: Message: {:?}", envelope); }
|
if debug1 {info!("GAM: Message: {:?}", envelope); }
|
||||||
if let Ok(opcode) = Opcode::try_from(&envelope.body) {
|
if let Ok(opcode) = Opcode::try_from(&envelope.body) {
|
||||||
|
|
@ -222,9 +224,6 @@ fn xmain() -> ! {
|
||||||
// silently fail if a bogus Gid is given???
|
// silently fail if a bogus Gid is given???
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TextOp::ComputeBounds => {
|
|
||||||
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
_ => panic!("GAM: invalid mutable borrow message"),
|
_ => panic!("GAM: invalid mutable borrow message"),
|
||||||
|
|
@ -244,16 +243,16 @@ fn xmain() -> ! {
|
||||||
if canvas.is_drawable() {
|
if canvas.is_drawable() {
|
||||||
match obj.obj {
|
match obj.obj {
|
||||||
GamObjectType::Line(line) => {
|
GamObjectType::Line(line) => {
|
||||||
graphics_server::draw_line(gfx_conn, line);
|
graphics_server::draw_line(gfx_conn, line).expect("GAM: couldn't draw line");
|
||||||
},
|
},
|
||||||
GamObjectType::Circ(circ) => {
|
GamObjectType::Circ(circ) => {
|
||||||
graphics_server::draw_circle(gfx_conn, circ);
|
graphics_server::draw_circle(gfx_conn, circ).expect("GAM: couldn't draw circle");
|
||||||
},
|
},
|
||||||
GamObjectType::Rect(rect) => {
|
GamObjectType::Rect(rect) => {
|
||||||
graphics_server::draw_rectangle(gfx_conn, rect);
|
graphics_server::draw_rectangle(gfx_conn, rect).expect("GAM: couldn't draw rectangle");
|
||||||
},
|
},
|
||||||
GamObjectType::RoundRect(rr) => {
|
GamObjectType::RoundRect(rr) => {
|
||||||
graphics_server::draw_rounded_rectangle(gfx_conn, rr);
|
graphics_server::draw_rounded_rectangle(gfx_conn, rr).expect("GAM: couldn't draw rounded rectangle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -273,13 +272,13 @@ fn xmain() -> ! {
|
||||||
},
|
},
|
||||||
_ => xous::yield_slice(),
|
_ => xous::yield_slice(),
|
||||||
// envelope implements Drop(), which includes a call to syscall::return_memory(self.sender, message.buf)
|
// envelope implements Drop(), which includes a call to syscall::return_memory(self.sender, message.buf)
|
||||||
} // */
|
}
|
||||||
//graphics_server::flush(gfx_conn).expect("GAM: couldn't flush buffer to screen");
|
|
||||||
///*
|
|
||||||
if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) {
|
if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) {
|
||||||
if elapsed_time - last_time > 33 { // rate limit updates to 30fps
|
if elapsed_time - last_time > 33 { // rate limit updates to 30fps
|
||||||
|
last_time = elapsed_time;
|
||||||
graphics_server::flush(gfx_conn).expect("GAM: couldn't flush buffer to screen");
|
graphics_server::flush(gfx_conn).expect("GAM: couldn't flush buffer to screen");
|
||||||
}
|
}
|
||||||
}//*/
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
use crate::api::*;
|
|
||||||
|
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use com::api::BattStats;
|
use com::api::BattStats;
|
||||||
use graphics_server::*;
|
use graphics_server::*;
|
||||||
|
|
@ -18,7 +16,6 @@ pub fn status_thread(canvas_gid: [u32; 4]) {
|
||||||
|
|
||||||
let ticktimer_conn = xous::connect(xous::SID::from_bytes(b"ticktimer-server").unwrap()).unwrap();
|
let ticktimer_conn = xous::connect(xous::SID::from_bytes(b"ticktimer-server").unwrap()).unwrap();
|
||||||
let com_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_COM).expect("GAM|status: can't connect to COM");
|
let com_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_COM).expect("GAM|status: can't connect to COM");
|
||||||
let gfx_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_GFX).expect("GAM|status: can't connect to COM");
|
|
||||||
let gam_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_GAM).expect("GAM|status: can't connect to GAM");
|
let gam_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_GAM).expect("GAM|status: can't connect to GAM");
|
||||||
|
|
||||||
if debug1{info!("GAM|status: getting screen size");}
|
if debug1{info!("GAM|status: getting screen size");}
|
||||||
|
|
@ -46,7 +43,7 @@ pub fn status_thread(canvas_gid: [u32; 4]) {
|
||||||
battstats_tv.draw_border = false;
|
battstats_tv.draw_border = false;
|
||||||
battstats_tv.margin = Point::new(0, 0);
|
battstats_tv.margin = Point::new(0, 0);
|
||||||
|
|
||||||
let mut stats: BattStats = BattStats::default();
|
let mut stats: BattStats;
|
||||||
let mut last_time: u64 = ticktimer_server::elapsed_ms(ticktimer_conn).unwrap();
|
let mut last_time: u64 = ticktimer_server::elapsed_ms(ticktimer_conn).unwrap();
|
||||||
let mut stats_phase: usize = 0;
|
let mut stats_phase: usize = 0;
|
||||||
let mut last_seconds: usize = ((last_time / 1000) % 60) as usize;
|
let mut last_seconds: usize = ((last_time / 1000) % 60) as usize;
|
||||||
|
|
@ -59,6 +56,9 @@ pub fn status_thread(canvas_gid: [u32; 4]) {
|
||||||
)).expect("GAM|status: Can't draw border line");
|
)).expect("GAM|status: Can't draw border line");
|
||||||
|
|
||||||
com::request_battstat_events(xous::names::SERVER_NAME_STATUS, com_conn).expect("GAM|status: couldn't request events from COM");
|
com::request_battstat_events(xous::names::SERVER_NAME_STATUS, com_conn).expect("GAM|status: couldn't request events from COM");
|
||||||
|
// prime the loop
|
||||||
|
com::get_batt_stats_nb(com_conn).expect("Can't get battery stats from COM");
|
||||||
|
last_seconds = last_seconds - 1; // this will force the uptime to redraw
|
||||||
info!("GAM|status: starting main loop");
|
info!("GAM|status: starting main loop");
|
||||||
loop {
|
loop {
|
||||||
let maybe_env = xous::try_receive_message(status_sid).unwrap();
|
let maybe_env = xous::try_receive_message(status_sid).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::op::{HEIGHT, WIDTH};
|
||||||
use crate::api::{Point, DrawStyle};
|
use crate::api::{Point, DrawStyle};
|
||||||
use blitstr_ref as blitstr;
|
use blitstr_ref as blitstr;
|
||||||
use blitstr::{ClipRect};
|
use blitstr::{ClipRect};
|
||||||
use core::{cmp::{max, min}, ops::Add};
|
use core::{cmp::{max, min}};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, rkyv::Archive, rkyv::Unarchive)]
|
#[derive(Debug, Clone, Copy, rkyv::Archive, rkyv::Unarchive)]
|
||||||
pub struct Rectangle {
|
pub struct Rectangle {
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ use crate::api::{Point, Rectangle, Gid};
|
||||||
use blitstr_ref as blitstr;
|
use blitstr_ref as blitstr;
|
||||||
use blitstr::{GlyphStyle, Cursor};
|
use blitstr::{GlyphStyle, Cursor};
|
||||||
|
|
||||||
use log::info;
|
|
||||||
|
|
||||||
/// coordinates are local to the canvas, not absolute to the screen
|
/// coordinates are local to the canvas, not absolute to the screen
|
||||||
#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Unarchive)]
|
#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Unarchive)]
|
||||||
pub enum TextBounds {
|
pub enum TextBounds {
|
||||||
|
|
@ -46,12 +44,6 @@ impl From<usize> for TextOp {
|
||||||
// roughly 168 bytes to represent the rest of the struct, and we want to fill out the 4096 byte page with text
|
// roughly 168 bytes to represent the rest of the struct, and we want to fill out the 4096 byte page with text
|
||||||
const TEXTVIEW_LEN: usize = 3072;
|
const TEXTVIEW_LEN: usize = 3072;
|
||||||
|
|
||||||
#[derive(Copy, Clone, rkyv::Archive, Debug, rkyv::Unarchive)]
|
|
||||||
pub struct TextViewResult {
|
|
||||||
pub bounds_computed: Option<Rectangle>,
|
|
||||||
pub cursor: Cursor,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, rkyv::Archive, rkyv::Unarchive)]
|
#[derive(Copy, Clone, rkyv::Archive, rkyv::Unarchive)]
|
||||||
pub struct TextView {
|
pub struct TextView {
|
||||||
// this is the operation as specified for the GAM. Note this is different from the "op" when sent to graphics-server
|
// this is the operation as specified for the GAM. Note this is different from the "op" when sent to graphics-server
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ pub fn draw_textview(cid: CID, tv: &mut TextView) -> Result<(), xous::Error> {
|
||||||
use rkyv::Write;
|
use rkyv::Write;
|
||||||
use rkyv::Unarchive;
|
use rkyv::Unarchive;
|
||||||
|
|
||||||
let mut rkyv_tv = api::Opcode::DrawTextView(*tv);
|
let rkyv_tv = api::Opcode::DrawTextView(*tv);
|
||||||
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
||||||
let pos = writer.archive(&rkyv_tv).expect("couldn't archive textview");
|
let pos = writer.archive(&rkyv_tv).expect("couldn't archive textview");
|
||||||
let mut xous_buffer = writer.into_inner();
|
let mut xous_buffer = writer.into_inner();
|
||||||
|
|
@ -129,14 +129,13 @@ pub fn draw_textview(cid: CID, tv: &mut TextView) -> Result<(), xous::Error> {
|
||||||
|
|
||||||
let returned = unsafe { rkyv::archived_value::<api::Opcode>(xous_buffer.as_ref(), pos)};
|
let returned = unsafe { rkyv::archived_value::<api::Opcode>(xous_buffer.as_ref(), pos)};
|
||||||
if let rkyv::Archived::<api::Opcode>::DrawTextView(result) = returned {
|
if let rkyv::Archived::<api::Opcode>::DrawTextView(result) = returned {
|
||||||
let tvr: TextView = result.unarchive();
|
let tvr: TextView = result.unarchive();
|
||||||
tv.bounds_computed = tvr.bounds_computed;
|
tv.bounds_computed = tvr.bounds_computed;
|
||||||
tv.cursor = tvr.cursor;
|
tv.cursor = tvr.cursor;
|
||||||
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
let tvr = returned.unarchive();
|
let tvr = returned.unarchive();
|
||||||
info!("draw_textview saw a return of {:?}", tvr);
|
info!("draw_textview saw an unhandled return type of {:?}", tvr);
|
||||||
panic!("draw_textview got a return value from the server that isn't expected or handled");
|
Err(xous::Error::InternalError)
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ use api::Opcode;
|
||||||
|
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use rkyv::{archived_value, Unarchive, archived_value_mut};
|
use rkyv::{archived_value, Unarchive, archived_value_mut};
|
||||||
use core::convert::TryInto;
|
|
||||||
|
|
||||||
mod backend;
|
mod backend;
|
||||||
use backend::XousDisplay;
|
use backend::XousDisplay;
|
||||||
|
|
@ -163,13 +162,13 @@ fn xmain() -> ! {
|
||||||
TextBounds::BoundingBox(r) => {
|
TextBounds::BoundingBox(r) => {
|
||||||
tv.bounds_computed = Some(r);
|
tv.bounds_computed = Some(r);
|
||||||
},
|
},
|
||||||
TextBounds::GrowableFromBr(br, width) => {
|
TextBounds::GrowableFromBr(_br, _width) => {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
},
|
},
|
||||||
TextBounds::GrowableFromTl(tl, width) => {
|
TextBounds::GrowableFromTl(_tl, _width) => {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
},
|
},
|
||||||
TextBounds::GrowableFromBl(bl, width) => {
|
TextBounds::GrowableFromBl(_bl, _width) => {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
use crate::api::{Circle, DrawStyle, Line, Pixel, PixelColor, Point, Rectangle, TextView, RoundedRectangle};
|
use crate::api::{Circle, DrawStyle, Line, Pixel, PixelColor, Point, Rectangle, RoundedRectangle};
|
||||||
use log::info;
|
|
||||||
use blitstr_ref as blitstr;
|
|
||||||
|
|
||||||
/// LCD Frame buffer bounds
|
/// LCD Frame buffer bounds
|
||||||
pub const LCD_WORDS_PER_LINE: usize = 11;
|
pub const LCD_WORDS_PER_LINE: usize = 11;
|
||||||
|
|
@ -456,7 +454,7 @@ impl Iterator for RoundedRectangleIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rounded_rectangle(fb: &mut LcdFB, rr: RoundedRectangle) {
|
pub fn rounded_rectangle(fb: &mut LcdFB, rr: RoundedRectangle) {
|
||||||
/// left off: compute the four quadrants
|
// compute the four quadrants
|
||||||
// call the rr iterator on the rectangle
|
// call the rr iterator on the rectangle
|
||||||
// then call it on one each of the four circle quadrants
|
// then call it on one each of the four circle quadrants
|
||||||
|
|
||||||
|
|
|
||||||
24
services/ime-frontend/Cargo.toml
Normal file
24
services/ime-frontend/Cargo.toml
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
[package]
|
||||||
|
name = "ime-frontend"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["bunnie <bunnie@kosagi.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
description = "IME front end"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
xous = { path = "../../xous-rs" }
|
||||||
|
heapless = "0.5.6"
|
||||||
|
log-server = { path = "../log-server" }
|
||||||
|
ticktimer-server = { path = "../ticktimer-server" }
|
||||||
|
xous-names = { path = "../xous-names" }
|
||||||
|
graphics-server = {path = "../graphics-server"}
|
||||||
|
log = "0.4"
|
||||||
|
rkyv = { version = "0.3.1", default_features = false }
|
||||||
|
|
||||||
|
|
||||||
|
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
||||||
|
utralib = { path = "../../utralib"}
|
||||||
|
|
||||||
|
[features]
|
||||||
|
debugprint = []
|
||||||
|
default = [] # "debugprint"
|
||||||
37
services/ime-frontend/src/api.rs
Normal file
37
services/ime-frontend/src/api.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
use xous::{Message, ScalarMessage};
|
||||||
|
|
||||||
|
use graphics_server::Gid;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Debug, rkyv::Archive, rkyv::Unarchive)]
|
||||||
|
pub enum Opcode {
|
||||||
|
/// informs me where my canvas is
|
||||||
|
SetCanvas(Gid),
|
||||||
|
|
||||||
|
/// set prediction. Must be a String of the name of a server that is loaded in the system.
|
||||||
|
SetPrediction(xous::String<256>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl core::convert::TryFrom<& Message> for Opcode {
|
||||||
|
type Error = &'static str;
|
||||||
|
fn try_from(message: & Message) -> Result<Self, Self::Error> {
|
||||||
|
match message {
|
||||||
|
Message::Scalar(m) => match m.id {
|
||||||
|
0 => Ok(Opcode::SetCanvas(Gid::new([m.arg1 as _, m.arg2 as _, m.arg3 as _, m.arg4 as _]))),
|
||||||
|
_ => Err("IMEF api: unknown Scalar ID"),
|
||||||
|
},
|
||||||
|
_ => Err("IMEF api: unhandled message type"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<Message> for Opcode {
|
||||||
|
fn into(self) -> Message {
|
||||||
|
match self {
|
||||||
|
Opcode::SetCanvas(gid) => Message::Scalar(ScalarMessage {
|
||||||
|
id: 0, arg1: gid.gid()[0] as _, arg2: gid.gid()[1] as _, arg3: gid.gid()[2] as _, arg4: gid.gid()[3] as _
|
||||||
|
}),
|
||||||
|
_ => panic!("IMEF api: Opcode type not handled by into()"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
services/ime-frontend/src/lib.rs
Normal file
9
services/ime-frontend/src/lib.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#![cfg_attr(target_os = "none", no_std)]
|
||||||
|
|
||||||
|
pub mod api;
|
||||||
|
use xous::{CID, send_message};
|
||||||
|
|
||||||
|
pub fn set_canvas(cid: CID, g: graphics_server::Gid) -> Result<(), xous::Error> {
|
||||||
|
send_message(cid, api::Opcode::SetCanvas(g).into())?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
105
services/ime-frontend/src/main.rs
Normal file
105
services/ime-frontend/src/main.rs
Normal file
|
|
@ -0,0 +1,105 @@
|
||||||
|
#![cfg_attr(target_os = "none", no_std)]
|
||||||
|
#![cfg_attr(target_os = "none", no_main)]
|
||||||
|
|
||||||
|
mod api;
|
||||||
|
use api::*;
|
||||||
|
|
||||||
|
use core::convert::TryFrom;
|
||||||
|
|
||||||
|
use log::{error, info};
|
||||||
|
|
||||||
|
use graphics_server::Gid;
|
||||||
|
use heapless::Vec;
|
||||||
|
use heapless::consts::U32;
|
||||||
|
|
||||||
|
/*
|
||||||
|
what else do we need:
|
||||||
|
- current string that is being built up
|
||||||
|
- cursor position in string, so we can do insertion/deletion
|
||||||
|
*/
|
||||||
|
fn draw_canvas(gam_conn: xous::CID, canvas: Gid, pred_conn: xous::CID, newkeys: [char; 4]) {
|
||||||
|
|
||||||
|
// this is just reference to remind me how to decode the key array
|
||||||
|
for &k in newkeys.iter() {
|
||||||
|
if k != '\u{0000}' {
|
||||||
|
key_queue.push(k).unwrap();
|
||||||
|
if debug1{info!("IMEF: got key '{}'", k);}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[xous::xous_main]
|
||||||
|
fn xmain() -> ! {
|
||||||
|
let debug1 = true;
|
||||||
|
log_server::init_wait().unwrap();
|
||||||
|
info!("IMEF: my PID is {}", xous::process::id());
|
||||||
|
|
||||||
|
let imef_sid = xous_names::register_name(xous::names::SERVER_NAME_IME_FRONT).expect("IMEF: can't register server");
|
||||||
|
info!("IMEF: registered with NS -- {:?}", imef_sid);
|
||||||
|
|
||||||
|
let kbd_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_KBD).expect("IMEF: can't connect to KBD");
|
||||||
|
keyboard::request_events(xous::names::SERVER_NAME_IME_FRONT, kbd_conn).expect("IMEF: couldn't request events from keyboard");
|
||||||
|
|
||||||
|
let gam_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_GAM).expect("IMEF: can't connect to GAM");
|
||||||
|
|
||||||
|
// set a "default" prediction that is a shell-like history buffer of things previously typed
|
||||||
|
let mut prediction_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_IME_PLUGIN_SHELL)
|
||||||
|
.expect("IMEF: can't connect to shell prediction engine");
|
||||||
|
|
||||||
|
// The first message should be my Gid from the GAM.
|
||||||
|
let mut canvas: Gid = Gid::new([0,0,0,0]);
|
||||||
|
info!("IMEF: waiting for my canvas Gid");
|
||||||
|
loop {
|
||||||
|
let envelope = xous::receive_message(imef_sid).unwrap();
|
||||||
|
if let Ok(opcode) = Opcode::try_from(&envelope.body) {
|
||||||
|
match opcode {
|
||||||
|
Opcode::SetCanvas(g) => {
|
||||||
|
canvas = g;
|
||||||
|
},
|
||||||
|
_ => info!("IMEF: expected canvas Gid, but got {:?}", opcode)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
info!("IMEF: expected canvas Gid, but got other message first {:?}", envelope);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut key_queue: Vec<char, U32> = Vec::new();
|
||||||
|
info!("IMEF: entering main loop");
|
||||||
|
loop {
|
||||||
|
let envelope = xous::receive_message(imef_sid).unwrap();
|
||||||
|
if let Ok(opcode) = Opcode::try_from(&envelope.body) {
|
||||||
|
match opcode {
|
||||||
|
Opcode::SetCanvas(g) => {
|
||||||
|
// there are valid reasons for this to happen, but it should be rare.
|
||||||
|
info!("IMEF: warning: canvas Gid has been reset");
|
||||||
|
canvas = g;
|
||||||
|
},
|
||||||
|
_ => info!("IMEF: unhandled opcode {:?}", opcode)
|
||||||
|
}
|
||||||
|
} else if let xous::Message::Borrow(m) = &msg.body {
|
||||||
|
let buf = unsafe { xous::XousBuffer::from_memory_message(m) };
|
||||||
|
let bytes = Pin::new(buf.as_ref());
|
||||||
|
let value = unsafe {
|
||||||
|
archived_value::<api::Opcode>(&bytes, m.id as usize)
|
||||||
|
};
|
||||||
|
match &*value {
|
||||||
|
rkyv::Archived::<api::Opcode>::SetPrediction(rkyv_s) => {
|
||||||
|
let s: xous::String<4096> = rkyv_s.unarchive();
|
||||||
|
prediction_conn = xous_names::request_connection(s.as_str());
|
||||||
|
},
|
||||||
|
_ => panic!("IME_SH: invalid response from server -- corruption occurred in MemoryMessage")
|
||||||
|
};
|
||||||
|
} else if let Ok(opcode) = keyboard::api::Opcode::try_from(&envelope.body) {
|
||||||
|
match opcode {
|
||||||
|
keyboard::api::Opcode::KeyboardEvent(keys) => {
|
||||||
|
draw_canvas(gam_conn, canvas, prediction_conn, keys);
|
||||||
|
},
|
||||||
|
_ => error!("IMEF: received KBD event opcode that wasn't expected"),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
info!("IMEF: expected canvas Gid, but got {:?}", envelope);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
23
services/ime-plugin-shell/Cargo.toml
Normal file
23
services/ime-plugin-shell/Cargo.toml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
[package]
|
||||||
|
name = "ime-plugin-shell"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["bunnie <bunnie@kosagi.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
description = "IME Shell Plugin"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
xous = { path = "../../xous-rs" }
|
||||||
|
heapless = "0.5.6"
|
||||||
|
log-server = { path = "../log-server" }
|
||||||
|
ticktimer-server = { path = "../ticktimer-server" }
|
||||||
|
xous-names = { path = "../xous-names" }
|
||||||
|
log = "0.4"
|
||||||
|
rkyv = { version = "0.3.1", default_features = false }
|
||||||
|
|
||||||
|
|
||||||
|
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
||||||
|
utralib = { path = "../../utralib"}
|
||||||
|
|
||||||
|
[features]
|
||||||
|
debugprint = []
|
||||||
|
default = [] # "debugprint"
|
||||||
21
services/ime-plugin-shell/src/api.rs
Normal file
21
services/ime-plugin-shell/src/api.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
use xous::{Message, ScalarMessage};
|
||||||
|
|
||||||
|
#[derive(Debug, rkyv::Archive, rkyv::Unarchive)]
|
||||||
|
pub struct Prediction {
|
||||||
|
index: u32,
|
||||||
|
string: xous::String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Debug, rkyv::Archive, rkyv::Unarchive)]
|
||||||
|
pub enum Opcode {
|
||||||
|
/// update with the latest input candidate. Replaces the previous input.
|
||||||
|
Input(xous::String),
|
||||||
|
|
||||||
|
/// feed back to the IME plugin as to what was picked, so predictions can be updated
|
||||||
|
Picked(xous::String),
|
||||||
|
|
||||||
|
/// fetch the prediction at a given index, where the index is ordered from 0..N, where 0 is the most likely prediction
|
||||||
|
/// if there is no prediction available, just return an empty string
|
||||||
|
Prediction(Prediction),
|
||||||
|
}
|
||||||
60
services/ime-plugin-shell/src/lib.rs
Normal file
60
services/ime-plugin-shell/src/lib.rs
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
#![cfg_attr(target_os = "none", no_std)]
|
||||||
|
|
||||||
|
pub mod api;
|
||||||
|
use xous::{CID, send_message, String};
|
||||||
|
|
||||||
|
pub fn set_input(cid: CID, s: String) -> Result<(), xous::Error> {
|
||||||
|
use rkyv::Write;
|
||||||
|
|
||||||
|
let mut rkyv_input = api::Opcode::Input(*s);
|
||||||
|
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
||||||
|
let pos = writer.archive(&rkyv_s).expect("IMES|API: couldn't archive input string");
|
||||||
|
let mut xous_buffer = writer.into_inner();
|
||||||
|
|
||||||
|
xous_buffer.lend(cid, pos as u32).expect("IMES|API: set_input operation failure");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn feedback_picked(cid: CID, s: String) -> Result<(), xous::Error> {
|
||||||
|
use rkyv::Write;
|
||||||
|
|
||||||
|
let mut rkyv_input = api::Opcode::Picked(*s);
|
||||||
|
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
||||||
|
let pos = writer.archive(&rkyv_s).expect("IMES|API: couldn't archive picked string");
|
||||||
|
let mut xous_buffer = writer.into_inner();
|
||||||
|
|
||||||
|
xous_buffer.lend(cid, pos as u32).expect("IMES|API: feedback_picked operation failure");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_prediction(cid: CID, index: u32) -> Result<xous::String, xous::Error> {
|
||||||
|
use rkyv::Write;
|
||||||
|
use rkyv::Unarchive;
|
||||||
|
|
||||||
|
let mut mutstr = xous::String::new();
|
||||||
|
let mut prediction = api::Prediction {
|
||||||
|
index,
|
||||||
|
string: mutstr
|
||||||
|
};
|
||||||
|
let mut pred_op = api::Opcode::Prediction(*prediction);
|
||||||
|
|
||||||
|
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
|
||||||
|
let pos = writer.archive(&pred_op).expect("IMES|API: couldn't archive prediction request");
|
||||||
|
let mut xous_buffer = writer.into_inner();
|
||||||
|
|
||||||
|
xous_buffer.lend_mut(cid, pos as u32).expect("IMES|API: prediction fetch operation failure");
|
||||||
|
|
||||||
|
let returned = unsafe { rkyv::archived_value::<api::Opcode>(xous_buffer.as_ref(), pos)};
|
||||||
|
if let rkyv::Archived::<api::Opcode>::Prediction(result) = returned {
|
||||||
|
let pred_r: api::Prediction = result.unarchive();
|
||||||
|
|
||||||
|
let retstring: xous::String = pred_r.string.clone();
|
||||||
|
Ok(retstring)
|
||||||
|
} else {
|
||||||
|
let r = returned.unarchive();
|
||||||
|
info!("get_prediciton saw an unhandled return of {:?}", r);
|
||||||
|
Err(xous::Error::InvalidString)
|
||||||
|
}
|
||||||
|
}
|
||||||
87
services/ime-plugin-shell/src/main.rs
Normal file
87
services/ime-plugin-shell/src/main.rs
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
#![cfg_attr(target_os = "none", no_std)]
|
||||||
|
#![cfg_attr(target_os = "none", no_main)]
|
||||||
|
|
||||||
|
mod api;
|
||||||
|
use api::*;
|
||||||
|
|
||||||
|
use core::convert::TryFrom;
|
||||||
|
|
||||||
|
use log::{error, info};
|
||||||
|
|
||||||
|
use heapless::spsc::Queue;
|
||||||
|
use heapless::consts::U3;
|
||||||
|
|
||||||
|
#[xous::xous_main]
|
||||||
|
fn xmain() -> ! {
|
||||||
|
let debug1 = true;
|
||||||
|
log_server::init_wait().unwrap();
|
||||||
|
info!("IME_SH: my PID is {}", xous::process::id());
|
||||||
|
|
||||||
|
let ime_sh_sid = xous_names::register_name(xous::names::SERVER_NAME_IME_PLUGIN_SHELL).expect("IME_SH: can't register server");
|
||||||
|
info!("IME_SH: registered with NS -- {:?}", ime_sh_sid);
|
||||||
|
|
||||||
|
let imef_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_IME_FRONT).expect("IME_SH: can't connect to IMEF");
|
||||||
|
|
||||||
|
info!("IME_SH: ready to accept requests");
|
||||||
|
|
||||||
|
let mut history: Queue<xous::String, U3> = Queue::new(); // this has 2^3 elements = 8
|
||||||
|
let history_max = 8;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let envelope = xous::receive_message(ime_sh_sid).unwrap();
|
||||||
|
if let xous::Message::Borrow(m) = &msg.body {
|
||||||
|
let buf = unsafe { xous::XousBuffer::from_memory_message(m) };
|
||||||
|
let bytes = Pin::new(buf.as_ref());
|
||||||
|
let value = unsafe {
|
||||||
|
archived_value::<api::Opcode>(&bytes, m.id as usize)
|
||||||
|
};
|
||||||
|
match &*value {
|
||||||
|
rkyv::Archived::<api::Opcode>::Input(rkyv_s) => {
|
||||||
|
let s: xous::String<4096> = rkyv_s.unarchive();
|
||||||
|
if history.len() == history_max {
|
||||||
|
history.dequeue()?;
|
||||||
|
}
|
||||||
|
history.enqueue(s).expect("IME_SH: couldn't store history");
|
||||||
|
},
|
||||||
|
rkyv::Archived::<api::Opcode>::Picked(rkyv_s) => {
|
||||||
|
let s: xous::String<4096> = rkyv_s.unarchive();
|
||||||
|
if debug1{info!("Received prediction feedback but ignored: {}", s);}
|
||||||
|
},
|
||||||
|
_ => panic!("IME_SH: invalid response from server -- corruption occurred in MemoryMessage")
|
||||||
|
};
|
||||||
|
} else if let xous::Message::MutableBorrow(m) = &msg.body {
|
||||||
|
let mut buf = unsafe { xous::XousBuffer::from_memory_message(m) };
|
||||||
|
let value = unsafe {
|
||||||
|
archived_value_mut::<api::Opcode>(Pin::new(buf.as_mut()), m.id as usize)
|
||||||
|
};
|
||||||
|
match &*value {
|
||||||
|
rkyv::Archived::<api::Opcode>::Prediction(pred_r) => {
|
||||||
|
let mut prediction: api::Prediction = pred_r.unarchive();
|
||||||
|
if history.len() > 0 {
|
||||||
|
let mut index = prediction.index;
|
||||||
|
if index >= history.len() {
|
||||||
|
index = history.len() - 1;
|
||||||
|
}
|
||||||
|
let mut i = history_len();
|
||||||
|
let mut retstr = xous::String::new();
|
||||||
|
for s in history.iter() {
|
||||||
|
// iterator is from oldest to newest, so do some math to go from newest to oldest
|
||||||
|
if (history.len() - i) == index {
|
||||||
|
retstr = s;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
prediction.string = s;
|
||||||
|
} else { // there is no history
|
||||||
|
// return the empty string
|
||||||
|
prediction.string = xous::String::new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
info!("IME_SH: received unknown message type {}", envelope);
|
||||||
|
panic!("IME_SH: received unknown message type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
services/kernel-test/Cargo.toml
Normal file
16
services/kernel-test/Cargo.toml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
[package]
|
||||||
|
name = "kernel-test"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Sean Cross <sean@xobs.io>"]
|
||||||
|
edition = "2018"
|
||||||
|
description = "Program to test various aspects of the kernel"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
xous = { path = "../../xous-rs" }
|
||||||
|
|
||||||
|
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
||||||
|
utralib = { path = "../../utralib"}
|
||||||
|
|
||||||
|
[features]
|
||||||
|
logging = [] # adding this allocates the UART for logging of Xous
|
||||||
|
default = ["logging"]
|
||||||
5
services/kernel-test/README.md
Normal file
5
services/kernel-test/README.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Kernel Test
|
||||||
|
|
||||||
|
Run various tests inside the kernel.
|
||||||
|
|
||||||
|
This is supposed to be the only program running.
|
||||||
17
services/kernel-test/build.rs
Normal file
17
services/kernel-test/build.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
// NOTE: Adapted from cortex-m/build.rs
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let target = env::var("TARGET").unwrap();
|
||||||
|
|
||||||
|
let target_os = target.split('-').nth(2).unwrap_or("none");
|
||||||
|
|
||||||
|
// If we're not running on a desktop-class operating system, emit the "baremetal"
|
||||||
|
// config setting. This will enable software to do tasks such as
|
||||||
|
// managing memory.
|
||||||
|
if target_os == "none" {
|
||||||
|
println!("cargo:rustc-cfg=baremetal");
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
|
}
|
||||||
111
services/kernel-test/src/debug.rs
Normal file
111
services/kernel-test/src/debug.rs
Normal file
|
|
@ -0,0 +1,111 @@
|
||||||
|
use core::fmt::{Error, Write};
|
||||||
|
|
||||||
|
use utralib::generated::*;
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! print
|
||||||
|
{
|
||||||
|
($($args:tt)+) => ({
|
||||||
|
use core::fmt::Write;
|
||||||
|
let _ = write!(crate::debug::Uart {}, $($args)+);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! println
|
||||||
|
{
|
||||||
|
() => ({
|
||||||
|
print!("\r\n")
|
||||||
|
});
|
||||||
|
($fmt:expr) => ({
|
||||||
|
print!(concat!($fmt, "\r\n"))
|
||||||
|
});
|
||||||
|
($fmt:expr, $($args:tt)+) => ({
|
||||||
|
print!(concat!($fmt, "\r\n"), $($args)+)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_irq(irq_no: usize, arg: *mut usize) {
|
||||||
|
print!("Handling IRQ {} (arg: {:08x}): ", irq_no, arg as usize);
|
||||||
|
|
||||||
|
while let Some(c) = { crate::debug::Uart {} }.getc() {
|
||||||
|
print!("{}", c as char);
|
||||||
|
}
|
||||||
|
println!();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Uart {}
|
||||||
|
|
||||||
|
// this is a hack to bypass an explicit initialization/allocation step for the debug structure
|
||||||
|
pub static mut DEFAULT_UART_ADDR: *mut usize = 0x0000_0000 as *mut usize;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn putc(&self, c: u8) {
|
||||||
|
if unsafe { DEFAULT_UART_ADDR } as usize == 0 {
|
||||||
|
self.map_uart();
|
||||||
|
}
|
||||||
|
let mut uart_csr = CSR::new(unsafe { DEFAULT_UART_ADDR as *mut u32 });
|
||||||
|
|
||||||
|
// Wait until TXFULL is `0`
|
||||||
|
while uart_csr.r(utra::uart::TXFULL) != 0 {}
|
||||||
|
uart_csr.wo(utra::uart::RXTX, c as u32);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn enable_rx(&self) {
|
||||||
|
let mut uart_csr = CSR::new(unsafe { DEFAULT_UART_ADDR as *mut u32 });
|
||||||
|
uart_csr.rmwf(utra::uart::EV_ENABLE_RX, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn getc(&self) -> Option<u8> {
|
||||||
|
if unsafe { DEFAULT_UART_ADDR } as usize == 0 {
|
||||||
|
self.map_uart();
|
||||||
|
}
|
||||||
|
let mut uart_csr = CSR::new(unsafe { DEFAULT_UART_ADDR as *mut u32 });
|
||||||
|
match uart_csr.rf(utra::uart::EV_PENDING_RX) {
|
||||||
|
0 => None,
|
||||||
|
ack => {
|
||||||
|
let c = Some(uart_csr.rf(utra::uart::RXTX_RXTX) as u8);
|
||||||
|
uart_csr.wfo(utra::uart::EV_PENDING_RX, ack);
|
||||||
|
c
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Write for Uart {
|
||||||
|
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||||
|
for c in s.bytes() {
|
||||||
|
self.putc(c);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
57
services/kernel-test/src/log_string.rs
Normal file
57
services/kernel-test/src/log_string.rs
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
use core::fmt;
|
||||||
|
use core::slice;
|
||||||
|
|
||||||
|
pub struct LogString<'a> {
|
||||||
|
raw_slice: &'a mut [u8],
|
||||||
|
pub s: &'a str,
|
||||||
|
pub len: u32,
|
||||||
|
msg_len: &'a mut Option<xous::MemorySize>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> LogString<'a> {
|
||||||
|
pub fn from_message(message: &'a mut xous::MemoryMessage) -> LogString<'a> {
|
||||||
|
// println!("LOG: Message address is at {:08x} (whole message: {:?})", message.buf.addr.get(), message);
|
||||||
|
let raw_slice = unsafe { slice::from_raw_parts_mut(message.buf.as_ptr() as *mut u8, message.buf.len() as usize) };
|
||||||
|
let starting_length = message.valid.map(|x| x.get()).unwrap_or(0);
|
||||||
|
|
||||||
|
// print!("LOG: String @ {:08x}:", message.buf.as_ptr() as usize);
|
||||||
|
// for offset in 0..starting_length {
|
||||||
|
// print!(" {:02x}", raw_slice[offset]);
|
||||||
|
// }
|
||||||
|
// println!(" (length: {})", starting_length);
|
||||||
|
|
||||||
|
LogString {
|
||||||
|
s: unsafe {
|
||||||
|
core::str::from_utf8_unchecked(slice::from_raw_parts(
|
||||||
|
message.buf.as_ptr() as *mut u8,
|
||||||
|
starting_length,
|
||||||
|
))
|
||||||
|
},
|
||||||
|
len: starting_length as u32,
|
||||||
|
raw_slice,
|
||||||
|
msg_len: &mut message.valid,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> fmt::Display for LogString<'a> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(f, "{}", self.s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> fmt::Write for LogString<'a> {
|
||||||
|
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
|
||||||
|
for c in s.bytes() {
|
||||||
|
if self.len as usize < self.raw_slice.len() {
|
||||||
|
self.raw_slice[self.len as usize] = c;
|
||||||
|
self.len += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.s = unsafe {
|
||||||
|
core::str::from_utf8_unchecked(slice::from_raw_parts(self.raw_slice.as_ptr(), self.len as usize))
|
||||||
|
};
|
||||||
|
*self.msg_len = Some(xous::MemorySize::new(self.len as usize).unwrap());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
336
services/kernel-test/src/main.rs
Normal file
336
services/kernel-test/src/main.rs
Normal file
|
|
@ -0,0 +1,336 @@
|
||||||
|
#![cfg_attr(target_os = "none", no_std)]
|
||||||
|
#![cfg_attr(target_os = "none", no_main)]
|
||||||
|
|
||||||
|
#[cfg(baremetal)]
|
||||||
|
#[macro_use]
|
||||||
|
mod debug;
|
||||||
|
|
||||||
|
use core::fmt::Write;
|
||||||
|
use xous::String;
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "none"))]
|
||||||
|
mod implementation {
|
||||||
|
use core::fmt::{Error, Write};
|
||||||
|
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
|
|
||||||
|
enum ControlMessage {
|
||||||
|
Text(String),
|
||||||
|
Byte(u8),
|
||||||
|
Exit,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Output {
|
||||||
|
tx: Sender<ControlMessage>,
|
||||||
|
rx: Receiver<ControlMessage>,
|
||||||
|
stdout: std::io::Stdout,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init() -> Output {
|
||||||
|
let (tx, rx) = channel();
|
||||||
|
|
||||||
|
Output {
|
||||||
|
tx,
|
||||||
|
rx,
|
||||||
|
stdout: std::io::stdout(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Output {
|
||||||
|
pub fn run(&mut self) {
|
||||||
|
use std::io::Write;
|
||||||
|
loop {
|
||||||
|
match self.rx.recv_timeout(std::time::Duration::from_millis(50)) {
|
||||||
|
Ok(msg) => match msg {
|
||||||
|
ControlMessage::Exit => break,
|
||||||
|
ControlMessage::Text(s) => print!("{}", s),
|
||||||
|
ControlMessage::Byte(s) => {
|
||||||
|
let mut handle = self.stdout.lock();
|
||||||
|
handle.write_all(&[s]).unwrap();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(std::sync::mpsc::RecvTimeoutError::Timeout) => {}
|
||||||
|
Err(e) => panic!("Error: {}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_writer(&self) -> OutputWriter {
|
||||||
|
OutputWriter {
|
||||||
|
tx: self.tx.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for Output {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
self.tx.send(ControlMessage::Exit).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Write for Output {
|
||||||
|
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||||
|
// It would be nice if this worked with &str
|
||||||
|
self.tx.send(ControlMessage::Text(s.to_owned())).unwrap();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct OutputWriter {
|
||||||
|
tx: Sender<ControlMessage>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OutputWriter {
|
||||||
|
pub fn putc(&self, c: u8) {
|
||||||
|
self.tx.send(ControlMessage::Byte(c)).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Write for OutputWriter {
|
||||||
|
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||||
|
// It would be nice if this worked with &str
|
||||||
|
self.tx.send(ControlMessage::Text(s.to_owned())).unwrap();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "none")]
|
||||||
|
mod implementation {
|
||||||
|
use core::fmt::{Error, Write};
|
||||||
|
use utralib::generated::*;
|
||||||
|
|
||||||
|
pub struct Output {}
|
||||||
|
|
||||||
|
pub fn init() -> Output {
|
||||||
|
if cfg!(feature = "logging") {
|
||||||
|
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 serial port");
|
||||||
|
unsafe { crate::debug::DEFAULT_UART_ADDR = uart.as_mut_ptr() as _ };
|
||||||
|
println!("Mapped UART @ {:08x}", uart.addr.get());
|
||||||
|
|
||||||
|
println!("Process: map success!");
|
||||||
|
crate::debug::DEFAULT.enable_rx();
|
||||||
|
|
||||||
|
println!("Allocating IRQ...");
|
||||||
|
xous::syscall::claim_interrupt(
|
||||||
|
utra::console::CONSOLE_IRQ,
|
||||||
|
handle_irq,
|
||||||
|
core::ptr::null_mut::<usize>(),
|
||||||
|
)
|
||||||
|
.expect("couldn't claim interrupt");
|
||||||
|
println!("Claimed IRQ {}", utra::console::CONSOLE_IRQ);
|
||||||
|
}
|
||||||
|
Output {}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Output {
|
||||||
|
pub fn get_writer(&self) -> OutputWriter {
|
||||||
|
OutputWriter {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run(&mut self) {
|
||||||
|
loop {
|
||||||
|
xous::wait_event();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_irq(irq_no: usize, arg: *mut usize) {
|
||||||
|
if cfg!(feature = "logging") {
|
||||||
|
print!("Handling IRQ {} (arg: {:08x}): ", irq_no, arg as usize);
|
||||||
|
|
||||||
|
while let Some(c) = crate::debug::DEFAULT.getc() {
|
||||||
|
print!("0x{:02x}", c);
|
||||||
|
}
|
||||||
|
println!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct OutputWriter {}
|
||||||
|
|
||||||
|
impl OutputWriter {
|
||||||
|
pub fn putc(&self, c: u8) {
|
||||||
|
if cfg!(feature = "logging") {
|
||||||
|
let mut uart_csr = CSR::new(unsafe { crate::debug::DEFAULT_UART_ADDR as *mut u32 });
|
||||||
|
|
||||||
|
// Wait until TXFULL is `0`
|
||||||
|
while uart_csr.r(utra::uart::TXFULL) != 0 {}
|
||||||
|
uart_csr.wo(utra::uart::RXTX, c as u32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Write for OutputWriter {
|
||||||
|
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||||
|
for c in s.bytes() {
|
||||||
|
self.putc(c);
|
||||||
|
if c == '\n' as u8 {
|
||||||
|
self.putc('\r' as u8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_scalar(
|
||||||
|
output: &mut implementation::OutputWriter,
|
||||||
|
sender: xous::MessageSender,
|
||||||
|
msg: &xous::ScalarMessage,
|
||||||
|
sender_pid: xous::PID,
|
||||||
|
) {
|
||||||
|
match msg.id {
|
||||||
|
1000 => writeln!(output, "PANIC from PID {} | {}", sender_pid, sender).unwrap(),
|
||||||
|
1100 => (),
|
||||||
|
1101..=1132 => {
|
||||||
|
let mut output_bfr = [0u8; core::mem::size_of::<usize>() * 4];
|
||||||
|
let output_iter = output_bfr.iter_mut();
|
||||||
|
|
||||||
|
// Combine the four arguments to form a single
|
||||||
|
// contiguous buffer. Note: The buffer size will change
|
||||||
|
// depending on the platfor's `usize` length.
|
||||||
|
let arg1_bytes = msg.arg1.to_le_bytes();
|
||||||
|
let arg2_bytes = msg.arg2.to_le_bytes();
|
||||||
|
let arg3_bytes = msg.arg3.to_le_bytes();
|
||||||
|
let arg4_bytes = msg.arg4.to_le_bytes();
|
||||||
|
let input_iter = arg1_bytes
|
||||||
|
.iter()
|
||||||
|
.chain(arg2_bytes.iter())
|
||||||
|
.chain(arg3_bytes.iter())
|
||||||
|
.chain(arg4_bytes.iter());
|
||||||
|
for (dest, src) in output_iter.zip(input_iter) {
|
||||||
|
*dest = *src;
|
||||||
|
}
|
||||||
|
let total_chars = msg.id - 1100;
|
||||||
|
for (idx, c) in output_bfr.iter().enumerate() {
|
||||||
|
if idx >= total_chars {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
output.putc(*c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1200 => writeln!(output, "Terminating process").unwrap(),
|
||||||
|
_ => writeln!(
|
||||||
|
output,
|
||||||
|
"Unrecognized scalar message from {}: {:#?}",
|
||||||
|
sender, msg
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn reader_thread(mut output: implementation::OutputWriter) {
|
||||||
|
writeln!(output, "LOG: Xous Logging Server starting up...").unwrap();
|
||||||
|
|
||||||
|
writeln!(output, "LOG: ****************************************************************").unwrap();
|
||||||
|
// time stamp isn't actually the time stamp of the build, unfortunately. It's the time stamp of the
|
||||||
|
// last time you managed to force a rebuild that also causes log-server to be rebuilt, not necessarily
|
||||||
|
// capturing the build time of the very most recent change!
|
||||||
|
// writeln!(output, "LOG: *** Built: {:49} ***", env!("VERGEN_BUILD_TIMESTAMP")).unwrap();
|
||||||
|
writeln!(output, "LOG: ****************************************************************").unwrap();
|
||||||
|
let server_addr = xous::create_server_with_address(b"xous-log-server ").unwrap();
|
||||||
|
writeln!(output, "LOG: Server listening on address {:?}", server_addr).unwrap();
|
||||||
|
|
||||||
|
let mut counter: usize = 0;
|
||||||
|
loop {
|
||||||
|
if counter.trailing_zeros() >= 12 {
|
||||||
|
writeln!(output, "LOG: Counter tick: {}", counter).unwrap();
|
||||||
|
}
|
||||||
|
counter += 1;
|
||||||
|
// writeln!(output, "LOG: Waiting for an event...").unwrap();
|
||||||
|
let mut envelope =
|
||||||
|
xous::syscall::receive_message(server_addr).expect("couldn't get address");
|
||||||
|
let sender = envelope.sender;
|
||||||
|
// writeln!(output, "LOG: Got message envelope: {:?}", envelope).unwrap();
|
||||||
|
match &mut envelope.body {
|
||||||
|
xous::Message::Scalar(msg) => handle_scalar(&mut output, sender, msg, envelope.sender.pid().unwrap()),
|
||||||
|
xous::Message::BlockingScalar(msg) => {
|
||||||
|
writeln!(
|
||||||
|
output,
|
||||||
|
"LOG: BlockingScalar message from {}: {:?}",
|
||||||
|
envelope.sender, msg
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
xous::Message::Move(msg) => {
|
||||||
|
String::<4000>::from_message(msg)
|
||||||
|
.map(|log_entry: String<4000>| {
|
||||||
|
writeln!(
|
||||||
|
output,
|
||||||
|
"LOG: Moved log message from {}: {}",
|
||||||
|
sender, log_entry
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
})
|
||||||
|
.or_else(|e| {
|
||||||
|
writeln!(output, "LOG: unable to convert Move message to str: {}", e)
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
xous::Message::Borrow(msg) => {
|
||||||
|
String::<4000>::from_message(msg)
|
||||||
|
.map(|log_entry: String<4000>| writeln!(output, "{}", log_entry).unwrap())
|
||||||
|
.or_else(|e| {
|
||||||
|
writeln!(
|
||||||
|
output,
|
||||||
|
"LOG: unable to convert Borrow message to str: {}",
|
||||||
|
e
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
xous::Message::MutableBorrow(msg) => {
|
||||||
|
String::<4000>::from_message(msg)
|
||||||
|
.map(|mut log_entry: String<4000>| {
|
||||||
|
writeln!(
|
||||||
|
output,
|
||||||
|
"LOG: Mutable borrowed log message from {} len {}:\n\r {}\n\r",
|
||||||
|
sender,
|
||||||
|
log_entry.len(),
|
||||||
|
log_entry,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
writeln!(log_entry, " << HELLO FROM THE SERVER").unwrap();
|
||||||
|
})
|
||||||
|
.or_else(|e| {
|
||||||
|
writeln!(
|
||||||
|
output,
|
||||||
|
"LOG: unable to convert MutableBorrow message to str: {}",
|
||||||
|
e
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn writer_thread(_ignored: usize) {
|
||||||
|
let mut counter = 0;
|
||||||
|
loop {
|
||||||
|
let conn = xous::connect(xous::SID::from_bytes(b"xous-log-server ").unwrap()).unwrap();
|
||||||
|
let mut buffer = xous::String::<4000>::new();
|
||||||
|
write!(buffer, "Hello, myself! Loop: {}", counter).unwrap();
|
||||||
|
buffer.lend(conn).unwrap();
|
||||||
|
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[xous::xous_main]
|
||||||
|
fn test_main() -> ! {
|
||||||
|
let mut output = implementation::init();
|
||||||
|
let writer = output.get_writer();
|
||||||
|
println!("LOG: my PID is {}", xous::process::id());
|
||||||
|
println!("LOG: Creating the reader thread");
|
||||||
|
xous::create_thread_simple(reader_thread, writer).unwrap();
|
||||||
|
xous::create_thread_simple(writer_thread, 0usize).unwrap();
|
||||||
|
println!("LOG: Running the output");
|
||||||
|
output.run();
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
@ -19,6 +19,7 @@ use xous::buffer;
|
||||||
use rkyv::{archived_value, Write};
|
use rkyv::{archived_value, Write};
|
||||||
|
|
||||||
/// Compute the dvorak key mapping of row/col to key tuples
|
/// Compute the dvorak key mapping of row/col to key tuples
|
||||||
|
#[allow(dead_code)]
|
||||||
fn map_dvorak(code: RowCol) -> ScanCode {
|
fn map_dvorak(code: RowCol) -> ScanCode {
|
||||||
let rc = (code.r, code.c);
|
let rc = (code.r, code.c);
|
||||||
|
|
||||||
|
|
@ -93,6 +94,7 @@ fn map_dvorak(code: RowCol) -> ScanCode {
|
||||||
|
|
||||||
|
|
||||||
/// Compute the dvorak key mapping of row/col to key tuples
|
/// Compute the dvorak key mapping of row/col to key tuples
|
||||||
|
#[allow(dead_code)]
|
||||||
fn map_qwerty(code: RowCol) -> ScanCode {
|
fn map_qwerty(code: RowCol) -> ScanCode {
|
||||||
let rc = (code.r, code.c);
|
let rc = (code.r, code.c);
|
||||||
|
|
||||||
|
|
@ -743,9 +745,10 @@ mod implementation {
|
||||||
use heapless::Vec;
|
use heapless::Vec;
|
||||||
use heapless::consts::*;
|
use heapless::consts::*;
|
||||||
use crate::api::*;
|
use crate::api::*;
|
||||||
use crate::{map_dvorak, map_qwerty};
|
//use crate::{map_dvorak, map_qwerty};
|
||||||
use log::{error, info};
|
//use log::{error, info};
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct Keyboard {
|
pub struct Keyboard {
|
||||||
map: KeyMap,
|
map: KeyMap,
|
||||||
rate: u32,
|
rate: u32,
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,7 @@ mod implementation {
|
||||||
// a stub to try to avoid breaking hosted mode for as long as possible.
|
// a stub to try to avoid breaking hosted mode for as long as possible.
|
||||||
#[cfg(not(target_os = "none"))]
|
#[cfg(not(target_os = "none"))]
|
||||||
mod implementation {
|
mod implementation {
|
||||||
use crate::api::*;
|
use log::info;
|
||||||
use log::{error, info};
|
|
||||||
|
|
||||||
pub struct Trng {
|
pub struct Trng {
|
||||||
seed: u32,
|
seed: u32,
|
||||||
|
|
@ -131,6 +130,7 @@ mod implementation {
|
||||||
lfsr
|
lfsr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn wait_full(&self) { }
|
pub fn wait_full(&self) { }
|
||||||
|
|
||||||
pub fn get_trng(&mut self, _count: usize) -> [u32; 2] {
|
pub fn get_trng(&mut self, _count: usize) -> [u32; 2] {
|
||||||
|
|
|
||||||
|
|
@ -491,6 +491,17 @@ impl From<usize> for MemoryType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl core::fmt::Display for MemoryType {
|
||||||
|
fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
match *self {
|
||||||
|
MemoryType::Default => write!(fmt, "Default"),
|
||||||
|
MemoryType::Heap => write!(fmt, "Heap"),
|
||||||
|
MemoryType::Stack => write!(fmt, "Stack"),
|
||||||
|
MemoryType::Messages => write!(fmt, "Messages"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum Result {
|
pub enum Result {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ pub const SERVER_NAME_KBD: &str = "_Matrix keyboard driver_";
|
||||||
pub const SERVER_NAME_TRNG: &str = "_TRNG manager_";
|
pub const SERVER_NAME_TRNG: &str = "_TRNG manager_";
|
||||||
pub const SERVER_NAME_GAM: &str = "_Graphical Abstraction Manager_";
|
pub const SERVER_NAME_GAM: &str = "_Graphical Abstraction Manager_";
|
||||||
pub const SERVER_NAME_STATUS: &str = "_Status bar manager_";
|
pub const SERVER_NAME_STATUS: &str = "_Status bar manager_";
|
||||||
|
pub const SERVER_NAME_IME_FRONT: &str = "_IME front end_";
|
||||||
|
pub const SERVER_NAME_IME_PLUGIN_SHELL: &str = "_IME shell plugin_";
|
||||||
|
|
||||||
pub const SERVER_NAME_FCCAGENT: &str = "_Agent for EMC Testing_";
|
pub const SERVER_NAME_FCCAGENT: &str = "_Agent for EMC Testing_";
|
||||||
pub const SERVER_NAME_BENCHMARK: &str= "_Benchmark target_";
|
pub const SERVER_NAME_BENCHMARK: &str= "_Benchmark target_";
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,14 @@ fn try_main() -> Result<(), DynError> {
|
||||||
let hw_pkgs = [
|
let hw_pkgs = [
|
||||||
"gam",
|
"gam",
|
||||||
//"shell",
|
//"shell",
|
||||||
|
//"ime-frontend",
|
||||||
|
//"ime-plugin-shell",
|
||||||
"graphics-server",
|
"graphics-server",
|
||||||
"ticktimer-server",
|
"ticktimer-server",
|
||||||
"log-server",
|
"log-server",
|
||||||
"com",
|
"com",
|
||||||
"xous-names",
|
"xous-names",
|
||||||
//"keyboard",
|
"keyboard",
|
||||||
"trng",
|
"trng",
|
||||||
//"llio",
|
//"llio",
|
||||||
];
|
];
|
||||||
|
|
@ -71,6 +73,7 @@ fn try_main() -> Result<(), DynError> {
|
||||||
let task = env::args().nth(1);
|
let task = env::args().nth(1);
|
||||||
match task.as_deref() {
|
match task.as_deref() {
|
||||||
Some("renode-image") => renode_image(false, &hw_pkgs)?,
|
Some("renode-image") => renode_image(false, &hw_pkgs)?,
|
||||||
|
Some("renode-test") => renode_image(false, &["kernel-test"])?,
|
||||||
Some("renode-image-debug") => renode_image(true, &hw_pkgs)?,
|
Some("renode-image-debug") => renode_image(true, &hw_pkgs)?,
|
||||||
Some("run") => run(false)?,
|
Some("run") => run(false)?,
|
||||||
Some("hw-image") => build_hw_image(false, env::args().nth(2), &hw_pkgs)?,
|
Some("hw-image") => build_hw_image(false, env::args().nth(2), &hw_pkgs)?,
|
||||||
|
|
@ -85,7 +88,8 @@ fn try_main() -> Result<(), DynError> {
|
||||||
fn print_help() {
|
fn print_help() {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"Tasks:
|
"Tasks:
|
||||||
renode-image builds a test image for renode
|
renode-image builds a functional image for renode
|
||||||
|
renode-test builds a test image for renode
|
||||||
renode-image-debug builds a test image for renode in debug mode
|
renode-image-debug builds a test image for renode in debug mode
|
||||||
hw-image [soc.svd] builds an image for real hardware
|
hw-image [soc.svd] builds an image for real hardware
|
||||||
run runs a release build using a hosted environment
|
run runs a release build using a hosted environment
|
||||||
|
|
@ -188,6 +192,8 @@ fn run(debug: bool) -> Result<(), DynError> {
|
||||||
let init = [
|
let init = [
|
||||||
//"shell",
|
//"shell",
|
||||||
"gam",
|
"gam",
|
||||||
|
//"ime-frontend",
|
||||||
|
//"ime-plugin-shell",
|
||||||
//"benchmark",
|
//"benchmark",
|
||||||
//"benchmark-target",
|
//"benchmark-target",
|
||||||
"log-server",
|
"log-server",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue