blob: e301da1be47f2d0ff469c4c5b9326a4ba7f155ad [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/fdt_handler.h"
18#include "hf/plat/boot_flow.h"
19
20/* Set by arch-specific boot-time hook. */
Andrew Scullc3771072019-09-19 13:30:42 +010021uintreg_t plat_boot_flow_fdt_addr;
David Brazdil0dbb41f2019-09-09 18:03:35 +010022
23/**
24 * Returns the physical address of board FDT. This was passed to Hafnium in the
25 * first kernel arg by the boot loader.
26 */
Andrew Scullc3771072019-09-19 13:30:42 +010027paddr_t plat_boot_flow_get_fdt_addr(void)
David Brazdil0dbb41f2019-09-09 18:03:35 +010028{
Andrew Scullc3771072019-09-19 13:30:42 +010029 return pa_init((uintpaddr_t)plat_boot_flow_fdt_addr);
David Brazdil0dbb41f2019-09-09 18:03:35 +010030}
31
32/**
33 * When handing over to the primary, give it the same FDT address that was given
34 * to Hafnium. The FDT may have been modified during Hafnium init.
35 */
Andrew Scullc3771072019-09-19 13:30:42 +010036uintreg_t plat_boot_flow_get_kernel_arg(void)
David Brazdil0dbb41f2019-09-09 18:03:35 +010037{
Andrew Scullc3771072019-09-19 13:30:42 +010038 return plat_boot_flow_fdt_addr;
David Brazdil0dbb41f2019-09-09 18:03:35 +010039}
40
41/**
42 * Load initrd range from the board FDT.
43 */
Andrew Scullc3771072019-09-19 13:30:42 +010044bool plat_boot_flow_get_initrd_range(const struct fdt_node *fdt_root,
45 paddr_t *begin, paddr_t *end)
David Brazdil0dbb41f2019-09-09 18:03:35 +010046{
47 return fdt_find_initrd(fdt_root, begin, end);
48}
Andrew Scullc3771072019-09-19 13:30:42 +010049
50bool plat_boot_flow_update(struct mm_stage1_locked stage1_locked,
51 struct boot_params_update *p, struct mpool *ppool)
52{
53 return fdt_patch(stage1_locked, plat_boot_flow_get_fdt_addr(), p,
54 ppool);
55}