summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2013-08-19 09:12:02 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2013-08-19 09:12:02 +0000
commit12e809d59091e9522c8464ed9b40e52e40880ac9 (patch)
treeabfb26889b8350279bb61b1398b2a06001d2094e
parent6f3c730d98095e9a9f30088c4b403661808623d5 (diff)
Fix double allocation of memory in beagle machdep. This was caused by
resetting physical_free{start,end}, although they had already been used. Also, set physical_freestart correctly and allocate the pagetables and stacks directly after the kernel. ok florian@
-rw-r--r--sys/arch/beagle/beagle/beagle_machdep.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/sys/arch/beagle/beagle/beagle_machdep.c b/sys/arch/beagle/beagle/beagle_machdep.c
index f8cd608025c..dea0080dd6f 100644
--- a/sys/arch/beagle/beagle/beagle_machdep.c
+++ b/sys/arch/beagle/beagle/beagle_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: beagle_machdep.c,v 1.19 2013/05/22 17:44:46 rapha Exp $ */
+/* $OpenBSD: beagle_machdep.c,v 1.20 2013/08/19 09:12:01 patrick Exp $ */
/* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */
/*
@@ -541,7 +541,6 @@ initarm(void *arg0, void *arg1, void *arg2)
/* doesn't deal with multiple segments, hopefully u-boot collaped them into one */
memstart = bootconfig.dram[0].address;
memsize = bootconfig.dram[0].pages * PAGE_SIZE;
- memsize = 0x02000000; /* 32MB */ /* WTF? */
printf("memory size derived from u-boot\n");
for (loop = 0; loop < bootconfig.dramblocks; loop++) {
printf("bootconf.mem[%d].address = %08x pages %d/0x%08x\n",
@@ -567,7 +566,7 @@ initarm(void *arg0, void *arg1, void *arg2)
{
extern char _end[];
- physical_freestart = (((unsigned long)_end - KERNEL_TEXT_BASE +0xfff) & ~0xfff);
+ physical_freestart = (((unsigned long)_end - KERNEL_TEXT_BASE +0xfff) & ~0xfff) + memstart;
physical_freeend = memstart+memsize;
}
@@ -614,10 +613,10 @@ initarm(void *arg0, void *arg1, void *arg2)
(var).pv_va = KERNEL_BASE + (var).pv_pa - physical_start;
#define alloc_pages(var, np) \
- physical_freeend -= ((np) * PAGE_SIZE); \
+ (var) = physical_freestart ; \
+ physical_freestart += ((np) * PAGE_SIZE); \
if (physical_freeend < physical_freestart) \
panic("initarm: out of memory"); \
- (var) = physical_freeend; \
free_pages -= (np); \
memset((char *)(var), 0, ((np) * PAGE_SIZE));
@@ -625,7 +624,7 @@ initarm(void *arg0, void *arg1, void *arg2)
kernel_l1pt.pv_pa = 0;
for (loop = 0; loop <= NUM_KERNEL_PTS; ++loop) {
/* Are we 16KB aligned for an L1 ? */
- if (((physical_freeend - L1_TABLE_SIZE) & (L1_TABLE_SIZE - 1)) == 0
+ if (((physical_freestart) & (L1_TABLE_SIZE - 1)) == 0
&& kernel_l1pt.pv_pa == 0) {
valloc_pages(kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE);
} else {
@@ -778,21 +777,6 @@ initarm(void *arg0, void *arg1, void *arg2)
* tables.
*/
- /*
- * Update the physical_freestart/physical_freeend/free_pages
- * variables.
- */
- {
- extern char _end[];
-
- physical_freestart = physical_start +
- (((((u_int32_t) _end) + PGOFSET) & ~PGOFSET) -
- KERNEL_BASE);
- physical_freeend = physical_end;
- free_pages =
- (physical_freeend - physical_freestart) / PAGE_SIZE;
- }
-
/* be a client to all domains */
cpu_domains(0x55555555);
/* Switch tables */
@@ -999,7 +983,7 @@ consinit(void)
paddr = 0x48020000;
break;
default:
- printf("board type %x unknown", board_id);
+ panic("board type %x unknown", board_id);
/* XXX - HELP */
}
comcnattach(&armv7_a4x_bs_tag, paddr, comcnspeed, 48000000, comcnmode);