Skip to content

Commit 50b993a

Browse files
committed
Allow generic_timer example to build for Armv7-R.
It just stubs out all the timer code.
1 parent bff4c63 commit 50b993a

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ jobs:
7171
- name: Build
7272
run: |
7373
cargo build --target ${{ matrix.target }} -Zbuild-std=core
74+
cargo build --target ${{ matrix.target }} -Zbuild-std=core --no-default-features
75+
cargo build --target ${{ matrix.target }} -Zbuild-std=core --all-features
7476
7577
# Gather all the above build jobs together for the purposes of getting an overall pass-fail
7678
build-all:

cortex-r-examples/src/bin/generic_timer.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#![no_main]
55

66
// pull in our start-up code
7-
use cortex_r::generic_timer::{El1PhysicalTimer, El1VirtualTimer, GenericTimer};
87
use cortex_r_examples as _;
98

109
use semihosting::println;
@@ -14,16 +13,20 @@ use semihosting::println;
1413
/// It is called by the start-up code in `cortex-m-rt`.
1514
#[no_mangle]
1615
pub extern "C" fn kmain() {
17-
if let Err(e) = main() {
18-
panic!("main returned {:?}", e);
19-
}
16+
main();
2017
semihosting::process::exit(0);
2118
}
2219

23-
/// The main function of our Rust application.
24-
///
25-
/// Called by [`kmain`].
26-
fn main() -> Result<(), core::fmt::Error> {
20+
/// A placeholder function so that the workspace still builds
21+
#[cfg(not(arm_architecture = "v8-r"))]
22+
fn main() {
23+
println!("No generic timers on this platform");
24+
}
25+
26+
/// Let's test some timers!
27+
#[cfg(arm_architecture = "v8-r")]
28+
fn main() {
29+
use cortex_r::generic_timer::{El1PhysicalTimer, El1VirtualTimer, GenericTimer};
2730
let cntfrq = cortex_r::register::Cntfrq::read().0;
2831
println!("cntfrq = {:.03} MHz", cntfrq as f32 / 1_000_000.0);
2932

@@ -68,6 +71,4 @@ fn main() -> Result<(), core::fmt::Error> {
6871
timer.countdown() as i32
6972
);
7073
}
71-
72-
Ok(())
7374
}

cortex-r/src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@
55
#[cfg(feature = "critical-section-single-core")]
66
mod critical_section;
77

8-
pub mod register;
9-
10-
pub mod interrupt;
11-
128
pub mod asm;
13-
14-
#[cfg(any(test, arm_architecture = "v8-r"))]
15-
pub mod pmsav8;
9+
pub mod interrupt;
10+
pub mod register;
1611

1712
#[cfg(any(test, arm_architecture = "v7-r"))]
1813
pub mod pmsav7;
1914

20-
#[cfg(arm_architecture = "v8-r")]
15+
#[cfg(any(test, arm_architecture = "v8-r"))]
2116
pub mod generic_timer;
2217

18+
#[cfg(any(test, arm_architecture = "v8-r"))]
19+
pub mod pmsav8;
20+
2321
/// Generate an SVC call with the given argument.
2422
///
2523
/// Safe to call even in Supervisor (Svc) mode, as long as your Svc handler

cortex-r/src/register/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ pub use vmpidr::Vmpidr;
175175
pub use vpidr::Vpidr;
176176
pub use vsctlr::Vsctlr;
177177

178-
//#[cfg(arm_architecture = "v8-r")]
178+
#[cfg(arm_architecture = "v8-r")]
179179
pub mod armv8r;
180-
//#[cfg(arm_architecture = "v8-r")]
180+
#[cfg(arm_architecture = "v8-r")]
181181
pub use armv8r::*;
182182

183183
pub use imp::*;

0 commit comments

Comments
 (0)