Skip to content

Commit af57235

Browse files
Patatermeriac
authored andcommitted
Don't call __disable_irq for uVisor
This is a hack to get debug builds applications that use uVisor to work. The assertions in core_util_critical_section fail because interrupts can't actually be disabled from unprivileged mode. Without this hack, core_util_critical_section_enter() calls mbed_assert_internal() when the assertion fails, which calls core_util_critical_section_enter() again, which calls mbed_assert_internal() again; this is infinite recursion. core_util_critical_section_enter needs some fixing.
1 parent 516c7cd commit af57235

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

hal/common/critical.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ void core_util_critical_section_enter()
5353
are enabled, then something has gone badly wrong thus assert an error.
5454
*/
5555
MBED_ASSERT(interrupt_enable_counter < UINT32_MAX);
56+
// FIXME
57+
#ifndef FEATURE_UVISOR
5658
if (interrupt_enable_counter > 0) {
5759
MBED_ASSERT(interrupts_disabled & 0x1);
5860
}
61+
#else
62+
#warning "core_util_critical_section_enter needs fixing to work from unprivileged code"
63+
#endif /* FEATURE_UVISOR */
5964
interrupt_enable_counter++;
6065
}
6166

@@ -64,9 +69,14 @@ void core_util_critical_section_exit()
6469
/* If critical_section_enter has not previously been called, do nothing */
6570
if (interrupt_enable_counter) {
6671

72+
// FIXME
73+
#ifndef FEATURE_UVISOR
6774
uint32_t interrupts_disabled = get_interrupts_disabled(); /* get the current interrupt disabled state */
6875

6976
MBED_ASSERT(interrupts_disabled & 0x1); /* Interrupts must be disabled on invoking an exit from a critical section */
77+
#else
78+
#warning "core_util_critical_section_exit needs fixing to work from unprivileged code"
79+
#endif /* FEATURE_UVISOR */
7080

7181
interrupt_enable_counter--;
7282

0 commit comments

Comments
 (0)