diff options
author | 2020-07-05 20:55:57 +0000 | |
---|---|---|
committer | 2020-07-05 20:55:57 +0000 | |
commit | 2ce2384d8dd239301b606921abe3b3f35d5fbb05 (patch) | |
tree | 66c82004d10112306a8700aeb2216babffdbde5b /src | |
parent | b70c25a9b887fc19ce94a9789a34c1a036186c76 (diff) | |
parent | a763f2bcef19c156ef56bb810f9b7401b4c99387 (diff) | |
download | cortex-m-2ce2384d8dd239301b606921abe3b3f35d5fbb05.tar.gz cortex-m-2ce2384d8dd239301b606921abe3b3f35d5fbb05.tar.zst cortex-m-2ce2384d8dd239301b606921abe3b3f35d5fbb05.zip |
Merge #234
234: Use assembly sequences to enable caches. r=adamgreig a=cbiffle
See #232, which this partially fixes -- there's still the question of
taking an interrupt in the midst of these sequences.
Co-authored-by: Cliff L. Biffle <cliff@oxide.computer>
Diffstat (limited to 'src')
-rw-r--r-- | src/peripheral/scb.rs | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/peripheral/scb.rs b/src/peripheral/scb.rs index 733a3ec..7343b4d 100644 --- a/src/peripheral/scb.rs +++ b/src/peripheral/scb.rs @@ -331,11 +331,15 @@ impl SCB { cbp.iciallu(); // Enable I-cache - // NOTE(unsafe): We have synchronised access by &mut self - unsafe { self.ccr.modify(|r| r | SCB_CCR_IC_MASK) }; + extern "C" { + // see asm-v7m.s + fn __enable_icache(); + } - crate::asm::dsb(); - crate::asm::isb(); + // NOTE(unsafe): The asm routine manages exclusive access to the SCB + // registers and applies the proper barriers; it is technically safe on + // its own, and is only `unsafe` here because it's `extern "C"`. + unsafe { __enable_icache(); } } /// Disables I-cache if currently enabled. @@ -400,11 +404,15 @@ impl SCB { unsafe { self.invalidate_dcache(cpuid) }; // Now turn on the D-cache - // NOTE(unsafe): We have synchronised access by &mut self - unsafe { self.ccr.modify(|r| r | SCB_CCR_DC_MASK) }; + extern "C" { + // see asm-v7m.s + fn __enable_dcache(); + } - crate::asm::dsb(); - crate::asm::isb(); + // NOTE(unsafe): The asm routine manages exclusive access to the SCB + // registers and applies the proper barriers; it is technically safe on + // its own, and is only `unsafe` here because it's `extern "C"`. + unsafe { __enable_dcache(); } } /// Disables D-cache if currently enabled. |