Skip to content

Commit

Permalink
Avoid being interrupted while krobe does single-step.
Browse files Browse the repository at this point in the history
Fixes f9micro#55

Raise the execution priority to be the highest among other irq handlers.
  • Loading branch information
arcbbb committed Oct 14, 2013
1 parent 2e9f2b3 commit e39a772
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/platform/hw_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef PLATFORM_HW_DEBUG_H_
#define PLATFORM_HW_DEBUG_H_

#include <platform/irq.h>

typedef struct {
uint32_t comp;
uint32_t mask;
Expand Down Expand Up @@ -57,10 +59,13 @@ void breakpoint_uninstall(int id);

#define cpu_enable_single_step() \
do { \
set_irq_mask(1); \
*DCB_DEMCR |= DCB_DEMCR_MON_STEP; \
} while (0)

#define cpu_disable_single_step() \
do { \
set_irq_mask(0); \
*DCB_DEMCR &= ~DCB_DEMCR_MON_STEP; \
} while (0)

Expand Down
7 changes: 7 additions & 0 deletions include/platform/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@

void irq_init(void);

static inline void set_irq_mask(unsigned int mask)
{
__asm__ __volatile__ (
"msr basepri, %0\n"
: : "r" (mask) : );
}

static inline void irq_disable(void)
{
__asm__ __volatile__ ("cpsid i");
Expand Down

0 comments on commit e39a772

Please sign in to comment.