summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYilun Lin <yllin@google.com>2019-04-15 18:16:54 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-04-30 06:08:07 -0700
commit3c49473cd607bc5debbbbd22118bad18d11b8611 (patch)
treefd1fa234a159a3436559b8f3a79a81615041bd50
parent631000bdf478b8ad206753f4ffeb2af879129866 (diff)
downloadchrome-ec-3c49473cd607bc5debbbbd22118bad18d11b8611.tar.gz
mt_scp: Generate IPI tables with util gen_ipi_table.
IPI table is board-specific. This CL removes the original IPI table in chip layer, and uses gen_ipi_table to generate the table for each board to reduce the maintenance effort. TEST=make BOARD=kukui_scp, and see build/kukui_scp/ipi_table_gen.inc exists. Push to Kukui, and see SCP boots. TEST=modify IPI_COUNT in board.h and see it generates a new ipi_table_gen.inc BUG=b:130508869 BRANCH=None Change-Id: I0c05319447d15917e8833aa80d61166c4e396370 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1568890 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r--Makefile.rules2
-rw-r--r--chip/mt_scp/build.mk5
-rw-r--r--chip/mt_scp/ipi_table.c30
-rw-r--r--util/build.mk8
-rw-r--r--util/gen_ipi_table.c58
5 files changed, 78 insertions, 25 deletions
diff --git a/Makefile.rules b/Makefile.rules
index a45e9ad981..419dd5a9ee 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -121,6 +121,8 @@ cmd_tp_hash = $(out)/util/gen_touchpad_hash \
cmd_emmc_bootblock = $(out)/util/gen_emmc_transfer_data \
$(if $(BOOTBLOCK),-i $(BOOTBLOCK)) -o $@
+cmd_ipi_table = $(out)/util/gen_ipi_table $@
+
# commands for RSA signature: rwsig does not need to sign the whole image
# (it signs the RW part separately). usbpd1 type needs to sign the final image.
ifeq ($(CONFIG_RWSIG_TYPE_RWSIG),)
diff --git a/chip/mt_scp/build.mk b/chip/mt_scp/build.mk
index af1ba08170..aecdb8beaf 100644
--- a/chip/mt_scp/build.mk
+++ b/chip/mt_scp/build.mk
@@ -12,6 +12,11 @@ CFLAGS_CPU+=-march=armv7e-m -mcpu=cortex-m4
# Required chip modules
chip-y=clock.o gpio.o memmap.o system.o uart.o
+ifeq ($(CONFIG_IPI),y)
+$(out)/RO/chip/$(CHIP)/ipi_table.o: $(out)/ipi_table_gen.inc
+$(out)/RW/chip/$(CHIP)/ipi_table.o: $(out)/ipi_table_gen.inc
+endif
+
# Optional chip modules
chip-$(CONFIG_COMMON_TIMER)+=hrtimer.o
chip-$(CONFIG_I2C)+=i2c.o
diff --git a/chip/mt_scp/ipi_table.c b/chip/mt_scp/ipi_table.c
index aaeadb40d5..8569ab24a7 100644
--- a/chip/mt_scp/ipi_table.c
+++ b/chip/mt_scp/ipi_table.c
@@ -53,35 +53,15 @@ const int ipi_wakeup_undefined;
#endif /* PASS == 2 */
/*
- * Table to hold all the IPI handler function pointer.
+ * Include generated IPI table (by util/gen_ipi_table). The contents originate
+ * from IPI_COUNT definition in board.h
*/
-table(ipi_handler_t, ipi_handler_table,
- ipi_x_func(handler, ipi_arguments, 0)
- ipi_x_func(handler, ipi_arguments, 1)
- ipi_x_func(handler, ipi_arguments, 2)
- ipi_x_func(handler, ipi_arguments, 3)
- ipi_x_func(handler, ipi_arguments, 4)
- ipi_x_func(handler, ipi_arguments, 5)
- ipi_x_func(handler, ipi_arguments, 6)
- ipi_x_func(handler, ipi_arguments, 7)
-);
-
-/*
- * Table to hold all the wake-up bool address.
- */
-table(int*, ipi_wakeup_table,
- ipi_x_var(wakeup, 0)
- ipi_x_var(wakeup, 1)
- ipi_x_var(wakeup, 2)
- ipi_x_var(wakeup, 3)
- ipi_x_var(wakeup, 4)
- ipi_x_var(wakeup, 5)
- ipi_x_var(wakeup, 6)
- ipi_x_var(wakeup, 7)
-);
+#include "ipi_table_gen.inc"
#if PASS == 1
#undef PASS
#define PASS 2
#include "ipi_table.c"
+BUILD_ASSERT(ARRAY_SIZE(ipi_handler_table) == IPI_COUNT);
+BUILD_ASSERT(ARRAY_SIZE(ipi_wakeup_table) == IPI_COUNT);
#endif
diff --git a/util/build.mk b/util/build.mk
index 7699ef4572..4fb6b7e1f0 100644
--- a/util/build.mk
+++ b/util/build.mk
@@ -66,6 +66,14 @@ build-util-bin += gen_emmc_transfer_data
$(out)/util/gen_emmc_transfer_data: BUILD_LDFLAGS += -DSECTION_IS_RO
endif # CONFIG_BOOTBLOCK
+ifneq ($(CONFIG_IPI),)
+build-util-bin += gen_ipi_table
+
+$(out)/util/gen_ipi_table: board/$(BOARD)/board.h
+$(out)/ipi_table_gen.inc: $(out)/util/gen_ipi_table
+ $(call quiet,ipi_table,IPITBL )
+endif
+
ifneq ($(CONFIG_TOUCHPAD_HASH_FW),)
build-util-bin += gen_touchpad_hash
diff --git a/util/gen_ipi_table.c b/util/gen_ipi_table.c
new file mode 100644
index 0000000000..07a3a39be0
--- /dev/null
+++ b/util/gen_ipi_table.c
@@ -0,0 +1,58 @@
+/* Copyright 2019 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.
+ *
+ * Generate IPI tables, and inputs come from IPI_COUNT macro in board.h.
+ */
+
+#include <stdio.h>
+
+/* Prevent from including gpio configs . */
+#define __ASSEMBLER__
+
+#include "board.h"
+
+#define FPRINTF(format, args...) fprintf(fout, format, ## args)
+
+int main(int argc, char **argv)
+{
+ FILE *fout;
+ int i;
+
+ if (argc != 2) {
+ fprintf(stderr, "USAGE: %s <output>\n", argv[0]);
+ return 1;
+ }
+
+ fout = fopen(argv[1], "w");
+
+ if (!fout) {
+ fprintf(stderr, "Cannot open output file %s\n", argv[1]);
+ return 1;
+ }
+
+ FPRINTF("/* This is a generated file. Do not modify. */\n");
+ FPRINTF("\n");
+ FPRINTF("/*\n");
+ FPRINTF(" * Table to hold all the IPI handler function pointer.\n");
+ FPRINTF(" */\n");
+ FPRINTF("table(ipi_handler_t, ipi_handler_table,\n");
+
+ for (i = 0; i < IPI_COUNT; ++i)
+ FPRINTF("ipi_x_func(handler, ipi_arguments, %d)\n", i);
+
+ FPRINTF(");\n");
+
+ FPRINTF("/*\n");
+ FPRINTF(" * Table to hold all the wake-up bool address.\n");
+ FPRINTF(" */\n");
+ FPRINTF("table(int *, ipi_wakeup_table,\n");
+
+ for (i = 0; i < IPI_COUNT; ++i)
+ FPRINTF("ipi_x_var(wakeup, %d)\n", i);
+
+ FPRINTF(");\n");
+
+ fclose(fout);
+ return 0;
+}