Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 43 additions & 9 deletions arch/arm/include/arm/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,26 @@ struct xcptcontext
uintptr_t far;
#endif
};
#endif

/****************************************************************************
* Inline functions
* Public Data
****************************************************************************/

#ifndef __ASSEMBLY__
/* g_current_regs[] holds a references to the current interrupt level
* register storage structure. If is non-NULL only during interrupt
* processing. Access to g_current_regs[] must be through the
* [get/set]_current_regs for portability.
*/

/* For the case of architectures with multiple CPUs, then there must be one
* such value for each processor that can receive an interrupt.
*/

extern volatile uint32_t *g_current_regs[CONFIG_SMP_NCPUS];

/****************************************************************************
* Inline functions
****************************************************************************/

/* Name: up_irq_save, up_irq_restore, and friends.
*
Expand Down Expand Up @@ -242,17 +255,38 @@ int up_cpu_index(void) noinstrument_function;
# define up_cpu_index() 0
#endif /* CONFIG_SMP */

#endif /* __ASSEMBLY__ */
noinstrument_function
static inline_function uint32_t *up_current_regs(void)
{
return (uint32_t *)g_current_regs[up_cpu_index()];
}

/****************************************************************************
* Public Data
****************************************************************************/
noinstrument_function
static inline_function void up_set_current_regs(uint32_t *regs)
{
g_current_regs[up_cpu_index()] = regs;
}

noinstrument_function
static inline_function bool up_interrupt_context(void)
{
#ifdef CONFIG_SMP
irqstate_t flags = up_irq_save();
#endif

bool ret = up_current_regs() != NULL;

#ifdef CONFIG_SMP
up_irq_restore(flags);
#endif

return ret;
}

/****************************************************************************
* Public Function Prototypes
****************************************************************************/

#ifndef __ASSEMBLY__
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
Expand All @@ -265,6 +299,6 @@ extern "C"
#ifdef __cplusplus
}
#endif
#endif
#endif /* __ASSEMBLY__ */

#endif /* __ARCH_ARM_INCLUDE_ARM_IRQ_H */
42 changes: 33 additions & 9 deletions arch/arm/include/armv6-m/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,26 @@ struct xcptcontext

uint32_t *regs;
};
#endif

/****************************************************************************
* Inline functions
* Public Data
****************************************************************************/

#ifndef __ASSEMBLY__
/* g_current_regs[] holds a references to the current interrupt level
* register storage structure. If is non-NULL only during interrupt
* processing. Access to g_current_regs[] must be through the
* [get/set]_current_regs for portability.
*/

/* For the case of architectures with multiple CPUs, then there must be one
* such value for each processor that can receive an interrupt.
*/

extern volatile uint32_t *g_current_regs[CONFIG_SMP_NCPUS];

/****************************************************************************
* Inline functions
****************************************************************************/

/* Name: up_irq_save, up_irq_restore, and friends.
*
Expand Down Expand Up @@ -366,17 +379,28 @@ static inline_function uint32_t up_getsp(void)
return sp;
}

#endif /* __ASSEMBLY__ */
noinstrument_function
static inline_function uint32_t *up_current_regs(void)
Comment thread
xiaoxiang781216 marked this conversation as resolved.
{
return (uint32_t *)g_current_regs[up_cpu_index()];
}

/****************************************************************************
* Public Data
****************************************************************************/
noinstrument_function
static inline_function void up_set_current_regs(uint32_t *regs)
Comment thread
xiaoxiang781216 marked this conversation as resolved.
{
g_current_regs[up_cpu_index()] = regs;
}

noinstrument_function
static inline_function bool up_interrupt_context(void)
{
return getipsr() != 0;
}

/****************************************************************************
* Public Function Prototypes
****************************************************************************/

#ifndef __ASSEMBLY__
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
Expand All @@ -389,6 +413,6 @@ extern "C"
#ifdef __cplusplus
}
#endif
#endif
#endif /* __ASSEMBLY__ */

#endif /* __ARCH_ARM_INCLUDE_ARMV6_M_IRQ_H */
50 changes: 41 additions & 9 deletions arch/arm/include/armv7-a/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ struct xcpt_syscall_s
* For a total of 17 (XCPTCONTEXT_REGS)
*/

#ifndef __ASSEMBLY__
struct xcptcontext
{
/* The following function pointer is non-zero if there are pending signals
Expand Down Expand Up @@ -326,16 +325,11 @@ struct xcptcontext
#endif
#endif
};
#endif

#endif /* __ASSEMBLY__ */

/****************************************************************************
* Inline functions
****************************************************************************/

#ifndef __ASSEMBLY__

/* Name: up_irq_save, up_irq_restore, and friends.
*
* NOTE: This function should never be called from application code and,
Expand Down Expand Up @@ -490,13 +484,51 @@ static inline_function uint32_t up_getsp(void)
return sp;
}

#endif /* __ASSEMBLY__ */
/****************************************************************************
* Name:
* up_current_regs/up_set_current_regs
*
* Description:
* We use the following code to manipulate the TPIDRPRW register,
* which exists uniquely for each CPU and is primarily designed to store
* current thread information. Currently, we leverage it to store interrupt
* information, with plans to further optimize its use for storing both
* thread and interrupt information in the future.
*
****************************************************************************/

noinstrument_function
static inline_function uint32_t *up_current_regs(void)
Comment thread
xiaoxiang781216 marked this conversation as resolved.
{
uint32_t *regs;
__asm__ __volatile__
(
"mrc " "p15, " "0" ", %0, " "c13" ", " "c0" ", " "4" "\n"
Comment thread
xiaoxiang781216 marked this conversation as resolved.
: "=r"(regs)
);
return regs;
}

noinstrument_function
static inline_function void up_set_current_regs(uint32_t *regs)
{
__asm__ __volatile__
(
"mcr " "p15, " "0" ", %0, " "c13" ", " "c0" ", " "4" "\n"
:: "r"(regs)
);
}

noinstrument_function
static inline_function bool up_interrupt_context(void)
{
return up_current_regs() != NULL;
}

/****************************************************************************
* Public Data
****************************************************************************/

#ifndef __ASSEMBLY__
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
Expand All @@ -513,6 +545,6 @@ extern "C"
#ifdef __cplusplus
}
#endif
#endif
#endif /* __ASSEMBLY__ */

#endif /* __ARCH_ARM_INCLUDE_ARMV7_A_IRQ_H */
42 changes: 33 additions & 9 deletions arch/arm/include/armv7-m/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,26 @@ struct xcptcontext

uint32_t *regs;
};
#endif

/****************************************************************************
* Inline functions
* Public Data
****************************************************************************/

#ifndef __ASSEMBLY__
/* g_current_regs[] holds a references to the current interrupt level
* register storage structure. If is non-NULL only during interrupt
* processing. Access to g_current_regs[] must be through the
* [get/set]_current_regs for portability.
*/

/* For the case of architectures with multiple CPUs, then there must be one
* such value for each processor that can receive an interrupt.
*/

extern volatile uint32_t *g_current_regs[CONFIG_SMP_NCPUS];

/****************************************************************************
* Inline functions
****************************************************************************/

/* Name: up_irq_save, up_irq_restore, and friends.
*
Expand Down Expand Up @@ -571,17 +584,28 @@ static inline_function uint32_t up_getsp(void)
return sp;
}

#endif /* __ASSEMBLY__ */
noinstrument_function
static inline_function uint32_t *up_current_regs(void)
{
return (uint32_t *)g_current_regs[up_cpu_index()];
}

/****************************************************************************
* Public Data
****************************************************************************/
noinstrument_function
static inline_function void up_set_current_regs(uint32_t *regs)
{
g_current_regs[up_cpu_index()] = regs;
}

noinstrument_function
static inline_function bool up_interrupt_context(void)
{
return getipsr() != 0;
}

/****************************************************************************
* Public Function Prototypes
****************************************************************************/

#ifndef __ASSEMBLY__
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
Expand All @@ -594,6 +618,6 @@ extern "C"
#ifdef __cplusplus
}
#endif
#endif
#endif /* __ASSEMBLY__ */

#endif /* __ARCH_ARM_INCLUDE_ARMV7_M_IRQ_H */
37 changes: 28 additions & 9 deletions arch/arm/include/armv7-r/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ struct xcpt_syscall_s
* For a total of 17 (XCPTCONTEXT_REGS)
*/

#ifndef __ASSEMBLY__
struct xcptcontext
{
/* The following function pointer is non-zero if there are pending signals
Expand Down Expand Up @@ -325,16 +324,11 @@ struct xcptcontext
#endif
#endif
};
#endif

#endif /* __ASSEMBLY__ */

/****************************************************************************
* Inline functions
****************************************************************************/

#ifndef __ASSEMBLY__

/* Name: up_irq_save, up_irq_restore, and friends.
*
* NOTE: This function should never be called from application code and,
Expand Down Expand Up @@ -485,13 +479,38 @@ static inline_function uint32_t up_getsp(void)
return sp;
}

#endif /* __ASSEMBLY__ */
noinstrument_function
static inline_function uint32_t *up_current_regs(void)
{
uint32_t *regs;
__asm__ __volatile__
(
"mrc " "p15, " "0" ", %0, " "c13" ", " "c0" ", " "4" "\n"
: "=r"(regs)
);
return regs;
}

noinstrument_function
static inline_function void up_set_current_regs(uint32_t *regs)
{
__asm__ __volatile__
(
"mcr " "p15, " "0" ", %0, " "c13" ", " "c0" ", " "4" "\n"
:: "r"(regs)
);
}

noinstrument_function
static inline_function bool up_interrupt_context(void)
{
return up_current_regs() != NULL;
}

/****************************************************************************
* Public Data
****************************************************************************/

#ifndef __ASSEMBLY__
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
Expand All @@ -508,6 +527,6 @@ extern "C"
#ifdef __cplusplus
}
#endif
#endif
#endif /* __ASSEMBLY__ */

#endif /* __ARCH_ARM_INCLUDE_ARMV7_R_IRQ_H */
Loading