mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00
lib: utils/fdt: Add fdt_get_address_rw() helper
Help tracking the lifecycle of the FDT blob by indicating which parts of the firmware modify it, and thus invalidate any previously-obtained offsets or pointers to data inside the blob. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:

committed by
Anup Patel

parent
c36801841e
commit
8cb7f89d7c
@@ -114,7 +114,12 @@ int fdt_parse_plicsw_node(const void *fdt, int nodeoffset, unsigned long *plicsw
|
||||
int fdt_parse_compat_addr(const void *fdt, uint64_t *addr,
|
||||
const char *compatible);
|
||||
|
||||
static inline void *fdt_get_address(void)
|
||||
static inline const void *fdt_get_address(void)
|
||||
{
|
||||
return (const void *)root.next_arg1;
|
||||
}
|
||||
|
||||
static inline void *fdt_get_address_rw(void)
|
||||
{
|
||||
return (void *)root.next_arg1;
|
||||
}
|
||||
|
@@ -87,7 +87,7 @@ static int ariane_final_init(bool cold_boot)
|
||||
if (!cold_boot)
|
||||
return 0;
|
||||
|
||||
fdt = fdt_get_address();
|
||||
fdt = fdt_get_address_rw();
|
||||
fdt_fixups(fdt);
|
||||
|
||||
return 0;
|
||||
|
@@ -70,7 +70,7 @@ static struct aclint_mtimer_data mtimer = {
|
||||
*/
|
||||
static int openpiton_early_init(bool cold_boot)
|
||||
{
|
||||
void *fdt;
|
||||
const void *fdt;
|
||||
struct platform_uart_data uart_data = { 0 };
|
||||
struct plic_data plic_data;
|
||||
unsigned long aclint_freq;
|
||||
@@ -118,7 +118,7 @@ static int openpiton_final_init(bool cold_boot)
|
||||
if (!cold_boot)
|
||||
return 0;
|
||||
|
||||
fdt = fdt_get_address();
|
||||
fdt = fdt_get_address_rw();
|
||||
fdt_fixups(fdt);
|
||||
|
||||
return 0;
|
||||
|
@@ -243,7 +243,7 @@ static int generic_early_init(bool cold_boot)
|
||||
|
||||
static int generic_final_init(bool cold_boot)
|
||||
{
|
||||
void *fdt = fdt_get_address();
|
||||
void *fdt = fdt_get_address_rw();
|
||||
int rc;
|
||||
|
||||
if (generic_plat && generic_plat->final_init) {
|
||||
@@ -314,7 +314,7 @@ static int generic_extensions_init(struct sbi_hart_features *hfeatures)
|
||||
|
||||
static int generic_domains_init(void)
|
||||
{
|
||||
void *fdt = fdt_get_address();
|
||||
const void *fdt = fdt_get_address();
|
||||
int offset, ret;
|
||||
|
||||
ret = fdt_domains_populate(fdt);
|
||||
|
@@ -124,7 +124,7 @@ static int k210_final_init(bool cold_boot)
|
||||
if (!cold_boot)
|
||||
return 0;
|
||||
|
||||
fdt = fdt_get_address();
|
||||
fdt = fdt_get_address_rw();
|
||||
|
||||
fdt_cpu_fixup(fdt);
|
||||
fdt_fixups(fdt);
|
||||
|
@@ -181,7 +181,7 @@ static int ux600_final_init(bool cold_boot)
|
||||
if (!cold_boot)
|
||||
return 0;
|
||||
|
||||
fdt = fdt_get_address();
|
||||
fdt = fdt_get_address_rw();
|
||||
ux600_modify_dt(fdt);
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user