zynq-rs/libcortex_a9/src/fpu.rs

18 lines
556 B
Rust
Raw Normal View History

2024-10-22 12:04:08 +08:00
use core::arch::asm;
2020-07-03 16:02:34 +08:00
/// Enable FPU in the current core.
2025-01-06 11:17:13 +08:00
/// You must execute an ISB immediately after an update of the CPACR.
/// https://developer.arm.com/documentation/ddi0388/i/system-control/register-descriptions/coprocessor-access-control-register
2020-07-03 16:02:34 +08:00
pub fn enable_fpu() {
unsafe {
2024-10-22 12:04:08 +08:00
asm!("
2020-07-03 16:02:34 +08:00
mrc p15, 0, r1, c1, c0, 2
orr r1, r1, (0b1111<<20)
mcr p15, 0, r1, c1, c0, 2
2025-01-06 11:17:13 +08:00
isb
2020-07-03 16:02:34 +08:00
vmrs r1, fpexc
orr r1, r1, (1<<30)
vmsr fpexc, r1
2024-10-22 12:04:08 +08:00
", out("r1") _);
2020-07-03 16:02:34 +08:00
}
}