Browse Source

Merge changes from topic "early_console" into integration

* changes:
  feat(stm32mp2): use early traces
  feat(st-bsec): use early traces
  refactor(st): replace STM32MP_EARLY_CONSOLE with EARLY_CONSOLE
  feat(console): introduce EARLY_CONSOLE
  feat(bl32): create an sp_min_setup function
pull/2000/merge
Manish Pandey 6 months ago
committed by TrustedFirmware Code Review
parent
commit
a97e1f9747
  1. 2
      Makefile
  2. 3
      bl1/bl1_main.c
  3. 6
      bl2/bl2_main.c
  4. 3
      bl31/bl31_main.c
  5. 5
      bl32/sp_min/aarch32/entrypoint.S
  6. 14
      bl32/sp_min/sp_min_main.c
  7. 6
      bl32/sp_min/sp_min_private.h
  8. 5
      bl32/tsp/tsp_common.c
  9. 7
      docs/getting_started/build-options.rst
  10. 2
      docs/plat/st/stm32mpus.rst
  11. 13
      docs/porting-guide.rst
  12. 16
      drivers/st/bsec/bsec2.c
  13. 2
      drivers/st/bsec/bsec3.c
  14. 8
      include/common/debug.h
  15. 8
      include/plat/common/platform.h
  16. 5
      make_helpers/defaults.mk
  17. 3
      plat/st/common/common.mk
  18. 8
      plat/st/common/include/stm32mp_common.h
  19. 6
      plat/st/common/stm32mp_common.c
  20. 2
      plat/st/stm32mp1/bl2_plat_setup.c
  21. 2
      plat/st/stm32mp1/sp_min/sp_min_setup.c
  22. 3
      plat/st/stm32mp2/bl2_plat_setup.c

2
Makefile

@ -1206,6 +1206,7 @@ $(eval $(call assert_booleans,\
ENABLE_CONSOLE_GETC \
INIT_UNUSED_NS_EL2 \
PLATFORM_REPORT_CTX_MEM_USE \
EARLY_CONSOLE \
)))
# Numeric_Flags
@ -1403,6 +1404,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)

3
bl1/bl1_main.c

@ -44,6 +44,9 @@ uint64_t bl1_apiakey[2];
******************************************************************************/
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();

6
bl2/bl2_main.c

@ -42,6 +42,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);
@ -64,6 +67,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);

3
bl31/bl31_main.c

@ -95,6 +95,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);

5
bl32/sp_min/aarch32/entrypoint.S

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2023, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -118,8 +118,7 @@ func sp_min_entrypoint
mov r1, r10
mov r2, r11
mov r3, r12
bl sp_min_early_platform_setup2
bl sp_min_plat_arch_setup
bl sp_min_setup
/* Jump to the main function */
bl sp_min_main

14
bl32/sp_min/sp_min_main.c

@ -170,6 +170,20 @@ uintptr_t get_arm_std_svc_args(unsigned int svc_mask)
return (uintptr_t)&psci_args;
}
/******************************************************************************
* The SP_MIN setup function. Calls platforms init functions
*****************************************************************************/
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();
}
/******************************************************************************
* The SP_MIN main function. Do the platform and PSCI Library setup. Also
* initialize the runtime service framework.

6
bl32/sp_min/sp_min_private.h

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -7,6 +7,10 @@
#ifndef SP_MIN_PRIVATE_H
#define SP_MIN_PRIVATE_H
#include <stdint.h>
void sp_min_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
u_register_t arg3);
void sp_min_main(void);
void sp_min_warm_boot(void);
void sp_min_fiq(void);

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

2
docs/plat/st/stm32mpus.rst

@ -54,8 +54,6 @@ Other configuration flags:
| Default: stm32mp157c-ev1.dtb
- | ``DWL_BUFFER_BASE``: the 'serial boot' load address of FIP,
| default location (end of the first 128MB) is used when absent
- | ``STM32MP_EARLY_CONSOLE``: to enable early traces before clock driver is setup.
| Default: 0 (disabled)
- | ``STM32MP_RECONFIGURE_CONSOLE``: to re-configure crash console (especially after BL2).
| Default: 0 (disabled)
- | ``STM32MP_UART_BAUDRATE``: to select UART baud rate.

13
docs/porting-guide.rst

@ -3286,6 +3286,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
@ -3572,7 +3583,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

16
drivers/st/bsec/bsec2.c

@ -166,11 +166,13 @@ static void bsec_late_init(void)
struct dt_node_info bsec_info;
if (fdt_get_address(&fdt) == 0) {
EARLY_ERROR("%s: DT not found\n", __func__);
panic();
}
node = bsec_get_dt_node(&bsec_info);
if (node < 0) {
EARLY_ERROR("%s: BSEC node not found\n", __func__);
panic();
}
@ -226,13 +228,21 @@ static uint32_t bsec_check_error(uint32_t otp, bool check_disturbed)
*/
uint32_t bsec_probe(void)
{
uint32_t version;
uint32_t id;
if (is_otp_invalid_mode()) {
EARLY_ERROR("%s: otp_invalid_mod\n", __func__);
return BSEC_ERROR;
}
if (((bsec_get_version() != BSEC_IP_VERSION_1_1) &&
(bsec_get_version() != BSEC_IP_VERSION_2_0)) ||
(bsec_get_id() != BSEC_IP_ID_2)) {
version = bsec_get_version();
id = bsec_get_id();
if (((version != BSEC_IP_VERSION_1_1) &&
(version != BSEC_IP_VERSION_2_0)) ||
(id != BSEC_IP_ID_2)) {
EARLY_ERROR("%s: version = 0x%x, id = 0x%x\n", __func__, version, id);
panic();
}

2
drivers/st/bsec/bsec3.c

@ -188,7 +188,7 @@ uint32_t bsec_probe(void)
uint32_t id = bsec_get_id();
if ((version != BSEC_IP_VERSION_1_0) || (id != BSEC_IP_ID_3)) {
ERROR("%s: version = 0x%x, id = 0x%x\n", __func__, version, id);
EARLY_ERROR("%s: version = 0x%x, id = 0x%x\n", __func__, version, id);
panic();
}

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

3
plat/st/common/common.mk

@ -6,7 +6,6 @@
RESET_TO_BL2 := 1
STM32MP_EARLY_CONSOLE ?= 0
STM32MP_RECONFIGURE_CONSOLE ?= 0
STM32MP_UART_BAUDRATE ?= 115200
@ -82,7 +81,6 @@ endif
$(eval $(call assert_booleans,\
$(sort \
PLAT_XLAT_TABLES_DYNAMIC \
STM32MP_EARLY_CONSOLE \
STM32MP_EMMC \
STM32MP_EMMC_BOOT \
STM32MP_RAW_NAND \
@ -104,7 +102,6 @@ $(eval $(call add_defines,\
$(sort \
PLAT_XLAT_TABLES_DYNAMIC \
STM32_TF_VERSION \
STM32MP_EARLY_CONSOLE \
STM32MP_EMMC \
STM32MP_EMMC_BOOT \
STM32MP_RAW_NAND \

8
plat/st/common/include/stm32mp_common.h

@ -77,14 +77,6 @@ uintptr_t get_uart_address(uint32_t instance_nb);
/* Setup the UART console */
int stm32mp_uart_console_setup(void);
#if STM32MP_EARLY_CONSOLE
void stm32mp_setup_early_console(void);
#else
static inline void stm32mp_setup_early_console(void)
{
}
#endif
/*
* Platform util functions for the GPIO driver
* @bank: Target GPIO bank ID as per DT bindings

6
plat/st/common/stm32mp_common.c

@ -269,8 +269,8 @@ int stm32mp_uart_console_setup(void)
return 0;
}
#if STM32MP_EARLY_CONSOLE
void stm32mp_setup_early_console(void)
#if EARLY_CONSOLE
void plat_setup_early_console(void)
{
#if defined(IMAGE_BL2) || STM32MP_RECONFIGURE_CONSOLE
plat_crash_console_init();
@ -278,7 +278,7 @@ void stm32mp_setup_early_console(void)
set_console(STM32MP_DEBUG_USART_BASE, STM32MP_DEBUG_USART_CLK_FRQ);
NOTICE("Early console setup\n");
}
#endif /* STM32MP_EARLY_CONSOLE */
#endif /* EARLY_CONSOLE */
/*****************************************************************************
* plat_is_smccc_feature_available() - This function checks whether SMCCC

2
plat/st/stm32mp1/bl2_plat_setup.c

@ -142,8 +142,6 @@ void bl2_el3_early_platform_setup(u_register_t arg0,
u_register_t arg2 __unused,
u_register_t arg3 __unused)
{
stm32mp_setup_early_console();
stm32mp_save_boot_ctx_address(arg0);
}

2
plat/st/stm32mp1/sp_min/sp_min_setup.c

@ -116,8 +116,6 @@ void sp_min_early_platform_setup2(u_register_t arg0, u_register_t arg1,
bl_params_t *params_from_bl2 = (bl_params_t *)arg0;
uintptr_t dt_addr = arg1;
stm32mp_setup_early_console();
/* Imprecise aborts can be masked in NonSecure */
write_scr(read_scr() | SCR_AW_BIT);

3
plat/st/stm32mp2/bl2_plat_setup.c

@ -18,7 +18,6 @@ void bl2_el3_early_platform_setup(u_register_t arg0 __unused,
u_register_t arg2 __unused,
u_register_t arg3 __unused)
{
stm32mp_setup_early_console();
}
void bl2_platform_setup(void)
@ -28,7 +27,7 @@ void bl2_platform_setup(void)
void bl2_el3_plat_arch_setup(void)
{
if (stm32_otp_probe() != 0U) {
ERROR("OTP probe failed\n");
EARLY_ERROR("OTP probe failed\n");
panic();
}
}

Loading…
Cancel
Save