diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2021-05-13 22:42:15 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2021-05-13 22:42:15 +0000 |
commit | 92e02d567c9de7d39b4a5b2e441725dc44698bf3 (patch) | |
tree | 45acaea12545647b1f9688e5d7d7fa17e69020cd | |
parent | 07f815ede6cd74d12038282b7da52b262307c25c (diff) |
Improve mereg_add() like I did on arm64.
-rw-r--r-- | sys/arch/powerpc64/powerpc64/machdep.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sys/arch/powerpc64/powerpc64/machdep.c b/sys/arch/powerpc64/powerpc64/machdep.c index b8467449ee6..3a7bcd53301 100644 --- a/sys/arch/powerpc64/powerpc64/machdep.c +++ b/sys/arch/powerpc64/powerpc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.68 2021/04/15 07:28:37 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.69 2021/05/13 22:42:14 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org> @@ -355,6 +355,23 @@ init_powernv(void *fdt, void *tocbase) void memreg_add(const struct fdt_reg *reg) { + int i; + + for (i = 0; i < nmemreg; i++) { + if (reg->addr == memreg[i].addr + memreg[i].size) { + memreg[i].size += reg->size; + return; + } + if (reg->addr + reg->size == memreg[i].addr) { + memreg[i].addr = reg->addr; + memreg[i].size += reg->size; + return; + } + } + + if (nmemreg >= nitems(memreg)) + return; + memreg[nmemreg++] = *reg; } |