Skip to content

Commit e395753

Browse files
committed
Remove the system_init macro and replaced with blocks of asm marked with cfg.
Requires Rust 1.93 or higher.
1 parent 9c63190 commit e395753

5 files changed

Lines changed: 49 additions & 77 deletions

File tree

aarch32-rt/src/arch_v4/boot.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ core::arch::global_asm!(
1616
mov r0, #0
1717
bl _stack_setup_preallocated
1818
"#,
19-
crate::system_init!(),
19+
#[cfg(any(target_abi = "eabihf", feature = "eabi-fpu"))]
20+
r#"
21+
// Allow VFP coprocessor access
22+
mrc p15, 0, r0, c1, c0, 2
23+
orr r0, r0, #0xF00000
24+
mcr p15, 0, r0, c1, c0, 2
25+
// Enable VFP
26+
mov r0, #0x40000000
27+
vmsr fpexc, r0
28+
"#,
2029
r#"
2130
// Zero all registers before calling kmain
2231
mov r0, 0

aarch32-rt/src/arch_v7/boot_from_el1.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,21 @@ core::arch::global_asm!(
1515
// Set up stacks.
1616
mov r0, #0
1717
bl _stack_setup_preallocated
18+
// Clear Thumb Exception bit
19+
mrc p15, 0, r0, c1, c0, 0
20+
bic r0, #0x40000000
21+
mcr p15, 0, r0, c1, c0, 0
22+
"#,
23+
#[cfg(any(target_abi = "eabihf", feature = "eabi-fpu"))]
24+
r#"
25+
// Allow VFP coprocessor access
26+
mrc p15, 0, r0, c1, c0, 2
27+
orr r0, r0, #0xF00000
28+
mcr p15, 0, r0, c1, c0, 2
29+
// Enable VFP
30+
mov r0, #0x40000000
31+
vmsr fpexc, r0
1832
"#,
19-
crate::system_init!(),
2033
r#"
2134
// Zero all registers before calling kmain
2235
mov r0, 0

aarch32-rt/src/arch_v7/boot_from_el2.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,21 @@ core::arch::global_asm!(
4646
// Set up stacks.
4747
mov r0, #0
4848
bl _stack_setup_preallocated
49+
// Clear Thumb Exception bit
50+
mrc p15, 0, r0, c1, c0, 0
51+
bic r0, #0x40000000
52+
mcr p15, 0, r0, c1, c0, 0
53+
"#,
54+
#[cfg(any(target_abi = "eabihf", feature = "eabi-fpu"))]
55+
r#"
56+
// Allow VFP coprocessor access
57+
mrc p15, 0, r0, c1, c0, 2
58+
orr r0, r0, #0xF00000
59+
mcr p15, 0, r0, c1, c0, 2
60+
// Enable VFP
61+
mov r0, #0x40000000
62+
vmsr fpexc, r0
4963
"#,
50-
crate::system_init!(),
5164
r#"
5265
// Zero all registers before calling kmain
5366
mov r0, 0

aarch32-rt/src/arch_v8_hyp/boot.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@ core::arch::global_asm!(
2222
mrs r0, CPSR
2323
orr r0, {irq_fiq}
2424
msr CPSR, r0
25-
"#,
26-
crate::system_init!(),
27-
r#"
25+
// Clear Thumb Exception bit
26+
mrc p15, 0, r0, c1, c0, 0
27+
bic r0, #0x40000000
28+
mcr p15, 0, r0, c1, c0, 0
29+
// Allow VFP coprocessor access
30+
mrc p15, 0, r0, c1, c0, 2
31+
orr r0, r0, #0xF00000
32+
mcr p15, 0, r0, c1, c0, 2
33+
// Enable VFP
34+
mov r0, #0x40000000
35+
vmsr fpexc, r0
2836
// Zero all registers before calling kmain
2937
mov r0, 0
3038
mov r1, 0

aarch32-rt/src/lib.rs

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -730,77 +730,6 @@ macro_rules! restore_fpu_context {
730730
};
731731
}
732732

733-
/// This is for ARMv7 and ARMv8 systems with an FPU
734-
///
735-
/// It just disables Thumb Exceptions and turns on the FPU
736-
#[cfg(all(armv7_or_higher, any(target_abi = "eabihf", feature = "eabi-fpu")))]
737-
#[macro_export]
738-
macro_rules! system_init {
739-
() => {
740-
r#"
741-
// Allow VFP coprocessor access
742-
mrc p15, 0, r0, c1, c0, 2
743-
orr r0, r0, #0xF00000
744-
mcr p15, 0, r0, c1, c0, 2
745-
// Enable VFP
746-
mov r0, #0x40000000
747-
vmsr fpexc, r0
748-
// Clear Thumb Exception bit
749-
mrc p15, 0, r0, c1, c0, 0
750-
bic r0, #0x40000000
751-
mcr p15, 0, r0, c1, c0, 0
752-
"#
753-
};
754-
}
755-
756-
/// This is for ARMv7 and ARMv8 systems without an FPU
757-
///
758-
/// It just disables Thumb Exceptions
759-
#[cfg(all(armv7_or_higher, not(any(target_abi = "eabihf", feature = "eabi-fpu"))))]
760-
#[macro_export]
761-
macro_rules! system_init {
762-
() => {
763-
r#"
764-
// Clear Thumb Exception bit
765-
mrc p15, 0, r0, c1, c0, 0
766-
bic r0, #0x40000000
767-
mcr p15, 0, r0, c1, c0, 0
768-
"#
769-
};
770-
}
771-
772-
/// This is for ARMv6 and earlier systems with an FPU
773-
///
774-
/// It enables the FPU
775-
#[cfg(all(armv6_or_lower, any(target_abi = "eabihf", feature = "eabi-fpu")))]
776-
#[macro_export]
777-
macro_rules! system_init {
778-
() => {
779-
r#"
780-
// Allow VFP coprocessor access
781-
mrc p15, 0, r0, c1, c0, 2
782-
orr r0, r0, #0xF00000
783-
mcr p15, 0, r0, c1, c0, 2
784-
// Enable VFP
785-
mov r0, #0x40000000
786-
vmsr fpexc, r0
787-
"#
788-
};
789-
}
790-
791-
/// This is for ARMv6 and earlier systems without an FPU
792-
///
793-
/// It does nothing
794-
#[cfg(all(armv6_or_lower, not(any(target_abi = "eabihf", feature = "eabi-fpu"))))]
795-
#[macro_export]
796-
macro_rules! system_init {
797-
() => {
798-
r#"
799-
// No system init required
800-
"#
801-
};
802-
}
803-
804733
// *****************************************************************************
805734
// Functions
806735
// *****************************************************************************

0 commit comments

Comments
 (0)