Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/evbarm/fdt Parse more than one entry from the /memo...



details:   https://anonhg.NetBSD.org/src/rev/8b567d3d201b
branches:  trunk
changeset: 824620:8b567d3d201b
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Jun 11 20:25:07 2017 +0000

description:
Parse more than one entry from the /memory node's reg property.

diffstat:

 sys/arch/evbarm/fdt/fdt_machdep.c |  36 +++++++++++++++++++++++++++++++-----
 1 files changed, 31 insertions(+), 5 deletions(-)

diffs (64 lines):

diff -r df40db062d48 -r 8b567d3d201b sys/arch/evbarm/fdt/fdt_machdep.c
--- a/sys/arch/evbarm/fdt/fdt_machdep.c Sun Jun 11 17:34:54 2017 +0000
+++ b/sys/arch/evbarm/fdt/fdt_machdep.c Sun Jun 11 20:25:07 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.6 2017/06/06 09:56:00 jmcneill Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.7 2017/06/11 20:25:07 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.6 2017/06/06 09:56:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.7 2017/06/11 20:25:07 jmcneill Exp $");
 
 #include "opt_machdep.h"
 #include "opt_ddb.h"
@@ -139,6 +139,34 @@
 #define DPRINTN(x,b)
 #endif
 
+/*
+ * Get the first physically contiguous region of memory.
+ */
+static void
+fdt_get_memory(uint64_t *paddr, uint64_t *psize)
+{
+       const int memory = OF_finddevice("/memory");
+       uint64_t cur_addr, cur_size;
+       int index;
+
+       /* Assume the first entry is the start of memory */
+       if (fdtbus_get_reg64(memory, 0, paddr, psize) != 0)
+               panic("Cannot determine memory size");
+
+       DPRINTF("FDT /memory [%d] @ 0x%" PRIx64 " size 0x%" PRIx64 "\n",
+           0, *paddr, *psize);
+
+       /* If subsequent entries follow the previous one, append them. */
+       for (index = 1;
+            fdtbus_get_reg64(memory, index, &cur_addr, &cur_size) == 0;
+            index++) {
+               DPRINTF("FDT /memory [%d] @ 0x%" PRIx64 " size 0x%" PRIx64 "\n",
+                   index, cur_addr, cur_size);
+               if (*paddr + *psize == cur_addr)
+                       *psize += cur_size;
+       }
+}
+
 u_int
 initarm(void *arg)
 {
@@ -219,9 +247,7 @@
                KERNEL_VM_BASE - KERNEL_BASE,
                KERNEL_BASE_VOFFSET);
 
-       const int memory = OF_finddevice("/memory");
-       if (fdtbus_get_reg64(memory, 0, &memory_addr, &memory_size) != 0)
-               panic("Cannot determine memory size");
+       fdt_get_memory(&memory_addr, &memory_size);
 
 #if !defined(_LP64)
        /* Cannot map memory above 4GB */



Home | Main Index | Thread Index | Old Index