Module Name: src
Committed By: skrll
Date: Sun Apr 6 12:43:19 UTC 2014
Modified Files:
src/sys/arch/evbarm/conf: std.rpi
src/sys/arch/evbarm/rpi: rpi.h rpi_machdep.c
Log Message:
Re-arrange RPI VM layout and enable __HAVE_MM_MD_DIRECT_MAPPED_PHYS. RPI
kernels now boot again.
I'm not admitting defeat in why there are problems with the
non-__HAVE_MM_MD_DIRECT_MAPPED_PHYS case.
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/evbarm/conf/std.rpi
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbarm/rpi/rpi.h
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/evbarm/rpi/rpi_machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/evbarm/conf/std.rpi
diff -u src/sys/arch/evbarm/conf/std.rpi:1.13 src/sys/arch/evbarm/conf/std.rpi:1.14
--- src/sys/arch/evbarm/conf/std.rpi:1.13 Tue Feb 25 19:37:30 2014
+++ src/sys/arch/evbarm/conf/std.rpi Sun Apr 6 12:43:18 2014
@@ -1,4 +1,4 @@
-# $NetBSD: std.rpi,v 1.13 2014/02/25 19:37:30 skrll Exp $
+# $NetBSD: std.rpi,v 1.14 2014/04/06 12:43:18 skrll Exp $
#
# standard NetBSD/evbarm for Raspberry Pi options
@@ -13,6 +13,7 @@ options ARM11_COMPAT_MMU
options __HAVE_CPU_COUNTER
options __HAVE_FAST_SOFTINTS # should be in types.h
options __HAVE_CPU_UAREA_ALLOC_IDLELWP
+options __HAVE_MM_MD_DIRECT_MAPPED_PHYS
options TPIDRPRW_IS_CURCPU
options ARM_HAS_VBAR
options KERNEL_BASE_EXT=0xc0000000
Index: src/sys/arch/evbarm/rpi/rpi.h
diff -u src/sys/arch/evbarm/rpi/rpi.h:1.2 src/sys/arch/evbarm/rpi/rpi.h:1.3
--- src/sys/arch/evbarm/rpi/rpi.h:1.2 Thu Sep 5 07:09:33 2013
+++ src/sys/arch/evbarm/rpi/rpi.h Sun Apr 6 12:43:19 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: rpi.h,v 1.2 2013/09/05 07:09:33 skrll Exp $ */
+/* $NetBSD: rpi.h,v 1.3 2014/04/06 12:43:19 skrll Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
/*
* Kernel VM space: KERNEL_VM_BASE to 0xf0000000
*/
-#define KERNEL_VM_BASE (KERNEL_BASE + 0x01000000)
+#define KERNEL_VM_BASE (KERNEL_BASE + 0x20000000)
#define KERNEL_VM_SIZE (0xf0000000 - KERNEL_VM_BASE)
/*
Index: src/sys/arch/evbarm/rpi/rpi_machdep.c
diff -u src/sys/arch/evbarm/rpi/rpi_machdep.c:1.40 src/sys/arch/evbarm/rpi/rpi_machdep.c:1.41
--- src/sys/arch/evbarm/rpi/rpi_machdep.c:1.40 Tue Apr 1 06:55:29 2014
+++ src/sys/arch/evbarm/rpi/rpi_machdep.c Sun Apr 6 12:43:19 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: rpi_machdep.c,v 1.40 2014/04/01 06:55:29 skrll Exp $ */
+/* $NetBSD: rpi_machdep.c,v 1.41 2014/04/06 12:43:19 skrll Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rpi_machdep.c,v 1.40 2014/04/01 06:55:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rpi_machdep.c,v 1.41 2014/04/06 12:43:19 skrll Exp $");
#include "opt_evbarm_boardtype.h"
#include "opt_ddb.h"
@@ -537,11 +537,41 @@ initarm(void *arg)
#ifdef VERBOSE_INIT_ARM
printf("initarm: Configuring system ...\n");
#endif
- arm32_bootmem_init(bootconfig.dram[0].address,
- bootconfig.dram[0].pages * PAGE_SIZE, (uintptr_t)KERNEL_BASE_phys);
+
+ psize_t ram_size = bootconfig.dram[0].pages * PAGE_SIZE;
+
+#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
+ if (ram_size > KERNEL_VM_BASE - KERNEL_BASE) {
+ printf("%s: dropping RAM size from %luMB to %uMB\n",
+ __func__, (unsigned long) (ram_size >> 20),
+ (KERNEL_VM_BASE - KERNEL_BASE) >> 20);
+ ram_size = KERNEL_VM_BASE - KERNEL_BASE;
+ }
+#endif
+
+ /*
+ * If MEMSIZE specified less than what we really have, limit ourselves
+ * to that.
+ */
+#ifdef MEMSIZE
+ if (ram_size == 0 || ram_size > (unsigned)MEMSIZE * 1024 * 1024)
+ ram_size = (unsigned)MEMSIZE * 1024 * 1024;
+#else
+ KASSERTMSG(ram_size > 0, "RAM size unknown and MEMSIZE undefined");
+#endif
+
+ arm32_bootmem_init(bootconfig.dram[0].address, ram_size,
+ (uintptr_t)KERNEL_BASE_phys);
+
+#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
+ const bool mapallmem_p = true;
+ KASSERT(ram_size <= KERNEL_VM_BASE - KERNEL_BASE);
+#else
+ const bool mapallmem_p = false;
+#endif
arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_HIGH, 0, rpi_devmap,
- false);
+ mapallmem_p);
cpu_reset_address = bcm2835_system_reset;