Module Name: src Committed By: ryo Date: Fri Jun 25 08:41:09 UTC 2021
Modified Files: src/sys/dev/fdt: fdt_memory.c Log Message: fdt "/reserved-memory" node should be handled To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/fdt/fdt_memory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/fdt/fdt_memory.c diff -u src/sys/dev/fdt/fdt_memory.c:1.1 src/sys/dev/fdt/fdt_memory.c:1.2 --- src/sys/dev/fdt/fdt_memory.c:1.1 Sat Dec 12 09:27:31 2020 +++ src/sys/dev/fdt/fdt_memory.c Fri Jun 25 08:41:09 2021 @@ -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 @@ fdt_memory_remove_reserved(uint64_t min_ { 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 @@ fdt_memory_remove_reserved(uint64_t min_ 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