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>
This commit is contained in:
Yilun Lin 2019-04-15 18:16:54 +08:00 committed by chrome-bot
parent 631000bdf4
commit 3c49473cd6
5 changed files with 78 additions and 25 deletions

View File

@ -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),)

View File

@ -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

View File

@ -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

View File

@ -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

58
util/gen_ipi_table.c Normal file
View File

@ -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;
}