Splits UART tx/rx into separate CAmkES procedures

This ends the behavior where log messages would block on the prompt.

This change does not fix the potential race on dataports if
kata-uart-client read or write has multiple concurrent callers. A later
change will protect those using CAmkES mutexes, although the
alternative of having DebugConsole *own* the UART should also be
considered.

Change-Id: I8d5d8336cd58b9f22cca81ae6aca13b4ed57e7e4
GitOrigin-RevId: e781fd8454d22e0f829d788fe602e431551e259a
This commit is contained in:
Matt Harvey
2021-08-15 14:06:55 -07:00
committed by Sam Leffler
parent 20c83f6777
commit 7c3cc70ab1
6 changed files with 49 additions and 41 deletions

View File

@@ -6,9 +6,12 @@ import <SeL4DebugInterface.camkes>;
component DebugConsole {
control;
uses uart_inf uart;
dataport Buf tx_dataport;
uses dataport_io_inf uart_tx;
dataport Buf rx_dataport;
uses dataport_io_inf uart_rx;
provides LoggerInterface logger;
uses ProcessControlInterface proc_ctrl;

View File

@@ -8,8 +8,8 @@ use kata_io as io;
extern "C" {
static rx_dataport: *mut cty::c_uchar;
static tx_dataport: *mut cty::c_uchar;
fn uart_rx(n: cty::size_t);
fn uart_tx(n: cty::size_t);
fn uart_rx_update(n: cty::size_t);
fn uart_tx_update(n: cty::size_t);
}
// Console logging interface.
@@ -27,7 +27,7 @@ pub struct Rx {}
impl io::Read for Rx {
fn read(&mut self, buf: &mut [u8]) -> Result<usize, io::Error> {
unsafe {
uart_rx(buf.len());
uart_rx_update(buf.len());
let port = core::slice::from_raw_parts(rx_dataport, buf.len());
buf.copy_from_slice(&port);
}
@@ -42,7 +42,7 @@ impl io::Write for Tx {
unsafe {
let port = core::slice::from_raw_parts_mut(tx_dataport, buf.len());
port.copy_from_slice(buf);
uart_tx(buf.len());
uart_tx_update(buf.len());
}
Ok(buf.len())
}