summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile15
-rw-r--r--Makefile.rules2
-rw-r--r--Makefile.toolchain12
-rw-r--r--board/bds/ec.tasklist10
-rw-r--r--board/daisy/ec.tasklist18
-rw-r--r--board/link/ec.tasklist26
-rw-r--r--board/mccroskey/ec.tasklist12
-rw-r--r--board/pit/ec.tasklist14
-rw-r--r--board/snow/ec.tasklist20
-rw-r--r--board/spring/ec.tasklist18
-rw-r--r--core/cortex-m/task.c8
-rw-r--r--include/task_id.h24
12 files changed, 110 insertions, 69 deletions
diff --git a/Makefile b/Makefile
index 5fae04b54a..38a8fc0d55 100644
--- a/Makefile
+++ b/Makefile
@@ -19,9 +19,18 @@ include board/$(BOARD)/build.mk
# Transform the configuration into make variables
includes=include core/$(CORE)/include $(dirs) $(out)
-_tsk_lst:=$(shell echo "CONFIG_TASK_LIST" | $(CPP) -P -Iboard/$(BOARD) -Itest \
- -D"TASK(n, r, d, s)=n" -imacros $(PROJECT).tasklist)
-_tsk_cfg:=$(foreach t,$(_tsk_lst),CONFIG_TASK_$(t))
+ifeq "$(TEST_BUILD)" "y"
+ _tsk_lst:=$(shell echo "CONFIG_TASK_LIST CONFIG_TEST_TASK_LIST" | \
+ $(CPP) -P -Iboard/$(BOARD) -Itest \
+ -D"TASK_NOTEST(n, r, d, s)=" -D"TASK_ALWAYS(n, r, d, s)=n" \
+ -D"TASK_TEST(n, r, d, s)=n" -imacros ec.tasklist \
+ -imacros $(PROJECT).tasklist)
+else
+ _tsk_lst:=$(shell echo "CONFIG_TASK_LIST" | $(CPP) -P \
+ -Iboard/$(BOARD) -D"TASK_NOTEST(n, r, d, s)=n" \
+ -D"TASK_ALWAYS(n, r, d, s)=n" -imacros ec.tasklist)
+endif
+_tsk_cfg:=$(foreach t,$(_tsk_lst) ,CONFIG_TASK_$(t))
_flag_cfg:=$(shell $(CPP) $(CPPFLAGS) -P -dN chip/$(CHIP)/config.h | \
grep -o "CONFIG_.*") \
$(shell $(CPP) $(CPPFLAGS) -P -dN board/$(BOARD)/board.h | \
diff --git a/Makefile.rules b/Makefile.rules
index 50709aa64c..ae173eab98 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -63,7 +63,7 @@ $(test-targets): test-%:
@set -e ; \
echo " BUILD $(out)/$*" ; \
$(MAKE) --no-print-directory BOARD=$(BOARD) PROJECT=$* \
- V=$(V) out=$(out)/$*
+ V=$(V) out=$(out)/$* TEST_BUILD=y
$(qemu-test-targets): qemu-%: test-%
$(call quiet,qemu,TEST )
diff --git a/Makefile.toolchain b/Makefile.toolchain
index ddf8452210..fd64ff5c26 100644
--- a/Makefile.toolchain
+++ b/Makefile.toolchain
@@ -25,11 +25,13 @@ CFLAGS_WARN=-Wall -Werror -Wundef -Wstrict-prototypes -Wno-trigraphs \
-Wno-pointer-sign -fno-strict-overflow -fconserve-stack
CFLAGS_DEBUG= -g
CFLAGS_INCLUDE=$(foreach i,$(includes),-I$(i) )
-CFLAGS_DEFINE=-DOUTDIR=$(out) -DCHIP=$(CHIP) -DTASKFILE=$(PROJECT).tasklist \
- -DBOARD=$(BOARD) -DBOARD_$(BOARD) -DCORE=$(CORE) -DCHIP_$(CHIP) \
- -DCHIP_VARIANT=$(CHIP_VARIANT) -DCHIP_VARIANT_$(CHIP_VARIANT) \
- -DPROJECT=$(PROJECT)
-CPPFLAGS=$(CFLAGS_DEFINE) $(CFLAGS_INCLUDE) $(EXTRA_CFLAGS)
+CFLAGS_TEST=$(if $(TEST_BUILD),-DTEST_BUILD \
+ -DTEST_TASKFILE=$(PROJECT).tasklist,)
+CFLAGS_DEFINE=-DOUTDIR=$(out) -DCHIP=$(CHIP) -DBOARD_TASKFILE=ec.tasklist \
+ -DBOARD=$(BOARD) -DBOARD_$(BOARD) -DCORE=$(CORE) \
+ -DCHIP_$(CHIP) -DCHIP_VARIANT=$(CHIP_VARIANT) \
+ -DCHIP_VARIANT_$(CHIP_VARIANT) -DPROJECT=$(PROJECT)
+CPPFLAGS=$(CFLAGS_DEFINE) $(CFLAGS_INCLUDE) $(CFLAGS_TEST) $(EXTRA_CFLAGS)
CFLAGS=$(CPPFLAGS) $(CFLAGS_CPU) $(CFLAGS_DEBUG) $(CFLAGS_WARN) $(CFLAGS_y)
BUILD_CFLAGS=$(CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN)
HOST_CFLAGS=$(CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN)
diff --git a/board/bds/ec.tasklist b/board/bds/ec.tasklist
index d5f66a6570..556f3cbb7e 100644
--- a/board/bds/ec.tasklist
+++ b/board/bds/ec.tasklist
@@ -8,13 +8,15 @@
*
* The first one has the lowest priority.
*
- * For each task, use the macro TASK(n, r, d, s) where :
+ * For each task, use the macro TASK_ALWAYS(n, r, d, s) for base tasks and
+ * TASK_NOTEST(n, r, d, s) for tasks that can be excluded in test binaries,
+ * where :
* 'n' in the name of the task
* 'r' in the main routine of the task
* 'd' in an opaque parameter passed to the routine at startup
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
- TASK(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
- TASK(LIGHTBAR, lightbar_task, NULL, TASK_STACK_SIZE) \
- TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE)
+ TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(LIGHTBAR, lightbar_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE)
diff --git a/board/daisy/ec.tasklist b/board/daisy/ec.tasklist
index 68f48ebf4c..092b1faa7b 100644
--- a/board/daisy/ec.tasklist
+++ b/board/daisy/ec.tasklist
@@ -8,17 +8,19 @@
*
* The first one has the lowest priority.
*
- * For each task, use the macro TASK(n, r, d, s) where :
+ * For each task, use the macro TASK_ALWAYS(n, r, d, s) for base tasks and
+ * TASK_NOTEST(n, r, d, s) for tasks that can be excluded in test binaries,
+ * where :
* 'n' in the name of the task
* 'r' in the main routine of the task
* 'd' in an opaque parameter passed to the routine at startup
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
- TASK(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
- TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
- TASK(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
- TASK(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE) \
- TASK(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
- TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
- TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE)
+ TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE)
diff --git a/board/link/ec.tasklist b/board/link/ec.tasklist
index 63628b1741..e3b02e5f94 100644
--- a/board/link/ec.tasklist
+++ b/board/link/ec.tasklist
@@ -8,21 +8,23 @@
*
* The first one has the lowest priority.
*
- * For each task, use the macro TASK(n, r, d, s) where :
+ * For each task, use the macro TASK_ALWAYS(n, r, d, s) for base tasks and
+ * TASK_NOTEST(n, r, d, s) for tasks that can be excluded in test binaries,
+ * where :
* 'n' is the name of the task
* 'r' is the main routine of the task
* 'd' is an opaque parameter passed to the routine at startup
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
- TASK(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
- TASK(VBOOTHASH, vboot_hash_task, NULL, LARGER_TASK_STACK_SIZE) \
- TASK(LIGHTBAR, lightbar_task, NULL, TASK_STACK_SIZE) \
- TASK(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
- TASK(THERMAL, thermal_task, NULL, TASK_STACK_SIZE) \
- TASK(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
- TASK(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \
- TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \
- TASK(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) \
- TASK(SWITCH, switch_task, NULL, TASK_STACK_SIZE) \
- TASK(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE)
+ TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(VBOOTHASH, vboot_hash_task, NULL, LARGER_TASK_STACK_SIZE) \
+ TASK_NOTEST(LIGHTBAR, lightbar_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(THERMAL, thermal_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) \
+ TASK_ALWAYS(SWITCH, switch_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE)
diff --git a/board/mccroskey/ec.tasklist b/board/mccroskey/ec.tasklist
index 6820cd84b4..80c7a74f31 100644
--- a/board/mccroskey/ec.tasklist
+++ b/board/mccroskey/ec.tasklist
@@ -8,14 +8,16 @@
*
* The first one has the lowest priority.
*
- * For each task, use the macro TASK(n, r, d, s) where :
+ * For each task, use the macro TASK_ALWAYS(n, r, d, s) for base tasks and
+ * TASK_NOTEST(n, r, d, s) for tasks that can be excluded in test binaries,
+ * where :
* 'n' in the name of the task
* 'r' in the main routine of the task
* 'd' in an opaque parameter passed to the routine at startup
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
- TASK(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
- TASK(KEYSCAN, keyboard_scan_task, NULL, 360) \
- TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
- TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE)
+ TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, 360) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE)
diff --git a/board/pit/ec.tasklist b/board/pit/ec.tasklist
index 68f48ebf4c..aa27474785 100644
--- a/board/pit/ec.tasklist
+++ b/board/pit/ec.tasklist
@@ -15,10 +15,10 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
- TASK(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
- TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
- TASK(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
- TASK(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE) \
- TASK(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
- TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
- TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE)
+ TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE)
diff --git a/board/snow/ec.tasklist b/board/snow/ec.tasklist
index d84f9818fa..39ce64e09b 100644
--- a/board/snow/ec.tasklist
+++ b/board/snow/ec.tasklist
@@ -8,18 +8,20 @@
*
* The first one has the lowest priority.
*
- * For each task, use the macro TASK(n, r, d, s) where :
+ * For each task, use the macro TASK_ALWAYS(n, r, d, s) for base tasks and
+ * TASK_NOTEST(n, r, d, s) for tasks that can be excluded in test binaries,
+ * where :
* 'n' in the name of the task
* 'r' in the main routine of the task
* 'd' in an opaque parameter passed to the routine at startup
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
- TASK(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
- TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
- TASK(POWERLED, power_led_task, NULL, 256) \
- TASK(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
- TASK(KEYSCAN, keyboard_scan_task, NULL, 360) \
- TASK(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
- TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
- TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE)
+ TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(POWERLED, power_led_task, NULL, 256) \
+ TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, 360) \
+ TASK_ALWAYS(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE)
diff --git a/board/spring/ec.tasklist b/board/spring/ec.tasklist
index a50d2ab798..3c57844983 100644
--- a/board/spring/ec.tasklist
+++ b/board/spring/ec.tasklist
@@ -8,17 +8,19 @@
*
* The first one has the lowest priority.
*
- * For each task, use the macro TASK(n, r, d, s) where :
+ * For each task, use the macro TASK_ALWAYS(n, r, d, s) for base tasks and
+ * TASK_NOTEST(n, r, d, s) for tasks that can be excluded in test binaries,
+ * where :
* 'n' in the name of the task
* 'r' in the main routine of the task
* 'd' in an opaque parameter passed to the routine at startup
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
- TASK(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
- TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
- TASK(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
- TASK(KEYSCAN, keyboard_scan_task, NULL, 256) \
- TASK(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
- TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
- TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE)
+ TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, 256) \
+ TASK_ALWAYS(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE)
diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c
index 485e58e06d..47bbbee1e9 100644
--- a/core/cortex-m/task.c
+++ b/core/cortex-m/task.c
@@ -33,17 +33,17 @@ typedef union {
/* declare task routine prototypes */
#define TASK(n, r, d, s) int r(void *);
-#include TASK_LIST
void __idle(void);
CONFIG_TASK_LIST
+CONFIG_TEST_TASK_LIST
#undef TASK
/* Task names for easier debugging */
#define TASK(n, r, d, s) #n,
-#include TASK_LIST
static const char * const task_names[] = {
"<< idle >>",
CONFIG_TASK_LIST
+ CONFIG_TEST_TASK_LIST
};
#undef TASK
@@ -96,7 +96,6 @@ static void task_exit_trap(void)
.pc = (uint32_t)r, \
.stack_size = s, \
},
-#include TASK_LIST
static const struct {
uint32_t r0;
uint32_t pc;
@@ -104,6 +103,7 @@ static const struct {
} const tasks_init[] = {
TASK(IDLE, __idle, 0, IDLE_TASK_STACK_SIZE)
CONFIG_TASK_LIST
+ CONFIG_TEST_TASK_LIST
};
#undef TASK
@@ -112,10 +112,10 @@ static task_ tasks[TASK_ID_COUNT];
/* Stacks for all tasks */
#define TASK(n, r, d, s) + s
-#include TASK_LIST
uint8_t task_stacks[0
TASK(IDLE, __idle, 0, IDLE_TASK_STACK_SIZE)
CONFIG_TASK_LIST
+ CONFIG_TEST_TASK_LIST
] __attribute__((aligned(8)));
#undef TASK
diff --git a/include/task_id.h b/include/task_id.h
index cf359ec6d2..33445aee9c 100644
--- a/include/task_id.h
+++ b/include/task_id.h
@@ -8,10 +8,27 @@
#ifndef __TASK_ID_H
#define __TASK_ID_H
+/* excludes non-base tasks for test build */
+#ifdef TEST_BUILD
+#define TASK_NOTEST(n, r, d, s)
+#define TASK_TEST TASK
+#else
+#define TASK_NOTEST TASK
+#define CONFIG_TEST_TASK_LIST
+#endif
+
+#define TASK_ALWAYS TASK
+
/* define the name of the header containing the list of tasks */
#define STRINGIFY0(name) #name
#define STRINGIFY(name) STRINGIFY0(name)
-#define TASK_LIST STRINGIFY(TASKFILE)
+#define TEST_TASK_LIST STRINGIFY(TEST_TASKFILE)
+#define BOARD_TASK_LIST STRINGIFY(BOARD_TASKFILE)
+
+#include BOARD_TASK_LIST
+#ifdef TEST_BUILD
+#include TEST_TASK_LIST
+#endif
/* Task identifier (8 bits) */
typedef uint8_t task_id_t;
@@ -24,11 +41,12 @@ typedef uint8_t task_id_t;
* TASK macro in the TASK_LIST file.
*/
#define TASK(n, r, d, s) TASK_ID_##n,
-#include TASK_LIST
enum {
TASK_ID_IDLE,
- /* CONFIG_TASK_LIST is a macro coming from the TASK_LIST file */
+ /* CONFIG_TASK_LIST is a macro coming from the BOARD_TASK_LIST file */
CONFIG_TASK_LIST
+ /* CONFIG_TEST_TASK_LIST is a macro from the TEST_TASK_LIST file */
+ CONFIG_TEST_TASK_LIST
/* Number of tasks */
TASK_ID_COUNT,
/* Special task identifiers */