summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-12-07 18:56:30 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-12-07 18:56:30 +0000
commit459c6d4adc693a14cf2621663822e56d5ac95d32 (patch)
tree040022702cb8fa22c987bbe71e73b514d9316802
parent75e0b83b6df4e4439d807344a92acd009d8e8207 (diff)
When converting ARCBios memory spaces from ARCBios page size to the kernel
page size, be sure to pick the strictest interval so as not to incorrectly claim ARCBios reserved data not (kernel) page size aligned as free memory. No functional change since the kernel uses the same page size as ARCBios (at the moment).
-rw-r--r--sys/arch/mips64/include/arcbios.h4
-rw-r--r--sys/arch/mips64/mips64/arcbios.c38
2 files changed, 32 insertions, 10 deletions
diff --git a/sys/arch/mips64/include/arcbios.h b/sys/arch/mips64/include/arcbios.h
index 77b411fcc96..85480a913d7 100644
--- a/sys/arch/mips64/include/arcbios.h
+++ b/sys/arch/mips64/include/arcbios.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: arcbios.h,v 1.12 2009/05/09 18:08:57 miod Exp $ */
+/* $OpenBSD: arcbios.h,v 1.13 2009/12/07 18:56:27 miod Exp $ */
/*-
* Copyright (c) 1996 M. Warner Losh. All rights reserved.
*
@@ -399,6 +399,8 @@ typedef struct arc_param_blk_64
#endif
#define ArcBios (ArcBiosBase->firmware_vect)
+#define ARCBIOS_PAGE_SIZE 4096
+
extern int bios_is_32bit;
extern char bios_enaddr[20];
extern char bios_console[10];
diff --git a/sys/arch/mips64/mips64/arcbios.c b/sys/arch/mips64/mips64/arcbios.c
index 449e621b533..437d38b2560 100644
--- a/sys/arch/mips64/mips64/arcbios.c
+++ b/sys/arch/mips64/mips64/arcbios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arcbios.c,v 1.26 2009/12/07 18:51:24 miod Exp $ */
+/* $OpenBSD: arcbios.c,v 1.27 2009/12/07 18:56:29 miod Exp $ */
/*-
* Copyright (c) 1996 M. Warner Losh. All rights reserved.
* Copyright (c) 1996-2004 Opsycon AB. All rights reserved.
@@ -247,8 +247,8 @@ void
bios_configure_memory()
{
arc_mem_t *descr = NULL;
- uint64_t start, count;
- MEMORYTYPE type;
+ uint64_t start, count, prevend = 0;
+ MEMORYTYPE type, prevtype = BadMemory;
uint64_t seg_start, seg_end;
#ifdef TGT_ORIGIN
int seen_free = 0;
@@ -327,11 +327,6 @@ bios_configure_memory()
#endif /* O200 || O300 */
}
- /* convert from ARCBios page size to kernel page size */
- seg_start = atop(start * 4096);
- count = atop(count * 4096);
- seg_end = seg_start + count;
-
switch (type) {
case BadMemory: /* have no use for these */
break;
@@ -347,6 +342,26 @@ bios_configure_memory()
/* FALLTHROUGH */
case FreeMemory:
case FreeContigous:
+ /*
+ * Convert from ARCBios page size to kernel page size.
+ * As this can yield a smaller range due to possible
+ * different page size, we try to force coalescing
+ * with the previous range if this is safe.
+ */
+ seg_start = atop(round_page(start * ARCBIOS_PAGE_SIZE));
+ seg_end = atop(trunc_page((start + count) *
+ ARCBIOS_PAGE_SIZE));
+ if (start == prevend)
+ switch (prevtype) {
+ case LoadedProgram:
+ case FreeMemory:
+ case FreeContigous:
+ seg_start = atop(trunc_page(start *
+ ARCBIOS_PAGE_SIZE));
+ break;
+ default:
+ break;
+ }
memrange_register(seg_start, seg_end, 0,
VM_FREELIST_DEFAULT);
break;
@@ -355,11 +370,12 @@ bios_configure_memory()
case FirmwareTemporary:
case FirmwarePermanent:
rsvdmem += count;
- physmem += count;
break;
default: /* Unknown type, leave it alone... */
break;
}
+ prevtype = type;
+ prevend = start + count;
#ifdef TGT_ORIGIN
if (descr == NULL)
break;
@@ -367,6 +383,10 @@ bios_configure_memory()
descr = (arc_mem_t *)Bios_GetMemoryDescriptor(descr);
}
+ /* convert rsvdmem to kernel pages, and count it in physmem */
+ rsvdmem = atop(round_page(rsvdmem * ARCBIOS_PAGE_SIZE));
+ physmem += rsvdmem;
+
#ifdef DEBUG
for (i = 0; i < MAXMEMSEGS; i++) {
if (mem_layout[i].mem_last_page) {