Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/fdt fdt "/reserved-memory" node should be handled



details:   https://anonhg.NetBSD.org/src/rev/b9e4ca2a093f
branches:  trunk
changeset: 984163:b9e4ca2a093f
user:      ryo <ryo%NetBSD.org@localhost>
date:      Fri Jun 25 08:41:09 2021 +0000

description:
fdt "/reserved-memory" node should be handled

diffstat:

 sys/dev/fdt/fdt_memory.c |  24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diffs (52 lines):

diff -r 4745c723d6ca -r b9e4ca2a093f sys/dev/fdt/fdt_memory.c
--- a/sys/dev/fdt/fdt_memory.c  Fri Jun 25 07:03:28 2021 +0000
+++ b/sys/dev/fdt/fdt_memory.c  Fri Jun 25 08:41:09 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_memory.c,v 1.1 2020/12/12 09:27:31 skrll Exp $ */
+/* $NetBSD: fdt_memory.c,v 1.2 2021/06/25 08:41:09 ryo Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "opt_fdt.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.1 2020/12/12 09:27:31 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.2 2021/06/25 08:41:09 ryo Exp $");
 
 #include <sys/param.h>
 #include <sys/queue.h>
@@ -111,7 +111,7 @@
 {
        uint64_t lstart = 0, lend = 0;
        uint64_t addr, size;
-       int index, error;
+       int index, error, phandle, child;
 
        const int num = fdt_num_mem_rsv(fdtbus_get_data());
        for (index = 0; index <= num; index++) {
@@ -139,6 +139,24 @@
                lstart = addr;
                lend = addr + size;
        }
+
+       /*
+        * "no-map" ranges defined in the /reserved-memory node
+        * must also be excluded.
+        */
+       phandle = OF_finddevice("/reserved-memory");
+       if (phandle != -1) {
+               for (child = OF_child(phandle); child; child = OF_peer(child)) {
+                       if (!of_hasprop(child, "no-map"))
+                               continue;
+
+                       if (fdtbus_get_reg(child, 0, &addr, &size) != 0)
+                               continue;
+                       if (size == 0)
+                               continue;
+                       fdt_memory_remove_range(addr, size);
+               }
+       }
 }
 
 void



Home | Main Index | Thread Index | Old Index