summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2022-06-24 12:00:53 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-07 18:43:11 +0000
commit12865c86276d642a526df5f7b053db62409fe421 (patch)
tree63286cea7607d96e62c91e1d264f2c2ce809f5e5
parent4dfe7f2a385d9ad3ca10064b29e4acb0f68c30a3 (diff)
downloadchrome-ec-12865c86276d642a526df5f7b053db62409fe421.tar.gz
tree: Move stdlib implementation to builtin directory
Keeping all of the standard library implementation in a single directory makes it easier to choose between EC's implementation or the implementation from the toolchain. BRANCH=none BUG=b:234181908, b:172020503 TEST=make buildall -j TEST=Using icetower v0.1, Segger J-Trace, and servo micro: ./test/run_device_tests.py -b dartmonkey Test "aes": PASSED Test "cec": PASSED Test "cortexm_fpu": PASSED Test "crc": PASSED Test "flash_physical": PASSED Test "flash_write_protect": PASSED Test "fpsensor_hw": PASSED Test "fpsensor_spi_ro": PASSED Test "fpsensor_spi_rw": PASSED Test "fpsensor_uart_ro": PASSED Test "fpsensor_uart_rw": PASSED Test "mpu_ro": PASSED Test "mpu_rw": PASSED Test "mutex": PASSED Test "pingpong": PASSED Test "printf": PASSED Test "queue": PASSED Test "rollback_region0": PASSED Test "rollback_region1": PASSED Test "rollback_entropy": PASSED Test "rtc": PASSED Test "sha256": PASSED Test "sha256_unrolled": PASSED Test "static_if": PASSED Test "system_is_locked_wp_on": PASSED Test "system_is_locked_wp_off": PASSED Test "timer_dos": PASSED Test "utils": PASSED Test "utils_str": PASSED Test "panic_data_dartmonkey_v2.0.2887": PASSED Test "panic_data_nocturne_fp_v2.2.64": PASSED Test "panic_data_nami_fp_v2.2.144": PASSED Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I75f8591e87a9076d47208eb598186a391c77966d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3724488 Reviewed-by: Edward Hill <ecgh@chromium.org>
-rw-r--r--Makefile3
-rw-r--r--Makefile.toolchain2
-rw-r--r--builtin/build.mk6
-rw-r--r--builtin/stdlib.c (renamed from common/util_stdlib.c)0
-rw-r--r--chip/mchp/build.mk6
-rw-r--r--common/build.mk2
-rw-r--r--zephyr/CMakeLists.txt9
7 files changed, 20 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 0602fd4abf..cdf926daa8 100644
--- a/Makefile
+++ b/Makefile
@@ -268,6 +268,7 @@ include $(BASEDIR)/build.mk
ifneq ($(BASEDIR),$(BDIR))
include $(BDIR)/build.mk
endif
+include builtin/build.mk
include chip/$(CHIP)/build.mk
include core/$(CORE)/build.mk
include common/build.mk
@@ -307,6 +308,7 @@ ifneq ($(PBDIR),)
all-obj-$(1)+=$(call objs_from_dir_p,$(PBDIR),board-private,$(1))
endif
all-obj-$(1)+=$(call objs_from_dir_p,common,common,$(1))
+all-obj-$(1)+=$(call objs_from_dir_p,builtin,builtin,$(1))
all-obj-$(1)+=$(call objs_from_dir_p,driver,driver,$(1))
all-obj-$(1)+=$(call objs_from_dir_p,power,power,$(1))
ifdef CTS_MODULE
@@ -353,6 +355,7 @@ dirs=core/$(CORE) chip/$(CHIP) $(BASEDIR) $(BDIR) common fuzz power test \
dirs+= private private-kandou $(PDIR) $(PBDIR)
dirs+=$(shell find common -type d)
dirs+=$(shell find driver -type d)
+dirs+=builtin
common_dirs=util
ifeq ($(custom-ro_objs-y),)
diff --git a/Makefile.toolchain b/Makefile.toolchain
index 6b82885522..2ce8f2ba5f 100644
--- a/Makefile.toolchain
+++ b/Makefile.toolchain
@@ -89,7 +89,7 @@ CFLAGS_WARN = $(COMMON_WARN) $(C_WARN)
CXXFLAGS_WARN = $(COMMON_WARN)
CFLAGS_DEBUG= -g
CFLAGS_DEBUG+=$(CFLAGS_DEBUG_CHIP)
-CFLAGS_INCLUDE=$(foreach i,$(includes),-I$(i) ) -I.
+CFLAGS_INCLUDE=$(foreach i,$(filter-out builtin, $(includes)),-I$(i) ) -I.
CFLAGS_TEST=$(if $(TEST_BUILD),-DTEST_BUILD=$(EMPTY) \
-DTEST_TASKFILE=$(PROJECT).tasklist,) \
$(if $(CTS_MODULE), $(CFLAGS_CTS)) \
diff --git a/builtin/build.mk b/builtin/build.mk
new file mode 100644
index 0000000000..c4ec975e6b
--- /dev/null
+++ b/builtin/build.mk
@@ -0,0 +1,6 @@
+# Copyright 2022 The ChromiumOS Authors.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Build for EC's standard library implementation.
+builtin-y=stdlib.o
diff --git a/common/util_stdlib.c b/builtin/stdlib.c
index e42788c4af..e42788c4af 100644
--- a/common/util_stdlib.c
+++ b/builtin/stdlib.c
diff --git a/chip/mchp/build.mk b/chip/mchp/build.mk
index 1e3de24d06..0ffb3a7c4a 100644
--- a/chip/mchp/build.mk
+++ b/chip/mchp/build.mk
@@ -81,9 +81,11 @@ chip-lfw-flat = $(out)/RW/$(chip-lfw)-lfw.flat
# build these specifically for lfw with -lfw suffix
objs_lfw = $(patsubst %, $(out)/RW/%-lfw.o, \
- $(addprefix common/, util util_stdlib gpio) \
+ $(addprefix common/, util gpio) \
$(addprefix chip/$(CHIP)/, spi qmspi dma gpio clock hwtimer tfdp) \
- core/$(CORE)/cpu $(chip-lfw))
+ core/$(CORE)/cpu $(chip-lfw) \
+ builtin/stdlib \
+ )
# reuse version.o (and its dependencies) from main board
objs_lfw += $(out)/RW/common/version.o
diff --git a/common/build.mk b/common/build.mk
index 6473d53291..9f9bad8138 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -9,7 +9,7 @@
# Note that this variable includes the trailing "/"
_common_dir:=$(dir $(lastword $(MAKEFILE_LIST)))
-common-y=util.o util_stdlib.o
+common-y=util.o
common-y+=version.o printf.o queue.o queue_policies.o irq_locking.o
common-$(CONFIG_ACCELGYRO_BMI160)+=math_util.o
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index 444e320dad..b3eaefb2a3 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -134,7 +134,11 @@ configure_file(gcov.tmpl.sh ${CMAKE_BINARY_DIR}/gcov.sh)
# included here, sorted by filename. This is common functionality which is
# supported by all boards and emulators (including unit tests) using the shim
# layer.
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC "${PLATFORM_EC}/common/base32.c"
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC
+ # TODO(b/237712836): Remove once
+ # Zephyr's libc has strcasecmp.
+ "${PLATFORM_EC}/builtin/stdlib.c"
+ "${PLATFORM_EC}/common/base32.c"
"${PLATFORM_EC}/common/console_output.c"
"${PLATFORM_EC}/common/ec_features.c"
"${PLATFORM_EC}/common/gpio_commands.c"
@@ -145,9 +149,6 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC "${PLATFORM_EC}/common/base32.c"
"${PLATFORM_EC}/common/system.c"
"${PLATFORM_EC}/common/uart_printf.c"
"${PLATFORM_EC}/common/util.c"
- # TODO(b/237712836): Remove once
- # Zephyr's libc has strcasecmp.
- "${PLATFORM_EC}/common/util_stdlib.c"
"${PLATFORM_EC}/common/version.c")
# Now include files that depend on or relate to other CONFIG options, sorted by