Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add armv7a-vex-v5 tier three target #131530

Closed
wants to merge 72 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
5b5f0a7
add armv7a-vex-v5 target
max-niederman May 28, 2024
266d1b6
add (shimmed) std support for armv7a-vex-v5
max-niederman May 28, 2024
83f35f3
add panic, stdio, and alloc support to armv7a-vex-v5
max-niederman May 28, 2024
56084eb
fix linker script and call main
max-niederman May 30, 2024
c204550
zero out bss section in _start
max-niederman Jul 17, 2024
c684a49
use static TLS implementation on vexos
max-niederman Jul 17, 2024
cdbfde6
make minor improvements to linker script
max-niederman Jul 17, 2024
5f8ee0c
enable stdio and fix stdout flushing
max-niederman Jul 18, 2024
a5403ca
add: `Instant` implementation
Gavin-Niederman Jul 18, 2024
d8c32e9
remove broken cleanup
max-niederman Jul 18, 2024
f5125f6
fix `.code_signature` section error
Tropix126 Jul 18, 2024
ac5f552
move `.code_signature` section into `.text`
Tropix126 Jul 18, 2024
bc07881
adjust `armv7a-vex-v5` target features for more aggressive hardware o…
Tropix126 Jul 18, 2024
170ba62
switch `llvm_target` to use ARM hard-float abi
Tropix126 Jul 18, 2024
80b1d36
add `env` implementation for `vexos` PAL
Tropix126 Jul 18, 2024
2855b31
feat: experimental fs support
Gavin-Niederman Jul 18, 2024
9aeeaa0
add support for more missing file operations
Tropix126 Jul 18, 2024
4f59642
feat: file writes vectored writes and vectored reads
Gavin-Niederman Jul 18, 2024
1900699
add helper for mapping FRESULT values
Tropix126 Jul 21, 2024
92d44bc
add: try_file_exists and stat
Gavin-Niederman Jul 21, 2024
62b6344
add: fileattr functions
Gavin-Niederman Jul 21, 2024
cf90d39
fix: check current position in file when getting size
Gavin-Niederman Jul 21, 2024
ff1aaf8
refactor: pseudorandom hashmap keys
Gavin-Niederman Jul 21, 2024
5e78476
fix: support File::file_attr and dissalow read and write mode at the …
Gavin-Niederman Jul 22, 2024
a5b9f71
feat: seek implementation
Gavin-Niederman Jul 22, 2024
1878f62
feat: almost working directory reading
Gavin-Niederman Jul 23, 2024
0aff419
fix: remove trailing slashes sooner
Gavin-Niederman Jul 23, 2024
0e0579a
remove test code and document filesystem quirks
Tropix126 Jul 27, 2024
ea7507e
add default code signature, ensure stdout flush
Tropix126 Aug 4, 2024
77e03a9
add platform docs
Tropix126 Aug 4, 2024
1581d08
adjust wording and fix typos in target documentation
Tropix126 Aug 4, 2024
8a69bd7
update PAL and add `check-cfg` override for `target_os`
Tropix126 Aug 5, 2024
1dbfada
add additional information to target spec and supporting docs
Tropix126 Aug 5, 2024
f39ea4a
fix `EXE_SUFFFIX` to use dot
Tropix126 Aug 9, 2024
77ddf8d
fix: use correct code signature default values
Tropix126 Aug 17, 2024
b6b3789
don't compile with `+thumb-mode` feature for now
Tropix126 Aug 21, 2024
b1671f1
properly flush serial on abort
Tropix126 Sep 6, 2024
3d0f59f
clarify documentation regarding cargo-v5, adjust `SystemTime` panic m…
Tropix126 Sep 7, 2024
ace69e6
use aapcs as system abi
max-niederman Oct 9, 2024
ea04c92
fix stack corruptions in startup routine
max-niederman Oct 9, 2024
f5237d6
fix thread locals
max-niederman Oct 9, 2024
e0e1eba
implement (shimmed) std::random
max-niederman Oct 9, 2024
e183779
fix allocation
max-niederman Oct 9, 2024
c492684
update linkerscript to include unwinding-related sections
Tropix126 Oct 11, 2024
84dcb23
format target doc and reorder maintainer list
max-niederman Oct 11, 2024
097d792
bump vex-sdk version and allow vex-sdk to be a stdlib dep
max-niederman Oct 11, 2024
6c2287c
add assembly test for armv7a-vex-v5
max-niederman Oct 11, 2024
b6d41fa
add armv7a-vex-v5 target docs to summary
max-niederman Oct 11, 2024
0d441ab
better document the is_like_vexos property of TargetOptions
max-niederman Oct 11, 2024
7bb6a04
detail summary of armv7a-vex-v5's target support
max-niederman Oct 11, 2024
a9ca387
add more descriptive comments to the `armv7a-vex-v5` linkerscript
Tropix126 Oct 13, 2024
24e381c
add `"v5"` target env armv7a-vex-v5 target spec
Tropix126 Oct 15, 2024
d11d208
implement `Stderr` in vexos PAL
Tropix126 Oct 23, 2024
1660bc6
run VEXos cpu1 scheduler while waiting for abort
Tropix126 Oct 23, 2024
508177c
update to `vex-sdk` 0.23.0
Tropix126 Oct 23, 2024
4d95d1f
add rudimentary implementation of `Thread::sleep` and `Thread::yield_…
Tropix126 Oct 25, 2024
034467f
fix broken reference to Instant in pal
max-niederman Oct 30, 2024
ed57739
switch to `+vfp3d16` LLVM feature in `armv7a-vex-v5`
Tropix126 Nov 11, 2024
a4701ce
fix and clean up comments surrounding file seeking
Tropix126 Dec 23, 2024
33f5078
add private unit to all pub fs types in vexos PAL
Tropix126 Dec 23, 2024
7168feb
treat all `io::Error`s as non-EBADF in vexos
Tropix126 Dec 23, 2024
8239a82
adjust error message for `FRESULT::FR_INT_ERR`
Tropix126 Dec 23, 2024
0b7aa15
bump `vex-sdk` to 0.26.0
Tropix126 Dec 23, 2024
fd8d110
update libstd lockfile
Tropix126 Dec 23, 2024
f76ae6f
fix circular dependency on cc-rs using a temporary patched version of…
max-niederman Jan 1, 2025
c0b0879
add unsupported file_lock functions
max-niederman Jan 1, 2025
08ace18
fix mistakes in fs PAL
max-niederman Jan 1, 2025
9f5c3f7
add `llvm_floatabi` to armv7a-vex-v5 spec
Tropix126 Jan 2, 2025
2081cf5
serialize `is_like_vexos` in target json specs
doinkythederp Jan 2, 2025
d0d1fd9
ensure `arm` arch before adjusting VEXos system ABI to `aapcs`
doinkythederp Jan 2, 2025
ee12faa
bless tests, add `armv7a-vex-v5` to assembly tests
Tropix126 Jan 25, 2025
d9a1349
backlink to relevant cleanup issues in FIXMEs
Tropix126 Jan 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: experimental fs support
  • Loading branch information
Gavin-Niederman authored and Tropix126 committed Jan 25, 2025
commit 2855b3113177a6daa8112003b99c970a9ceb70ff
325 changes: 325 additions & 0 deletions library/std/src/sys/pal/vexos/fs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
use crate::ffi::{CString, OsString};
use crate::fmt;
use crate::hash::Hash;
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom};
use crate::path::{Path, PathBuf};
use crate::sys::time::SystemTime;
use crate::sys::unsupported;

struct Fd(*mut vex_sdk::FIL);

pub struct File(Fd);

//TODO: We may be able to get some of this info
#[derive(Clone)]
pub struct FileAttr;

pub struct ReadDir(!);

pub struct DirEntry(!);

#[derive(Clone, Debug)]
pub struct OpenOptions {
read: bool,
write: bool,
append: bool,
}

#[derive(Copy, Clone, Debug, Default)]
pub struct FileTimes {}
jieyouxu marked this conversation as resolved.
Show resolved Hide resolved

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct FilePermissions;

#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash)]
pub struct FileType {
is_dir: bool,
}

#[derive(Debug)]
pub struct DirBuilder {}

impl FileAttr {
pub fn size(&self) -> u64 {
todo!()
}

pub fn perm(&self) -> FilePermissions {
todo!()
}

pub fn file_type(&self) -> FileType {
todo!()
}

pub fn modified(&self) -> io::Result<SystemTime> {
todo!()
}

pub fn accessed(&self) -> io::Result<SystemTime> {
todo!()
}

pub fn created(&self) -> io::Result<SystemTime> {
todo!()
}
}

impl FilePermissions {
pub fn readonly(&self) -> bool {
false
}

pub fn set_readonly(&mut self, _readonly: bool) {
panic!("Perimissions do not exist")
}
}

impl FileTimes {
pub fn set_accessed(&mut self, _t: SystemTime) {}
pub fn set_modified(&mut self, _t: SystemTime) {}
}

impl FileType {
pub fn is_dir(&self) -> bool {
self.is_dir
}

pub fn is_file(&self) -> bool {
!self.is_dir
}

pub fn is_symlink(&self) -> bool {
false
}
}

impl fmt::Debug for ReadDir {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0
}
}

impl Iterator for ReadDir {
type Item = io::Result<DirEntry>;

fn next(&mut self) -> Option<io::Result<DirEntry>> {
self.0
}
}

impl DirEntry {
pub fn path(&self) -> PathBuf {
self.0
}

pub fn file_name(&self) -> OsString {
self.0
}

pub fn metadata(&self) -> io::Result<FileAttr> {
self.0
}

pub fn file_type(&self) -> io::Result<FileType> {
self.0
}
}

impl OpenOptions {
pub fn new() -> OpenOptions {
OpenOptions { read: false, write: false, append: false }
}

pub fn read(&mut self, read: bool) {
self.read = read;
}
pub fn write(&mut self, write: bool) {
self.write = write;
}
pub fn append(&mut self, append: bool) {
self.append = append;
}
pub fn truncate(&mut self, _truncate: bool) {}
pub fn create(&mut self, create: bool) {
self.write = create;
}
pub fn create_new(&mut self, _create_new: bool) {}
}

impl File {
pub fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> {
let path = CString::new(path.as_os_str().as_encoded_bytes()).map_err(|_| {
io::Error::new(io::ErrorKind::InvalidData, "Path contained a null byte")
})?;

let file = if opts.read && !opts.write {
// The second argument to this function is ignored.
// Open in read only mode
unsafe { vex_sdk::vexFileOpen(path.as_ptr(), c"".as_ptr()) }
} else if opts.write && opts.append {
// Open in read/write and append mode
unsafe { vex_sdk::vexFileOpenWrite(path.as_ptr()) }
} else if opts.write {
// Open in read/write mode
unsafe { vex_sdk::vexFileOpenCreate(path.as_ptr()) }
} else {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
"Files cannot be opened without read or write access",
));
};

if file.is_null() {
Err(io::Error::new(io::ErrorKind::NotFound, "Could not open file"))
} else {
Ok(Self(Fd(file)))
}
}

pub fn file_attr(&self) -> io::Result<FileAttr> {
todo!()
}

pub fn fsync(&self) -> io::Result<()> {
todo!()
}

pub fn datasync(&self) -> io::Result<()> {
todo!()
}

pub fn truncate(&self, _size: u64) -> io::Result<()> {
todo!()
}

pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
let len = buf.len() as _;
let buf_ptr = buf.as_mut_ptr();
let read = unsafe { vex_sdk::vexFileRead(buf_ptr.cast(), 1, len, self.0.0) };
if read < 0 {
Err(io::Error::new(
io::ErrorKind::Other,
"Could not read from file",
))
} else {
Ok(read as usize)
}
}

pub fn read_vectored(&self, _bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
todo!()
}

pub fn is_read_vectored(&self) -> bool {
todo!()
}

pub fn read_buf(&self, _cursor: BorrowedCursor<'_>) -> io::Result<()> {
todo!()
}

pub fn write(&self, _buf: &[u8]) -> io::Result<usize> {
todo!()
}

pub fn write_vectored(&self, _bufs: &[IoSlice<'_>]) -> io::Result<usize> {
todo!()
}

pub fn is_write_vectored(&self) -> bool {
todo!()
}

pub fn flush(&self) -> io::Result<()> {
todo!()
}

pub fn seek(&self, _pos: SeekFrom) -> io::Result<u64> {
todo!()
}

pub fn duplicate(&self) -> io::Result<File> {
todo!()
}

pub fn set_permissions(&self, _perm: FilePermissions) -> io::Result<()> {
todo!()
}

pub fn set_times(&self, _times: FileTimes) -> io::Result<()> {
todo!()
}
}

impl DirBuilder {
pub fn new() -> DirBuilder {
DirBuilder {}
}

pub fn mkdir(&self, _p: &Path) -> io::Result<()> {
unsupported()
}
}

impl fmt::Debug for File {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("File").finish_non_exhaustive()
}
}

pub fn readdir(_p: &Path) -> io::Result<ReadDir> {
unsupported()
}

pub fn unlink(_p: &Path) -> io::Result<()> {
unsupported()
}

pub fn rename(_old: &Path, _new: &Path) -> io::Result<()> {
unsupported()
}

pub fn set_perm(_p: &Path, _perm: FilePermissions) -> io::Result<()> {
unsupported()
}

pub fn rmdir(_p: &Path) -> io::Result<()> {
unsupported()
}

pub fn remove_dir_all(_path: &Path) -> io::Result<()> {
unsupported()
}

pub fn try_exists(_path: &Path) -> io::Result<bool> {
unsupported()
}

pub fn readlink(_p: &Path) -> io::Result<PathBuf> {
unsupported()
}

pub fn symlink(_original: &Path, _link: &Path) -> io::Result<()> {
unsupported()
}

pub fn link(_src: &Path, _dst: &Path) -> io::Result<()> {
unsupported()
}

pub fn stat(_p: &Path) -> io::Result<FileAttr> {
unsupported()
}

pub fn lstat(_p: &Path) -> io::Result<FileAttr> {
unsupported()
}

pub fn canonicalize(_p: &Path) -> io::Result<PathBuf> {
unsupported()
}

pub fn copy(_from: &Path, _to: &Path) -> io::Result<u64> {
unsupported()
}
2 changes: 0 additions & 2 deletions library/std/src/sys/pal/vexos/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pub mod alloc;
#[path = "../unsupported/args.rs"]
pub mod args;
#[path = "../unsupported/env.rs"]
pub mod env;
#[path = "../unsupported/fs.rs"]
pub mod fs;
#[path = "../unsupported/io.rs"]
pub mod io;
Expand Down