Andrew Scull | 2d527c2 | 2018-11-27 14:21:08 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 Google LLC |
| 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" |
| 20 | |
| 21 | /* This is set by plat_entry.S. */ |
| 22 | uintpaddr_t plat_fdt_addr; |
| 23 | |
| 24 | paddr_t plat_get_fdt_addr(void) |
| 25 | { |
| 26 | return pa_init(plat_fdt_addr); |
| 27 | } |
| 28 | |
Wedson Almeida Filho | 8e1da4f | 2018-12-16 16:34:48 +0000 | [diff] [blame^] | 29 | void plat_get_initrd_range(paddr_t *begin, paddr_t *end, struct mpool *ppool) |
Andrew Scull | 2d527c2 | 2018-11-27 14:21:08 +0000 | [diff] [blame] | 30 | { |
| 31 | struct fdt_header *fdt; |
| 32 | struct fdt_node n; |
| 33 | |
| 34 | /* Get the memory map from the FDT. */ |
Wedson Almeida Filho | 8e1da4f | 2018-12-16 16:34:48 +0000 | [diff] [blame^] | 35 | fdt = fdt_map(plat_get_fdt_addr(), &n, ppool); |
Andrew Scull | 2d527c2 | 2018-11-27 14:21:08 +0000 | [diff] [blame] | 36 | if (!fdt) { |
| 37 | return; |
| 38 | } |
| 39 | |
| 40 | if (!fdt_find_child(&n, "")) { |
| 41 | dlog("Unable to find FDT root node.\n"); |
| 42 | goto out_unmap_fdt; |
| 43 | } |
| 44 | |
| 45 | fdt_find_initrd(&n, begin, end); |
| 46 | |
| 47 | out_unmap_fdt: |
Wedson Almeida Filho | 8e1da4f | 2018-12-16 16:34:48 +0000 | [diff] [blame^] | 48 | if (!fdt_unmap(fdt, ppool)) { |
Andrew Scull | 2d527c2 | 2018-11-27 14:21:08 +0000 | [diff] [blame] | 49 | dlog("Unable to unmap fdt."); |
| 50 | } |
| 51 | } |