aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm-v8-main.s28
-rwxr-xr-xassemble.sh6
-rw-r--r--bin/thumbv8m.main-none-eabi.abin2810 -> 5220 bytes
-rw-r--r--bin/thumbv8m.main-none-eabihf.abin0 -> 5220 bytes
-rw-r--r--build.rs6
-rw-r--r--src/register/mod.rs6
-rw-r--r--src/register/msplim.rs47
-rw-r--r--src/register/psplim.rs47
8 files changed, 138 insertions, 2 deletions
diff --git a/asm-v8-main.s b/asm-v8-main.s
new file mode 100644
index 0000000..a59845c
--- /dev/null
+++ b/asm-v8-main.s
@@ -0,0 +1,28 @@
+ .section .text.__msplim_r
+ .global __msplim_r
+ .thumb_func
+__msplim_r:
+ mrs r0, MSPLIM
+ bx lr
+
+ .section .text.__msplim_w
+ .global __msplim_w
+ .thumb_func
+__msplim_w:
+ msr MSPLIM, r0
+ bx lr
+
+ .section .text.__psplim_r
+ .global __psplim_r
+ .thumb_func
+__psplim_r:
+ mrs r0, PSPLIM
+ bx lr
+
+ .section .text.__psplim_w
+ .global __psplim_w
+ .thumb_func
+__psplim_w:
+ msr PSPLIM, r0
+ bx lr
+
diff --git a/assemble.sh b/assemble.sh
index 28494a9..6a4ccdd 100755
--- a/assemble.sh
+++ b/assemble.sh
@@ -26,8 +26,12 @@ arm-none-eabi-as -march=armv8-m.base asm.s -o bin/$crate.o
ar crs bin/thumbv8m.base-none-eabi.a bin/$crate.o
arm-none-eabi-as -march=armv8-m.main asm.s -o bin/$crate.o
-ar crs bin/thumbv8m.main-none-eabi.a bin/$crate.o
+arm-none-eabi-as -march=armv8-m.main asm-v7.s -o bin/$crate-v7.o
+arm-none-eabi-as -march=armv8-m.main asm-v8-main.s -o bin/$crate-v8-main.o
+ar crs bin/thumbv8m.main-none-eabi.a bin/$crate.o bin/$crate-v7.o bin/$crate-v8-main.o
+ar crs bin/thumbv8m.main-none-eabihf.a bin/$crate.o bin/$crate-v7.o bin/$crate-v8-main.o
rm bin/$crate.o
rm bin/$crate-v7.o
rm bin/$crate-cm7-r0p1.o
+rm bin/$crate-v8-main.o
diff --git a/bin/thumbv8m.main-none-eabi.a b/bin/thumbv8m.main-none-eabi.a
index ddf83c1..a0b35de 100644
--- a/bin/thumbv8m.main-none-eabi.a
+++ b/bin/thumbv8m.main-none-eabi.a
Binary files differ
diff --git a/bin/thumbv8m.main-none-eabihf.a b/bin/thumbv8m.main-none-eabihf.a
new file mode 100644
index 0000000..a0b35de
--- /dev/null
+++ b/bin/thumbv8m.main-none-eabihf.a
Binary files differ
diff --git a/build.rs b/build.rs
index 47e86bb..3ca7ddf 100644
--- a/build.rs
+++ b/build.rs
@@ -26,9 +26,13 @@ fn main() {
println!("cargo:rustc-cfg=cortex_m");
println!("cargo:rustc-cfg=armv7m");
//println!("cargo:rustc-cfg=armv7em");
- } else if target.starts_with("thumbv8m") {
+ } else if target.starts_with("thumbv8m.base") {
println!("cargo:rustc-cfg=cortex_m");
println!("cargo:rustc-cfg=armv8m");
+ } else if target.starts_with("thumbv8m.main") {
+ println!("cargo:rustc-cfg=cortex_m");
+ println!("cargo:rustc-cfg=armv8m");
+ println!("cargo:rustc-cfg=armv8m_main");
}
if target.ends_with("-eabihf") {
diff --git a/src/register/mod.rs b/src/register/mod.rs
index 1444aff..854d725 100644
--- a/src/register/mod.rs
+++ b/src/register/mod.rs
@@ -43,6 +43,12 @@ pub mod primask;
pub mod psp;
+#[cfg(armv8m_main)]
+pub mod msplim;
+
+#[cfg(armv8m_main)]
+pub mod psplim;
+
// Accessing these registers requires inline assembly because their contents are tied to the current
// stack frame
#[cfg(any(feature = "inline-asm", target_arch = "x86_64"))]
diff --git a/src/register/msplim.rs b/src/register/msplim.rs
new file mode 100644
index 0000000..df3642a
--- /dev/null
+++ b/src/register/msplim.rs
@@ -0,0 +1,47 @@
+//! Main Stack Pointer Limit Register
+
+/// Reads the CPU register
+#[inline]
+pub fn read() -> u32 {
+ match () {
+ #[cfg(all(cortex_m, feature = "inline-asm"))]
+ () => {
+ let r;
+ unsafe { asm!("mrs $0,MSPLIM" : "=r"(r) ::: "volatile") }
+ r
+ }
+
+ #[cfg(all(cortex_m, not(feature = "inline-asm")))]
+ () => unsafe {
+ extern "C" {
+ fn __msplim_r() -> u32;
+ }
+
+ __msplim_r()
+ },
+
+ #[cfg(not(cortex_m))]
+ () => unimplemented!(),
+ }
+}
+
+/// Writes `bits` to the CPU register
+#[inline]
+pub unsafe fn write(_bits: u32) {
+ match () {
+ #[cfg(all(cortex_m, feature = "inline-asm"))]
+ () => asm!("msr MSPLIM,$0" :: "r"(_bits) :: "volatile"),
+
+ #[cfg(all(cortex_m, not(feature = "inline-asm")))]
+ () => {
+ extern "C" {
+ fn __msplim_w(_: u32);
+ }
+
+ __msplim_w(_bits);
+ }
+
+ #[cfg(not(cortex_m))]
+ () => unimplemented!(),
+ }
+}
diff --git a/src/register/psplim.rs b/src/register/psplim.rs
new file mode 100644
index 0000000..6c27008
--- /dev/null
+++ b/src/register/psplim.rs
@@ -0,0 +1,47 @@
+//! Process Stack Pointer Limit Register
+
+/// Reads the CPU register
+#[inline]
+pub fn read() -> u32 {
+ match () {
+ #[cfg(all(cortex_m, feature = "inline-asm"))]
+ () => {
+ let r;
+ unsafe { asm!("mrs $0,PSPLIM" : "=r"(r) ::: "volatile") }
+ r
+ }
+
+ #[cfg(all(cortex_m, not(feature = "inline-asm")))]
+ () => unsafe {
+ extern "C" {
+ fn __psplim_r() -> u32;
+ }
+
+ __psplim_r()
+ },
+
+ #[cfg(not(cortex_m))]
+ () => unimplemented!(),
+ }
+}
+
+/// Writes `bits` to the CPU register
+#[inline]
+pub unsafe fn write(_bits: u32) {
+ match () {
+ #[cfg(all(cortex_m, feature = "inline-asm"))]
+ () => asm!("msr PSPLIM,$0" :: "r"(_bits) :: "volatile"),
+
+ #[cfg(all(cortex_m, not(feature = "inline-asm")))]
+ () => {
+ extern "C" {
+ fn __psplim_w(_: u32);
+ }
+
+ __psplim_w(_bits);
+ }
+
+ #[cfg(not(cortex_m))]
+ () => unimplemented!(),
+ }
+}
dd integration test for reading .json files that have UTF-8 string literalsGravatar Jarred Sumner 2-0/+9 2022-02-04[http] fix segfaultGravatar Jarred Sumner 1-17/+25 2022-02-04[bun dev] Fix bug with serving static files on next.js apps introduced in af6...Gravatar Jarred Sumner 1-5/+7 2022-02-04Update types.zigGravatar Jarred Sumner 1-9/+10 2022-02-04Update test_command.zigGravatar Jarred Sumner 1-2/+0 2022-02-04`path.normalize()` tests passGravatar Jarred Sumner 2-146/+213 2022-02-03Fix test failures in path.joinGravatar Jarred Sumner 1-8/+115 2022-02-03Update mimalloc_arena.zigGravatar Jarred Sumner 1-0/+9 2022-02-03[bun test] Support multiple filesGravatar Jarred Sumner 1-2/+12 2022-02-03Update js_ast.zigGravatar Jarred Sumner 1-0/+1 2022-02-03Support loading multiple entry points by changing what `bun:main` points toGravatar Jarred Sumner 6-4/+36 2022-02-03[bun install] Configurable max http retry countGravatar Jarred Sumner 1-0/+7 2022-02-03Missing newline in errors in bun installGravatar Jarred Sumner 1-4/+8 2022-02-03Fix bug with http clientGravatar Jarred Sumner 6-107/+101 2022-02-03Move detectFastRefresh to later so HTTP request handler starts fasterGravatar Jarred Sumner 1-2/+1 2022-02-03Fix bug with macro remaps in Bun.Transpiler apiGravatar Jarred Sumner 2-5/+8 2022-02-03Slight improvement to non-ascii file path handlingGravatar Jarred Sumner 4-18/+79 2022-02-02`path.relative` passes Node's tests (which also fixed bugs)Gravatar Jarred Sumner 8-283/+571