Skip to content

Commit 0472a7f

Browse files
committed
Ran rustfmt - although sadly rustfmt has no sense of style, so it's made it worse
1 parent aba94b1 commit 0472a7f

3 files changed

Lines changed: 87 additions & 27 deletions

File tree

aarch32-cpu/src/lib.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ macro_rules! svc1 {
6161
let arg0: u32 = $arg0;
6262
unsafe {
6363
core::arch::asm!(
64-
"push {{ r7 }} // This is the frame pointer and we must save it",
64+
"push {{ r7 }} // This is the frame pointer and we must save it",
6565
"movs r7, r0 // Move into the now free r7",
6666
"svc {arg} // Do the SVCall",
67-
"pop {{ r7 }} // Restore the frame pointer",
68-
arg = const $num,
67+
"pop {{ r7 }} // Restore the frame pointer",
68+
arg = const $num,
6969
inout("r0") arg0 => retval,
7070
out("lr") _);
7171
}
@@ -85,11 +85,11 @@ macro_rules! svc2 {
8585
let arg1: u32 = $arg1;
8686
unsafe {
8787
core::arch::asm!(
88-
"push {{ r7 }} // This is the frame pointer and we must save it",
88+
"push {{ r7 }} // This is the frame pointer and we must save it",
8989
"movs r7, {i} // Move into the now free r7",
9090
"svc {arg} // Do the SVCall",
91-
"pop {{ r7 }} // Restore the frame pointer",
92-
arg = const $num,
91+
"pop {{ r7 }} // Restore the frame pointer",
92+
arg = const $num,
9393
i = in(reg) arg0,
9494
inout("r0") arg1 => retval,
9595
out("lr") _);
@@ -111,11 +111,11 @@ macro_rules! svc3 {
111111
let arg2: u32 = $arg2;
112112
unsafe {
113113
core::arch::asm!(
114-
"push {{ r7 }} // This is the frame pointer and we must save it",
114+
"push {{ r7 }} // This is the frame pointer and we must save it",
115115
"movs r7, {i} // Move into the now free r7",
116116
"svc {arg} // Do the SVCall",
117-
"pop {{ r7 }} // Restore the frame pointer",
118-
arg = const $num,
117+
"pop {{ r7 }} // Restore the frame pointer",
118+
arg = const $num,
119119
i = in(reg) arg0,
120120
inout("r0") arg1 => retval,
121121
in("r1") arg2,
@@ -139,11 +139,11 @@ macro_rules! svc4 {
139139
let arg3: u32 = $arg3;
140140
unsafe {
141141
core::arch::asm!(
142-
"push {{ r7 }} // This is the frame pointer and we must save it",
142+
"push {{ r7 }} // This is the frame pointer and we must save it",
143143
"movs r7, {i} // Move into the now free r7",
144144
"svc {arg} // Do the SVCall",
145-
"pop {{ r7 }} // Restore the frame pointer",
146-
arg = const $num,
145+
"pop {{ r7 }} // Restore the frame pointer",
146+
arg = const $num,
147147
i = in(reg) arg0,
148148
inout("r0") arg1 => retval,
149149
in("r1") arg2,
@@ -169,11 +169,11 @@ macro_rules! svc5 {
169169
let arg4: u32 = $arg4;
170170
unsafe {
171171
core::arch::asm!(
172-
"push {{ r7 }} // This is the frame pointer and we must save it",
172+
"push {{ r7 }} // This is the frame pointer and we must save it",
173173
"movs r7, {i} // Move into the now free r7",
174174
"svc {arg} // Do the SVCall",
175-
"pop {{ r7 }} // Restore the frame pointer",
176-
arg = const $num,
175+
"pop {{ r7 }} // Restore the frame pointer",
176+
arg = const $num,
177177
i = in(reg) arg0,
178178
inout("r0") arg1 => retval,
179179
in("r1") arg2,
@@ -201,11 +201,11 @@ macro_rules! svc6 {
201201
let arg5: u32 = $arg5;
202202
unsafe {
203203
core::arch::asm!(
204-
"push {{ r7 }} // This is the frame pointer and we must save it",
204+
"push {{ r7 }} // This is the frame pointer and we must save it",
205205
"movs r7, {i} // Move into the now free r7",
206206
"svc {arg} // Do the SVCall",
207-
"pop {{ r7 }} // Restore the frame pointer",
208-
arg = const $num,
207+
"pop {{ r7 }} // Restore the frame pointer",
208+
arg = const $num,
209209
i = in(reg) arg0,
210210
inout("r0") arg1 => retval,
211211
in("r1") arg2,

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

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#![no_main]
1313

1414
use aarch32_rt::{entry, exception};
15-
use semihosting::println;
1615
use mps3_an536 as _;
16+
use semihosting::println;
1717

1818
/// The entry-point to the Rust application.
1919
///
@@ -25,11 +25,26 @@ fn main() -> ! {
2525
let z = (y as f64) * 1.5;
2626
println!("x = {}, y = {}, z = {:0.3}", x, y, z);
2727

28-
let retval = aarch32_cpu::svc6!(0xF6, 0xE000_0001, 0xE000_0002, 0xE000_0003, 0xE000_0004, 0xE000_0005, 0xE000_0006);
28+
let retval = aarch32_cpu::svc6!(
29+
0xF6,
30+
0xE000_0001,
31+
0xE000_0002,
32+
0xE000_0003,
33+
0xE000_0004,
34+
0xE000_0005,
35+
0xE000_0006
36+
);
2937
if retval != 0xF065_4321 {
3038
panic!("Wanted 0xF065_4321, got {:08x}", retval);
3139
}
32-
let retval = aarch32_cpu::svc5!(0xF5, 0xE000_0001, 0xE000_0002, 0xE000_0003, 0xE000_0004, 0xE000_0005);
40+
let retval = aarch32_cpu::svc5!(
41+
0xF5,
42+
0xE000_0001,
43+
0xE000_0002,
44+
0xE000_0003,
45+
0xE000_0004,
46+
0xE000_0005
47+
);
3348
if retval != 0xF005_4321 {
3449
panic!("Wanted 0xF005_4321, got {:08x}", retval);
3550
}
@@ -68,8 +83,23 @@ fn svc_handler(arg: u32, frame: &aarch32_rt::Frame) -> u32 {
6883
0xF2 => 0x1000_0000 + frame.r7 + (frame.r0 << 4),
6984
0xF3 => 0x1000_0000 + frame.r7 + (frame.r0 << 4) + (frame.r1 << 8),
7085
0xF4 => 0x1000_0000 + frame.r7 + (frame.r0 << 4) + (frame.r1 << 8) + (frame.r2 << 12),
71-
0xF5 => 0x1000_0000 + frame.r7 + (frame.r0 << 4) + (frame.r1 << 8) + (frame.r2 << 12) + (frame.r3 << 16),
72-
0xF6 => 0x1000_0000 + frame.r7 + (frame.r0 << 4) + (frame.r1 << 8) + (frame.r2 << 12) + (frame.r3 << 16) + (frame.r4 << 20),
86+
0xF5 => {
87+
0x1000_0000
88+
+ frame.r7
89+
+ (frame.r0 << 4)
90+
+ (frame.r1 << 8)
91+
+ (frame.r2 << 12)
92+
+ (frame.r3 << 16)
93+
}
94+
0xF6 => {
95+
0x1000_0000
96+
+ frame.r7
97+
+ (frame.r0 << 4)
98+
+ (frame.r1 << 8)
99+
+ (frame.r2 << 12)
100+
+ (frame.r3 << 16)
101+
+ (frame.r4 << 20)
102+
}
73103
_ => 0xDEADC0DE,
74104
}
75105
}

examples/versatileab/src/bin/syscall.rs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,26 @@ fn main() -> ! {
2525
let z = (y as f64) * 1.5;
2626
println!("x = {}, y = {}, z = {:0.3}", x, y, z);
2727

28-
let retval = aarch32_cpu::svc6!(0xF6, 0xE000_0001, 0xE000_0002, 0xE000_0003, 0xE000_0004, 0xE000_0005, 0xE000_0006);
28+
let retval = aarch32_cpu::svc6!(
29+
0xF6,
30+
0xE000_0001,
31+
0xE000_0002,
32+
0xE000_0003,
33+
0xE000_0004,
34+
0xE000_0005,
35+
0xE000_0006
36+
);
2937
if retval != 0xF065_4321 {
3038
panic!("Wanted 0xF065_4321, got {:08x}", retval);
3139
}
32-
let retval = aarch32_cpu::svc5!(0xF5, 0xE000_0001, 0xE000_0002, 0xE000_0003, 0xE000_0004, 0xE000_0005);
40+
let retval = aarch32_cpu::svc5!(
41+
0xF5,
42+
0xE000_0001,
43+
0xE000_0002,
44+
0xE000_0003,
45+
0xE000_0004,
46+
0xE000_0005
47+
);
3348
if retval != 0xF005_4321 {
3449
panic!("Wanted 0xF005_4321, got {:08x}", retval);
3550
}
@@ -68,8 +83,23 @@ fn svc_handler(arg: u32, frame: &aarch32_rt::Frame) -> u32 {
6883
0xF2 => 0x1000_0000 + frame.r7 + (frame.r0 << 4),
6984
0xF3 => 0x1000_0000 + frame.r7 + (frame.r0 << 4) + (frame.r1 << 8),
7085
0xF4 => 0x1000_0000 + frame.r7 + (frame.r0 << 4) + (frame.r1 << 8) + (frame.r2 << 12),
71-
0xF5 => 0x1000_0000 + frame.r7 + (frame.r0 << 4) + (frame.r1 << 8) + (frame.r2 << 12) + (frame.r3 << 16),
72-
0xF6 => 0x1000_0000 + frame.r7 + (frame.r0 << 4) + (frame.r1 << 8) + (frame.r2 << 12) + (frame.r3 << 16) + (frame.r4 << 20),
86+
0xF5 => {
87+
0x1000_0000
88+
+ frame.r7
89+
+ (frame.r0 << 4)
90+
+ (frame.r1 << 8)
91+
+ (frame.r2 << 12)
92+
+ (frame.r3 << 16)
93+
}
94+
0xF6 => {
95+
0x1000_0000
96+
+ frame.r7
97+
+ (frame.r0 << 4)
98+
+ (frame.r1 << 8)
99+
+ (frame.r2 << 12)
100+
+ (frame.r3 << 16)
101+
+ (frame.r4 << 20)
102+
}
73103
_ => 0xDEADC0DE,
74104
}
75105
}

0 commit comments

Comments
 (0)