Browse Source

feat(console): introduce EARLY_CONSOLE

This is a generic porting of what was done on ST platforms with flag
STM32MP_EARLY_CONSOLE. It creates the flag and the prototype for
plat_setup_early_console(). This function depends on platform
implementation. This function call is added at the beginning of each BL
image early setup function.
The patch also introduce an extra log macro: EARLY_ERROR. This can
replace ERROR macro in code that will only be executed before the
default console is enabled, and will do nothing when the EARLY_CONSOLE
is not enabled. This can then save some space in memory.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I77bf0a0c4289b4c7df94e4bfb783a938e05bf023
pull/2000/merge
Yann Gautier 10 months ago
parent
commit
ae770fedf4
  1. 2
      Makefile
  2. 5
      bl1/bl1_main.c
  3. 8
      bl2/bl2_main.c
  4. 5
      bl31/bl31_main.c
  5. 3
      bl32/sp_min/sp_min_main.c
  6. 5
      bl32/tsp/tsp_common.c
  7. 7
      docs/getting_started/build-options.rst
  8. 13
      docs/porting-guide.rst
  9. 8
      include/common/debug.h
  10. 8
      include/plat/common/platform.h
  11. 5
      make_helpers/defaults.mk

2
Makefile

@ -1197,6 +1197,7 @@ $(eval $(call assert_booleans,\
ENABLE_CONSOLE_GETC \
INIT_UNUSED_NS_EL2 \
PLATFORM_REPORT_CTX_MEM_USE \
EARLY_CONSOLE \
)))
# Numeric_Flags
@ -1394,6 +1395,7 @@ $(eval $(call add_defines,\
ENABLE_CONSOLE_GETC \
INIT_UNUSED_NS_EL2 \
PLATFORM_REPORT_CTX_MEM_USE \
EARLY_CONSOLE \
)))
ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)

5
bl1/bl1_main.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -64,6 +64,9 @@ void bl1_calc_bl2_mem_layout(const meminfo_t *bl1_mem_layout,
******************************************************************************/
void bl1_setup(void)
{
/* Enable early console if EARLY_CONSOLE flag is enabled */
plat_setup_early_console();
/* Perform early platform-specific setup */
bl1_early_platform_setup();

8
bl2/bl2_main.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -41,6 +41,9 @@
void bl2_el3_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
u_register_t arg3)
{
/* Enable early console if EARLY_CONSOLE flag is enabled */
plat_setup_early_console();
/* Perform early platform-specific setup */
bl2_el3_early_platform_setup(arg0, arg1, arg2, arg3);
@ -63,6 +66,9 @@ void bl2_el3_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
void bl2_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
u_register_t arg3)
{
/* Enable early console if EARLY_CONSOLE flag is enabled */
plat_setup_early_console();
/* Perform early platform-specific setup */
bl2_early_platform_setup2(arg0, arg1, arg2, arg3);

5
bl31/bl31_main.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -94,6 +94,9 @@ static void __init bl31_lib_init(void)
void bl31_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
u_register_t arg3)
{
/* Enable early console if EARLY_CONSOLE flag is enabled */
plat_setup_early_console();
/* Perform early platform-specific setup */
bl31_early_platform_setup2(arg0, arg1, arg2, arg3);

3
bl32/sp_min/sp_min_main.c

@ -175,6 +175,9 @@ uintptr_t get_arm_std_svc_args(unsigned int svc_mask)
void sp_min_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
u_register_t arg3)
{
/* Enable early console if EARLY_CONSOLE flag is enabled */
plat_setup_early_console();
/* Perform early platform-specific setup */
sp_min_early_platform_setup2(arg0, arg1, arg2, arg3);
sp_min_plat_arch_setup();

5
bl32/tsp/tsp_common.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2022-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -66,6 +66,9 @@ smc_args_t *set_smc_args(uint64_t arg0,
******************************************************************************/
void tsp_setup(void)
{
/* Enable early console if EARLY_CONSOLE flag is enabled */
plat_setup_early_console();
/* Perform early platform-specific setup. */
tsp_early_platform_setup();

7
docs/getting_started/build-options.rst

@ -230,6 +230,13 @@ Common build options
contributions are still expected to build with ``W=0`` and ``E=1`` (the
default).
- ``EARLY_CONSOLE``: This option is used to enable early traces before default
console is properly setup. It introduces EARLY_* traces macros, that will
use the non-EARLY traces macros if the flag is enabled, or do nothing
otherwise. To use this feature, platforms will have to create the function
plat_setup_early_console().
Default is 0 (disabled)
- ``EL3_PAYLOAD_BASE``: This option enables booting an EL3 payload instead of
the normal boot flow. It must specify the entry point address of the EL3
payload. Please refer to the "Booting an EL3 payload" section for more

13
docs/porting-guide.rst

@ -3274,6 +3274,17 @@ This API is used by the crash reporting mechanism to force write of all buffered
data on the designated crash console. It should only use general purpose
registers x0 through x5 to do its work.
Function : plat_setup_early_console [optional]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
Argument : void
Return : void
This API is used to setup the early console, it is required only if the flag
``EARLY_CONSOLE`` is enabled.
.. _External Abort handling and RAS Support:
External Abort handling and RAS Support
@ -3560,7 +3571,7 @@ to :ref:`Measured Boot Design` for more details.
--------------
*Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.*
*Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.*
.. _PSCI: https://developer.arm.com/documentation/den0022/latest/
.. _Arm Generic Interrupt Controller version 2.0 (GICv2): http://infocenter.arm.com/help/topic/com.arm.doc.ihi0048b/index.html

8
include/common/debug.h

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -91,6 +91,12 @@
# define VERBOSE(...) no_tf_log(LOG_MARKER_VERBOSE __VA_ARGS__)
#endif
#if EARLY_CONSOLE
#define EARLY_ERROR(...) ERROR(__VA_ARGS__)
#else /* !EARLY_CONSOLE */
#define EARLY_ERROR(...) no_tf_log(LOG_MARKER_ERROR __VA_ARGS__)
#endif /* EARLY_CONSOLE */
const char *get_el_str(unsigned int el);
#if ENABLE_BACKTRACE

8
include/plat/common/platform.h

@ -184,6 +184,14 @@ static inline int plat_mboot_measure_key(const void *pk_oid __unused,
}
#endif /* MEASURED_BOOT */
#if EARLY_CONSOLE
void plat_setup_early_console(void);
#else
static inline void plat_setup_early_console(void)
{
}
#endif /* EARLY_CONSOLE */
/*******************************************************************************
* Mandatory BL1 functions
******************************************************************************/

5
make_helpers/defaults.mk

@ -1,5 +1,5 @@
#
# Copyright (c) 2016-2023, Arm Limited. All rights reserved.
# Copyright (c) 2016-2024, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@ -392,3 +392,6 @@ CTX_INCLUDE_MPAM_REGS := 0
# Enable context memory usage reporting during BL31 setup.
PLATFORM_REPORT_CTX_MEM_USE := 0
# Enable early console
EARLY_CONSOLE := 0

Loading…
Cancel
Save