Skip to content

Commit

Permalink
[imm_rom_ext] Link main imm_rom_ext into rom_ext
Browse files Browse the repository at this point in the history
Remove calling imm_rom_ext_main in rom_ext_main, and use prebuilt
IMM_ROM_EXT instead.

Signed-off-by: Chia-Wei Liu <[email protected]>
  • Loading branch information
lchiawei committed Jan 20, 2025
1 parent 2aeb83d commit 0f5589d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
27 changes: 26 additions & 1 deletion sw/device/silicon_creator/imm_rom_ext/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions sw/device/silicon_creator/imm_rom_ext/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
2 changes: 1 addition & 1 deletion sw/device/silicon_creator/rom_ext/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 0 additions & 13 deletions sw/device/silicon_creator/rom_ext/rom_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand All @@ -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) {}

0 comments on commit 0f5589d

Please sign in to comment.