aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <japaricious@gmail.com> 2017-03-08 10:02:51 -0500
committerGravatar Jorge Aparicio <japaricious@gmail.com> 2017-03-08 10:02:51 -0500
commit0e628b32ac27d47aa897dfd7930ddad85903bd37 (patch)
treecb3966272822615e5d2973af0cbbd314a5873b82
parentc3a35c1b6cea81aa71e8832bca79ccafa492be02 (diff)
downloadcortex-m-0e628b32ac27d47aa897dfd7930ddad85903bd37.tar.gz
cortex-m-0e628b32ac27d47aa897dfd7930ddad85903bd37.tar.zst
cortex-m-0e628b32ac27d47aa897dfd7930ddad85903bd37.zip
turn bkpt! into a function
-rw-r--r--CHANGELOG.md3
-rw-r--r--src/asm.rs54
-rw-r--r--src/exception.rs41
3 files changed, 44 insertions, 54 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 95f28c7..5289b6f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -37,6 +37,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- The safety of assembly wrappers like `wfi` and `interrupt::free` has been
reviewed. In many cases, the functions are no longer unsafe.
+- [breaking-change] `bkpt!` has been turned into a function. It no longer
+ accepts an immediate value.
+
### Removed
- `vector_table` and its associated `struct`, `VectorTable`. It's not a good
diff --git a/src/asm.rs b/src/asm.rs
index b94d4ef..c82d45d 100644
--- a/src/asm.rs
+++ b/src/asm.rs
@@ -3,45 +3,30 @@
/// Puts the processor in Debug state. Debuggers can pick this up as a
/// "breakpoint".
///
-/// Optionally, an "immediate" value (in the 0-255 range) can be passed to
-/// `bkpt!`. The debugger can then read this value using the Program Counter
-/// (PC).
-#[cfg(target_arch = "arm")]
-#[macro_export]
-macro_rules! bkpt {
- () => {
+/// NOTE calling `bkpt` when the processor is not connected to a debugger will
+/// cause an exception
+#[inline(always)]
+pub fn bkpt() {
+ #[cfg(target_arch = "arm")]
+ unsafe {
asm!("bkpt"
:
:
:
: "volatile");
- };
- ($imm:expr) => {
- asm!(concat!("bkpt #", stringify!($imm))
+ }
+}
+
+/// A no-operation. Useful to prevent delay loops from being optimized away.
+pub fn nop() {
+ unsafe {
+ asm!("nop"
:
:
:
: "volatile");
- };
-}
-
-/// Puts the processor in Debug state. Debuggers can pick this up as a
-/// "breakpoint".
-///
-/// Optionally, an "immediate" value (in the 0-255 range) can be passed to
-/// `bkpt!`. The debugger can then read this value using the Program Counter
-/// (PC).
-#[cfg(not(target_arch = "arm"))]
-#[macro_export]
-macro_rules! bkpt {
- () => {
- asm!("");
- };
- ($e:expr) => {
- asm!("");
- };
+ }
}
-
/// Wait For Event
pub fn wfe() {
match () {
@@ -73,14 +58,3 @@ pub fn wfi() {
() => {}
}
}
-
-/// A no-operation. Useful to prevent delay loops from being optimized away.
-pub fn nop() {
- unsafe {
- asm!("nop"
- :
- :
- :
- : "volatile");
- }
-}
diff --git a/src/exception.rs b/src/exception.rs
index b944d6c..8343d99 100644
--- a/src/exception.rs
+++ b/src/exception.rs
@@ -72,32 +72,48 @@ pub struct Handlers {
/// Pendable request for system service
pub pendsv: unsafe extern "C" fn(&PendsvCtxt),
/// System tick timer
- pub sys_tick: unsafe extern "C" fn (&SysTickCtxt),
+ pub sys_tick: unsafe extern "C" fn(&SysTickCtxt),
}
/// Identifies the Nmi exception
-pub struct NmiCtxt { _0: () }
+pub struct NmiCtxt {
+ _0: (),
+}
/// Identifies the HardFault exception
-pub struct HardFaultCtxt { _0: () }
+pub struct HardFaultCtxt {
+ _0: (),
+}
/// Identifies the MemManage exception
-pub struct MemManageCtxt { _0: () }
+pub struct MemManageCtxt {
+ _0: (),
+}
/// Identifies the BusFault exception
-pub struct BusFaultCtxt { _0: () }
+pub struct BusFaultCtxt {
+ _0: (),
+}
/// Identifies the UsageFault exception
-pub struct UsageFaultCtxt { _0: () }
+pub struct UsageFaultCtxt {
+ _0: (),
+}
/// Identifies the Svcall exception
-pub struct SvcallCtxt { _0: () }
+pub struct SvcallCtxt {
+ _0: (),
+}
/// Identifies the Pendsv exception
-pub struct PendsvCtxt { _0: () }
+pub struct PendsvCtxt {
+ _0: (),
+}
/// Identifies the Systick exception
-pub struct SysTickCtxt { _0: () }
+pub struct SysTickCtxt {
+ _0: (),
+}
unsafe impl Token for NmiCtxt {}
@@ -134,8 +150,7 @@ pub const DEFAULT_HANDLERS: Handlers = Handlers {
// This needs asm!, #[naked] and unreachable() to avoid modifying the stack
// pointer (MSP), that way it points to the stacked registers
#[naked]
-pub unsafe extern "C" fn default_handler<T>(_token: &T)
-{
+pub unsafe extern "C" fn default_handler<T>(_token: &T) {
// This is the actual exception handler. `_sf` is a pointer to the previous
// stack frame
#[cfg(target_arch = "arm")]
@@ -143,9 +158,7 @@ pub unsafe extern "C" fn default_handler<T>(_token: &T)
#[cfg(feature = "semihosting")]
hprintln!("EXCEPTION {:?} @ PC=0x{:08x}", Exception::current(), _sr.pc);
- unsafe {
- bkpt!();
- }
+ ::asm::bkpt();
loop {}
}
nse-experiment&id=f5129dbd1a0d801dcf2d457917d64d4e0de43f52&follow=1'>Fix issue with `process` esm node exportGravatar Jarred Sumner 1-31/+68 2022-09-06Set a default Loader based on filenameGravatar Jarred Sumner 1-5/+7 2022-09-06Add `node:assert` to list of hardcoded modules to fix ESM compat issueGravatar Jarred Sumner 2-13/+3241 2022-09-06Update README.mdGravatar Jarred Sumner 1-4/+27 2022-09-06Start to document loader apiGravatar Jarred Sumner 1-2/+130 2022-09-06preserve statements when generating a separate module for bun pluginGravatar Jarred Sumner 1-2/+29 2022-09-06Loosen-up the streams polyfillGravatar Jarred Sumner 1-21/+10 2022-09-06Add `@` to acceptable namespace charactersGravatar Jarred Sumner 1-1/+1 2022-09-06Make the plugins a little more resilientGravatar Jarred Sumner 5-53/+81 2022-09-06Add missing `Blob`Gravatar Jarred Sumner 1-2/+2 2022-09-06Make fs extensibleGravatar Jarred Sumner 1-108/+113 2022-09-06Fix crash in Buffer moduleGravatar Jarred Sumner 1-8/+11 2022-09-06Add native ReadableState (#1210)Gravatar Zilin Zhu 12-123/+526 2022-09-05[Bun.plugin] Clean up exception handlingGravatar Jarred Sumner 3-10/+11 2022-09-05Support async `onLoad` callbacks in `Bun.plugin`Gravatar Jarred Sumner 22-717/+1678 2022-09-05Move `generateObjectModuleSourceCode` to separate file to fix build errorGravatar Jarred Sumner 2-24/+31 2022-09-05`inline`Gravatar Jarred Sumner 1-1/+1 2022-09-05Missing #pragma onceGravatar Jarred Sumner 1-0/+2 2022-09-04Rename `is_macro_mode` -> `use_alternate_source_cache`Gravatar Jarred Sumner 2-4/+4 2022-09-04Some testsGravatar Jarred Sumner 1-0/+19 2022-09-04`[node:module]` Implement `_resolveFileName`, stub `_nodeModulePaths` & `_cache`Gravatar Jarred Sumner 7-86/+150 2022-09-04@globalPrivate -> @linkTimeConstantGravatar Jarred Sumner 6-111/+110 2022-09-03[Node API] Fix `napi_module_register`Gravatar Jarred Sumner 6-20/+59 2022-09-03Fix `createRequire()` in `node:module`Gravatar Jarred Sumner 10-161/+302 2022-09-03Fix C++ intellisenseGravatar Jarred Sumner 1-14/+23 2022-09-03Fix build errorGravatar Jarred Sumner 1-6/+5