From 0be966a98cd999239152881295acb24e9f4581e3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 4 Dec 2020 15:13:53 -0700 Subject: zephyr: Add basic support for shared memory On the EC, shared memory is at the top of RAM, above all linker symbols that are located in RAM. Add a simple shim for this. At present it does enough to compile, but does not actually work. Yuval probably knows what should be done here. Add a Kconfig for the 'shmem' command. BUG=b:174873770 BRANCH=none TEST=build and boot on volteer (nothing useful happens) 20-12-04 15:22:49.267 shmem 20-12-04 15:22:50.011 Size:-537684993 20-12-04 15:22:50.011 Used: 0 20-12-04 15:22:50.011 Max: 0 Signed-off-by: Simon Glass Change-Id: I465c8519476e7c4a4cafba2f06630675f396c252 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2575207 Reviewed-by: Yuval Peress --- include/link_defs.h | 4 ++++ zephyr/CMakeLists.txt | 3 ++- zephyr/Kconfig | 9 +++++++++ zephyr/shim/include/config_chip.h | 5 +++++ zephyr/shim/include/linker.h | 12 ++++++++++++ 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 zephyr/shim/include/linker.h diff --git a/include/link_defs.h b/include/link_defs.h index 5b04b857bb..4dc71d5f4f 100644 --- a/include/link_defs.h +++ b/include/link_defs.h @@ -15,6 +15,10 @@ #include "task.h" #include "test_util.h" +#ifdef CONFIG_ZEPHYR +#include +#endif + /* Console commands */ extern const struct console_command __cmds[]; extern const struct console_command __cmds_end[]; diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 05710985f0..514d1eb754 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -40,7 +40,8 @@ add_subdirectory_ifdef(CONFIG_PLATFORM_EC "shim") # supported by all boards and emulators (including unit tests) using the shim # layer. zephyr_sources_ifdef(CONFIG_PLATFORM_EC "${PLATFORM_EC}/common/base32.c" - "${PLATFORM_EC}/common/queue.c") + "${PLATFORM_EC}/common/queue.c" + "${PLATFORM_EC}/common/shared_mem.c") # Now include files that depend on or relate to other CONFIG options, sorted by # CONFIG diff --git a/zephyr/Kconfig b/zephyr/Kconfig index e05d47a688..fb50ac9c31 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -203,6 +203,15 @@ config PLATFORM_EC_POWER_BUTTON commands in platform/ec. This requires a GPIO named GPIO_POWER_BUTTON_L in gpio_map.h. +config PLATFORM_EC_CONSOLE_CMD_SHMEM + bool "Enable the 'shmem' command" + default y + help + This command prints basic information about the EC shared memory, + located at the top of RAM, above all RAM symbols: total size, bytes + used and the maximum number of bytes that have been used since + the EC started running. + menuconfig PLATFORM_EC_TIMER bool "Enable the EC timer module" default y diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 1dacf839a5..1eb5e17cb8 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -129,6 +129,11 @@ enum battery_type { #define CONFIG_POWER_PP5000_CONTROL #endif +#undef CONFIG_CMD_SHMEM +#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_SHMEM +#define CONFIG_CMD_SHMEM +#endif + #ifdef CONFIG_PLATFORM_EC_TIMER #define CONFIG_HWTIMER_64BIT #define CONFIG_HW_SPECIFIC_UDELAY diff --git a/zephyr/shim/include/linker.h b/zephyr/shim/include/linker.h new file mode 100644 index 0000000000..335f4f0f19 --- /dev/null +++ b/zephyr/shim/include/linker.h @@ -0,0 +1,12 @@ +/* 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_LINKER_H +#define __CROS_EC_LINKER_H + +/* Put the start of shared memory after all allocated RAM symbols */ +#define __shared_mem_buf _image_ram_end + +#endif -- cgit v1.2.1