Andrew Scull | 2d527c2 | 2018-11-27 14:21:08 +0000 | [diff] [blame] | 1 | /* |
Andrew Walbran | dc8ad20 | 2019-03-07 15:49:28 +0000 | [diff] [blame] | 2 | * Copyright 2018 The Hafnium Authors. |
Andrew Scull | 2d527c2 | 2018-11-27 14:21:08 +0000 | [diff] [blame] | 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/addr.h" |
| 18 | #include "hf/dlog.h" |
| 19 | #include "hf/fdt_handler.h" |
Andrew Walbran | fd37939 | 2019-03-14 17:45:04 +0000 | [diff] [blame] | 20 | #include "hf/mpool.h" |
Andrew Scull | 2d527c2 | 2018-11-27 14:21:08 +0000 | [diff] [blame] | 21 | |
| 22 | /* This is set by plat_entry.S. */ |
| 23 | uintpaddr_t plat_fdt_addr; |
| 24 | |
| 25 | paddr_t plat_get_fdt_addr(void) |
| 26 | { |
| 27 | return pa_init(plat_fdt_addr); |
| 28 | } |
| 29 | |
Andrew Scull | 105d519 | 2019-07-01 13:26:26 +0100 | [diff] [blame^] | 30 | void plat_get_initrd_range(struct mm_stage1_locked stage1_locked, |
| 31 | paddr_t *begin, paddr_t *end, struct mpool *ppool) |
Andrew Scull | 2d527c2 | 2018-11-27 14:21:08 +0000 | [diff] [blame] | 32 | { |
| 33 | struct fdt_header *fdt; |
| 34 | struct fdt_node n; |
| 35 | |
| 36 | /* Get the memory map from the FDT. */ |
Andrew Scull | 105d519 | 2019-07-01 13:26:26 +0100 | [diff] [blame^] | 37 | fdt = fdt_map(stage1_locked, plat_get_fdt_addr(), &n, ppool); |
Andrew Scull | 2d527c2 | 2018-11-27 14:21:08 +0000 | [diff] [blame] | 38 | if (!fdt) { |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | if (!fdt_find_child(&n, "")) { |
| 43 | dlog("Unable to find FDT root node.\n"); |
| 44 | goto out_unmap_fdt; |
| 45 | } |
| 46 | |
| 47 | fdt_find_initrd(&n, begin, end); |
| 48 | |
| 49 | out_unmap_fdt: |
Andrew Scull | 105d519 | 2019-07-01 13:26:26 +0100 | [diff] [blame^] | 50 | if (!fdt_unmap(stage1_locked, fdt, ppool)) { |
Andrew Scull | 2d527c2 | 2018-11-27 14:21:08 +0000 | [diff] [blame] | 51 | dlog("Unable to unmap fdt."); |
| 52 | } |
| 53 | } |