diff --git a/bl1/bl1.mk b/bl1/bl1.mk index 95fe50ed0..53946ab8d 100644 --- a/bl1/bl1.mk +++ b/bl1/bl1.mk @@ -25,6 +25,10 @@ ifeq (${TRUSTED_BOARD_BOOT},1) BL1_SOURCES += bl1/bl1_fwu.c endif +ifeq (${ENABLE_PMF},1) +BL1_SOURCES += lib/pmf/pmf_main.c +endif + ifneq ($(findstring gcc,$(notdir $(LD))),) BL1_LDFLAGS += -Wl,--sort-section=alignment else ifneq ($(findstring ld,$(notdir $(LD))),) diff --git a/bl1/bl1_main.c b/bl1/bl1_main.c index 3f64e271f..6fe551188 100644 --- a/bl1/bl1_main.c +++ b/bl1/bl1_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2022, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -17,7 +17,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -31,6 +33,11 @@ static void bl1_load_bl2(void); uint64_t bl1_apiakey[2]; #endif +#if ENABLE_RUNTIME_INSTRUMENTATION + PMF_REGISTER_SERVICE(bl_svc, PMF_RT_INSTR_SVC_ID, + BL_TOTAL_IDS, PMF_DUMP_ENABLE) +#endif + /******************************************************************************* * Helper utility to calculate the BL2 memory layout taking into consideration * the BL1 RW data assuming that it is at the top of the memory layout. @@ -81,6 +88,10 @@ void bl1_main(void) { unsigned int image_id; +#if ENABLE_RUNTIME_INSTRUMENTATION + PMF_CAPTURE_TIMESTAMP(bl_svc, BL1_ENTRY, PMF_CACHE_MAINT); +#endif + /* Announce our arrival */ NOTICE(FIRMWARE_WELCOME_STR); NOTICE("BL1: %s\n", version_string); @@ -156,6 +167,10 @@ void bl1_main(void) bl1_prepare_next_image(image_id); +#if ENABLE_RUNTIME_INSTRUMENTATION + PMF_CAPTURE_TIMESTAMP(bl_svc, BL1_EXIT, PMF_CACHE_MAINT); +#endif + console_flush(); } diff --git a/bl2/bl2.mk b/bl2/bl2.mk index 1663c52ef..b70a3fbed 100644 --- a/bl2/bl2.mk +++ b/bl2/bl2.mk @@ -49,3 +49,7 @@ endif BL2_DEFAULT_LINKER_SCRIPT_SOURCE := bl2/bl2_el3.ld.S endif + +ifeq (${ENABLE_PMF},1) +BL2_SOURCES += lib/pmf/pmf_main.c +endif \ No newline at end of file diff --git a/bl2/bl2_main.c b/bl2/bl2_main.c index ce83692e0..923a554fb 100644 --- a/bl2/bl2_main.c +++ b/bl2/bl2_main.c @@ -16,7 +16,9 @@ #include #include #include +#include #include +#include #include #include "bl2_private.h" @@ -27,6 +29,11 @@ #define NEXT_IMAGE "BL32" #endif +#if ENABLE_RUNTIME_INSTRUMENTATION + PMF_REGISTER_SERVICE(bl_svc, PMF_RT_INSTR_SVC_ID, + BL_TOTAL_IDS, PMF_DUMP_ENABLE); +#endif + #if RESET_TO_BL2 /******************************************************************************* * Setup function for BL2 when RESET_TO_BL2=1 @@ -81,6 +88,10 @@ void bl2_main(void) { entry_point_info_t *next_bl_ep_info; +#if ENABLE_RUNTIME_INSTRUMENTATION + PMF_CAPTURE_TIMESTAMP(bl_svc, BL2_ENTRY, PMF_CACHE_MAINT); +#endif + NOTICE("BL2: %s\n", version_string); NOTICE("BL2: %s\n", build_message); @@ -118,8 +129,6 @@ void bl2_main(void) disable_mmu_icache_secure(); #endif /* !__aarch64__ */ - console_flush(); - #if ENABLE_PAUTH /* * Disable pointer authentication before running next boot image @@ -127,6 +136,12 @@ void bl2_main(void) pauth_disable_el1(); #endif /* ENABLE_PAUTH */ +#if ENABLE_RUNTIME_INSTRUMENTATION + PMF_CAPTURE_TIMESTAMP(bl_svc, BL2_EXIT, PMF_CACHE_MAINT); +#endif + + console_flush(); + /* * Run next BL image via an SMC to BL1. Information on how to pass * control to the BL32 (if present) and BL33 software images will @@ -137,6 +152,9 @@ void bl2_main(void) NOTICE("BL2: Booting " NEXT_IMAGE "\n"); print_entry_point_info(next_bl_ep_info); +#if ENABLE_RUNTIME_INSTRUMENTATION + PMF_CAPTURE_TIMESTAMP(bl_svc, BL2_EXIT, PMF_CACHE_MAINT); +#endif console_flush(); #if ENABLE_PAUTH diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c index bf805f54c..cae55f314 100644 --- a/bl31/bl31_main.c +++ b/bl31/bl31_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2022, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -24,8 +25,13 @@ #include #if ENABLE_RUNTIME_INSTRUMENTATION -PMF_REGISTER_SERVICE_SMC(rt_instr_svc, PMF_RT_INSTR_SVC_ID, - RT_INSTR_TOTAL_IDS, PMF_STORE_ENABLE) + PMF_REGISTER_SERVICE_SMC(rt_instr_svc, PMF_RT_INSTR_SVC_ID, + RT_INSTR_TOTAL_IDS, PMF_STORE_ENABLE) +#endif + +#if ENABLE_RUNTIME_INSTRUMENTATION + PMF_REGISTER_SERVICE(bl_svc, PMF_RT_INSTR_SVC_ID, + BL_TOTAL_IDS, PMF_DUMP_ENABLE) #endif /******************************************************************************* @@ -123,6 +129,10 @@ void bl31_main(void) detect_arch_features(); #endif /* FEATURE_DETECTION */ +#if ENABLE_RUNTIME_INSTRUMENTATION + PMF_CAPTURE_TIMESTAMP(bl_svc, BL31_ENTRY, PMF_CACHE_MAINT); +#endif + #ifdef SUPPORT_UNKNOWN_MPID if (unsupported_mpid_flag == 0) { NOTICE("Unsupported MPID detected!\n"); @@ -201,6 +211,11 @@ void bl31_main(void) * from BL31 */ bl31_plat_runtime_setup(); + +#if ENABLE_RUNTIME_INSTRUMENTATION + PMF_CAPTURE_TIMESTAMP(bl_svc, BL31_EXIT, PMF_CACHE_MAINT); + console_flush(); +#endif } /******************************************************************************* diff --git a/include/lib/bootmarker_capture.h b/include/lib/bootmarker_capture.h new file mode 100644 index 000000000..31fe04804 --- /dev/null +++ b/include/lib/bootmarker_capture.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef BOOTMARKER_CAPTURE_H +#define BOOTMARKER_CAPTURE_H + +#define BL1_ENTRY U(0) +#define BL1_EXIT U(1) +#define BL2_ENTRY U(2) +#define BL2_EXIT U(3) +#define BL31_ENTRY U(4) +#define BL31_EXIT U(5) +#define BL_TOTAL_IDS U(6) + +#ifdef __ASSEMBLER__ +PMF_DECLARE_CAPTURE_TIMESTAMP(bl_svc) +#endif /*__ASSEMBLER__*/ + +#endif /*BOOTMARKER_CAPTURE_H*/