Module Name: src
Committed By: he
Date: Wed Dec 28 11:50:25 UTC 2022
Modified Files:
src/sys/arch/evbmips/mipssim: machdep.c mipssimreg.h
Log Message:
evbmips/mipssim: on mips64, probe for additional memory.
Probe for memory from above the ISA I/O hole and up to 16GB,
which acording to simonb@ is a somewhat arbitrary limit.
This makes it possible to specify e.g. "-m 2g" to qemu, and have
that memory be probed instead of being clamped to 508MB.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbmips/mipssim/machdep.c \
src/sys/arch/evbmips/mipssim/mipssimreg.h
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/evbmips/mipssim/machdep.c
diff -u src/sys/arch/evbmips/mipssim/machdep.c:1.3 src/sys/arch/evbmips/mipssim/machdep.c:1.4
--- src/sys/arch/evbmips/mipssim/machdep.c:1.3 Tue Nov 16 06:44:40 2021
+++ src/sys/arch/evbmips/mipssim/machdep.c Wed Dec 28 11:50:25 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.3 2021/11/16 06:44:40 simonb Exp $ */
+/* $NetBSD: machdep.c,v 1.4 2022/12/28 11:50:25 he Exp $ */
/*-
* Copyright (c) 2001,2021 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.3 2021/11/16 06:44:40 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.4 2022/12/28 11:50:25 he Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -229,6 +229,9 @@ mach_init_memory(void)
size_t addr;
uint32_t *memptr;
extern char end[]; /* XXX */
+#ifdef MIPS64
+ size_t highaddr;
+#endif
l->l_addr = &dummypcb;
memsize = roundup2(MIPS_KSEG0_TO_PHYS((uintptr_t)(end)), 1024 * 1024);
@@ -246,13 +249,43 @@ mach_init_memory(void)
}
l->l_addr = NULL;
- printf("Memory size: 0x%" PRIxPSIZE " (%" PRIdPSIZE " MB)\n",
- memsize, memsize / 1024 / 1024);
physmem = btoc(memsize);
mem_clusters[0].start = PAGE_SIZE;
mem_clusters[0].size = memsize - PAGE_SIZE;
mem_cluster_cnt = 1;
+
+#ifdef _LP64
+ /* probe for more memory above ISA I/O "hole" */
+ l->l_addr = &dummypcb;
+
+ for (highaddr = addr = MIPSSIM_MORE_MEM_BASE;
+ addr < MIPSSIM_MORE_MEM_END;
+ addr += 1024 * 1024) {
+ memptr = (void *)MIPS_PHYS_TO_XKPHYS(CCA_CACHEABLE,
+ addr - sizeof(*memptr));
+ if (badaddr(memptr, sizeof(uint32_t)) < 0)
+ break;
+
+ highaddr = addr;
+#ifdef MEM_DEBUG
+ printf("probed %zd MB\n", (addr - MIPSSIM_MORE_MEM_BASE)
+ / 1024 * 1024);
+#endif
+ }
+ l->l_addr = NULL;
+
+ if (highaddr != MIPSSIM_MORE_MEM_BASE) {
+ mem_clusters[1].start = MIPSSIM_MORE_MEM_BASE;
+ mem_clusters[1].size = highaddr - MIPSSIM_MORE_MEM_BASE;
+ mem_cluster_cnt++;
+ physmem += btoc(mem_clusters[1].size);
+ memsize += mem_clusters[1].size;
+ }
+#endif /* _LP64 */
+
+ printf("Memory size: 0x%" PRIxPSIZE " (%" PRIdPSIZE " MB)\n",
+ memsize, memsize / 1024 / 1024);
}
void
Index: src/sys/arch/evbmips/mipssim/mipssimreg.h
diff -u src/sys/arch/evbmips/mipssim/mipssimreg.h:1.3 src/sys/arch/evbmips/mipssim/mipssimreg.h:1.4
--- src/sys/arch/evbmips/mipssim/mipssimreg.h:1.3 Tue Feb 16 15:06:30 2021
+++ src/sys/arch/evbmips/mipssim/mipssimreg.h Wed Dec 28 11:50:25 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: mipssimreg.h,v 1.3 2021/02/16 15:06:30 simonb Exp $ */
+/* $NetBSD: mipssimreg.h,v 1.4 2022/12/28 11:50:25 he Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -37,6 +37,11 @@
* 1fd0.0000 64kB ISA IO space
* 1fd1.0000 64kB 'ISA' VirtIO IO space (non standard)
*
+ * Additionally, mips64 probes for memory up to 16G:
+ *
+ * 2000.0000 memory, probed, up to
+ * 4.0000.0000 16GB somewhat arbitrarily, could probably be higher
+ *
* CPU interrupts
*
* 0 mipsnet
@@ -56,5 +61,8 @@
#define MIPSSIM_DMA_PHYSBASE 0x00000000
#define MIPSSIM_DMA_SIZE (MIPSSIM_ISA_IO_BASE - MIPSSIM_DMA_BASE)
+#define MIPSSIM_MORE_MEM_BASE 0x20000000
+#define MIPSSIM_MORE_MEM_END (16ULL * 1024 * 1024 * 1024) /* 16GB */
+
#define VIRTIO_NUM_TRANSPORTS 32
#define VIRTIO_STRIDE 512