SOLID[1] is an embedded development platform provided by Kyoto
Microcomputer Co., Ltd. This commit introduces a basic Tier 3 support
for SOLID.
# New Targets
The following targets are added:
- `aarch64-kmc-solid_asp3`
- `armv7a-kmc-solid_asp3-eabi`
- `armv7a-kmc-solid_asp3-eabihf`
SOLID's target software system can be divided into two parts: an
RTOS kernel, which is responsible for threading and synchronization,
and Core Services, which provides filesystems, networking, and other
things. The RTOS kernel is a μITRON4.0[2][3]-derived kernel based on
the open-source TOPPERS RTOS kernels[4]. For uniprocessor systems
(more precisely, systems where only one processor core is allocated for
SOLID), this will be the TOPPERS/ASP3 kernel. As μITRON is
traditionally only specified at the source-code level, the ABI is
unique to each implementation, which is why `asp3` is included in the
target names.
More targets could be added later, as we support other base kernels
(there are at least three at the point of writing) and are interested
in supporting other processor architectures in the future.
# C Compiler
Although SOLID provides its own supported C/C++ build toolchain, GNU Arm
Embedded Toolchain seems to work for the purpose of building Rust.
# Unresolved Questions
A μITRON4 kernel can support `Thread::unpark` natively, but it's not
used by this commit's implementation because the underlying kernel
feature is also used to implement `Condvar`, and it's unclear whether
`std` should guarantee that parking tokens are not clobbered by other
synchronization primitives.
# Unsupported or Unimplemented Features
Most features are implemented. The following features are not
implemented due to the lack of native support:
- `fs::File::{file_attr, truncate, duplicate, set_permissions}`
- `fs::{symlink, link, canonicalize}`
- Process creation
- Command-line arguments
Backtrace generation is not really a good fit for embedded targets, so
it's intentionally left unimplemented. Unwinding is functional, however.
## Dynamic Linking
Dynamic linking is not supported. The target platform supports dynamic
linking, but enabling this in Rust causes several problems.
- The linker invocation used to build the shared object of `std` is
too long for the platform-provided linker to handle.
- A linker script with specific requirements is required for the
compiled shared object to be actually loadable.
As such, we decided to disable dynamic linking for now. Regardless, the
users can try to create shared objects by manually invoking the linker.
## Executable
Building an executable is not supported as the notion of "executable
files" isn't well-defined for these targets.
[1] https://solid.kmckk.com/SOLID/
[2] http://ertl.jp/ITRON/SPEC/mitron4-e.html
[3] https://en.wikipedia.org/wiki/ITRON_project
[4] https://toppers.jp/
80 lines
1.4 KiB
Rust
80 lines
1.4 KiB
Rust
use super::abi;
|
|
use crate::io;
|
|
|
|
pub struct Stdin;
|
|
pub struct Stdout;
|
|
pub struct Stderr;
|
|
struct PanicOutput;
|
|
|
|
impl Stdin {
|
|
pub const fn new() -> Stdin {
|
|
Stdin
|
|
}
|
|
}
|
|
|
|
impl io::Read for Stdin {
|
|
fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
|
|
Ok(0)
|
|
}
|
|
}
|
|
|
|
impl Stdout {
|
|
pub const fn new() -> Stdout {
|
|
Stdout
|
|
}
|
|
}
|
|
|
|
impl io::Write for Stdout {
|
|
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
|
unsafe { abi::SOLID_LOG_write(buf.as_ptr(), buf.len()) };
|
|
Ok(buf.len())
|
|
}
|
|
|
|
fn flush(&mut self) -> io::Result<()> {
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
impl Stderr {
|
|
pub const fn new() -> Stderr {
|
|
Stderr
|
|
}
|
|
}
|
|
|
|
impl io::Write for Stderr {
|
|
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
|
unsafe { abi::SOLID_LOG_write(buf.as_ptr(), buf.len()) };
|
|
Ok(buf.len())
|
|
}
|
|
|
|
fn flush(&mut self) -> io::Result<()> {
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
impl PanicOutput {
|
|
pub const fn new() -> PanicOutput {
|
|
PanicOutput
|
|
}
|
|
}
|
|
|
|
impl io::Write for PanicOutput {
|
|
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
|
unsafe { abi::SOLID_LOG_write(buf.as_ptr(), buf.len()) };
|
|
Ok(buf.len())
|
|
}
|
|
|
|
fn flush(&mut self) -> io::Result<()> {
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
pub const STDIN_BUF_SIZE: usize = 0;
|
|
|
|
pub fn is_ebadf(_err: &io::Error) -> bool {
|
|
true
|
|
}
|
|
|
|
pub fn panic_output() -> Option<impl io::Write> {
|
|
Some(PanicOutput::new())
|
|
}
|