1 /*
2 * Copyright 2019 The Hafnium Authors.
3 *
4 * Use of this source code is governed by a BSD-style
5 * license that can be found in the LICENSE file or at
6 * https://opensource.org/licenses/BSD-3-Clause.
7 */
8
9 #include "hf/boot_flow.h"
10 #include "hf/dlog.h"
11 #include "hf/fdt_handler.h"
12 #include "hf/plat/boot_flow.h"
13
14 /**
15 * Extract the boot parameters from the FDT and the boot-flow driver.
16 */
boot_flow_get_params(struct boot_params * p,const struct fdt * fdt)17 bool boot_flow_get_params(struct boot_params *p, const struct fdt *fdt)
18 {
19 struct string memory = STRING_INIT("memory");
20 struct string ns_memory = STRING_INIT("ns-memory");
21 struct string device_memory = STRING_INIT("device-memory");
22 struct string ns_device_memory = STRING_INIT("ns-device-memory");
23
24 p->mem_ranges_count = 0;
25 p->kernel_arg = plat_boot_flow_get_kernel_arg();
26
27 return plat_boot_flow_get_initrd_range(fdt, &p->initrd_begin,
28 &p->initrd_end) &&
29 fdt_find_cpus(fdt, p->cpu_ids, &p->cpu_count) &&
30 fdt_find_memory_ranges(fdt, &memory, p->mem_ranges,
31 &p->mem_ranges_count, MAX_MEM_RANGES) &&
32 fdt_find_memory_ranges(fdt, &ns_memory, p->ns_mem_ranges,
33 &p->ns_mem_ranges_count,
34 MAX_MEM_RANGES) &&
35 fdt_find_memory_ranges(fdt, &device_memory, p->device_mem_ranges,
36 &p->device_mem_ranges_count,
37 MAX_DEVICE_MEM_RANGES) &&
38 fdt_find_memory_ranges(
39 fdt, &ns_device_memory, p->ns_device_mem_ranges,
40 &p->ns_device_mem_ranges_count, MAX_DEVICE_MEM_RANGES);
41 }
42
43 /**
44 * Takes action on any updates that were generated.
45 */
boot_flow_update(struct mm_stage1_locked stage1_locked,const struct manifest * manifest,struct boot_params_update * p,struct memiter * cpio,struct mpool * ppool)46 bool boot_flow_update(struct mm_stage1_locked stage1_locked,
47 const struct manifest *manifest,
48 struct boot_params_update *p, struct memiter *cpio,
49 struct mpool *ppool)
50 {
51 return plat_boot_flow_update(stage1_locked, manifest, p, cpio, ppool);
52 }
53