Skip to content

Commit 0af1cfc

Browse files
committed
Adds support for ARMv6 targets.
Targets added in rust-lang/rust#150138. Tested with local build of rustc. Will fail with the versions of nightly rust specified in the CI config. Need to wait for 2025-01-26 to come out. thumbv6-none-eabi isn't tested because it requires a new compiler-builtins that isn't upstream yet.
1 parent 69de225 commit 0af1cfc

31 files changed

Lines changed: 681 additions & 12 deletions

.cargo/config.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ runner = "qemu-system-arm -machine versatileab -cpu cortex-a8 -semihosting -nogr
3434
[target.thumbv7a-none-eabi]
3535
runner = "qemu-system-arm -machine versatileab -cpu cortex-a8 -semihosting -nographic -audio none -kernel"
3636

37+
[target.armv6-none-eabihf]
38+
runner = "qemu-system-arm -machine versatileab -cpu arm1176 -semihosting -nographic -audio none -kernel"
39+
40+
[target.armv6-none-eabi]
41+
runner = "qemu-system-arm -machine versatileab -cpu arm1176 -semihosting -nographic -audio none -kernel"
42+
43+
[target.thumbv6-none-eabi]
44+
runner = "qemu-system-arm -machine versatileab -cpu arm1176 -semihosting -nographic -audio none -kernel"
45+
3746
[target.armv5te-none-eabi]
3847
runner = "qemu-system-arm -machine versatileab -cpu arm926 -semihosting -nographic -audio none -kernel"
3948

aarch32-cpu/src/register/cpsr.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ impl Cpsr {
7575
/// `thumb*` targets, as Thumb-1 cannot do an MRS.
7676
#[cfg_attr(not(feature = "check-asm"), inline)]
7777
#[cfg_attr(
78-
any(arm_architecture = "v4t", arm_architecture = "v5te"),
78+
any(
79+
arm_architecture = "v4t",
80+
arm_architecture = "v5te",
81+
arm_architecture = "v6"
82+
),
7983
instruction_set(arm::a32)
8084
)]
8185
pub fn read() -> Self {
@@ -108,7 +112,11 @@ impl Cpsr {
108112
/// `thumb*` targets, as Thumb-1 cannot do an MSR.
109113
#[cfg_attr(not(feature = "check-asm"), inline)]
110114
#[cfg_attr(
111-
any(arm_architecture = "v4t", arm_architecture = "v5te"),
115+
any(
116+
arm_architecture = "v4t",
117+
arm_architecture = "v5te",
118+
arm_architecture = "v6"
119+
),
112120
instruction_set(arm::a32)
113121
)]
114122
pub unsafe fn write(_value: Self) {

aarch32-cpu/src/register/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ pub trait SysRegRead: SysReg {
225225
/// may have side-effects.
226226
#[cfg_attr(not(feature = "check-asm"), inline)]
227227
#[cfg_attr(
228-
any(arm_architecture = "v4t", arm_architecture = "v5te"),
228+
any(
229+
arm_architecture = "v4t",
230+
arm_architecture = "v5te",
231+
arm_architecture = "v6"
232+
),
229233
instruction_set(arm::a32)
230234
)]
231235
unsafe fn read_raw() -> u32 {
@@ -261,7 +265,11 @@ pub trait SysRegWrite: SysReg {
261265
/// writing valid data here.
262266
#[cfg_attr(not(feature = "check-asm"), inline)]
263267
#[cfg_attr(
264-
any(arm_architecture = "v4t", arm_architecture = "v5te"),
268+
any(
269+
arm_architecture = "v4t",
270+
arm_architecture = "v5te",
271+
arm_architecture = "v6"
272+
),
265273
instruction_set(arm::a32)
266274
)]
267275
unsafe fn write_raw(_value: u32) {

arm-targets/src/lib.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ impl Arch {
227227
Some(Arch::Armv7A)
228228
} else if target.starts_with("aarch64-") || target.starts_with("aarch64be-") {
229229
Some(Arch::Armv8A)
230-
} else if target.starts_with("arm-") {
230+
} else if target.starts_with("arm-")
231+
|| target.starts_with("armv6-")
232+
|| target.starts_with("thumbv6-")
233+
{
231234
// If not specified, assume Armv6
232235
Some(Arch::Armv6)
233236
} else {
@@ -407,6 +410,26 @@ mod test {
407410
assert_eq!(target_info.abi(), Some(Abi::Eabi));
408411
}
409412

413+
#[test]
414+
fn armv6_none_eabi() {
415+
let target = "armv6-none-eabi";
416+
let target_info = process_target(target);
417+
assert_eq!(target_info.isa(), Some(Isa::A32));
418+
assert_eq!(target_info.arch(), Some(Arch::Armv6));
419+
assert_eq!(target_info.profile(), Some(Profile::Legacy));
420+
assert_eq!(target_info.abi(), Some(Abi::Eabi));
421+
}
422+
423+
#[test]
424+
fn armv6_none_eabihf() {
425+
let target = "armv6-none-eabihf";
426+
let target_info = process_target(target);
427+
assert_eq!(target_info.isa(), Some(Isa::A32));
428+
assert_eq!(target_info.arch(), Some(Arch::Armv6));
429+
assert_eq!(target_info.profile(), Some(Profile::Legacy));
430+
assert_eq!(target_info.abi(), Some(Abi::EabiHf));
431+
}
432+
410433
#[test]
411434
fn arm_unknown_linux_gnueabi() {
412435
let target = "arm-unknown-linux-gnueabi";
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Hello, this is an data abort exception example
2+
data abort occurred
3+
DFSR (Fault Status Register): DFSR { ext=false wnr=false Domain=0b0000 Status=0b00001 }
4+
DFSR Status: Ok(AlignmentFault)
5+
caught unaligned_from_a32
6+
caught fault on COUNTER
7+
Doing it again
8+
data abort occurred
9+
DFSR (Fault Status Register): DFSR { ext=false wnr=false Domain=0b0000 Status=0b00001 }
10+
DFSR Status: Ok(AlignmentFault)
11+
caught unaligned_from_a32
12+
caught fault on COUNTER
13+
Skipping instruction
14+
Recovered from fault OK!
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Hello, this is an data abort exception example
2+
data abort occurred
3+
DFSR (Fault Status Register): DFSR { ext=false wnr=false Domain=0b0000 Status=0b00001 }
4+
DFSR Status: Ok(AlignmentFault)
5+
caught unaligned_from_a32
6+
caught fault on COUNTER
7+
Doing it again
8+
data abort occurred
9+
DFSR (Fault Status Register): DFSR { ext=false wnr=false Domain=0b0000 Status=0b00001 }
10+
DFSR Status: Ok(AlignmentFault)
11+
caught unaligned_from_a32
12+
caught fault on COUNTER
13+
Skipping instruction
14+
Recovered from fault OK!
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Hello, this is an data abort exception example
2+
data abort occurred
3+
DFSR (Fault Status Register): DFSR { ext=false wnr=false Domain=0b0000 Status=0b00001 }
4+
DFSR Status: Ok(AlignmentFault)
5+
caught unaligned_from_t32
6+
caught fault on COUNTER
7+
Doing it again
8+
data abort occurred
9+
DFSR (Fault Status Register): DFSR { ext=false wnr=false Domain=0b0000 Status=0b00001 }
10+
DFSR Status: Ok(AlignmentFault)
11+
caught unaligned_from_t32
12+
caught fault on COUNTER
13+
Skipping instruction
14+
Recovered from fault OK!
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Hello, this is an data abort exception example
2+
data abort occurred
3+
DFSR (Fault Status Register): DFSR { ext=false wnr=false Domain=0b0000 Status=0b00001 }
4+
DFSR Status: Ok(AlignmentFault)
5+
caught unaligned_from_t32
6+
caught fault on COUNTER
7+
Doing it again
8+
data abort occurred
9+
DFSR (Fault Status Register): DFSR { ext=false wnr=false Domain=0b0000 Status=0b00001 }
10+
DFSR Status: Ok(AlignmentFault)
11+
caught unaligned_from_t32
12+
caught fault on COUNTER
13+
Skipping instruction
14+
Recovered from fault OK!
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
Sine wave test (f32)...
2+
( 0.0000) ..............................o
3+
( 0.1253) .................................o
4+
( 0.2487) .....................................o
5+
( 0.3681) .........................................o
6+
( 0.4818) ............................................o
7+
( 0.5878) ...............................................o
8+
( 0.6845) ..................................................o
9+
( 0.7705) .....................................................o
10+
( 0.8443) .......................................................o
11+
( 0.9048) .........................................................o
12+
( 0.9511) ..........................................................o
13+
( 0.9823) ...........................................................o
14+
( 0.9980) ...........................................................o
15+
( 0.9980) ...........................................................o
16+
( 0.9823) ...........................................................o
17+
( 0.9511) ..........................................................o
18+
( 0.9048) .........................................................o
19+
( 0.8443) .......................................................o
20+
( 0.7705) .....................................................o
21+
( 0.6845) ..................................................o
22+
( 0.5878) ...............................................o
23+
( 0.4818) ............................................o
24+
( 0.3681) .........................................o
25+
( 0.2487) .....................................o
26+
( 0.1253) .................................o
27+
(-0.0000) .............................o
28+
(-0.1253) ..........................o
29+
(-0.2487) ......................o
30+
(-0.3681) ..................o
31+
(-0.4818) ...............o
32+
(-0.5878) ............o
33+
(-0.6845) .........o
34+
(-0.7705) ......o
35+
(-0.8443) ....o
36+
(-0.9048) ..o
37+
(-0.9511) .o
38+
(-0.9823) o
39+
(-0.9980) o
40+
(-0.9980) o
41+
(-0.9823) o
42+
(-0.9511) .o
43+
(-0.9048) ..o
44+
(-0.8443) ....o
45+
(-0.7705) ......o
46+
(-0.6845) .........o
47+
(-0.5878) ............o
48+
(-0.4818) ...............o
49+
(-0.3681) ..................o
50+
(-0.2487) ......................o
51+
(-0.1253) ..........................o
52+
( 0.0000) ..............................o
53+
( 0.1253) .................................o
54+
( 0.2487) .....................................o
55+
( 0.3681) .........................................o
56+
( 0.4818) ............................................o
57+
( 0.5878) ...............................................o
58+
( 0.6845) ..................................................o
59+
( 0.7705) .....................................................o
60+
( 0.8443) .......................................................o
61+
( 0.9048) .........................................................o
62+
( 0.9511) ..........................................................o
63+
( 0.9823) ...........................................................o
64+
( 0.9980) ...........................................................o
65+
( 0.9980) ...........................................................o
66+
( 0.9823) ...........................................................o
67+
( 0.9511) ..........................................................o
68+
( 0.9048) .........................................................o
69+
( 0.8443) .......................................................o
70+
( 0.7705) .....................................................o
71+
( 0.6845) ..................................................o
72+
( 0.5878) ...............................................o
73+
( 0.4818) ............................................o
74+
( 0.3681) .........................................o
75+
( 0.2487) .....................................o
76+
( 0.1253) .................................o
77+
(-0.0000) ..............................o
78+
(-0.1253) ..........................o
79+
(-0.2487) ......................o
80+
(-0.3681) ..................o
81+
(-0.4818) ...............o
82+
(-0.5878) ............o
83+
(-0.6845) .........o
84+
(-0.7705) ......o
85+
(-0.8443) ....o
86+
(-0.9048) ..o
87+
(-0.9511) .o
88+
(-0.9823) o
89+
(-0.9980) o
90+
(-0.9980) o
91+
(-0.9823) o
92+
(-0.9511) .o
93+
(-0.9048) ..o
94+
(-0.8443) ....o
95+
(-0.7705) ......o
96+
(-0.6845) .........o
97+
(-0.5878) ............o
98+
(-0.4818) ...............o
99+
(-0.3681) ..................o
100+
(-0.2487) ......................o
101+
(-0.1253) ..........................o
102+
Sine wave test (f64)...
103+
( 0.0000) ..............................o
104+
( 0.1253) .................................o
105+
( 0.2487) .....................................o
106+
( 0.3681) .........................................o
107+
( 0.4818) ............................................o
108+
( 0.5878) ...............................................o
109+
( 0.6845) ..................................................o
110+
( 0.7705) .....................................................o
111+
( 0.8443) .......................................................o
112+
( 0.9048) .........................................................o
113+
( 0.9511) ..........................................................o
114+
( 0.9823) ...........................................................o
115+
( 0.9980) ...........................................................o
116+
( 0.9980) ...........................................................o
117+
( 0.9823) ...........................................................o
118+
( 0.9511) ..........................................................o
119+
( 0.9048) .........................................................o
120+
( 0.8443) .......................................................o
121+
( 0.7705) .....................................................o
122+
( 0.6845) ..................................................o
123+
( 0.5878) ...............................................o
124+
( 0.4818) ............................................o
125+
( 0.3681) .........................................o
126+
( 0.2487) .....................................o
127+
( 0.1253) .................................o
128+
(-0.0000) .............................o
129+
(-0.1253) ..........................o
130+
(-0.2487) ......................o
131+
(-0.3681) ..................o
132+
(-0.4818) ...............o
133+
(-0.5878) ............o
134+
(-0.6845) .........o
135+
(-0.7705) ......o
136+
(-0.8443) ....o
137+
(-0.9048) ..o
138+
(-0.9511) .o
139+
(-0.9823) o
140+
(-0.9980) o
141+
(-0.9980) o
142+
(-0.9823) o
143+
(-0.9511) .o
144+
(-0.9048) ..o
145+
(-0.8443) ....o
146+
(-0.7705) ......o
147+
(-0.6845) .........o
148+
(-0.5878) ............o
149+
(-0.4818) ...............o
150+
(-0.3681) ..................o
151+
(-0.2487) ......................o
152+
(-0.1253) ..........................o
153+
( 0.0000) ..............................o
154+
( 0.1253) .................................o
155+
( 0.2487) .....................................o
156+
( 0.3681) .........................................o
157+
( 0.4818) ............................................o
158+
( 0.5878) ...............................................o
159+
( 0.6845) ..................................................o
160+
( 0.7705) .....................................................o
161+
( 0.8443) .......................................................o
162+
( 0.9048) .........................................................o
163+
( 0.9511) ..........................................................o
164+
( 0.9823) ...........................................................o
165+
( 0.9980) ...........................................................o
166+
( 0.9980) ...........................................................o
167+
( 0.9823) ...........................................................o
168+
( 0.9511) ..........................................................o
169+
( 0.9048) .........................................................o
170+
( 0.8443) .......................................................o
171+
( 0.7705) .....................................................o
172+
( 0.6845) ..................................................o
173+
( 0.5878) ...............................................o
174+
( 0.4818) ............................................o
175+
( 0.3681) .........................................o
176+
( 0.2487) .....................................o
177+
( 0.1253) .................................o
178+
(-0.0000) .............................o
179+
(-0.1253) ..........................o
180+
(-0.2487) ......................o
181+
(-0.3681) ..................o
182+
(-0.4818) ...............o
183+
(-0.5878) ............o
184+
(-0.6845) .........o
185+
(-0.7705) ......o
186+
(-0.8443) ....o
187+
(-0.9048) ..o
188+
(-0.9511) .o
189+
(-0.9823) o
190+
(-0.9980) o
191+
(-0.9980) o
192+
(-0.9823) o
193+
(-0.9511) .o
194+
(-0.9048) ..o
195+
(-0.8443) ....o
196+
(-0.7705) ......o
197+
(-0.6845) .........o
198+
(-0.5878) ............o
199+
(-0.4818) ...............o
200+
(-0.3681) ..................o
201+
(-0.2487) ......................o
202+
(-0.1253) ..........................o

0 commit comments

Comments
 (0)