Skip to content

Commit 00e1f69

Browse files
jaccoo01adeaarm
authored andcommitted
RSE: Add system routing table to BL1_1
In the case that the routing tables are not in the OTP, they are compiled into BL1_1 instead. In order to facilitate this, we add a new script which parses the Routing_tables python class and uses it to generate a C source file. This can then be added to the BL1_1 source files. Change-Id: Ie6653da8ef00b8553383e500bba0e4f87bc3425a Signed-off-by: Jackson Cooper-Driver <[email protected]>
1 parent 3cadb54 commit 00e1f69

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

platform/ext/target/arm/rse/common/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,28 @@ if (RSE_AMOUNT GREATER 1)
915915
--topology_graph_file=${MULTI_RSE_TOPOLOGY_FILE}
916916
--routing_tables_output_file=${CMAKE_CURRENT_BINARY_DIR}/config/routing_tables.pickle
917917
)
918+
919+
if (NOT RSE_OTP_HAS_ROUTING_TABLES)
920+
add_custom_target(routing_tables_definition_source_file
921+
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/rse_system_routing_tables_definition.c
922+
)
923+
924+
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rse_system_routing_tables_definition.c
925+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_routing_tables_source_file.py
926+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/config/routing_tables.pickle
927+
COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_SOURCE_DIR}/tools/modules
928+
${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_routing_tables_source_file.py
929+
--routing_tables=${CMAKE_CURRENT_BINARY_DIR}/config/routing_tables.pickle
930+
--c_source_output_file ${CMAKE_CURRENT_BINARY_DIR}/rse_system_routing_tables_definition.c
931+
)
932+
933+
add_dependencies(platform_bl1_1 routing_tables_definition_source_file)
934+
935+
target_sources(platform_bl1_1
936+
PRIVATE
937+
${CMAKE_CURRENT_BINARY_DIR}/rse_system_routing_tables_definition.c
938+
)
939+
endif()
918940
endif()
919941
920942
#========================= Files for building NS side platform ================#
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env python3
2+
#-------------------------------------------------------------------------------
3+
# SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
4+
#
5+
# SPDX-License-Identifier: BSD-3-Clause
6+
#
7+
#-------------------------------------------------------------------------------
8+
9+
import argparse
10+
import sys
11+
import os
12+
13+
import arg_utils
14+
15+
import logging
16+
logger = logging.getLogger("TF-M.{}".format(__name__))
17+
18+
sys.path.append(os.path.join(sys.path[0], 'modules'))
19+
20+
import routing_tables as rt
21+
from routing_tables import Routing_tables
22+
23+
C_SOURCE = """/*
24+
* SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
25+
*
26+
* SPDX-License-Identifier: BSD-3-Clause
27+
*
28+
*/
29+
30+
/* This file is autogenerated - DO NOT EDIT! */
31+
32+
#include "rse_routing_tables.h"
33+
34+
const struct rse_whole_system_routing_tables_t rse_system_routing_tables =
35+
{};
36+
"""
37+
38+
def add_arguments(parser : argparse.ArgumentParser,
39+
prefix : str = "",
40+
required : bool = True,
41+
) -> None:
42+
rt.add_arguments(parser, prefix, required=True)
43+
44+
def parse_args(args : argparse.Namespace,
45+
prefix : str = "",
46+
) -> dict:
47+
out = {}
48+
49+
out |= rt.parse_args(args, prefix=prefix)
50+
51+
return out
52+
53+
script_description = """
54+
This script takes in the routing tables configuration and uses it to
55+
generate a C source file with the system wide routing tables definition
56+
"""
57+
58+
if __name__ == "__main__":
59+
parser = argparse.ArgumentParser(allow_abbrev=False,
60+
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
61+
description=script_description)
62+
63+
add_arguments(parser)
64+
65+
parser.add_argument("--c_source_output_file", help="File to output the generated source file to", required=True)
66+
parser.add_argument("--log_level", help="log level", required=False, default="ERROR", choices=logging._levelToName.values())
67+
68+
args = parser.parse_args()
69+
logging.getLogger("TF-M").setLevel(args.log_level)
70+
logger.addHandler(logging.StreamHandler())
71+
72+
kwargs = parse_args(args)
73+
74+
with open(args.c_source_output_file, "w") as f:
75+
f.write(C_SOURCE.format(kwargs['routing_tables'].get_routing_tables_source()))

0 commit comments

Comments
 (0)