From: kettenis Date: Sun, 16 May 2021 10:38:53 +0000 (+0000) Subject: Sync memreg_add() implementation with arm64 and powerpc64. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c9fd0cd67588a5b17ad589a9202d446e0963006d;p=openbsd Sync memreg_add() implementation with arm64 and powerpc64. --- 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;