Skip to content

Commit 0bf8356

Browse files
authored
Merge pull request #101 from thejpster/all-examples-exit-zero
All examples now return exit code zero
2 parents 3dea14a + 363b797 commit 0bf8356

39 files changed

Lines changed: 64 additions & 201 deletions

examples/mps3-an536/reference/el2_hello-armv8r-none-eabihf.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PANIC: PanicInfo {
1919
message: I am an example panic,
2020
location: Location {
2121
file: "src/bin/el2_hello.rs",
22-
line: 27,
22+
line: 28,
2323
column: 5,
2424
},
2525
can_unwind: true,

examples/mps3-an536/reference/hello-armv8r-none-eabihf.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PANIC: PanicInfo {
33
message: I am an example panic,
44
location: Location {
55
file: "src/bin/hello.rs",
6-
line: 18,
6+
line: 20,
77
column: 5,
88
},
99
can_unwind: true,

examples/mps3-an536/reference/svc-a32-armv8r-none-eabihf.out

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000
22
In svc_handler, with arg=0xabcdef
33
In svc_handler, with arg=0x456789
44
x = 1, y = 2, z = 3.000
5-
PANIC: PanicInfo {
6-
message: I am an example panic,
7-
location: Location {
8-
file: "src/bin/svc-a32.rs",
9-
line: 21,
10-
column: 5,
11-
},
12-
can_unwind: true,
13-
force_no_backtrace: false,
14-
}

examples/mps3-an536/reference/svc-t32-armv8r-none-eabihf.out

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,3 @@ x = 1, y = 2, z = 3.000
22
In svc_handler, with arg=0x000012
33
In svc_handler, with arg=0x000034
44
x = 1, y = 2, z = 3.000
5-
PANIC: PanicInfo {
6-
message: I am an example panic,
7-
location: Location {
8-
file: "src/bin/svc-t32.rs",
9-
line: 23,
10-
column: 5,
11-
},
12-
can_unwind: true,
13-
force_no_backtrace: false,
14-
}

examples/mps3-an536/src/bin/el2_hello.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn main() -> ! {
2424
}
2525
}
2626

27+
mps3_an536::want_panic();
2728
panic!("I am an example panic");
2829
}
2930

examples/mps3-an536/src/bin/hello.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
#![no_main]
55

66
use aarch32_rt::entry;
7-
use mps3_an536 as _;
87
use semihosting::println;
98

9+
use mps3_an536 as _;
10+
1011
/// The entry-point to the Rust application.
1112
///
1213
/// It is called by the start-up code in `aarch32-rt`.
@@ -15,5 +16,6 @@ fn main() -> ! {
1516
let x = 1.0f64;
1617
let y = x * 2.0;
1718
println!("Hello, this is semihosting! x = {:0.3}, y = {:0.3}", x, y);
19+
mps3_an536::want_panic();
1820
panic!("I am an example panic");
1921
}

examples/mps3-an536/src/bin/svc-a32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn main() -> ! {
1818
println!("x = {}, y = {}, z = {:0.3}", x, y, z);
1919
aarch32_cpu::svc!(0xABCDEF);
2020
println!("x = {}, y = {}, z = {:0.3}", x, y, z);
21-
panic!("I am an example panic");
21+
semihosting::process::exit(0);
2222
}
2323

2424
/// This is our SVC exception handler

examples/mps3-an536/src/bin/svc-t32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn main() -> ! {
2020
svc12_from_t32();
2121
}
2222
println!("x = {}, y = {}, z = {:0.3}", x, y, z);
23-
panic!("I am an example panic");
23+
semihosting::process::exit(0);
2424
}
2525

2626
/// This is our SVC exception handler

examples/mps3-an536/src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ pub const VIRTUAL_TIMER_PPI: arm_gic::IntId = arm_gic::IntId::ppi(11);
6464
#[cfg(not(arm_architecture = "v8-r"))]
6565
compile_error!("This example is only compatible to the ARMv8-R architecture");
6666

67+
static WANT_PANIC: AtomicBool = AtomicBool::new(false);
68+
6769
/// Called when the application raises an unrecoverable `panic!`.
6870
///
6971
/// Prints the panic to the console and then exits QEMU using a semihosting
@@ -72,7 +74,16 @@ compile_error!("This example is only compatible to the ARMv8-R architecture");
7274
#[cfg(target_os = "none")]
7375
fn panic(info: &core::panic::PanicInfo) -> ! {
7476
semihosting::println!("PANIC: {:#?}", info);
75-
semihosting::process::abort();
77+
if WANT_PANIC.load(Ordering::Relaxed) {
78+
semihosting::process::exit(0);
79+
} else {
80+
semihosting::process::abort();
81+
}
82+
}
83+
84+
/// Set the panic function as no longer returning a failure code via semihosting
85+
pub fn want_panic() {
86+
WANT_PANIC.store(true, Ordering::Relaxed);
7687
}
7788

7889
#[derive(Clone, Debug)]

examples/versatileab/reference/hello-armv4t-none-eabi.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PANIC: PanicInfo {
33
message: I am an example panic,
44
location: Location {
55
file: "src/bin/hello.rs",
6-
line: 18,
6+
line: 19,
77
column: 5,
88
},
99
can_unwind: true,

0 commit comments

Comments
 (0)