From 913266d6e4ec6196b3bff17399a62697cc485781 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 3 Dec 2019 13:09:25 +0900 Subject: [PATCH] Include arch specific header and implementation by ARCH. Signed-off-by: NIIBE Yutaka --- ChangeLog | 15 +++++++++++++++ chopstx.c | 12 ++---------- example-cdc-gnu-linux/Makefile | 1 + example-cdc/Makefile | 1 + example-fraucheky/Makefile | 1 + example-fs-bb48/Makefile | 1 + example-fsm-55/Makefile | 1 + example-led/Makefile | 1 + example-primer2/Makefile | 1 + example-usart/Makefile | 1 + example-usb-serial/Makefile | 1 + rules.mk | 4 +++- 12 files changed, 29 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 262e060..5f853a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2019-12-03 NIIBE Yutaka + + * example-cdc/Makefile (ARCH): Define. + * example-cdc-gnu-linux/Makefile (ARCH): Ditto. + * example-fraucheky/Makefile (ARCH): Ditto. + * example-fs-bb48/Makefile (ARCH): Ditto. + * example-fsm-55/Makefile (ARCH): Ditto. + * example-led/Makefile (ARCH): Ditto. + * example-primer2/Makefile (ARCH): Ditto. + * example-usart/Makefile (ARCH): Ditto. + * example-usb-serial/Makefile (ARCH): Ditto. + + * chopstx.c: Include files by ARCH_HEADER and ARCH_IMPL. + * rules.mk (DEFS): Define ARCH_HEADER and ARCH_IMPL by ARCH. + 2019-11-25 NIIBE Yutaka * chopstx-gnu-linux.c (chx_idle): Synchronous IDLE. diff --git a/chopstx.c b/chopstx.c index e488920..c936976 100644 --- a/chopstx.c +++ b/chopstx.c @@ -73,11 +73,7 @@ chx_fatal (uint32_t err_code) } /* Include the definition of thread context structure. */ -#ifdef GNU_LINUX_EMULATION -#include "chopstx-gnu-linux.h" -#else -#include "chopstx-cortex-m.h" -#endif +#include ARCH_HEADER /* ALLOW_SLEEP for the idle thread. */ int chx_allow_sleep; @@ -304,11 +300,7 @@ static struct chx_thread *chx_running_preempted (struct chx_thread *tp_next); * Here comes architecture specific code. */ -#ifdef GNU_LINUX_EMULATION -#include "chopstx-gnu-linux.c" -#else -#include "chopstx-cortex-m.c" -#endif +#include ARCH_IMPL static void chx_set_timer (struct chx_thread *tp, uint32_t ticks) diff --git a/example-cdc-gnu-linux/Makefile b/example-cdc-gnu-linux/Makefile index 28896aa..1ff8510 100644 --- a/example-cdc-gnu-linux/Makefile +++ b/example-cdc-gnu-linux/Makefile @@ -8,6 +8,7 @@ CHOPSTX = .. LDSCRIPT= CSRC = sample.c usb-cdc.c command.c +ARCH=gnu-linux CHIP=gnu-linux USE_SYS = yes USE_USB = yes diff --git a/example-cdc/Makefile b/example-cdc/Makefile index 5246c42..67df7a5 100644 --- a/example-cdc/Makefile +++ b/example-cdc/Makefile @@ -6,6 +6,7 @@ CHOPSTX = .. LDSCRIPT= sample.ld.m4 CSRC = sample.c usb-cdc.c +ARCH=cortex-m CHIP=stm32l4 USE_SYS = yes diff --git a/example-fraucheky/Makefile b/example-fraucheky/Makefile index 7458b5f..ae53a73 100644 --- a/example-fraucheky/Makefile +++ b/example-fraucheky/Makefile @@ -8,6 +8,7 @@ FRAUCHEKY = ../../fraucheky LDSCRIPT= CSRC = main.c +ARCH=gnu-linux CHIP=gnu-linux USE_SYS = yes USE_USB = yes diff --git a/example-fs-bb48/Makefile b/example-fs-bb48/Makefile index e4d0c73..af7bf95 100644 --- a/example-fs-bb48/Makefile +++ b/example-fs-bb48/Makefile @@ -7,6 +7,7 @@ PROJECT = sample CHOPSTX = .. LDSCRIPT= sample.ld CSRC = sample.c usb-cdc.c command.c touch.c +ARCH=cortex-m CHIP=mkl27z USE_SYS = yes diff --git a/example-fsm-55/Makefile b/example-fsm-55/Makefile index 791b2b9..96ca4e3 100644 --- a/example-fsm-55/Makefile +++ b/example-fsm-55/Makefile @@ -7,6 +7,7 @@ LDSCRIPT= hacker-emblem.ld CSRC = reset.c hh.c +ARCH=cortex-m CHIP=stm32f0 # Hacker Emblem and "Happy Hacking!" demonstration diff --git a/example-led/Makefile b/example-led/Makefile index 2e9af44..355bfc9 100644 --- a/example-led/Makefile +++ b/example-led/Makefile @@ -15,6 +15,7 @@ LDSCRIPT= sample.ld.m4 ### LDSCRIPT= sample.ld.m3 CSRC = sample.c +ARCH=cortex-m CHIP=stm32l4 USE_SYS = yes diff --git a/example-primer2/Makefile b/example-primer2/Makefile index 0a0f397..32a9992 100644 --- a/example-primer2/Makefile +++ b/example-primer2/Makefile @@ -8,6 +8,7 @@ LDSCRIPT= lcd.ld CSRC = primer2-switches.c primer2-ts.c lcd.c main.c \ neug.c sha256.c +ARCH=cortex-m CHIP=stm32f103 USE_SYS = yes USE_USB = yes diff --git a/example-usart/Makefile b/example-usart/Makefile index c7d82a4..11c5d68 100644 --- a/example-usart/Makefile +++ b/example-usart/Makefile @@ -15,6 +15,7 @@ LDSCRIPT= sample.ld.m4 ### LDSCRIPT= sample.ld.m3 CSRC = sample.c +ARCH=cortex-m CHIP=stm32l4 USE_SYS = yes USE_USART = yes diff --git a/example-usb-serial/Makefile b/example-usb-serial/Makefile index 168b913..bff6b09 100644 --- a/example-usb-serial/Makefile +++ b/example-usb-serial/Makefile @@ -6,6 +6,7 @@ CHOPSTX = .. LDSCRIPT= sample.ld CSRC = sample.c usb-cdc.c +ARCH=cortex-m CHIP=stm32f103 USE_SYS = yes diff --git a/rules.mk b/rules.mk index 1174c60..b80552a 100644 --- a/rules.mk +++ b/rules.mk @@ -65,10 +65,12 @@ ifeq ($(EMULATION),) MCFLAGS = -mcpu=$(MCU) LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) \ -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections +DEFS += -DARCH_HEADER='"chopstx-$(ARCH).h"' -DARCH_IMPL='"chopstx-$(ARCH).c"' else MCFLAGS = LDFLAGS = -DEFS += -D_GNU_SOURCE +DEFS += -D_GNU_SOURCE -DARCH_HEADER='"chopstx-gnu-linux.h"' \ + -DARCH_IMPL='"chopstx-gnu-linux.c"' endif CFLAGS = $(MCFLAGS) $(OPT) $(CWARN) -Wa,-alms=$(BUILDDIR)/$(notdir $(<:.c=.lst)) $(DEFS)