diff options
-rw-r--r-- | include/config.h | 6 | ||||
-rw-r--r-- | zephyr/Kconfig | 21 | ||||
-rw-r--r-- | zephyr/Kconfig.powerseq | 7 | ||||
-rw-r--r-- | zephyr/Kconfig.tasks | 35 | ||||
-rw-r--r-- | zephyr/shim/include/shimmed_task_id.h | 34 | ||||
-rw-r--r-- | zephyr/shim/include/shimmed_tasks.h | 30 | ||||
-rw-r--r-- | zephyr/shim/src/tasks.c | 8 |
7 files changed, 124 insertions, 17 deletions
diff --git a/include/config.h b/include/config.h index 16b75a04f3..c294f1384a 100644 --- a/include/config.h +++ b/include/config.h @@ -19,13 +19,13 @@ #define __CROS_EC_CONFIG_H /* - * When building for Zephyr, a shimmed_tasks.h header may be defined + * When building for Zephyr tests, a shimmed_tasks.h header is defined * to create all the HAS_TASK_* definitions. Since those are used in * config.h, we need to include that header first. */ -#ifdef CONFIG_SHIMMED_TASKS +#ifdef CONFIG_ZEPHYR #include "shimmed_tasks.h" -#endif +#endif /* CONFIG_ZEPHYR */ #ifdef INCLUDE_ENV_CONFIG /* diff --git a/zephyr/Kconfig b/zephyr/Kconfig index d120530391..d5ee960e7a 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -13,6 +13,7 @@ menuconfig PLATFORM_EC if PLATFORM_EC rsource "Kconfig.powerseq" +rsource "Kconfig.tasks" # Below is a hack to use CONFIG_ZEPHYR in platform/ec code before # config.h has been included. There is some tricky ordering in some @@ -84,10 +85,16 @@ menuconfig PLATFORM_EC_KEYBOARD the resulting input to the AP over the host interface. This consists of a keyboard-scanning task which provides key scans via it calling keyboard_state_changed() (for i8042) or its client calling - keyboard_scan_get_state() (for MKBP). + keyboard_scan_get_state() (for MKBP). This implies HAS_TASK_KEYSCAN. if PLATFORM_EC_KEYBOARD +config TASK_KEYSCAN_STACK_SIZE + hex "keyscan task stack size" + default 0x200 + help + The size of the keyboard scan task stack. + choice "Protocol select" prompt "Select the keyboard protocol to use" @@ -145,12 +152,22 @@ config PLATFORM_EC_I2C should make shimming other platform/ec modules which rely on i2c communication "just work" without requiring any further code changes. -config PLATFORM_EC_HOSTCMD +menuconfig PLATFORM_EC_HOSTCMD bool "Enable host commands shim" default y if AP help Enable the host commands shim in platform/ec. +if PLATFORM_EC_HOSTCMD + +config TASK_HOSTCMD_STACK_SIZE + hex "hostcmd task stack size" + default 0x200 + help + The size of the host command task stack. + +endif # PLATFORM_EC_HOSTCMD + config PLATFORM_EC_LID_SWITCH bool "Enable the lid switch module" help diff --git a/zephyr/Kconfig.powerseq b/zephyr/Kconfig.powerseq index 81935cdace..6716e6c976 100644 --- a/zephyr/Kconfig.powerseq +++ b/zephyr/Kconfig.powerseq @@ -7,9 +7,16 @@ menuconfig PLATFORM_EC_POWERSEQ depends on AP help Enable shimming the platform/ec AP power sequencing code. + This config implies HAS_TASK_CHIPSET. if PLATFORM_EC_POWERSEQ +menuconfig TASK_CHIPSET_STACK_SIZE + hex "The size of the chipset task stack size" + default 0x200 + help + The stack size of the shipset task. + menuconfig PLATFORM_EC_POWERSEQ_INTEL bool "Enable shimming common Intel power sequencing code" depends on AP_X86_INTEL diff --git a/zephyr/Kconfig.tasks b/zephyr/Kconfig.tasks new file mode 100644 index 0000000000..9a2a6d94a0 --- /dev/null +++ b/zephyr/Kconfig.tasks @@ -0,0 +1,35 @@ +# Copyright 2020 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +config HAS_TASK_KEYPROTO + bool "Whether or not the keyproto task should be run." + default n + help + This turns on the keyproto task. + +if HAS_TASK_KEYPROTO + +config TASK_KEYPROTO_STACK_SIZE + hex "keyproto task stack size" + default 0x200 + help + The stack size of the keyproto task. + +endif # HAS_TASK_KEYPROTO + +config HAS_TASK_POWERBTN + bool "Whether or not the power button task should be run." + default n + help + This turns on the power button task. + +if HAS_TASK_POWERBTN + +config TASK_POWERBTN_STACK_SIZE + hex "powerbtn task stack size" + default 0x200 + help + The stack size of the power button task. + +endif # HAS_TASK_POWERBTN diff --git a/zephyr/shim/include/shimmed_task_id.h b/zephyr/shim/include/shimmed_task_id.h index bc6a5d828b..dc7e7f24ff 100644 --- a/zephyr/shim/include/shimmed_task_id.h +++ b/zephyr/shim/include/shimmed_task_id.h @@ -6,15 +6,39 @@ #ifndef __CROS_EC_SHIMMED_TASK_ID_H #define __CROS_EC_SHIMMED_TASK_ID_H +#include "common.h" + /* Task identifier (8 bits) */ typedef uint8_t task_id_t; -/* Include the shimmed tasks for the project/board */ -#ifdef CONFIG_SHIMMED_TASKS -#include "shimmed_tasks.h" -#else +/* + * Highest priority on bottom -- same as in platform/ec. List of CROS_EC_TASK + * items. See CONFIG_TASK_LIST in platform/ec's config.h for more information. + * This will only automatically get generated if CONFIG_ZTEST is not defined. + * Unit tests must define their own tasks. + */ +#ifndef CONFIG_ZTEST +#define CROS_EC_TASK_LIST \ + COND_CODE_1(HAS_TASK_CHIPSET, \ + (CROS_EC_TASK(CHIPSET, chipset_task, 0, \ + CONFIG_TASK_CHIPSET_STACK_SIZE)), ()) \ + COND_CODE_1(HAS_TASK_HOSTCMD, \ + (CROS_EC_TASK(HOSTCMD, host_command_task, 0, \ + CONFIG_TASK_HOSTCMD_STACK_SIZE)), ()) \ + COND_CODE_1(HAS_TASK_KEYPROTO, \ + (CROS_EC_TASK(KEYPROTO, keyboard_protocol_task, 0, \ + CONFIG_TASK_KEYPROTO_STACK_SIZE)), ()) \ + COND_CODE_1(HAS_TASK_POWERBTN, \ + (CROS_EC_TASK(POWERBTN, power_button_task, 0, \ + CONFIG_TASK_POWERBTN_STACK_SIZE)), ()) \ + COND_CODE_1(HAS_TASK_KEYSCAN, \ + (CROS_EC_TASK(KEYSCAN, keyboard_scan_task, 0, \ + CONFIG_TASK_KEYSCAN_STACK_SIZE)), ()) +#endif /* !CONFIG_ZTEST */ + +#ifndef CROS_EC_TASK_LIST #define CROS_EC_TASK_LIST -#endif +#endif /* CROS_EC_TASK_LIST */ /* Define the task_ids globally for all shimmed platform/ec code to use */ #define CROS_EC_TASK(name, ...) TASK_ID_##name, diff --git a/zephyr/shim/include/shimmed_tasks.h b/zephyr/shim/include/shimmed_tasks.h new file mode 100644 index 0000000000..3a34e79715 --- /dev/null +++ b/zephyr/shim/include/shimmed_tasks.h @@ -0,0 +1,30 @@ +/* Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __CROS_EC_SHIMMED_TASKS_H +#define __CROS_EC_SHIMMED_TASKS_H + +#ifdef CONFIG_PLATFORM_EC_POWERSEQ +#define HAS_TASK_CHIPSET 1 +#endif /* CONFIG_PLATFORM_EC_POWERSEQ */ + +#ifdef CONFIG_PLATFORM_EC_HOSTCMD +#define HAS_TASK_HOSTCMD 1 +#define CONFIG_HOSTCMD_EVENTS +#endif /* CONFIG_PLATFORM_EC_HOSTCMD */ + +#ifdef CONFIG_PLATFORM_EC_KEYBOARD +#define HAS_TASK_KEYSCAN 1 +#endif /* CONFIG_PLATFORM_EC_KEYBOARD */ + +#ifdef CONFIG_HAS_TASK_KEYPROTO +#define HAS_TASK_KEYPROTO 1 +#endif /* CONFIG_HAS_TASK_KEYPROTO */ + +#ifdef CONFIG_HAS_TASK_POWERBTN +#define HAS_TASK_POWERBTN 1 +#endif /* CONFIG_HAS_TASK_POWERBTN */ + +#endif /* __CROS_EC_SHIMMED_TASKS_H */ diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c index dc9f466d97..78bee0a69a 100644 --- a/zephyr/shim/src/tasks.c +++ b/zephyr/shim/src/tasks.c @@ -7,19 +7,13 @@ #include <init.h> #include <sys/atomic.h> -#include "shimmed_tasks.h" +#include "common.h" #include "task.h" /* We need to ensure that is one lower priority for the deferred task */ BUILD_ASSERT(CONFIG_NUM_PREEMPT_PRIORITIES + 1 >= TASK_ID_COUNT, "Must increase number of available preempt priorities"); -/* Ensure all of the manually defined HAS_TASK_ defines are present */ -#define CROS_EC_TASK(name, ...) \ - BUILD_ASSERT(HAS_TASK_##name, "Must define HAS_TASK_*"); -CROS_EC_TASK_LIST -#undef CROS_EC_TASK - /* Declare all task stacks here */ #define CROS_EC_TASK(name, e, p, size) \ K_THREAD_STACK_DEFINE(name##_STACK, size); |