-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add armv7a-vex-v5
tier three target
#131530
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
Closed
Closed
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
5b5f0a7
add armv7a-vex-v5 target
max-niederman 266d1b6
add (shimmed) std support for armv7a-vex-v5
max-niederman 83f35f3
add panic, stdio, and alloc support to armv7a-vex-v5
max-niederman 56084eb
fix linker script and call main
max-niederman c204550
zero out bss section in _start
max-niederman c684a49
use static TLS implementation on vexos
max-niederman cdbfde6
make minor improvements to linker script
max-niederman 5f8ee0c
enable stdio and fix stdout flushing
max-niederman a5403ca
add: `Instant` implementation
Gavin-Niederman d8c32e9
remove broken cleanup
max-niederman f5125f6
fix `.code_signature` section error
Tropix126 ac5f552
move `.code_signature` section into `.text`
Tropix126 bc07881
adjust `armv7a-vex-v5` target features for more aggressive hardware o…
Tropix126 170ba62
switch `llvm_target` to use ARM hard-float abi
Tropix126 80b1d36
add `env` implementation for `vexos` PAL
Tropix126 2855b31
feat: experimental fs support
Gavin-Niederman 9aeeaa0
add support for more missing file operations
Tropix126 4f59642
feat: file writes vectored writes and vectored reads
Gavin-Niederman 1900699
add helper for mapping FRESULT values
Tropix126 92d44bc
add: try_file_exists and stat
Gavin-Niederman 62b6344
add: fileattr functions
Gavin-Niederman cf90d39
fix: check current position in file when getting size
Gavin-Niederman ff1aaf8
refactor: pseudorandom hashmap keys
Gavin-Niederman 5e78476
fix: support File::file_attr and dissalow read and write mode at the …
Gavin-Niederman a5b9f71
feat: seek implementation
Gavin-Niederman 1878f62
feat: almost working directory reading
Gavin-Niederman 0aff419
fix: remove trailing slashes sooner
Gavin-Niederman 0e0579a
remove test code and document filesystem quirks
Tropix126 ea7507e
add default code signature, ensure stdout flush
Tropix126 77e03a9
add platform docs
Tropix126 1581d08
adjust wording and fix typos in target documentation
Tropix126 8a69bd7
update PAL and add `check-cfg` override for `target_os`
Tropix126 1dbfada
add additional information to target spec and supporting docs
Tropix126 f39ea4a
fix `EXE_SUFFFIX` to use dot
Tropix126 77ddf8d
fix: use correct code signature default values
Tropix126 b6b3789
don't compile with `+thumb-mode` feature for now
Tropix126 b1671f1
properly flush serial on abort
Tropix126 3d0f59f
clarify documentation regarding cargo-v5, adjust `SystemTime` panic m…
Tropix126 ace69e6
use aapcs as system abi
max-niederman ea04c92
fix stack corruptions in startup routine
max-niederman f5237d6
fix thread locals
max-niederman e0e1eba
implement (shimmed) std::random
max-niederman e183779
fix allocation
max-niederman c492684
update linkerscript to include unwinding-related sections
Tropix126 84dcb23
format target doc and reorder maintainer list
max-niederman 097d792
bump vex-sdk version and allow vex-sdk to be a stdlib dep
max-niederman 6c2287c
add assembly test for armv7a-vex-v5
max-niederman b6d41fa
add armv7a-vex-v5 target docs to summary
max-niederman 0d441ab
better document the is_like_vexos property of TargetOptions
max-niederman 7bb6a04
detail summary of armv7a-vex-v5's target support
max-niederman a9ca387
add more descriptive comments to the `armv7a-vex-v5` linkerscript
Tropix126 24e381c
add `"v5"` target env armv7a-vex-v5 target spec
Tropix126 d11d208
implement `Stderr` in vexos PAL
Tropix126 1660bc6
run VEXos cpu1 scheduler while waiting for abort
Tropix126 508177c
update to `vex-sdk` 0.23.0
Tropix126 4d95d1f
add rudimentary implementation of `Thread::sleep` and `Thread::yield_…
Tropix126 034467f
fix broken reference to Instant in pal
max-niederman ed57739
switch to `+vfp3d16` LLVM feature in `armv7a-vex-v5`
Tropix126 a4701ce
fix and clean up comments surrounding file seeking
Tropix126 33f5078
add private unit to all pub fs types in vexos PAL
Tropix126 7168feb
treat all `io::Error`s as non-EBADF in vexos
Tropix126 8239a82
adjust error message for `FRESULT::FR_INT_ERR`
Tropix126 0b7aa15
bump `vex-sdk` to 0.26.0
Tropix126 fd8d110
update libstd lockfile
Tropix126 f76ae6f
fix circular dependency on cc-rs using a temporary patched version of…
max-niederman c0b0879
add unsupported file_lock functions
max-niederman 08ace18
fix mistakes in fs PAL
max-niederman 9f5c3f7
add `llvm_floatabi` to armv7a-vex-v5 spec
Tropix126 2081cf5
serialize `is_like_vexos` in target json specs
doinkythederp d0d1fd9
ensure `arm` arch before adjusting VEXos system ABI to `aapcs`
doinkythederp ee12faa
bless tests, add `armv7a-vex-v5` to assembly tests
Tropix126 d9a1349
backlink to relevant cleanup issues in FIXMEs
Tropix126 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use crate::spec::{ | ||
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, | ||
}; | ||
|
||
const LINK_SCRIPT: &str = include_str!("./armv7a_vex_v5_linker_script.ld"); | ||
|
||
pub(crate) fn target() -> Target { | ||
Target { | ||
llvm_target: "armv7a-none-eabihf".into(), | ||
metadata: crate::spec::TargetMetadata { | ||
description: Some("Armv7-A Cortex-A9 VEX V5 Brain, VEXos".into()), | ||
tier: Some(3), | ||
host_tools: Some(false), | ||
std: Some(true), | ||
}, | ||
pointer_width: 32, | ||
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), | ||
arch: "arm".into(), | ||
options: TargetOptions { | ||
llvm_floatabi: Some(FloatAbi::Hard), | ||
os: "vexos".into(), | ||
is_like_vexos: true, | ||
vendor: "vex".into(), | ||
env: "v5".into(), | ||
cpu: "cortex-a9".into(), | ||
abi: "eabihf".into(), | ||
features: "+v7,+neon,+vfp3d16,+thumb2".into(), | ||
linker: Some("rust-lld".into()), | ||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), | ||
link_script: Some(LINK_SCRIPT.into()), | ||
panic_strategy: PanicStrategy::Abort, | ||
relocation_model: RelocModel::Static, | ||
c_enum_min_bits: Some(8), | ||
max_atomic_width: Some(64), | ||
disable_redzone: true, | ||
emit_debug_gdb_scripts: false, | ||
has_thumb_interworking: true, | ||
..Default::default() | ||
}, | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
compiler/rustc_target/src/spec/targets/armv7a_vex_v5_linker_script.ld
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
OUTPUT_FORMAT("elf32-littlearm") | ||
|
||
ENTRY(_boot) | ||
|
||
__user_ram_start = 0x03800000; | ||
__user_ram_length = 0x04800000; | ||
__user_ram_end = __user_ram_start + __user_ram_length; | ||
|
||
__code_signature_length = 0x20; | ||
|
||
__stack_length = 0x400000; | ||
__heap_end = __user_ram_end - __stack_length; | ||
|
||
/* see https://github.com/llvm/llvm-project/blob/main/libunwind/src/AddressSpace.hpp#L78 */ | ||
__eh_frame_hdr_start = SIZEOF(.eh_frame_hdr) > 0 ? ADDR(.eh_frame_hdr) : 0; | ||
__eh_frame_hdr_end = SIZEOF(.eh_frame_hdr) > 0 ? . : 0; | ||
|
||
MEMORY { | ||
USER_RAM : ORIGIN = __user_ram_start, LENGTH = __user_ram_length | ||
} | ||
|
||
SECTIONS { | ||
/* | ||
* VEXos expects program binaries to have a 32-byte header called a "code signature", | ||
* at their start, which tells the OS that we are a valid program and configures some | ||
* miscellaneous startup behavior. | ||
* | ||
* This section is then initialized as a weak symbol in our PAL. | ||
*/ | ||
.code_signature : { | ||
KEEP(*(.code_signature)) | ||
. = __user_ram_start + __code_signature_length; | ||
} > USER_RAM | ||
|
||
.text : { | ||
*(.boot) | ||
*(.text .text.*) | ||
} > USER_RAM | ||
|
||
/* Global/uninitialized/static/constant data sections. */ | ||
.rodata : { | ||
*(.rodata .rodata.*) | ||
} > USER_RAM | ||
|
||
.data : { | ||
*(.data .data.*) | ||
} > USER_RAM | ||
|
||
.bss : { | ||
__bss_start = .; | ||
*(.bss .bss.*) | ||
__bss_end = .; | ||
} > USER_RAM | ||
|
||
/* | ||
* These sections are added by the compiler in some cases to facilitate stack unwinding. | ||
* __eh_frame_start and similar symbols are used by libunwind. | ||
*/ | ||
.eh_frame_hdr : { | ||
KEEP(*(.eh_frame_hdr)) | ||
} > USER_RAM | ||
|
||
.eh_frame : { | ||
__eh_frame_start = .; | ||
KEEP(*(.eh_frame)) | ||
__eh_frame_end = .; | ||
} > USER_RAM | ||
|
||
.ARM.exidx : { | ||
__exidx_start = .; | ||
*(.ARM.exidx*) | ||
__exidx_end = .; | ||
} > USER_RAM | ||
|
||
.ARM.extab : { | ||
__extab_start = .; | ||
*(.ARM.extab*) | ||
__extab_end = .; | ||
} > USER_RAM | ||
|
||
/* Active memory regions for the stack/heap. */ | ||
.heap (NOLOAD) : ALIGN(4) { | ||
__heap_start = .; | ||
. = __heap_end; | ||
} > USER_RAM | ||
|
||
.stack (NOLOAD) : ALIGN(8) { | ||
__stack_bottom = .; | ||
. += __stack_length; | ||
__stack_top = .; | ||
} > USER_RAM | ||
|
||
/* | ||
* `.ARM.attributes` contains arch metadata for compatibility purposes, but we | ||
* only target one hardware configuration, meaning it'd just take up space. | ||
*/ | ||
/DISCARD/ : { | ||
*(.ARM.attributes*) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint | ||
#![allow(static_mut_refs)] | ||
|
||
use crate::alloc::{GlobalAlloc, Layout, System}; | ||
use crate::ptr; | ||
use crate::sync::atomic::{AtomicBool, Ordering}; | ||
|
||
static mut DLMALLOC: dlmalloc::Dlmalloc<Vexos> = dlmalloc::Dlmalloc::new_with_allocator(Vexos); | ||
|
||
extern "C" { | ||
static mut __heap_start: u8; | ||
static mut __heap_end: u8; | ||
} | ||
|
||
struct Vexos; | ||
|
||
unsafe impl dlmalloc::Allocator for Vexos { | ||
/// Allocs system resources | ||
fn alloc(&self, _size: usize) -> (*mut u8, usize, u32) { | ||
static INIT: AtomicBool = AtomicBool::new(false); | ||
|
||
if !INIT.swap(true, Ordering::Relaxed) { | ||
unsafe { | ||
( | ||
ptr::addr_of_mut!(__heap_start).cast(), | ||
ptr::addr_of!(__heap_end).byte_offset_from(ptr::addr_of!(__heap_start)) as _, | ||
0, | ||
) | ||
} | ||
} else { | ||
(ptr::null_mut(), 0, 0) | ||
} | ||
} | ||
|
||
fn remap(&self, _ptr: *mut u8, _oldsize: usize, _newsize: usize, _can_move: bool) -> *mut u8 { | ||
ptr::null_mut() | ||
} | ||
|
||
fn free_part(&self, _ptr: *mut u8, _oldsize: usize, _newsize: usize) -> bool { | ||
false | ||
} | ||
|
||
fn free(&self, _ptr: *mut u8, _size: usize) -> bool { | ||
false | ||
} | ||
|
||
fn can_release_part(&self, _flags: u32) -> bool { | ||
false | ||
} | ||
|
||
fn allocates_zeros(&self) -> bool { | ||
false | ||
} | ||
|
||
fn page_size(&self) -> usize { | ||
0x1000 | ||
} | ||
} | ||
|
||
#[stable(feature = "alloc_system_type", since = "1.28.0")] | ||
unsafe impl GlobalAlloc for System { | ||
#[inline] | ||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 { | ||
// SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access. | ||
// Calling malloc() is safe because preconditions on this function match the trait method preconditions. | ||
let _lock = lock::lock(); | ||
unsafe { DLMALLOC.malloc(layout.size(), layout.align()) } | ||
} | ||
|
||
#[inline] | ||
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { | ||
// SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access. | ||
// Calling calloc() is safe because preconditions on this function match the trait method preconditions. | ||
let _lock = lock::lock(); | ||
unsafe { DLMALLOC.calloc(layout.size(), layout.align()) } | ||
} | ||
|
||
#[inline] | ||
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { | ||
// SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access. | ||
// Calling free() is safe because preconditions on this function match the trait method preconditions. | ||
let _lock = lock::lock(); | ||
unsafe { DLMALLOC.free(ptr, layout.size(), layout.align()) } | ||
} | ||
|
||
#[inline] | ||
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { | ||
// SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access. | ||
// Calling realloc() is safe because preconditions on this function match the trait method preconditions. | ||
let _lock = lock::lock(); | ||
unsafe { DLMALLOC.realloc(ptr, layout.size(), layout.align(), new_size) } | ||
} | ||
} | ||
|
||
mod lock { | ||
#[inline] | ||
pub fn lock() {} // we don't have threads, which makes this real easy | ||
} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pub mod os { | ||
pub const FAMILY: &str = ""; | ||
pub const OS: &str = "vexos"; | ||
pub const DLL_PREFIX: &str = ""; | ||
pub const DLL_SUFFIX: &str = ""; | ||
pub const DLL_EXTENSION: &str = ""; | ||
pub const EXE_SUFFIX: &str = ".bin"; | ||
pub const EXE_EXTENSION: &str = "bin"; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.