summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwma <wma@FreeBSD.org>2016-03-01 12:50:24 +0000
committerwma <wma@FreeBSD.org>2016-03-01 12:50:24 +0000
commit0a7f0b77a3997aceb1642341e8efa2b7013bf74b (patch)
tree7670d25b4473bb7b8c5a595673ccad1da9637225
parentf5009ab96f95675190ec64e737eee2590f029ad0 (diff)
downloadFreeBSD-src-0a7f0b77a3997aceb1642341e8efa2b7013bf74b.zip
FreeBSD-src-0a7f0b77a3997aceb1642341e8efa2b7013bf74b.tar.gz
Get memory ranges from FDT if no EFI API is available on ARM64
Obtained from: Semihalf Submitted by: Michal Stanek <mst@semihalf.com> Sponsored by: Annapurna Labs Approved by: cognet (mentor) Reviewed by: andrew, wma Differential revision: https://reviews.freebsd.org/D5408
-rw-r--r--sys/arm64/arm64/machdep.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index f7552c4..49c9610 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$");
#endif
#ifdef FDT
+#include <dev/fdt/fdt_common.h>
#include <dev/ofw/openfirm.h>
#endif
@@ -668,6 +669,20 @@ add_physmap_entry(uint64_t base, uint64_t length, vm_paddr_t *physmap,
return (1);
}
+#ifdef FDT
+static void
+add_fdt_mem_regions(struct mem_region *mr, int mrcnt, vm_paddr_t *physmap,
+ u_int *physmap_idxp)
+{
+
+ for (int i = 0; i < mrcnt; i++) {
+ if (!add_physmap_entry(mr[i].mr_start, mr[i].mr_size, physmap,
+ physmap_idxp))
+ break;
+ }
+}
+#endif
+
#define efi_next_descriptor(ptr, size) \
((struct efi_md *)(((uint8_t *) ptr) + size))
@@ -807,6 +822,10 @@ initarm(struct arm64_bootparams *abp)
{
struct efi_map_header *efihdr;
struct pcpu *pcpup;
+#ifdef FDT
+ struct mem_region mem_regions[FDT_MEM_REGIONS];
+ int mem_regions_sz;
+#endif
vm_offset_t lastaddr;
caddr_t kmdp;
vm_paddr_t mem_len;
@@ -834,7 +853,18 @@ initarm(struct arm64_bootparams *abp)
physmap_idx = 0;
efihdr = (struct efi_map_header *)preload_search_info(kmdp,
MODINFO_METADATA | MODINFOMD_EFI_MAP);
- add_efi_map_entries(efihdr, physmap, &physmap_idx);
+ if (efihdr != NULL)
+ add_efi_map_entries(efihdr, physmap, &physmap_idx);
+#ifdef FDT
+ else {
+ /* Grab physical memory regions information from device tree. */
+ if (fdt_get_mem_regions(mem_regions, &mem_regions_sz,
+ NULL) != 0)
+ panic("Cannot get physical memory regions");
+ add_fdt_mem_regions(mem_regions, mem_regions_sz, physmap,
+ &physmap_idx);
+ }
+#endif
/* Print the memory map */
mem_len = 0;
OpenPOWER on IntegriCloud