diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2017-09-05 14:34:25 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2017-09-05 14:34:25 +0900 |
commit | af5982507f5f6831b202d1014138a92b8a243183 (patch) | |
tree | 7b8e6ad6008d5a93783fe7b27e10dd9afe4a9788 | |
parent | a1b993c2e24d2e94fe5284cdbfec712b6d358785 (diff) |
Define threads stack size by stack-def.h.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | example-cdc/sample.c | 16 | ||||
-rw-r--r-- | example-cdc/sample.ld | 28 | ||||
-rw-r--r-- | example-cdc/stack-def.h | 24 | ||||
-rw-r--r-- | example-cdc/usb-cdc.c | 7 |
5 files changed, 46 insertions, 34 deletions
@@ -1,3 +1,8 @@ +2017-09-05 NIIBE Yutaka <gniibe@fsij.org> + + * example-cdc: Use stack-def.h. + * example-cdc/stack-def.h: New. + 2017-09-04 NIIBE Yutaka <gniibe@fsij.org> * mcu/sys-stm32f103.h (nvic_system_reset): Add noreturn attribute. diff --git a/example-cdc/sample.c b/example-cdc/sample.c index d9c38c8..13860e7 100644 --- a/example-cdc/sample.c +++ b/example-cdc/sample.c @@ -61,14 +61,14 @@ blk (void *arg) #define PRIO_PWM 3 #define PRIO_BLK 2 -extern uint8_t __process1_stack_base__[], __process1_stack_size__[]; -extern uint8_t __process2_stack_base__[], __process2_stack_size__[]; - -#define STACK_ADDR_PWM ((uint32_t)__process1_stack_base__) -#define STACK_SIZE_PWM ((uint32_t)__process1_stack_size__) - -#define STACK_ADDR_BLK ((uint32_t)__process2_stack_base__) -#define STACK_SIZE_BLK ((uint32_t)__process2_stack_size__) +#define STACK_MAIN +#define STACK_PROCESS_1 +#define STACK_PROCESS_2 +#include "stack-def.h" +#define STACK_ADDR_PWM ((uint32_t)process1_base) +#define STACK_SIZE_PWM (sizeof process1_base) +#define STACK_ADDR_BLK ((uint32_t)process2_base) +#define STACK_SIZE_BLK (sizeof process2_base) static char hexchar (uint8_t x) diff --git a/example-cdc/sample.ld b/example-cdc/sample.ld index 0e66d51..09f59c2 100644 --- a/example-cdc/sample.ld +++ b/example-cdc/sample.ld @@ -1,11 +1,6 @@ /* * ST32F103 memory setup. */ -__main_stack_size__ = 0x0100; /* Idle+Exception handlers */ -__process0_stack_size__ = 0x0400; /* Main program */ -__process1_stack_size__ = 0x0200; /* first thread program */ -__process2_stack_size__ = 0x0200; /* second thread program */ -__process3_stack_size__ = 0x0200; /* third thread program */ MEMORY { @@ -81,31 +76,18 @@ SECTIONS .process_stack : { . = ALIGN(8); - __process3_stack_base__ = .; - . += __process3_stack_size__; + *(.process_stack.3) + *(.process_stack.2) + *(.process_stack.1) + *(.process_stack.0) . = ALIGN(8); - __process3_stack_end__ = .; - __process2_stack_base__ = .; - . += __process2_stack_size__; - . = ALIGN(8); - __process2_stack_end__ = .; - __process1_stack_base__ = .; - . += __process1_stack_size__; - . = ALIGN(8); - __process1_stack_end__ = .; - __process0_stack_base__ = .; - . += __process0_stack_size__; - . = ALIGN(8); - __process0_stack_end__ = .; } > ram .main_stack : { . = ALIGN(8); - __main_stack_base__ = .; - . += __main_stack_size__; + *(.main_stack) . = ALIGN(8); - __main_stack_end__ = .; } > ram .data : diff --git a/example-cdc/stack-def.h b/example-cdc/stack-def.h new file mode 100644 index 0000000..cc7babb --- /dev/null +++ b/example-cdc/stack-def.h @@ -0,0 +1,24 @@ +#if defined(STACK_MAIN) +/* Idle+Exception handlers */ +char __main_stack_end__[0] __attribute__ ((section(".main_stack"))); +char main_base[0x0100] __attribute__ ((section(".main_stack"))); + +/* Main program */ +char __process0_stack_end__[0] __attribute__ ((section(".process_stack.0"))); +char process0_base[0x0400] __attribute__ ((section(".process_stack.0"))); +#endif + +/* First thread program */ +#if defined(STACK_PROCESS_1) +char process1_base[0x0200] __attribute__ ((section(".process_stack.1"))); +#endif + +/* Second thread program */ +#if defined(STACK_PROCESS_2) +char process2_base[0x0200] __attribute__ ((section(".process_stack.2"))); +#endif + +/* Third thread program */ +#if defined(STACK_PROCESS_3) +char process3_base[0x0200] __attribute__ ((section(".process_stack.3"))); +#endif diff --git a/example-cdc/usb-cdc.c b/example-cdc/usb-cdc.c index 360023d..cdad7dc 100644 --- a/example-cdc/usb-cdc.c +++ b/example-cdc/usb-cdc.c @@ -642,9 +642,10 @@ static void *tty_main (void *arg); #define INTR_REQ_USB 20 #define PRIO_TTY 4 -extern uint8_t __process3_stack_base__[], __process3_stack_size__[]; -#define STACK_ADDR_TTY ((uint32_t)__process3_stack_base__) -#define STACK_SIZE_TTY ((uint32_t)__process3_stack_size__) +#define STACK_PROCESS_3 +#include "stack-def.h" +#define STACK_ADDR_TTY ((uint32_t)process3_base) +#define STACK_SIZE_TTY (sizeof process3_base) struct tty * tty_open (void) |