summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/loongson/loongson/machdep.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/sys/arch/loongson/loongson/machdep.c b/sys/arch/loongson/loongson/machdep.c
index 4a44dd24003..f675c573144 100644
--- a/sys/arch/loongson/loongson/machdep.c
+++ b/sys/arch/loongson/loongson/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.25 2011/03/16 21:10:17 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.26 2011/03/27 15:28:54 miod Exp $ */
/*
* Copyright (c) 2009, 2010 Miodrag Vallat.
@@ -499,10 +499,40 @@ mips_init(int32_t argc, int32_t argv, int32_t envp, int32_t cv,
printf("Initial setup done, switching console.\n");
/*
- * Init message buffer.
+ * Init message buffer. This is similar to pmap_steal_memory(), but
+ * without zeroing the area, to keep the message buffer from the
+ * previous kernel run intact, if any.
*/
+ for (i = 0; i < vm_nphysseg; i++) {
+ struct vm_physseg *vps = &vm_physmem[i];
+ uint npg = atop(round_page(MSGBUFSIZE));
+ int j;
- msgbufbase = (caddr_t)pmap_steal_memory(MSGBUFSIZE, NULL,NULL);
+ if (vps->avail_start != vps->start ||
+ vps->avail_start >= vps->avail_end) {
+ continue;
+ }
+
+ if ((vps->avail_end - vps->avail_start) < npg)
+ continue;
+
+ msgbufbase = (caddr_t)PHYS_TO_XKPHYS(ptoa(vps->avail_start),
+ CCA_CACHED);
+ vps->avail_start += npg;
+ vps->start += npg;
+
+ if (vps->avail_start == vps->end) {
+ /* don't bother panicing if nphysseg becomes zero, */
+ /* the next pmap_steal_memory() call will. */
+ vm_nphysseg--;
+ for (j = i; j < vm_nphysseg; j++)
+ vm_physmem[j] = vm_physmem[j + 1];
+ }
+
+ break;
+ }
+ if (msgbufbase == NULL)
+ panic("not enough contiguous memory for message buffer");
initmsgbuf(msgbufbase, MSGBUFSIZE);
/*