blob: 8f0317429871919986a7f4bf620b13ac72d72cf0 [file] [log] [blame]
Andrew Scull2d527c22018-11-27 14:21:08 +00001/*
Andrew Walbrandc8ad202019-03-07 15:49:28 +00002 * Copyright 2018 The Hafnium Authors.
Andrew Scull2d527c22018-11-27 14:21:08 +00003 *
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/addr.h"
18#include "hf/dlog.h"
19#include "hf/fdt_handler.h"
Andrew Walbranfd379392019-03-14 17:45:04 +000020#include "hf/mpool.h"
Andrew Scull2d527c22018-11-27 14:21:08 +000021
22/* This is set by plat_entry.S. */
23uintpaddr_t plat_fdt_addr;
24
25paddr_t plat_get_fdt_addr(void)
26{
27 return pa_init(plat_fdt_addr);
28}
29
Wedson Almeida Filho8e1da4f2018-12-16 16:34:48 +000030void plat_get_initrd_range(paddr_t *begin, paddr_t *end, struct mpool *ppool)
Andrew Scull2d527c22018-11-27 14:21:08 +000031{
32 struct fdt_header *fdt;
33 struct fdt_node n;
34
35 /* Get the memory map from the FDT. */
Wedson Almeida Filho8e1da4f2018-12-16 16:34:48 +000036 fdt = fdt_map(plat_get_fdt_addr(), &n, ppool);
Andrew Scull2d527c22018-11-27 14:21:08 +000037 if (!fdt) {
38 return;
39 }
40
41 if (!fdt_find_child(&n, "")) {
42 dlog("Unable to find FDT root node.\n");
43 goto out_unmap_fdt;
44 }
45
46 fdt_find_initrd(&n, begin, end);
47
48out_unmap_fdt:
Wedson Almeida Filho8e1da4f2018-12-16 16:34:48 +000049 if (!fdt_unmap(fdt, ppool)) {
Andrew Scull2d527c22018-11-27 14:21:08 +000050 dlog("Unable to unmap fdt.");
51 }
52}