Skip to content

Commit 7a0ea10

Browse files
jasonbuxiaoxiang781216
authored andcommitted
arch/arm-m: add api getpsp, for exception direct case
For exception_direct causing unwind to read NULL and breaks thread backtrace. Signed-off-by: buxiasen <[email protected]>
1 parent 9bdcc4d commit 7a0ea10

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

arch/arm/include/armv6-m/irq.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,20 @@ static always_inline_function void setcontrol(uint32_t control)
323323
: "memory");
324324
}
325325

326+
static always_inline_function uint32_t getpsp(void)
327+
{
328+
uint32_t psp;
329+
330+
__asm__ __volatile__
331+
(
332+
"\tmrs %0, psp\n"
333+
: "=r" (psp)
334+
:
335+
: "memory");
336+
337+
return psp;
338+
}
339+
326340
/****************************************************************************
327341
* Name: up_cpu_index
328342
*

arch/arm/include/armv7-m/irq.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,20 @@ static always_inline_function void setcontrol(uint32_t control)
473473
: "memory");
474474
}
475475

476+
static always_inline_function uint32_t getpsp(void)
477+
{
478+
uint32_t psp;
479+
480+
__asm__ __volatile__
481+
(
482+
"\tmrs %0, psp\n"
483+
: "=r" (psp)
484+
:
485+
: "memory");
486+
487+
return psp;
488+
}
489+
476490
/****************************************************************************
477491
* Name: up_cpu_index
478492
*

arch/arm/include/armv8-m/irq.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,20 @@ static always_inline_function void setcontrol(uint32_t control)
448448
: "memory");
449449
}
450450

451+
static always_inline_function uint32_t getpsp(void)
452+
{
453+
uint32_t psp;
454+
455+
__asm__ __volatile__
456+
(
457+
"\tmrs %0, psp\n"
458+
: "=r" (psp)
459+
:
460+
: "memory");
461+
462+
return psp;
463+
}
464+
451465
/****************************************************************************
452466
* Name: up_cpu_index
453467
*

0 commit comments

Comments
 (0)