-/* $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 <patrick@blueri.se>
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;