From 0f5589d16fbc3b938d5ae2e1b5a950a33de7f647 Mon Sep 17 00:00:00 2001 From: Chia-Wei Liu Date: Tue, 3 Dec 2024 03:51:44 +0800 Subject: [PATCH] [imm_rom_ext] Link main imm_rom_ext into rom_ext Remove calling imm_rom_ext_main in rom_ext_main, and use prebuilt IMM_ROM_EXT instead. Signed-off-by: Chia-Wei Liu --- sw/device/silicon_creator/imm_rom_ext/BUILD | 27 ++++++++++++++++++- .../silicon_creator/imm_rom_ext/defs.bzl | 3 +-- sw/device/silicon_creator/rom_ext/BUILD | 2 +- sw/device/silicon_creator/rom_ext/rom_ext.c | 13 --------- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/sw/device/silicon_creator/imm_rom_ext/BUILD b/sw/device/silicon_creator/imm_rom_ext/BUILD index 51587a60f0d95..d9fc0223991aa 100644 --- a/sw/device/silicon_creator/imm_rom_ext/BUILD +++ b/sw/device/silicon_creator/imm_rom_ext/BUILD @@ -11,8 +11,12 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "main_lib", - srcs = ["imm_rom_ext.c"], + srcs = [ + "hello_world_start.S", + "imm_rom_ext.c", + ], hdrs = ["imm_rom_ext.h"], + target_compatible_with = [OPENTITAN_CPU], deps = [ ":imm_rom_ext_epmp", "//hw/top:flash_ctrl_c_regs", @@ -51,6 +55,27 @@ cc_library( ], ) +opentitan_binary( + name = "main_binaries", + # TODO(#24368): Support multiple executing environments. Currently all + # environments derive the same binary so only one environment is kept here, + # but we need to support multiple executing environments and make sure + # ROM_EXT targets choose the matched environment when linking IMM_ROM_EXT. + exec_env = [ + "//hw/top_earlgrey:fpga_cw340", + ], + linker_script = ":ld_hello_world", + deps = [ + ":main_lib", + "//sw/device/lib/crt", + ], +) + +imm_rom_ext_section( + name = "main_section", + srcs = [":main_binaries"], +) + ld_library( name = "ld_hello_world", script = "hello_world.ld", diff --git a/sw/device/silicon_creator/imm_rom_ext/defs.bzl b/sw/device/silicon_creator/imm_rom_ext/defs.bzl index 04ada7e14b651..ad4f98675cac8 100644 --- a/sw/device/silicon_creator/imm_rom_ext/defs.bzl +++ b/sw/device/silicon_creator/imm_rom_ext/defs.bzl @@ -4,6 +4,5 @@ # The target list should contian prebuilt artifacts and run-time build targets. IMM_ROM_EXT_TARGETS = { - "nop": "//sw/device/silicon_creator/imm_rom_ext/prebuilts:nop_imm_rom_ext", - "hello_world": "//sw/device/silicon_creator/imm_rom_ext:hello_world_section", + "main": "//sw/device/silicon_creator/imm_rom_ext:main_section", } diff --git a/sw/device/silicon_creator/rom_ext/BUILD b/sw/device/silicon_creator/rom_ext/BUILD index 97b9bc066606f..c994ede35fbe4 100644 --- a/sw/device/silicon_creator/rom_ext/BUILD +++ b/sw/device/silicon_creator/rom_ext/BUILD @@ -233,7 +233,7 @@ cc_library( "//sw/device/lib/base:memory", "//sw/device/lib/base:stdasm", "//sw/device/lib/runtime:hart", - "//sw/device/silicon_creator/imm_rom_ext:main_lib", + "//sw/device/silicon_creator/imm_rom_ext:main_section", "//sw/device/silicon_creator/lib:boot_data", "//sw/device/silicon_creator/lib:boot_log", "//sw/device/silicon_creator/lib:dbg_print", diff --git a/sw/device/silicon_creator/rom_ext/rom_ext.c b/sw/device/silicon_creator/rom_ext/rom_ext.c index c9df0d54c3cad..1cd63a1f2ee09 100644 --- a/sw/device/silicon_creator/rom_ext/rom_ext.c +++ b/sw/device/silicon_creator/rom_ext/rom_ext.c @@ -10,7 +10,6 @@ #include "sw/device/lib/base/memory.h" #include "sw/device/lib/base/stdasm.h" #include "sw/device/lib/runtime/hart.h" -#include "sw/device/silicon_creator/imm_rom_ext/imm_rom_ext.h" #include "sw/device/silicon_creator/lib/base/boot_measurements.h" #include "sw/device/silicon_creator/lib/base/chip.h" #include "sw/device/silicon_creator/lib/base/sec_mmio.h" @@ -602,11 +601,6 @@ static rom_error_t rom_ext_start(boot_data_t *boot_data, boot_log_t *boot_log) { } void rom_ext_main(void) { - // TODO(opentitan#24368): Call immutable main in .rom_ext_immutable. - // The immutable rom_ext startup code is not ready yet, so we call it here - // to avoid breaking tests. - imm_rom_ext_main(); - rom_ext_check_rom_expectations(); boot_data_t boot_data; boot_log_t *boot_log = &retention_sram_get()->creator.boot_log; @@ -632,10 +626,3 @@ void rom_ext_exception_handler(void); OT_USED OT_ALIAS("rom_ext_interrupt_handler") void rom_ext_nmi_handler(void); - -// A no-op immutable rom_ext fallback to avoid breaking tests before the -// proper bazel target is ready. -// TODO(opentitan#24368): Remove this nop fallback. -OT_USED -OT_SECTION(".rom_ext_immutable.fallback") -void imm_rom_ext_placeholder(void) {}