Skip to content

Commit bb93b45

Browse files
committed
std: xous: use constants for stdout and stderr
Use constants for the opcodes when writing to stdout or stderr. There still is no stdin operation. Signed-off-by: Sean Cross <[email protected]>
1 parent 49af5f0 commit bb93b45

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

library/std/src/os/xous/services/log.rs

+14
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ impl<'a> Into<[usize; 5]> for LogScalar<'a> {
4545
}
4646
}
4747

48+
pub(crate) enum LogLend {
49+
StandardOutput, /* 1 */
50+
StandardError, /* 2 */
51+
}
52+
53+
impl Into<usize> for LogLend {
54+
fn into(self) -> usize {
55+
match self {
56+
LogLend::StandardOutput => 1,
57+
LogLend::StandardError => 2,
58+
}
59+
}
60+
}
61+
4862
/// Return a `Connection` to the log server, which is used for printing messages to
4963
/// the console and reporting panics. If the log server has not yet started, this
5064
/// will block until the server is running. It is safe to call this multiple times,

library/std/src/sys/xous/stdio.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub struct Stdout {}
55
pub struct Stderr;
66

77
use crate::os::xous::ffi::{lend, try_lend, try_scalar, Connection};
8-
use crate::os::xous::services::{log_server, try_connect, LogScalar};
8+
use crate::os::xous::services::{log_server, try_connect, LogLend, LogScalar};
99

1010
impl Stdin {
1111
pub const fn new() -> Stdin {
@@ -35,7 +35,8 @@ impl io::Write for Stdout {
3535
for (dest, src) in lend_buffer.0.iter_mut().zip(chunk) {
3636
*dest = *src;
3737
}
38-
lend(connection, 1, &lend_buffer.0, 0, chunk.len()).unwrap();
38+
lend(connection, LogLend::StandardOutput.into(), &lend_buffer.0, 0, chunk.len())
39+
.unwrap();
3940
}
4041
Ok(buf.len())
4142
}
@@ -61,7 +62,8 @@ impl io::Write for Stderr {
6162
for (dest, src) in lend_buffer.0.iter_mut().zip(chunk) {
6263
*dest = *src;
6364
}
64-
lend(connection, 1, &lend_buffer.0, 0, chunk.len()).unwrap();
65+
lend(connection, LogLend::StandardError.into(), &lend_buffer.0, 0, chunk.len())
66+
.unwrap();
6567
}
6668
Ok(buf.len())
6769
}

0 commit comments

Comments
 (0)