From c9fd0cd67588a5b17ad589a9202d446e0963006d Mon Sep 17 00:00:00 2001 From: kettenis Date: Sun, 16 May 2021 10:38:53 +0000 Subject: [PATCH] Sync memreg_add() implementation with arm64 and powerpc64. --- sys/arch/riscv64/riscv64/machdep.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sys/arch/riscv64/riscv64/machdep.c b/sys/arch/riscv64/riscv64/machdep.c index a1dd5f9d0a4..1faeac1cf12 100644 --- a/sys/arch/riscv64/riscv64/machdep.c +++ b/sys/arch/riscv64/riscv64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.16 2021/05/14 06:48:52 jsg Exp $ */ +/* $OpenBSD: machdep.c,v 1.17 2021/05/16 10:38:53 kettenis Exp $ */ /* * Copyright (c) 2014 Patrick Wildt @@ -923,6 +923,20 @@ pmap_bootstrap_bs_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, 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; -- 2.20.1