Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/arch/evbarm/fdt Pull up following revision(s) (reques...



details:   https://anonhg.NetBSD.org/src/rev/e6bdd84320d2
branches:  netbsd-8
changeset: 850726:e6bdd84320d2
user:      snj <snj%NetBSD.org@localhost>
date:      Wed Jun 14 04:54:21 2017 +0000

description:
Pull up following revision(s) (requested by jmcneill in ticket #31):
        sys/arch/evbarm/fdt/fdt_machdep.c: revision 1.7
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 3bf6e528fffa -r e6bdd84320d2 sys/arch/evbarm/fdt/fdt_machdep.c
--- a/sys/arch/evbarm/fdt/fdt_machdep.c Wed Jun 14 04:53:12 2017 +0000
+++ b/sys/arch/evbarm/fdt/fdt_machdep.c Wed Jun 14 04:54:21 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.4.2.1 2017/06/06 16:26:53 snj Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.4.2.2 2017/06/14 04:54:21 snj 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.4.2.1 2017/06/06 16:26:53 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.4.2.2 2017/06/14 04:54:21 snj 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