Skip to content

Commit dfa7a44

Browse files
Merge pull request #78 from thejpster/merge-rename
Create aarch32-cpu and aarch32-rt crates.
2 parents b7d60b9 + 182fa95 commit dfa7a44

File tree

373 files changed

+1866
-1989
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

373 files changed

+1866
-1989
lines changed

.cargo/config.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,11 @@ runner = "qemu-system-arm -machine versatileab -cpu cortex-a8 -semihosting -nogr
1616
[target.armv7a-none-eabi]
1717
runner = "qemu-system-arm -machine versatileab -cpu cortex-a8 -semihosting -nographic -audio none -kernel"
1818

19+
[target.armv5te-none-eabi]
20+
runner = "qemu-system-arm -machine versatileab -cpu arm926 -semihosting -nographic -audio none -kernel"
21+
22+
[target.armv4t-none-eabi]
23+
runner = "qemu-system-arm -machine versatileab -cpu pxa250 -semihosting -nographic -audio none -kernel"
24+
1925
[unstable]
2026
build-std = ["core", "alloc"]

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ jobs:
294294
rustup default stable
295295
- name: Run cargo test
296296
run: |
297-
cargo test --manifest-path cortex-ar/Cargo.toml
297+
cargo test --manifest-path aarch32-cpu/Cargo.toml
298298
299299
# Run some programs in QEMU 9
300300
qemu-test:

Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ exclude = [
55
"examples/mps3-an536",
66
]
77
members = [
8-
"cortex-ar",
9-
"cortex-r-rt",
10-
"cortex-a-rt",
11-
"cortex-ar-rt-macros",
8+
"aarch32-cpu",
9+
"aarch32-rt",
10+
"aarch32-rt-macros",
1211
]
1312
resolver = "2"

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
# Rust on Arm Cortex-R and Cortex-A
1+
# Rust on Arm AArch32
22

33
This repository provides support for:
44

5+
* Legacy Arm Processors, like the ARM7TDMI and ARM926
56
* Armv7-R Processors, like the Arm Cortex-R5
67
* Armv8-R AArch32 Processors, like the Arm Cortex-R52
78
* Armv7-A Processors, like the Arm Cortex-A5
89
* Armv8-A AArch32 Processors, like the Arm Cortex-A53 running in 32-bit mode
910

11+
It does not support any M-Profile Processors (like the Arm Cortex-M3) as they
12+
have a fundamentally different interrupt vector table.
13+
14+
It also does not support processors running in AArch64 mode - A64 machine code
15+
uses different instructions for reading/writing system registers.
16+
1017
These libraries were originally written by Ferrous Systems, and are based on the
1118
[`cortex-m` libraries] from the [Rust Embedded Devices Working Group].
1219

@@ -15,11 +22,10 @@ These libraries were originally written by Ferrous Systems, and are based on the
1522

1623
There are currently five libraries here:
1724

18-
* [cortex-ar](./cortex-ar/) - support library for Cortex-R and Cortex-A CPUs (like [cortex-m])
19-
* [cortex-r-rt](./cortex-r-rt/) - run-time library for Cortex-R CPUs (like [cortex-m-rt])
20-
* [cortex-a-rt](./cortex-a-rt/) - run-time library for Cortex-A CPUs (like [cortex-m-rt])
25+
* [aarch32](./aarch32/) - support library for AArch32 CPUs (like the [cortex-m] crate)
26+
* [aarch32-rt](./aarch32-rt/) - run-time library for AArch32 CPUs (like the [cortex-m-rt] crate)
2127
* [arm-targets](./arm-targets/) - a helper library for your build.rs that sets various `--cfg` flags according to the current target
22-
* [cortex-ar-rt-macros](./cortex-ar-rt-macros/) - macros for `cortex-a-rt` and `cortex-r-rt` (this is an implementation detail - do not use this crate directly)
28+
* [aarch32-rt-macros](./aarch32-rt-macros/) - macros for `aarch32-rt` (this is an implementation detail - do not use this crate directly)
2329

2430
There are also example programs for QEMU in the [examples](./examples/) folder.
2531

cortex-ar/CHANGELOG.md renamed to aarch32-cpu/CHANGELOG.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10-
## [v0.3.0]
10+
### Changed
11+
12+
- Renamed from `cortex-ar` to `aarch32-cpu`
13+
- Added ARMv4T and ARMv5TE support
14+
15+
## [cortex-ar v0.3.0]
1116

12-
- Bumped MSRV for `cortex-ar` to v1.83 to allow compatibility with `arbitrary-int` v2.
17+
- Bumped MSRV to v1.83 to allow compatibility with `arbitrary-int` v2.
1318

1419
### Added
1520

@@ -30,7 +35,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3035
- Bumped `defmt` to v1
3136
- Bumped `arbitrary-int` to v2
3237

33-
## [v0.2.0]
38+
## [cortex-ar v0.2.0]
3439

3540
### Added
3641

@@ -45,11 +50,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4550
- The `dsb` and `isb` functions now include compiler fences
4651
- Added `nomem`, `nostack` and `preserves_flags` options for ASM where applicable.
4752

48-
## [v0.1.0]
53+
## [cortex-ar v0.1.0]
4954

5055
Initial release
5156

5257
[Unreleased]: https://github.com/rust-embedded/cortex-ar/compare/cortex-ar-v0.3.0...HEAD
53-
[v0.3.0]: https://github.com/rust-embedded/cortex-ar/compare/cortex-ar-v0.2.0...cortex-ar-v0.3.0
54-
[v0.2.0]: https://github.com/rust-embedded/cortex-ar/compare/cortex-ar-v0.1.0...cortex-ar-v0.2.0
55-
[v0.1.0]: https://github.com/rust-embedded/cortex-ar/releases/tag/cortex-ar-v0.1.0
58+
[cortex-ar v0.3.0]: https://github.com/rust-embedded/cortex-ar/compare/cortex-ar-v0.2.0...cortex-ar-v0.3.0
59+
[cortex-ar v0.2.0]: https://github.com/rust-embedded/cortex-ar/compare/cortex-ar-v0.1.0...cortex-ar-v0.2.0
60+
[cortex-ar v0.1.0]: https://github.com/rust-embedded/cortex-ar/releases/tag/cortex-ar-v0.1.0

cortex-ar/Cargo.toml renamed to aarch32-cpu/Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ categories = [
77
"embedded",
88
"no-std",
99
]
10-
description = "CPU support for AArch32 Arm Cortex-R and Arm Cortex-A"
10+
description = "CPU support for AArch32 Arm Processors"
1111
edition = "2021"
1212
keywords = [
1313
"arm",
@@ -17,12 +17,12 @@ keywords = [
1717
"no-std",
1818
]
1919
license = "MIT OR Apache-2.0"
20-
name = "cortex-ar"
20+
name = "aarch32-cpu"
2121
readme = "README.md"
2222
repository = "https://github.com/rust-embedded/cortex-ar.git"
2323
homepage = "https://github.com/rust-embedded/cortex-ar.git"
2424
rust-version = "1.83"
25-
version = "0.3.0"
25+
version = "0.1.0"
2626

2727
[dependencies]
2828
arbitrary-int = "2"
@@ -46,6 +46,9 @@ critical-section-multi-core = ["critical-section"]
4646
# Adds defmt::Format implementation for the register types
4747
defmt = ["dep:defmt", "arbitrary-int/defmt"]
4848
serde = ["dep:serde", "arbitrary-int/serde"]
49+
# Stops assembly routines being inlined, so they can be checked when this
50+
# library is compiled (as opposed to when the function is used)
51+
check-asm = []
4952

5053
[package.metadata.docs.rs]
5154
targets = ["armv7r-none-eabihf", "armv7r-none-eabi", "armv7a-none-eabihf"]

cortex-ar/README.md renamed to aarch32-cpu/README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
1-
[![crates.io](https://img.shields.io/crates/v/cortex-ar)](https://crates.io/crates/cortex-ar)
2-
[![docs.rs](https://img.shields.io/docsrs/cortex-ar)](https://docs.rs/cortex-ar)
1+
[![crates.io](https://img.shields.io/crates/v/aarch32-cpu)](https://crates.io/crates/aarch32-cpu)
2+
[![docs.rs](https://img.shields.io/docsrs/aarch32-cpu)](https://docs.rs/aarch32-cpu)
33

4-
# Support for Arm Cortex-R (AArch32) and Arm Cortex-A (AArch32)
4+
# Support for AArch32 Arm Processors
55

66
This crate provides access to CPU registers and common peripherals for:
77

8+
* Legacy Arm Processors, like the ARM7TDMI and ARM926
89
* Armv7-R Processors, like the Arm Cortex-R5
910
* Armv8-R AArch32 Processors, like the Arm Cortex-R52
1011
* Armv7-A Processors, like the Arm Cortex-A5
1112
* Armv8-A AArch32 Processors, like the Arm Cortex-A53 running in 32-bit mode
1213

13-
It does not support processors running in AArch64 mode - A64 machine code uses
14-
different instructions for reading/writing system registers.
14+
It does not support any M-Profile Processors (like the Arm Cortex-M3) as they
15+
have a fundamentally different interrupt vector table.
16+
17+
It also does not support processors running in AArch64 mode - A64 machine code
18+
uses different instructions for reading/writing system registers.
1519

1620
This crate contains:
1721

18-
* Raw register access to many Armv7-R and Armv8-R AArch32 system registers
22+
* Raw register access to many AArch32 system registers
1923
* A driver for the PMSAv7 Memory Protection Unit (MPU)
2024
* A driver for the PMSAv8-R Memory Protection Unit (MPU)
2125
* A driver for the Arm Generic Timer
2226

2327
If you need a driver for the Arm Generic Interrupt Controller, see
24-
<https://github.com/google/arm-gic>.
28+
<https://github.com/ArmFirmwareCrates/arm-gic>.
2529

2630
## Minimum Supported Rust Version (MSRV)
2731

File renamed without changes.

cortex-ar/src/asm.rs renamed to aarch32-cpu/src/asm.rs

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
//! Simple assembly routines
22
3-
use core::sync::atomic::{compiler_fence, Ordering};
4-
53
/// Data Memory Barrier
64
///
75
/// Ensures that all explicit memory accesses that appear in program order before the `DMB`
86
/// instruction are observed before any explicit memory accesses that appear in program order
97
/// after the `DMB` instruction.
10-
#[inline]
8+
#[cfg_attr(not(feature = "check-asm"), inline)]
9+
#[cfg(any(
10+
arm_architecture = "v7-r",
11+
arm_architecture = "v7-a",
12+
arm_architecture = "v8-r"
13+
))]
1114
pub fn dmb() {
15+
use core::sync::atomic::{compiler_fence, Ordering};
1216
compiler_fence(Ordering::SeqCst);
1317
unsafe {
1418
core::arch::asm!("dmb", options(nostack, preserves_flags));
@@ -23,8 +27,14 @@ pub fn dmb() {
2327
///
2428
/// * any explicit memory access made before this instruction is complete
2529
/// * all cache and branch predictor maintenance operations before this instruction complete
26-
#[inline]
30+
#[cfg_attr(not(feature = "check-asm"), inline)]
31+
#[cfg(any(
32+
arm_architecture = "v7-r",
33+
arm_architecture = "v7-a",
34+
arm_architecture = "v8-r"
35+
))]
2736
pub fn dsb() {
37+
use core::sync::atomic::{compiler_fence, Ordering};
2838
compiler_fence(Ordering::SeqCst);
2939
unsafe {
3040
core::arch::asm!("dsb", options(nostack, preserves_flags));
@@ -36,8 +46,14 @@ pub fn dsb() {
3646
///
3747
/// Flushes the pipeline in the processor, so that all instructions following the `ISB` are fetched
3848
/// from cache or memory, after the instruction has been completed.
39-
#[inline]
49+
#[cfg_attr(not(feature = "check-asm"), inline)]
50+
#[cfg(any(
51+
arm_architecture = "v7-r",
52+
arm_architecture = "v7-a",
53+
arm_architecture = "v8-r"
54+
))]
4055
pub fn isb() {
56+
use core::sync::atomic::{compiler_fence, Ordering};
4157
compiler_fence(Ordering::SeqCst);
4258
unsafe {
4359
core::arch::asm!("isb", options(nostack, preserves_flags));
@@ -46,25 +62,40 @@ pub fn isb() {
4662
}
4763

4864
/// Emit an NOP instruction
49-
#[inline]
65+
#[cfg_attr(not(feature = "check-asm"), inline)]
5066
pub fn nop() {
5167
unsafe { core::arch::asm!("nop", options(nomem, nostack, preserves_flags)) }
5268
}
5369

5470
/// Emit an WFI instruction
55-
#[inline]
71+
#[cfg_attr(not(feature = "check-asm"), inline)]
72+
#[cfg(any(
73+
arm_architecture = "v7-r",
74+
arm_architecture = "v7-a",
75+
arm_architecture = "v8-r"
76+
))]
5677
pub fn wfi() {
5778
unsafe { core::arch::asm!("wfi", options(nomem, nostack, preserves_flags)) }
5879
}
5980

6081
/// Emit an WFE instruction
61-
#[inline]
82+
#[cfg_attr(not(feature = "check-asm"), inline)]
83+
#[cfg(any(
84+
arm_architecture = "v7-r",
85+
arm_architecture = "v7-a",
86+
arm_architecture = "v8-r"
87+
))]
6288
pub fn wfe() {
6389
unsafe { core::arch::asm!("wfe", options(nomem, nostack, preserves_flags)) }
6490
}
6591

6692
/// Emit an SEV instruction
67-
#[inline]
93+
#[cfg_attr(not(feature = "check-asm"), inline)]
94+
#[cfg(any(
95+
arm_architecture = "v7-r",
96+
arm_architecture = "v7-a",
97+
arm_architecture = "v8-r"
98+
))]
6899
pub fn sev() {
69100
unsafe {
70101
core::arch::asm!("sev");
@@ -74,11 +105,20 @@ pub fn sev() {
74105
/// Which core are we?
75106
///
76107
/// Return the bottom 24-bits of the MPIDR
77-
#[inline]
108+
#[cfg_attr(not(feature = "check-asm"), inline)]
78109
pub fn core_id() -> u32 {
79110
let r: u32;
80111
unsafe {
81112
core::arch::asm!("MRC p15, 0, {}, c0, c0, 5", out(reg) r, options(nomem, nostack, preserves_flags));
82113
}
83114
r & 0x00FF_FFFF
84115
}
116+
117+
#[cfg(any(arm_architecture = "v4t", arm_architecture = "v5te"))]
118+
#[no_mangle]
119+
pub extern "C" fn __sync_synchronize() {
120+
// we don't have a barrier instruction - the linux kernel just uses an empty inline asm block
121+
unsafe {
122+
core::arch::asm!("");
123+
}
124+
}
File renamed without changes.

0 commit comments

Comments
 (0)