Skip to content

Commit

Permalink
Merge pull request #13317 from benpicco/arm7-event_thread
Browse files Browse the repository at this point in the history
tests/event_threads: remove arch_arm7 from blacklist
  • Loading branch information
benpicco committed Feb 26, 2020
2 parents 5c8d926 + 6666e1d commit 99f3f67
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 27 deletions.
16 changes: 10 additions & 6 deletions cpu/arm7_common/arm_cpu.c
Expand Up @@ -25,6 +25,13 @@
#define STACK_MARKER (0x77777777)
#define REGISTER_CNT (12)

__attribute__((used, section(".usr_stack"))) uint8_t usr_stack[USR_STACKSIZE];
__attribute__((used, section(".und_stack"))) uint8_t und_stack[UND_STACKSIZE];
__attribute__((used, section(".fiq_stack"))) uint8_t fiq_stack[FIQ_STACKSIZE];
__attribute__((used, section(".irq_stack"))) uint8_t irq_stack[ISR_STACKSIZE];
__attribute__((used, section(".abt_stack"))) uint8_t abt_stack[ABT_STACKSIZE];
__attribute__((used, section(".svc_stack"))) uint8_t svc_stack[ISR_STACKSIZE];

void thread_yield_higher(void)
{
if (irq_is_in()) {
Expand Down Expand Up @@ -121,16 +128,13 @@ void *thread_isr_stack_pointer(void)
/* This function returns the number of bytes used on the ISR stack */
int thread_isr_stack_usage(void)
{
extern uintptr_t __stack_irq_start;
extern uintptr_t __stack_irq_size;

uintptr_t *ptr = &__stack_irq_start - (unsigned) &__stack_irq_size;
uint32_t *ptr = (uint32_t*) &irq_stack[0];

while(((*ptr) == STACK_CANARY_WORD) && (ptr < &__stack_irq_start)) {
while(((*ptr) == STACK_CANARY_WORD) && (ptr < (uint32_t*) &irq_stack[ISR_STACKSIZE])) {
++ptr;
}

ptrdiff_t num_used_words = &__stack_irq_start - ptr;
ptrdiff_t num_used_words = (uint32_t*) &irq_stack[ISR_STACKSIZE] - ptr;

return num_used_words;
}
40 changes: 37 additions & 3 deletions cpu/lpc2387/include/cpu_conf.h
Expand Up @@ -76,11 +76,45 @@ extern "C" {
#define PUF_SRAM_ATTRIBUTES __attribute__((used, section(".noinit")))

/**
* @brief Stack size used for the exception (ISR) stack
* @brief Stack size used for the undefined instruction interrupt stack
* @{
*/
extern unsigned __stack_irq_size;
#define ISR_STACKSIZE ((unsigned) &__stack_irq_size)
#define UND_STACKSIZE (4)
/** @} */

/**
* @brief Stack size used for the abort interrupt stack
* @{
*/
#define ABT_STACKSIZE (4)
/** @} */

/**
* @brief Stack size used for the interrupt (ISR) stack
* @{
*/
#define ISR_STACKSIZE (400)
/** @} */

/**
* @brief Stack size used for the fast interrupt (FIQ) stack
* @{
*/
#define FIQ_STACKSIZE (64)
/** @} */

/**
* @brief Stack size used for the supervisor mode (SVC) stack
* @{
*/
#define SVC_STACKSIZE (400)
/** @} */

/**
* @brief Stack size used for the user mode/kernel init stack
* @{
*/
#define USR_STACKSIZE (4096)
/** @} */

/**
Expand Down
21 changes: 6 additions & 15 deletions cpu/lpc2387/ldscripts/lpc2387.ld
Expand Up @@ -17,14 +17,6 @@ MEMORY
ram_ethernet : ORIGIN = 0x7FE00000, LENGTH = 16K /* ethernet RAM */
}

__stack_und_size = 4; /* stack for "undefined instruction" interrupts */
__stack_abt_size = 4; /* stack for "abort" interrupts */
__stack_fiq_size = 64; /* stack for "FIQ" interrupts */
__stack_irq_size = 400; /* stack for "IRQ" normal interrupts */
__stack_svc_size = 400; /* stack for "SVC" supervisor mode */
__stack_usr_size = 4096; /* stack for user operation (kernel init) */
__stack_size = __stack_und_size + __stack_abt_size + __stack_fiq_size + __stack_irq_size + __stack_svc_size + __stack_usr_size;

/* now define the output sections */
SECTIONS
{
Expand Down Expand Up @@ -112,18 +104,17 @@ SECTIONS
.stack (NOLOAD) :
{
PROVIDE(__stack_start = .);

. = . + __stack_usr_size;
KEEP (*(.usr_stack))
__stack_usr_start = .;
. = . + __stack_und_size;
KEEP (*(.und_stack))
__stack_und_start = .;
. = . + __stack_fiq_size;
KEEP (*(.fiq_stack))
__stack_fiq_start = .;
. = . + __stack_irq_size;
KEEP (*(.irq_stack))
__stack_irq_start = .;
. = . + __stack_abt_size;
KEEP (*(.abt_stack))
__stack_abt_start = .;
. = . + __stack_svc_size;
KEEP (*(.svc_stack))
__stack_svc_start = .;

PROVIDE(__stack_end = .);
Expand Down
3 changes: 0 additions & 3 deletions tests/event_threads/Makefile
Expand Up @@ -2,7 +2,4 @@ include ../Makefile.tests_common

USEMODULE += event_thread_highest event_thread_medium event_thread_lowest

# arm7 has an issue with it's ISR_STACKSIZE define
FEATURES_BLACKLIST += arch_arm7

include $(RIOTBASE)/Makefile.include

0 comments on commit 99f3f67

Please sign in to comment.