blob: 8fbd77d7cb05b116a3c0e551a3617ece55c61b8a [file] [log] [blame]
David Brazdil0dbb41f2019-09-09 18:03:35 +01001/*
2 * Copyright 2019 The Hafnium Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "hf/boot_params.h"
18
19#include "hf/dlog.h"
20#include "hf/fdt_handler.h"
21#include "hf/layout.h"
22#include "hf/manifest.h"
23#include "hf/plat/boot_flow.h"
24
25/**
26 * Extract the boot parameters from the FDT and the boot-flow driver.
27 */
28bool boot_params_init(struct boot_params *p, const struct fdt_node *fdt_root)
29{
30 p->mem_ranges_count = 0;
31 p->kernel_arg = plat_get_kernel_arg();
32
33 return plat_get_initrd_range(fdt_root, &p->initrd_begin,
34 &p->initrd_end) &&
35 fdt_find_cpus(fdt_root, p->cpu_ids, &p->cpu_count) &&
36 fdt_find_memory_ranges(fdt_root, p);
37}
38
39/**
40 * Updates the FDT before being passed to the primary VM's kernel.
41 *
42 * TODO: in future, each VM will declare whether it expects an argument passed
43 * and that will be static data e.g. it will provide its own FDT so there will
44 * be no FDT modification. This is done because each VM has a very different
45 * view of the system and we don't want to force VMs to require loader code when
46 * another loader can load the data for it.
47 */
48bool boot_params_patch_fdt(struct mm_stage1_locked stage1_locked,
49 struct boot_params_update *p, struct mpool *ppool)
50{
51 return fdt_patch(stage1_locked, plat_get_fdt_addr(), p, ppool);
52}