mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
make the rawserial path queue up to 128 characters if getchar() isn't live
This commit is contained in:
parent
b0c7895e81
commit
ba874a653e
1 changed files with 31 additions and 7 deletions
|
|
@ -10,6 +10,11 @@ use log::info;
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
use xous_ipc::Buffer;
|
use xous_ipc::Buffer;
|
||||||
use xous::{CID, msg_scalar_unpack, msg_blocking_scalar_unpack, MessageSender};
|
use xous::{CID, msg_scalar_unpack, msg_blocking_scalar_unpack, MessageSender};
|
||||||
|
#[cfg(feature="rawserial")]
|
||||||
|
use std::collections::VecDeque;
|
||||||
|
#[cfg(feature="rawserial")]
|
||||||
|
const BLOCKING_QUEUE_LEN: usize = 128;
|
||||||
|
|
||||||
#[cfg(any(target_os = "none", target_os = "xous"))]
|
#[cfg(any(target_os = "none", target_os = "xous"))]
|
||||||
mod implementation {
|
mod implementation {
|
||||||
use utralib::generated::*;
|
use utralib::generated::*;
|
||||||
|
|
@ -762,10 +767,14 @@ fn main() -> ! {
|
||||||
log::warn!("kbd server is overriding WFI for debugging, remember to disable for production");
|
log::warn!("kbd server is overriding WFI for debugging, remember to disable for production");
|
||||||
llio.wfi_override(true).unwrap();
|
llio.wfi_override(true).unwrap();
|
||||||
}*/
|
}*/
|
||||||
|
#[cfg(not(feature="rawserial"))]
|
||||||
let mut esc_index: Option<usize> = None;
|
let mut esc_index: Option<usize> = None;
|
||||||
|
#[cfg(not(feature="rawserial"))]
|
||||||
let mut esc_chars = [0u8; 16];
|
let mut esc_chars = [0u8; 16];
|
||||||
// storage for any blocking listeners
|
// storage for any blocking listeners
|
||||||
let mut blocking_listener = Vec::<MessageSender>::new();
|
let mut blocking_listener = Vec::<MessageSender>::new();
|
||||||
|
#[cfg(feature="rawserial")]
|
||||||
|
let mut blocking_queue = VecDeque::<usize>::new();
|
||||||
|
|
||||||
log::trace!("starting main loop");
|
log::trace!("starting main loop");
|
||||||
loop {
|
loop {
|
||||||
|
|
@ -842,14 +851,28 @@ fn main() -> ! {
|
||||||
|
|
||||||
#[cfg(feature="rawserial")]
|
#[cfg(feature="rawserial")]
|
||||||
{
|
{
|
||||||
|
if blocking_listener.len() == 0 {
|
||||||
|
if blocking_queue.len() > BLOCKING_QUEUE_LEN {
|
||||||
|
log::warn!("blocking queue has overflowed, dropping {}", k);
|
||||||
|
} else {
|
||||||
|
blocking_queue.push_back(k);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for listener in blocking_listener.drain(..) {
|
for listener in blocking_listener.drain(..) {
|
||||||
// we must unblock anyways once the key is hit; even if the key is invalid,
|
// we must unblock anyways once the key is hit; even if the key is invalid,
|
||||||
// send the invalid key. The receiving library function will clean this up into a nil-response vector.
|
// send the invalid key. The receiving library function will clean this up into a nil-response vector.
|
||||||
|
if blocking_queue.len() != 0 {
|
||||||
|
blocking_queue.push_back(k);
|
||||||
|
let k_prime = blocking_queue.pop_front().unwrap();
|
||||||
|
xous::return_scalar2(listener, k_prime, 0).unwrap();
|
||||||
|
} else {
|
||||||
xous::return_scalar2(listener, k, 0).unwrap();
|
xous::return_scalar2(listener, k, 0).unwrap();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
continue; // do not execute the remaining code in this branch
|
continue; // do not execute the remaining code in this branch
|
||||||
}
|
}
|
||||||
|
#[cfg(not(feature="rawserial"))]
|
||||||
let key = match esc_index {
|
let key = match esc_index {
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
esc_chars[i] = (k & 0xff) as u8;
|
esc_chars[i] = (k & 0xff) as u8;
|
||||||
|
|
@ -896,7 +919,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#[cfg(feature="debuginject")]
|
#[cfg(all(feature="debuginject", not(feature="rawserial")))]
|
||||||
if let Some(conn) = listener_conn {
|
if let Some(conn) = listener_conn {
|
||||||
if key != '\u{0000}' {
|
if key != '\u{0000}' {
|
||||||
log::info!("injecting key '{}'({:x})", key, key as u32); // always be noisy about this, it's an exploit path
|
log::info!("injecting key '{}'({:x})", key, key as u32); // always be noisy about this, it's an exploit path
|
||||||
|
|
@ -910,7 +933,7 @@ fn main() -> ! {
|
||||||
).unwrap();
|
).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature="debuginject")]
|
#[cfg(all(feature="debuginject", not(feature="rawserial")))]
|
||||||
for listener in blocking_listener.drain(..) {
|
for listener in blocking_listener.drain(..) {
|
||||||
// we must unblock anyways once the key is hit; even if the key is invalid,
|
// we must unblock anyways once the key is hit; even if the key is invalid,
|
||||||
// send the invalid key. The receiving library function will clean this up into a nil-response vector.
|
// send the invalid key. The receiving library function will clean this up into a nil-response vector.
|
||||||
|
|
@ -1018,6 +1041,7 @@ fn main() -> ! {
|
||||||
xous::terminate_process(0)
|
xous::terminate_process(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature="rawserial"))]
|
||||||
fn esc_match(esc_chars: &[u8]) -> Result<Option<char>, ()> {
|
fn esc_match(esc_chars: &[u8]) -> Result<Option<char>, ()> {
|
||||||
let mut extended = Vec::<u8>::new();
|
let mut extended = Vec::<u8>::new();
|
||||||
for (i, &c) in esc_chars.iter().enumerate() {
|
for (i, &c) in esc_chars.iter().enumerate() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue