mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-16 01:24:27 +00:00
refactor(plat/st): avoid fixed DT address
Device Tree address is now a parameter for dt_open_and_check() function. This will allow better flexibility when introducing PIE and FIP. The fdt pointer is now only assigned if the given address holds a valid device tree file. This allows removing the fdt_checked variable, as we now check fdt is not null. Change-Id: I04cbb2fc05c9c711ae1c77d56368dbeb6dd4b01a Signed-off-by: Yann Gautier <yann.gautier@st.com>
This commit is contained in:
parent
1a2c0ff927
commit
c20b060661
4 changed files with 16 additions and 14 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
* Copyright (c) 2020-2021, STMicroelectronics - All Rights Reserved
|
||||||
* Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
|
* Copyright (c) 2017-2021, ARM Limited and Contributors. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
#define STM32MP_DT_H
|
#define STM32MP_DT_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#define DT_DISABLED U(0)
|
#define DT_DISABLED U(0)
|
||||||
#define DT_NON_SECURE U(1)
|
#define DT_NON_SECURE U(1)
|
||||||
|
@ -25,7 +26,7 @@ struct dt_node_info {
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Function and variable prototypes
|
* Function and variable prototypes
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
int dt_open_and_check(void);
|
int dt_open_and_check(uintptr_t dt_addr);
|
||||||
int fdt_get_address(void **fdt_addr);
|
int fdt_get_address(void **fdt_addr);
|
||||||
bool fdt_check_node(int node);
|
bool fdt_check_node(int node);
|
||||||
uint8_t fdt_get_status(int node);
|
uint8_t fdt_get_status(int node);
|
||||||
|
|
|
@ -19,20 +19,19 @@
|
||||||
|
|
||||||
#include <stm32mp_dt.h>
|
#include <stm32mp_dt.h>
|
||||||
|
|
||||||
static int fdt_checked;
|
static void *fdt;
|
||||||
|
|
||||||
static void *fdt = (void *)(uintptr_t)STM32MP_DTB_BASE;
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* This function checks device tree file with its header.
|
* This function checks device tree file with its header.
|
||||||
* Returns 0 on success and a negative FDT error code on failure.
|
* Returns 0 on success and a negative FDT error code on failure.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
int dt_open_and_check(void)
|
int dt_open_and_check(uintptr_t dt_addr)
|
||||||
{
|
{
|
||||||
int ret = fdt_check_header(fdt);
|
int ret;
|
||||||
|
|
||||||
|
ret = fdt_check_header((void *)dt_addr);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
fdt_checked = 1;
|
fdt = (void *)dt_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -45,11 +44,13 @@ int dt_open_and_check(void)
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
int fdt_get_address(void **fdt_addr)
|
int fdt_get_address(void **fdt_addr)
|
||||||
{
|
{
|
||||||
if (fdt_checked == 1) {
|
if (fdt == NULL) {
|
||||||
*fdt_addr = fdt;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fdt_checked;
|
*fdt_addr = fdt;
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
|
@ -196,7 +196,7 @@ void bl2_el3_plat_arch_setup(void)
|
||||||
|
|
||||||
configure_mmu();
|
configure_mmu();
|
||||||
|
|
||||||
if (dt_open_and_check() < 0) {
|
if (dt_open_and_check(STM32MP_DTB_BASE) < 0) {
|
||||||
panic();
|
panic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ void sp_min_early_platform_setup2(u_register_t arg0, u_register_t arg1,
|
||||||
bl_params = bl_params->next_params_info;
|
bl_params = bl_params->next_params_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dt_open_and_check() < 0) {
|
if (dt_open_and_check(STM32MP_DTB_BASE) < 0) {
|
||||||
panic();
|
panic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue