Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/hpcmips support non-contiguous memory.
details: https://anonhg.NetBSD.org/src/rev/b5297a706865
branches: trunk
changeset: 482765:b5297a706865
user: shin <shin%NetBSD.org@localhost>
date: Mon Feb 21 13:46:02 2000 +0000
description:
support non-contiguous memory.
patch from Mycroft <root%ihack.net@localhost> and uch%netbsd.org@localhost.
tested hardware:
VR4121 IBM WorkPad z50 (48MB, 16MB)
VR4121 NEC Mobile Gear II MC/R730
TX3912 Compaq C-series 810 (20MB), 2010c (20MB, 16MB)
TX3922 Sharp Telios HC-AJ2 (32MB)
diffstat:
sys/arch/hpcmips/hpcmips/machdep.c | 58 +++++++++-------
sys/arch/hpcmips/include/sysconf.h | 4 +-
sys/arch/hpcmips/include/vmparam.h | 4 +-
sys/arch/hpcmips/tx/tx39.c | 125 +++++++++++++++++++-----------------
sys/arch/hpcmips/vr/vr.c | 104 +++++++++++++++++++++++-------
5 files changed, 179 insertions(+), 116 deletions(-)
diffs (truncated from 466 to 300 lines):
diff -r 7d5f7eab8f74 -r b5297a706865 sys/arch/hpcmips/hpcmips/machdep.c
--- a/sys/arch/hpcmips/hpcmips/machdep.c Mon Feb 21 13:28:30 2000 +0000
+++ b/sys/arch/hpcmips/hpcmips/machdep.c Mon Feb 21 13:46:02 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.18 2000/02/10 08:34:08 sato Exp $ */
+/* $NetBSD: machdep.c,v 1.19 2000/02/21 13:46:02 shin Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -43,7 +43,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.18 2000/02/10 08:34:08 sato Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.19 2000/02/21 13:46:02 shin Exp $");
/* from: Utah Hdr: machdep.c 1.63 91/04/24 */
#include "opt_vr41x1.h"
@@ -131,7 +131,6 @@
vm_map_t phys_map = NULL;
int systype; /* mother board type */
-int maxmem; /* max memory per process */
int physmem; /* max supported memory, changes to actual */
int mem_cluster_cnt;
phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
@@ -171,7 +170,7 @@
void unimpl_iointr __P ((void *, u_long));
void unimpl_clockintr __P ((void *));
void unimpl_fb_init __P((caddr_t*));
-int unimpl_mem_init __P((caddr_t));
+void unimpl_mem_init __P((paddr_t));
void unimpl_reboot __P((int howto, char *bootstr));
struct platform platform = {
@@ -208,7 +207,6 @@
char *argv[];
struct bootinfo *bi;
{
- u_long first, last;
int i;
caddr_t kernend, v;
unsigned size;
@@ -388,28 +386,34 @@
Debugger();
#endif
- /*
- * Find out how much memory is available and clear memory.
- */
- physmem = btoc((paddr_t)kernend - MIPS_KSEG0_START) +
- (*platform.mem_init)(kernend);
- maxmem = physmem;
+ /* Find physical memory regions. */
+ (*platform.mem_init)((paddr_t)kernend - MIPS_KSEG0_START);
+
+ printf("mem_cluster_cnt = %d\n", mem_cluster_cnt);
+ physmem = 0;
+ for (i = 0; i < mem_cluster_cnt; i++) {
+ printf("mem_clusters[%d] = {0x%lx,0x%lx}\n", i,
+ (paddr_t)mem_clusters[i].start,
+ (paddr_t)mem_clusters[i].size);
+ physmem += atop(mem_clusters[i].size);
+ }
- /*
- * Now that we know how much memory we have, initialize the
- * mem cluster array.
- */
- mem_clusters[0].start = 0; /* XXX is this correct? */
- mem_clusters[0].size = ctob(physmem);
- mem_cluster_cnt = 1;
+ /* Cluster 0 is always the kernel, which doesn't get loaded. */
+ for (i = 1; i < mem_cluster_cnt; i++) {
+ paddr_t start, size;
+
+ start = (paddr_t)mem_clusters[i].start;
+ size = (paddr_t)mem_clusters[i].size;
- /*
- * Load the rest of the available pages into the VM system.
- */
- first = round_page(MIPS_KSEG0_TO_PHYS(kernend));
- last = mem_clusters[0].start + mem_clusters[0].size;
- uvm_page_physload(atop(first), atop(last), atop(first),
- atop(last), VM_FREELIST_DEFAULT);
+ printf("loading 0x%lx,0x%lx\n", start, size);
+
+ memset((void *)MIPS_PHYS_TO_KSEG1(start), 0,
+ size);
+
+ uvm_page_physload(atop(start), atop(start + size),
+ atop(start), atop(start + size),
+ VM_FREELIST_DEFAULT);
+ }
/*
* Initialize error message buffer (at end of core).
@@ -761,9 +765,9 @@
panic("sysconf.init didnt set intr");
}
-int
+void
unimpl_mem_init(kernend)
- caddr_t kernend;
+ paddr_t kernend;
{
panic("sysconf.init didnt set memory");
}
diff -r 7d5f7eab8f74 -r b5297a706865 sys/arch/hpcmips/include/sysconf.h
--- a/sys/arch/hpcmips/include/sysconf.h Mon Feb 21 13:28:30 2000 +0000
+++ b/sys/arch/hpcmips/include/sysconf.h Mon Feb 21 13:46:02 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysconf.h,v 1.5 1999/12/04 10:55:18 takemura Exp $ */
+/* $NetBSD: sysconf.h,v 1.6 2000/02/21 13:46:04 shin Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@@ -86,7 +86,7 @@
void (*iointr) __P((void *, unsigned long));
void (*clockintr) __P((void *));
void (*fb_init) __P((caddr_t*));
- int (*mem_init) __P((caddr_t));
+ void (*mem_init) __P((paddr_t));
#ifdef notyet
void (*mcheck_handler) __P((unsigned long, struct trapframe *,
unsigned long, unsigned long));
diff -r 7d5f7eab8f74 -r b5297a706865 sys/arch/hpcmips/include/vmparam.h
--- a/sys/arch/hpcmips/include/vmparam.h Mon Feb 21 13:28:30 2000 +0000
+++ b/sys/arch/hpcmips/include/vmparam.h Mon Feb 21 13:46:02 2000 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: vmparam.h,v 1.1.1.1 1999/09/16 12:23:24 takemura Exp $ */
+/* $NetBSD: vmparam.h,v 1.2 2000/02/21 13:46:04 shin Exp $ */
#include <mips/vmparam.h>
/*
* hpcmips has one physical memory segment.
*/
-#define VM_PHYSSEG_MAX 1
+#define VM_PHYSSEG_MAX 5
#define VM_NFREELIST 1
#define VM_FREELIST_DEFAULT 0
diff -r 7d5f7eab8f74 -r b5297a706865 sys/arch/hpcmips/tx/tx39.c
--- a/sys/arch/hpcmips/tx/tx39.c Mon Feb 21 13:28:30 2000 +0000
+++ b/sys/arch/hpcmips/tx/tx39.c Mon Feb 21 13:46:02 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tx39.c,v 1.13 2000/02/10 02:15:02 sato Exp $ */
+/* $NetBSD: tx39.c,v 1.14 2000/02/21 13:46:04 shin Exp $ */
/*
* Copyright (c) 1999, 2000, by UCHIYAMA Yasushi
@@ -33,6 +33,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
+#include <sys/kcore.h>
#include <machine/locore.h> /* cpu_id */
#include <machine/bootinfo.h> /* bootinfo */
@@ -79,7 +80,6 @@
void tx_init __P((void));
int tx39icu_intr __P((u_int32_t, u_int32_t, u_int32_t, u_int32_t));
-int tx39_find_dram __P((u_int32_t, u_int32_t));
void tx39clock_cpuspeed __P((int*, int*));
/* TX39-specific initialization vector */
@@ -88,11 +88,15 @@
void tx_cons_init __P((void));
void tx_device_register __P((struct device *, void *));
void tx_fb_init __P((caddr_t*));
-int tx_mem_init __P((caddr_t));
+void tx_mem_init __P((paddr_t));
+void tx_find_dram __P((paddr_t, paddr_t));
void tx_reboot __P((int howto, char *bootstr));
int tx_intr __P((u_int32_t mask, u_int32_t pc, u_int32_t statusReg,
u_int32_t causeReg));
+extern phys_ram_seg_t mem_clusters[];
+extern int mem_cluster_cnt;
+
void
tx_init()
{
@@ -188,46 +192,71 @@
#endif /* TX392X */
}
-int
+void
tx_mem_init(kernend)
- caddr_t kernend; /* kseg0 */
+ paddr_t kernend;
{
- u_int32_t startaddr, endaddr;
- int npage, xpage, kpage;
-
- startaddr = MIPS_PHYS_TO_KSEG1(
- (btoc((u_int32_t)kernend - MIPS_KSEG0_START)) << PGSHIFT);
- endaddr = MIPS_PHYS_TO_KSEG1(TX39_SYSADDR_DRAMBANK0CS1 +
- TX39_SYSADDR_DRAMBANK_LEN);
- kpage = btoc(MIPS_KSEG1_TO_PHYS(startaddr));
-
- /* D-RAM bank0 */
- npage = tx39_find_dram(startaddr, endaddr);
-
- printf("DRAM bank0: %d pages (%dMByte) reserved %d pages\n",
- npage + 1, ((npage + 1) * NBPG) / 0x100000, kpage + 1);
- npage -= kpage; /* exclude kernel area */
-
- /* Clear DRAM area */
- memset((void*)startaddr, 0, npage * NBPG);
+ mem_clusters[0].start = 0;
+ mem_clusters[0].size = kernend;
+ mem_cluster_cnt = 1;
+ /* search DRAM bank 0 */
+ tx_find_dram(kernend, 0x02000000);
- /* D-RAM bank1 XXX find only. not usable yet */
- startaddr = MIPS_PHYS_TO_KSEG1(TX39_SYSADDR_DRAMBANK1CS1);
- endaddr = MIPS_PHYS_TO_KSEG1(TX39_SYSADDR_DRAMBANK1CS1 +
- TX39_SYSADDR_DRAMBANK_LEN);
- xpage = tx39_find_dram(startaddr, endaddr);
- printf("DRAM bank1: %d pages (%dMByte) ...but not usable yet\n",
- xpage + 1, ((xpage + 1) * NBPG) / 0x100000);
-
+ /* search DRAM bank 1 */
+ tx_find_dram(0x02000000, 0x04000000);
/*
* Clear currently unused D-RAM area
* (For reboot Windows CE clearly)
*/
- memset((void*)startaddr, 0, npage * NBPG);
- memset((void*)(KERNBASE + 0x400), 0,
- KERNTEXTOFF - KERNBASE - 0x800);
-
- return npage; /* Return bank0's memory only */
+ memset((void *)(KERNBASE + 0x400), 0, KERNTEXTOFF -
+ (KERNBASE + 0x800));
+}
+
+void
+tx_find_dram(start, end)
+ paddr_t start, end;
+{
+ caddr_t page, startaddr, endaddr;
+
+ startaddr = (void*)MIPS_PHYS_TO_KSEG1(start);
+ endaddr = (void*)MIPS_PHYS_TO_KSEG1(end);
+
+#define DRAM_MAGIC0 0xac1dcafe
+#define DRAM_MAGIC1 0x19700220
+
+ page = startaddr;
+ if (badaddr(page, 4))
+ return;
+
+ *(volatile int *)(page+0) = DRAM_MAGIC0;
+ *(volatile int *)(page+4) = DRAM_MAGIC1;
+ wbflush();
+
+ if (*(volatile int *)(page+0) != DRAM_MAGIC0 ||
+ *(volatile int *)(page+4) != DRAM_MAGIC1)
+ return;
+
+ for (page += NBPG; page < endaddr; page += NBPG) {
+ if (badaddr(page, 4))
+ return;
+
+ if (*(volatile int *)(page+0) == DRAM_MAGIC0 &&
+ *(volatile int *)(page+4) == DRAM_MAGIC1) {
+ mem_clusters[mem_cluster_cnt].start = start;
+ mem_clusters[mem_cluster_cnt].size =
+ page - startaddr;
+ /* skip kernel area */
+ if (mem_cluster_cnt == 1)
+ mem_clusters[mem_cluster_cnt].size -= start;
+
+ mem_cluster_cnt++;
+
+ return;
+ }
+ }
+
+ /* no memory in this bank */
+ return;
}
void
@@ -238,30 +267,6 @@
goto *(u_int32_t *)MIPS_RESET_EXC_VEC;
}
-int
-tx39_find_dram(startaddr, endaddr)
- u_int32_t startaddr; /* kseg1 */
- u_int32_t endaddr; /* kseg1 */
Home |
Main Index |
Thread Index |
Old Index