diff --git a/sw/device/lib/testing/test_rom/BUILD b/sw/device/lib/testing/test_rom/BUILD index adc81d9dcd4b2..8a57178e95cdd 100644 --- a/sw/device/lib/testing/test_rom/BUILD +++ b/sw/device/lib/testing/test_rom/BUILD @@ -23,6 +23,7 @@ ld_library( "//hw/top:top_ld", "//sw/device:info_sections", "//sw/device/silicon_creator/lib/base:static_critical_sections", + "//sw/device/lib/testing/test_framework:ottf_ld_top_config", ], ) diff --git a/sw/device/lib/testing/test_rom/test_rom.c b/sw/device/lib/testing/test_rom/test_rom.c index 931e53e1631ce..827f458905c0d 100644 --- a/sw/device/lib/testing/test_rom/test_rom.c +++ b/sw/device/lib/testing/test_rom/test_rom.c @@ -68,10 +68,11 @@ static const dt_otp_ctrl_t kOtpCtrlDt = kDtOtpCtrl; /* These symbols are defined in * `opentitan/sw/device/lib/testing/test_rom/test_rom.ld`, and describes the - * location of the flash header. + * location of the flash header and manifest. */ extern char _rom_ext_virtual_start_address[]; extern char _rom_ext_virtual_size[]; +extern char _manifest_address[]; /** * Type alias for the OTTF entry point. @@ -231,22 +232,15 @@ bool rom_test_main(void) { } #endif -#if defined(HAS_FLASH_CTRL) +#ifdef OPENTITAN_IS_EARLGREY CHECK_DIF_OK( dif_flash_ctrl_set_exec_enablement(&flash_ctrl, kDifToggleEnabled)); - - // Always select slot a and enable address translation if manifest says to. - const manifest_t *manifest = (const manifest_t *)dt_flash_ctrl_reg_block( - kFlashCtrlDt, kDtFlashCtrlRegBlockMem); -#elif defined(OPENTITAN_IS_DARJEELING) - // Always select slot a and enable address translation if manifest says to. - const manifest_t *manifest = (const manifest_t *)dt_soc_proxy_reg_block( - kDtSocProxy, kDtSocProxyRegBlockCtn); -#else -#error I don't know how to find the test code on this platform! #endif + const manifest_t *manifest = (const manifest_t *)_manifest_address; + uintptr_t entry_point = manifest_entry_point_get(manifest); + // Enable address translation if manifest says to if (manifest->address_translation == kHardenedBoolTrue) { dif_rv_core_ibex_addr_translation_mapping_t addr_map = { .matching_addr = (uintptr_t)_rom_ext_virtual_start_address, diff --git a/sw/device/lib/testing/test_rom/test_rom.ld b/sw/device/lib/testing/test_rom/test_rom.ld index 44efa3d28ce91..3406f3a880a60 100644 --- a/sw/device/lib/testing/test_rom/test_rom.ld +++ b/sw/device/lib/testing/test_rom/test_rom.ld @@ -17,15 +17,15 @@ __DYNAMIC = 0; INCLUDE OPENTITAN_TOP_MEMORY_LD +#include "ottf_ld_top_config.ld" + /** * Region aliases. */ #ifdef OPENTITAN_IS_DARJEELING REGION_ALIAS("test_rom", rom0) -REGION_ALIAS("test_code_region", ctn) #else REGION_ALIAS("test_rom", rom) -REGION_ALIAS("test_code_region", eflash) #endif /** @@ -34,12 +34,17 @@ REGION_ALIAS("test_code_region", eflash) */ _boot_address = ORIGIN(test_rom); +/** + * Location of the manifest. + */ +_manifest_address = ORIGIN(ottf_storage); + /** * Symbols to be used in the setup of the address translation for ROM_EXT. */ _rom_ext_virtual_start_address = ORIGIN(rom_ext_virtual); _rom_ext_virtual_size = LENGTH(rom_ext_virtual); -ASSERT((_rom_ext_virtual_size <= (LENGTH(test_code_region) / 2)), +ASSERT((_rom_ext_virtual_size <= (LENGTH(ottf_storage) / 2)), "Error: rom ext flash is bigger than slot."); _rom_digest_size = 32;