Move boot params update to the boot_flow module.
Not all boot flows want to be doing updates so leave that decision to
the module responsible for coordinating the boot details.
Change-Id: Ia769f99e2221f12c79a364c3ad323c31d39c98f3
diff --git a/src/boot_flow/android.c b/src/boot_flow/android.c
index 4917ef4..73797e9 100644
--- a/src/boot_flow/android.c
+++ b/src/boot_flow/android.c
@@ -21,7 +21,7 @@
* FDT was compiled into Hafnium. Return physical address of the `.plat.fdt`
* section of Hafnium image.
*/
-paddr_t plat_get_fdt_addr(void)
+paddr_t plat_boot_flow_get_fdt_addr(void)
{
return layout_fdt_begin();
}
@@ -29,7 +29,7 @@
/**
* Android boot flow does not use kernel arguments. Pass zero.
*/
-uintreg_t plat_get_kernel_arg(void)
+uintreg_t plat_boot_flow_get_kernel_arg(void)
{
return 0;
}
@@ -37,8 +37,8 @@
/**
* Initrd was compiled into Hafnium. Return range of the '.plat.initrd' section.
*/
-bool plat_get_initrd_range(const struct fdt_node *fdt_root, paddr_t *begin,
- paddr_t *end)
+bool plat_boot_flow_get_initrd_range(const struct fdt_node *fdt_root,
+ paddr_t *begin, paddr_t *end)
{
(void)fdt_root;
@@ -46,3 +46,16 @@
*end = layout_initrd_end();
return true;
}
+
+/**
+ * Android boot flow does not change based on the updates.
+ */
+bool plat_boot_flow_update(struct mm_stage1_locked stage1_locked,
+ struct boot_params_update *p, struct mpool *ppool)
+{
+ (void)stage1_locked;
+ (void)p;
+ (void)ppool;
+
+ return true;
+}
diff --git a/src/boot_flow/common.c b/src/boot_flow/common.c
index d211df6..d489faa 100644
--- a/src/boot_flow/common.c
+++ b/src/boot_flow/common.c
@@ -20,6 +20,21 @@
#include "hf/plat/boot_flow.h"
/**
+ * Extract the boot parameters from the FDT and the boot-flow driver.
+ */
+static bool boot_params_init(struct boot_params *p,
+ const struct fdt_node *fdt_root)
+{
+ p->mem_ranges_count = 0;
+ p->kernel_arg = plat_boot_flow_get_kernel_arg();
+
+ return plat_boot_flow_get_initrd_range(fdt_root, &p->initrd_begin,
+ &p->initrd_end) &&
+ fdt_find_cpus(fdt_root, p->cpu_ids, &p->cpu_count) &&
+ fdt_find_memory_ranges(fdt_root, p);
+}
+
+/**
* Parses information from FDT needed to initialize Hafnium.
* FDT is mapped at the beginning and unmapped before exiting the function.
*/
@@ -33,7 +48,8 @@
enum manifest_return_code manifest_ret;
/* Get the memory map from the FDT. */
- fdt = fdt_map(stage1_locked, plat_get_fdt_addr(), &fdt_root, ppool);
+ fdt = fdt_map(stage1_locked, plat_boot_flow_get_fdt_addr(), &fdt_root,
+ ppool);
if (fdt == NULL) {
dlog("Unable to map FDT.\n");
return false;
@@ -66,3 +82,12 @@
return ret;
}
+
+/**
+ * Takes action on any updates that were generated.
+ */
+bool boot_flow_update(struct mm_stage1_locked stage1_locked,
+ struct boot_params_update *p, struct mpool *ppool)
+{
+ return plat_boot_flow_update(stage1_locked, p, ppool);
+}
diff --git a/src/boot_flow/linux.c b/src/boot_flow/linux.c
index 52fcb8a..e301da1 100644
--- a/src/boot_flow/linux.c
+++ b/src/boot_flow/linux.c
@@ -18,31 +18,38 @@
#include "hf/plat/boot_flow.h"
/* Set by arch-specific boot-time hook. */
-uintreg_t plat_fdt_addr;
+uintreg_t plat_boot_flow_fdt_addr;
/**
* Returns the physical address of board FDT. This was passed to Hafnium in the
* first kernel arg by the boot loader.
*/
-paddr_t plat_get_fdt_addr(void)
+paddr_t plat_boot_flow_get_fdt_addr(void)
{
- return pa_init((uintpaddr_t)plat_fdt_addr);
+ return pa_init((uintpaddr_t)plat_boot_flow_fdt_addr);
}
/**
* When handing over to the primary, give it the same FDT address that was given
* to Hafnium. The FDT may have been modified during Hafnium init.
*/
-uintreg_t plat_get_kernel_arg(void)
+uintreg_t plat_boot_flow_get_kernel_arg(void)
{
- return plat_fdt_addr;
+ return plat_boot_flow_fdt_addr;
}
/**
* Load initrd range from the board FDT.
*/
-bool plat_get_initrd_range(const struct fdt_node *fdt_root, paddr_t *begin,
- paddr_t *end)
+bool plat_boot_flow_get_initrd_range(const struct fdt_node *fdt_root,
+ paddr_t *begin, paddr_t *end)
{
return fdt_find_initrd(fdt_root, begin, end);
}
+
+bool plat_boot_flow_update(struct mm_stage1_locked stage1_locked,
+ struct boot_params_update *p, struct mpool *ppool)
+{
+ return fdt_patch(stage1_locked, plat_boot_flow_get_fdt_addr(), p,
+ ppool);
+}