Module Name:    src
Committed By:   matt
Date:           Thu Dec 31 00:54:10 UTC 2009

Modified Files:
        src/sys/arch/algor/algor [matt-nb5-mips64]: interrupt.c machdep.c
        src/sys/arch/algor/include [matt-nb5-mips64]: vmparam.h
        src/sys/arch/arc/include [matt-nb5-mips64]: vmparam.h
        src/sys/arch/evbmips/adm5120 [matt-nb5-mips64]: machdep.c
        src/sys/arch/evbmips/alchemy [matt-nb5-mips64]: machdep.c
        src/sys/arch/evbmips/atheros [matt-nb5-mips64]: machdep.c
        src/sys/arch/evbmips/include [matt-nb5-mips64]: vmparam.h
        src/sys/arch/evbmips/malta [matt-nb5-mips64]: machdep.c
        src/sys/arch/evbmips/rmixl [matt-nb5-mips64]: machdep.c
        src/sys/arch/mips/include [matt-nb5-mips64]: pmap.h
        src/sys/arch/mips/mips [matt-nb5-mips64]: mips_machdep.c
        src/sys/arch/pmax/include [matt-nb5-mips64]: vmparam.h
        src/sys/arch/pmax/pmax [matt-nb5-mips64]: machdep.c
        src/sys/arch/sbmips/sbmips [matt-nb5-mips64]: machdep.c

Log Message:
Use mips_page_physload and mips_init_lwp0_uarea.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.18.1 src/sys/arch/algor/algor/interrupt.c
cvs rdiff -u -r1.38.10.3 -r1.38.10.4 src/sys/arch/algor/algor/machdep.c
cvs rdiff -u -r1.1 -r1.1.148.1 src/sys/arch/algor/include/vmparam.h
cvs rdiff -u -r1.9 -r1.9.96.1 src/sys/arch/arc/include/vmparam.h
cvs rdiff -u -r1.6.10.1 -r1.6.10.2 src/sys/arch/evbmips/adm5120/machdep.c
cvs rdiff -u -r1.37.10.1 -r1.37.10.2 src/sys/arch/evbmips/alchemy/machdep.c
cvs rdiff -u -r1.13.10.1 -r1.13.10.2 src/sys/arch/evbmips/atheros/machdep.c
cvs rdiff -u -r1.1.142.2 -r1.1.142.3 src/sys/arch/evbmips/include/vmparam.h
cvs rdiff -u -r1.28.10.2 -r1.28.10.3 src/sys/arch/evbmips/malta/machdep.c
cvs rdiff -u -r1.1.2.10 -r1.1.2.11 src/sys/arch/evbmips/rmixl/machdep.c
cvs rdiff -u -r1.54.26.2 -r1.54.26.3 src/sys/arch/mips/include/pmap.h
cvs rdiff -u -r1.205.4.1.2.1.2.18 -r1.205.4.1.2.1.2.19 \
    src/sys/arch/mips/mips/mips_machdep.c
cvs rdiff -u -r1.14 -r1.14.148.1 src/sys/arch/pmax/include/vmparam.h
cvs rdiff -u -r1.223.8.1.2.3 -r1.223.8.1.2.4 src/sys/arch/pmax/pmax/machdep.c
cvs rdiff -u -r1.38.10.4 -r1.38.10.5 src/sys/arch/sbmips/sbmips/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/algor/algor/interrupt.c
diff -u src/sys/arch/algor/algor/interrupt.c:1.13 src/sys/arch/algor/algor/interrupt.c:1.13.18.1
--- src/sys/arch/algor/algor/interrupt.c:1.13	Mon Apr 28 20:23:10 2008
+++ src/sys/arch/algor/algor/interrupt.c	Thu Dec 31 00:54:08 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: interrupt.c,v 1.13 2008/04/28 20:23:10 martin Exp $	*/
+/*	$NetBSD: interrupt.c,v 1.13.18.1 2009/12/31 00:54:08 matt Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.13 2008/04/28 20:23:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.13.18.1 2009/12/31 00:54:08 matt Exp $");
 
 #include "opt_algor_p4032.h"
 #include "opt_algor_p5064.h" 
@@ -109,7 +109,7 @@
 }
 
 void
-cpu_intr(u_int32_t status, u_int32_t cause, u_int32_t pc, u_int32_t ipending)
+cpu_intr(u_int32_t status, u_int32_t cause, vaddr_t pc, u_int32_t ipending)
 {
 	struct clockframe cf;
 	struct cpu_info *ci;

Index: src/sys/arch/algor/algor/machdep.c
diff -u src/sys/arch/algor/algor/machdep.c:1.38.10.3 src/sys/arch/algor/algor/machdep.c:1.38.10.4
--- src/sys/arch/algor/algor/machdep.c:1.38.10.3	Wed Sep 16 03:44:59 2009
+++ src/sys/arch/algor/algor/machdep.c	Thu Dec 31 00:54:08 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.38.10.3 2009/09/16 03:44:59 matt Exp $	*/
+/*	$NetBSD: machdep.c,v 1.38.10.4 2009/12/31 00:54:08 matt Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -106,7 +106,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.38.10.3 2009/09/16 03:44:59 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.38.10.4 2009/12/31 00:54:08 matt Exp $");
 
 #include "opt_algor_p4032.h"
 #include "opt_algor_p5064.h" 
@@ -209,11 +209,9 @@
 {
 	extern char kernel_text[], edata[], end[];
 	vaddr_t kernstart, kernend;
-	paddr_t kernstartpfn, kernendpfn, pfn0, pfn1;
 	vsize_t size;
 	const char *cp;
 	char *cp0;
-	void *v;
 	size_t i;
 
 	/* Disable interrupts. */
@@ -235,9 +233,6 @@
 	led_display('p', 'g', 's', 'z');
 	uvm_setpagesize();
 
-	kernstartpfn = atop(MIPS_KSEG0_TO_PHYS(kernstart));
-	kernendpfn   = atop(MIPS_KSEG0_TO_PHYS(kernend));
-
 	/*
 	 * Initialize bus space tags and bring up the console.
 	 */
@@ -505,57 +500,19 @@
 	led_display('v', 'm', 'p', 'g');
 	for (i = 0; i < mem_cluster_cnt; i++) {
 		physmem += atop(mem_clusters[i].size);
-		pfn0 = atop(mem_clusters[i].start);
-		pfn1 = pfn0 + atop(mem_clusters[i].size);
-		if (pfn0 <= kernstartpfn && kernendpfn <= pfn1) {
-			/*
-			 * Must compute the location of the kernel
-			 * within the segment.
-			 */
-#if 1
-			printf("Cluster %zu contains kernel\n", i);
-#endif
-			if (pfn0 < kernstartpfn) {
-				/*
-				 * There is a chunk before the kernel.
-				 */
-#if 1
-				printf("Loading chunk before kernel: "
-				    "%#"PRIxPADDR" / %#"PRIxPADDR"\n",
-				    pfn0, kernstartpfn);
-#endif
-				uvm_page_physload(pfn0, kernstartpfn,
-				    pfn0, kernstartpfn, VM_FREELIST_DEFAULT);
-			}
-			if (kernendpfn < pfn1) {
-				/*
-				 * There is a chunk after the kernel.
-				 */
-#if 1
-				printf("Loading chunk after kernel: "
-				    "%#"PRIxPADDR" / %#"PRIxPADDR"\n",
-				    kernendpfn, pfn1);
-#endif
-				uvm_page_physload(kernendpfn, pfn1,
-				    kernendpfn, pfn1, VM_FREELIST_DEFAULT);
-			}
-		} else {
-			/*
-			 * Just load this cluster as one chunk.
-			 */
-#if 1
-			printf("Loading cluster %zu: %#"PRIxPADDR
-			    " / %#"PRIxPADDR"\n", i, pfn0, pfn1);
-#endif
-			uvm_page_physload(pfn0, pfn1, pfn0, pfn1,
-			    VM_FREELIST_DEFAULT);
-		}
 	}
-
 	if (physmem == 0)
 		panic("can't happen: system seems to have no memory!");
 	maxmem = physmem;
 
+	static const struct mips_vmfreelist isadma = {
+		.fl_start = 8*1024*1024,
+		.fl_end = 16*1024*1024,
+		.fl_freelist = VM_FREELIST_ISADMA,
+	};
+	mips_page_physload(kernstart, kernend,
+	    mem_clusters, mem_cluster_cnt, &isadma, 1);
+
 	/*
 	 * Initialize message buffer (at end of core).
 	 */
@@ -571,17 +528,7 @@
 	 * Init mapping for u page(s) for lwp0.
 	 */
 	led_display('u', 's', 'p', 'c');
-	v = (void *) uvm_pageboot_alloc(USPACE);
-	lwp0.l_addr = proc0paddr = (struct user *) v;
-	lwp0.l_md.md_regs = (struct frame *)((char*)v + USPACE) - 1;
-#ifdef _LP64
-	lwp0.l_md.md_regs->f_regs[_R_SR] = MIPS_SR_KX;
-#endif
-	proc0paddr->u_pcb.pcb_context.val[_L_SR] =
-#ifdef _LP64
-	    MIPS_SR_KX |
-#endif
-	    MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */
+	mips_init_lwp0_uarea();
 
 	/*
 	 * Initialize debuggers, and break into them, if appropriate.

Index: src/sys/arch/algor/include/vmparam.h
diff -u src/sys/arch/algor/include/vmparam.h:1.1 src/sys/arch/algor/include/vmparam.h:1.1.148.1
--- src/sys/arch/algor/include/vmparam.h:1.1	Mon May 28 16:22:20 2001
+++ src/sys/arch/algor/include/vmparam.h	Thu Dec 31 00:54:08 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.1 2001/05/28 16:22:20 thorpej Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.1.148.1 2009/12/31 00:54:08 matt Exp $	*/
 
 #ifndef _ALGOR_VMPARAM_H_
 #define _ALGOR_VMPARAM_H_
@@ -10,10 +10,8 @@
  * DMA (it's limited to 8MB on the Algorithmics P-5064, for example,
  * starting at 8MB).
  */
-#define	VM_NFREELIST		2
-#define	VM_FREELIST_DEFAULT	0
+#define	VM_PHYSSEG_MAX		2
 #define	VM_FREELIST_ISADMA	1
 
-#define	VM_PHYSSEG_MAX		2
 
 #endif	/* !_ALGOR_VMPARAM_H_ */

Index: src/sys/arch/arc/include/vmparam.h
diff -u src/sys/arch/arc/include/vmparam.h:1.9 src/sys/arch/arc/include/vmparam.h:1.9.96.1
--- src/sys/arch/arc/include/vmparam.h:1.9	Sun Dec 11 12:16:39 2005
+++ src/sys/arch/arc/include/vmparam.h	Thu Dec 31 00:54:08 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.9 2005/12/11 12:16:39 christos Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.9.96.1 2009/12/31 00:54:08 matt Exp $	*/
 /*	$OpenBSD: vmparam.h,v 1.3 1997/04/19 17:19:59 pefo Exp $	*/
 /*	NetBSD: vmparam.h,v 1.5 1994/10/26 21:10:10 cgd Exp 	*/
 
@@ -14,11 +14,9 @@
 /*
  * Maximum number of contigous physical memory segment.
  */
+#undef	VM_PHYSSEG_MAX
 #define	VM_PHYSSEG_MAX		16
 
-#define	VM_NFREELIST		1
-#define	VM_FREELIST_DEFAULT	0
-
 #ifndef KSEG2IOBUFSIZE
 #define KSEG2IOBUFSIZE	kseg2iobufsize	/* reserve PTEs for KSEG2 I/O space */
 

Index: src/sys/arch/evbmips/adm5120/machdep.c
diff -u src/sys/arch/evbmips/adm5120/machdep.c:1.6.10.1 src/sys/arch/evbmips/adm5120/machdep.c:1.6.10.2
--- src/sys/arch/evbmips/adm5120/machdep.c:1.6.10.1	Mon Sep  7 23:20:28 2009
+++ src/sys/arch/evbmips/adm5120/machdep.c	Thu Dec 31 00:54:08 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.6.10.1 2009/09/07 23:20:28 matt Exp $ */
+/* $NetBSD: machdep.c,v 1.6.10.2 2009/12/31 00:54:08 matt Exp $ */
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -107,7 +107,7 @@
  */
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.6.10.1 2009/09/07 23:20:28 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.6.10.2 2009/12/31 00:54:08 matt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -162,13 +162,15 @@
 struct	user *proc0paddr;
 
 /* Our exported CPU info; we can have only one. */  
-struct cpu_info cpu_info_store;
+struct cpu_info cpu_info_store = {
+	.ci_curlwp = &lwp0,
+};
 
 /* Maps for VM objects. */
 struct vm_map *mb_map = NULL;
 struct vm_map *phys_map = NULL;
 
-int physmem;		/* # pages of physical memory */
+int physmem;			/* # pages of physical memory */
 int maxmem;			/* max memory per process */
 
 int mem_cluster_cnt;
@@ -313,8 +315,6 @@
 	struct adm5120_config *admc = &adm5120_configuration;
 	uint32_t memsize;
 	vaddr_t kernend;
-	u_long first, last;
-	vaddr_t v;
 
 	extern char edata[], end[];	/* XXX */
 
@@ -419,10 +419,8 @@
 	/*
 	 * 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);
+	uvm_page_physload(MIPS_KSEG0_START, kernend,
+	   mem_clusters, mem_cluster_cnt, NULL, 0);
 
 	/*
 	 * Initialize message buffer (at end of core).
@@ -437,17 +435,7 @@
 	/*
 	 * Init mapping for u page(s) for proc0.
 	 */
-	v = uvm_pageboot_alloc(USPACE);
-	lwp0.l_addr = proc0paddr = (struct user *)v;
-	lwp0.l_md.md_regs = (struct frame *)(v + USPACE) - 1;
-#ifdef _LP64
-	lwp0.l_md.md_regs->f_regs[_R_SR] = MIPS_SR_KX;
-#endif
-	lwp0.l_addr->u_pcb.pcb_context.val[_L_SR] =
-#ifdef _LP64
-	    MIPS_SR_KX |
-#endif
-	    MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */
+	mips_init_lwp0_uarea();
 
 	/*
 	 * Initialize debuggers, and break into them, if appropriate.

Index: src/sys/arch/evbmips/alchemy/machdep.c
diff -u src/sys/arch/evbmips/alchemy/machdep.c:1.37.10.1 src/sys/arch/evbmips/alchemy/machdep.c:1.37.10.2
--- src/sys/arch/evbmips/alchemy/machdep.c:1.37.10.1	Mon Sep  7 23:20:28 2009
+++ src/sys/arch/evbmips/alchemy/machdep.c	Thu Dec 31 00:54:09 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.37.10.1 2009/09/07 23:20:28 matt Exp $ */
+/* $NetBSD: machdep.c,v 1.37.10.2 2009/12/31 00:54:09 matt Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -107,7 +107,7 @@
  */
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.37.10.1 2009/09/07 23:20:28 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.37.10.2 2009/12/31 00:54:09 matt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -161,16 +161,11 @@
 
 #include "ohci.h"
 
-struct	user *proc0paddr;
-
-/* Our exported CPU info; we can have only one. */  
-struct cpu_info cpu_info_store;
-
 /* Maps for VM objects. */
 struct vm_map *mb_map = NULL;
 struct vm_map *phys_map = NULL;
 
-int physmem;		/* # pages of physical memory */
+int physmem;			/* # pages of physical memory */
 int maxmem;			/* max memory per process */
 
 int mem_cluster_cnt;
@@ -187,8 +182,6 @@
 	bus_space_handle_t sh;
 	void *kernend;
 	const char *cp;
-	u_long first, last;
-	void *v;
 	int freqok, howto, i;
 	const struct alchemy_board *board;
 
@@ -345,10 +338,8 @@
 	/*
 	 * 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);
+	mips_add_physload(MIPS_KSEG0_START, kernend, 
+	    mem_clusters, mem_cluster_cnt, NULL, 0);
 
 	/*
 	 * Initialize message buffer (at end of core).
@@ -363,17 +354,7 @@
 	/*
 	 * Init mapping for u page(s) for proc0.
 	 */
-	v = (void *) uvm_pageboot_alloc(USPACE);
-	lwp0.l_addr = proc0paddr = (struct user *)v;
-	lwp0.l_md.md_regs = (struct frame *)((char *)v + USPACE) - 1;
-#ifdef _LP64
-	lwp0.l_md.md_regs->f_regs[_R_SR] = MIPS_SR_KX;
-#endif
-	lwp0.l_addr->u_pcb.pcb_context.val[_L_SR] =
-#ifdef _LP64
-	    MIPS_SR_KX |
-#endif
-	    MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */
+	mips_init_lwp0_uarea();
 
 	/*
 	 * Initialize debuggers, and break into them, if appropriate.

Index: src/sys/arch/evbmips/atheros/machdep.c
diff -u src/sys/arch/evbmips/atheros/machdep.c:1.13.10.1 src/sys/arch/evbmips/atheros/machdep.c:1.13.10.2
--- src/sys/arch/evbmips/atheros/machdep.c:1.13.10.1	Mon Sep  7 23:20:29 2009
+++ src/sys/arch/evbmips/atheros/machdep.c	Thu Dec 31 00:54:09 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.13.10.1 2009/09/07 23:20:29 matt Exp $ */
+/* $NetBSD: machdep.c,v 1.13.10.2 2009/12/31 00:54:09 matt Exp $ */
 
 /*
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -147,7 +147,7 @@
  */
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.13.10.1 2009/09/07 23:20:29 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.13.10.2 2009/12/31 00:54:09 matt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -182,16 +182,11 @@
 #include <mips/atheros/include/ar531xvar.h>
 #include <mips/atheros/include/arbusvar.h>
 
-struct	user *proc0paddr;
-
-/* Our exported CPU info; we can have only one. */  
-struct cpu_info cpu_info_store;
-
 /* Maps for VM objects. */
 struct vm_map *mb_map = NULL;
 struct vm_map *phys_map = NULL;
 
-int physmem;		/* # pages of physical memory */
+int physmem;			/* # pages of physical memory */
 int maxmem;			/* max memory per process */
 
 int mem_cluster_cnt;
@@ -289,12 +284,10 @@
 	mem_cluster_cnt++;
 
 	/*
-	 * Load the rest of the available pages into the VM system.
+	 * Load 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);
+	mips_add_physload(MIPS_KSEG0_START, kernend,
+	    mem_clusters, mem_cluster_cnt, NULL, 0);
 
 	/*
 	 * Initialize message buffer (at end of core).
@@ -309,17 +302,7 @@
 	/*
 	 * Init mapping for u page(s) for proc0.
 	 */
-	v = (void *) uvm_pageboot_alloc(USPACE);
-	lwp0.l_addr = proc0paddr = (struct user *)v;
-	lwp0.l_md.md_regs = (struct frame *)((char *)v + USPACE) - 1;
-#ifdef _LP64
-	lwp0.l_md.md_regs->f_regs[_R_SR] = MIPS_SR_KX;
-#endif
-	lwp0.l_addr->u_pcb.pcb_context.val[_L_SR] =
-#ifdef _LP64
-	    MIPS_SR_KX |
-#endif
-	    MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */
+	mips_init_lwp0_uarea();
 
 	/*
 	 * Initialize busses.
@@ -337,9 +320,9 @@
 	 * PROM.  VxWorks bootloader seems to leave one set.
 	 */ 
 	__asm volatile (
-		"mtc0	$0, $" ___STRING(MIPS_COP_0_WATCH_LO) " \n\t"
+		"mtc0	$0, $%0\n\t"
 		"nop\n\t"
-		"nop\n\t");
+		"nop\n\t" :: "n"(MIPS_COP_0_WATCH_LO));
 
 	/*
 	 * Initialize debuggers, and break into them, if appropriate.

Index: src/sys/arch/evbmips/include/vmparam.h
diff -u src/sys/arch/evbmips/include/vmparam.h:1.1.142.2 src/sys/arch/evbmips/include/vmparam.h:1.1.142.3
--- src/sys/arch/evbmips/include/vmparam.h:1.1.142.2	Fri Dec 11 20:22:15 2009
+++ src/sys/arch/evbmips/include/vmparam.h	Thu Dec 31 00:54:09 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.1.142.2 2009/12/11 20:22:15 matt Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.1.142.3 2009/12/31 00:54:09 matt Exp $	*/
 
 #ifndef _EVBMIPS_VMPARAM_H_
 #define _EVBMIPS_VMPARAM_H_
@@ -6,5 +6,14 @@
 #include <mips/vmparam.h>
 
 #define	VM_PHYSSEG_MAX		32
+
+#undef VMFREELIST_MAX
+#define	VMFREELIST_MAX		3
+#if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64)
+#define	VMFREELIST_FIRST4G	2
+#endif
+#if !defined(_LP64)
+#define	VMFREELIST_FIRST512M	1
+#endif
  
 #endif	/* !_EVBMIPS_VMPARAM_H_ */

Index: src/sys/arch/evbmips/malta/machdep.c
diff -u src/sys/arch/evbmips/malta/machdep.c:1.28.10.2 src/sys/arch/evbmips/malta/machdep.c:1.28.10.3
--- src/sys/arch/evbmips/malta/machdep.c:1.28.10.2	Mon Sep  7 23:20:29 2009
+++ src/sys/arch/evbmips/malta/machdep.c	Thu Dec 31 00:54:09 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.28.10.2 2009/09/07 23:20:29 matt Exp $	*/
+/*	$NetBSD: machdep.c,v 1.28.10.3 2009/12/31 00:54:09 matt Exp $	*/
 
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
@@ -112,7 +112,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.28.10.2 2009/09/07 23:20:29 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.28.10.3 2009/12/31 00:54:09 matt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
@@ -164,9 +164,6 @@
 /* For sysctl_hw. */
 extern char cpu_model[];
 
-/* Our exported CPU info; we can have only one. */  
-struct cpu_info cpu_info_store;
-
 /* Maps for VM objects. */
 struct vm_map *mb_map = NULL;
 struct vm_map *phys_map = NULL;
@@ -189,8 +186,6 @@
  */
 int	safepri = MIPS1_PSL_LOWIPL;
 
-extern struct user *proc0paddr;
-
 /*
  * Do all the stuff that locore normally does before calling main().
  */
@@ -198,11 +193,10 @@
 mach_init(int argc, char **argv, yamon_env_var *envp, u_long memsize)
 {
 	struct malta_config *mcp = &malta_configuration;
+	uint8_t * const brkres = (uint8_t *)MIPS_PHYS_TO_KSEG1(MALTA_BRKRES);
 	bus_space_handle_t sh;
-	void *kernend, *v;
-        u_long first, last;
+	void *kernend;
 	int freqok;
-	uint8_t *brkres = (uint8_t *)MIPS_PHYS_TO_KSEG1(MALTA_BRKRES);
 
 	extern char edata[], end[];
 
@@ -308,10 +302,8 @@
 	/*
 	 * 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);
+	mips_page_physload(MIPS_KSEG0_START, (vaddr_t)kernend,
+	    mem_clusters, mem_cluster_cnt, NULL, 0);
 
 	/*
 	 * Initialize error message buffer (at end of core).
@@ -323,17 +315,7 @@
 	/*
 	 * Allocate space for proc0's USPACE.
 	 */
-	v = (void *)uvm_pageboot_alloc(USPACE); 
-	lwp0.l_addr = proc0paddr = (struct user *)v;
-	lwp0.l_md.md_regs = (struct frame *)((char *)v + USPACE) - 1;
-#ifdef _LP64
-	lwp0.l_md.md_regs->f_regs[_R_SR] = MIPS_SR_KX;
-#endif
-	proc0paddr->u_pcb.pcb_context.val[_L_SR] =
-#ifdef _LP64
-	    MIPS_SR_KX |
-#endif
-	    MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */
+	mips_init_lwp0_uarea();
 
 	/*
 	 * Initialize debuggers, and break into them, if appropriate.

Index: src/sys/arch/evbmips/rmixl/machdep.c
diff -u src/sys/arch/evbmips/rmixl/machdep.c:1.1.2.10 src/sys/arch/evbmips/rmixl/machdep.c:1.1.2.11
--- src/sys/arch/evbmips/rmixl/machdep.c:1.1.2.10	Mon Dec 14 07:23:31 2009
+++ src/sys/arch/evbmips/rmixl/machdep.c	Thu Dec 31 00:54:09 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.1.2.10 2009/12/14 07:23:31 cliff Exp $	*/
+/*	$NetBSD: machdep.c,v 1.1.2.11 2009/12/31 00:54:09 matt Exp $	*/
 
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
@@ -112,7 +112,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.1.2.10 2009/12/14 07:23:31 cliff Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.1.2.11 2009/12/31 00:54:09 matt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_com.h"
@@ -258,8 +258,6 @@
  */
 int	safepri = MIPS1_PSL_LOWIPL;
 
-extern struct user *proc0paddr;
-
 /*
  * Do all the stuff that locore normally does before calling main().
  */
@@ -267,7 +265,7 @@
 mach_init(int argc, int32_t *argv, void *envp, int64_t infop)
 {
 	struct rmixl_config *rcp = &rmixl_configuration;
-	void *kernend, *v;
+	void *kernend;
 	u_long memsize;
 	u_int vm_cluster_cnt;
 	uint32_t r;
@@ -381,17 +379,8 @@
 	/*
 	 * Load vm_clusters[] into the VM system.
 	 */
-	for (u_int i=0; i < vm_cluster_cnt; i++) {
-		u_quad_t first, last;
-
-		first = trunc_page(vm_clusters[i].start);
-		last = round_page(vm_clusters[i].start + vm_clusters[i].size);
-		DPRINTF(("%s: %d: %#"PRIx64", %#"PRIx64"\n",
-			__func__, i, first, last));
-
-		uvm_page_physload(atop(first), atop(last), atop(first),
-			atop(last), VM_FREELIST_DEFAULT);
-	}
+	mips_page_physload(MIPS_KSEG0_START, (vaddr_t) kernend,
+	    vm_clusters, vm_cluster_cnt, NULL, 0);
 
 	/*
 	 * Initialize error message buffer (at end of core).
@@ -403,18 +392,7 @@
 	/*
 	 * Allocate space for proc0's USPACE.
 	 */
-	v = (void *)uvm_pageboot_alloc(USPACE); 
-	lwp0.l_addr = proc0paddr = (struct user *)v;
-	lwp0.l_md.md_regs = (struct frame *)((char *)v + USPACE) - 1;
-#ifdef _LP64
-        lwp0.l_md.md_regs->f_regs[_R_SR] = MIPS_SR_KX;
-#endif
-        proc0paddr->u_pcb.pcb_context.val[_L_SR] =
-#ifdef _LP64
-            MIPS_SR_KX |
-#endif  
-            MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */
-
+	mips_init_lwp0_uarea();
 
 	/*
 	 * Initialize debuggers, and break into them, if appropriate.

Index: src/sys/arch/mips/include/pmap.h
diff -u src/sys/arch/mips/include/pmap.h:1.54.26.2 src/sys/arch/mips/include/pmap.h:1.54.26.3
--- src/sys/arch/mips/include/pmap.h:1.54.26.2	Wed Dec 30 04:51:26 2009
+++ src/sys/arch/mips/include/pmap.h	Thu Dec 31 00:54:09 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.54.26.2 2009/12/30 04:51:26 matt Exp $	*/
+/*	$NetBSD: pmap.h,v 1.54.26.3 2009/12/31 00:54:09 matt Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -75,7 +75,7 @@
 #define	_MIPS_PMAP_H_
 
 #include <mips/cpuregs.h>	/* for KSEG0 below */
-#include <mips/pte.h>
+//#include <mips/pte.h>
 
 /*
  * The user address space is 2Gb (0x0 - 0x80000000).
@@ -111,10 +111,10 @@
 };
 
 struct pmap;
-typedef bool (*pte_callback_t)(struct pmap *, vaddr_t, vaddr_t, pt_entry_t *,
-	uintptr_t);
-pt_entry_t *pmap_pte_lookup(struct pmap *, vaddr_t);
-pt_entry_t *pmap_pte_reserve(struct pmap *, vaddr_t, int);
+typedef bool (*pte_callback_t)(struct pmap *, vaddr_t, vaddr_t,
+	union pt_entry *, uintptr_t);
+union pt_entry *pmap_pte_lookup(struct pmap *, vaddr_t);
+union pt_entry *pmap_pte_reserve(struct pmap *, vaddr_t, int);
 void pmap_pte_process(struct pmap *, vaddr_t, vaddr_t, pte_callback_t,
 	uintptr_t);
 void pmap_segtab_activate(struct lwp *);

Index: src/sys/arch/mips/mips/mips_machdep.c
diff -u src/sys/arch/mips/mips/mips_machdep.c:1.205.4.1.2.1.2.18 src/sys/arch/mips/mips/mips_machdep.c:1.205.4.1.2.1.2.19
--- src/sys/arch/mips/mips/mips_machdep.c:1.205.4.1.2.1.2.18	Wed Dec 30 04:51:26 2009
+++ src/sys/arch/mips/mips/mips_machdep.c	Thu Dec 31 00:54:09 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mips_machdep.c,v 1.205.4.1.2.1.2.18 2009/12/30 04:51:26 matt Exp $	*/
+/*	$NetBSD: mips_machdep.c,v 1.205.4.1.2.1.2.19 2009/12/31 00:54:09 matt Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -112,7 +112,7 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.205.4.1.2.1.2.18 2009/12/30 04:51:26 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.205.4.1.2.1.2.19 2009/12/31 00:54:09 matt Exp $");
 
 #include "opt_cputype.h"
 #include "opt_compat_netbsd32.h"
@@ -1657,8 +1657,8 @@
 	const phys_ram_seg_t *segs, size_t nseg,
 	const struct mips_vmfreelist *flp, size_t nfl)
 {
-	const paddr_t kernstart = MIPS_KSEG0_TO_PHYS(vkernstart);
-	const paddr_t kernend = MIPS_KSEG0_TO_PHYS(vkernend);
+	const paddr_t kernstart = MIPS_KSEG0_TO_PHYS(trunc_page(vkernstart));
+	const paddr_t kernend = MIPS_KSEG0_TO_PHYS(round_page(vkernend));
 #if defined(VM_FREELIST_FIRST4G) || defined(VM_FREELIST_FIRST512M)
 #ifdef VM_FREELIST_FIRST512M
 	bool need512m = false;
@@ -1690,7 +1690,25 @@
 		 * piecemeal.
 		 */
 		phys_ram_seg_t tmp = *segs++;
-		printf("phys segment: %#"PRIxPADDR"@%#"PRIxPADDR"\n", tmp.size, tmp.start);
+		printf("phys segment: %#"PRIxPADDR"@%#"PRIxPADDR"\n",
+		    (paddr_t)tmp.size,
+		    (paddr_t)tmp.start);
+
+		/*
+		 * Make sure everything is in page units.
+		 */
+		tmp.size = round_page(tmp.start + tmp.size) - trunc_page(tmp.start) ;
+		tmp.start = trunc_page(tmp.start);
+
+		/*
+		 * Page 0 is reserved for exception vectors.
+		 */
+		if (tmp.start == 0) {
+			tmp.start = PAGE_SIZE;
+			tmp.size -= PAGE_SIZE;
+			if (tmp.size == 0)
+				continue;
+		}
 		while (tmp.size > 0) {
 			int freelist = -1;	/* unknown freelist */
 			psize_t segsize = tmp.size;
@@ -1786,7 +1804,9 @@
 			paddr_t first = atop(tmp.start);
 			paddr_t last = first + atop(segsize);
 			printf("adding %#"PRIxPADDR"@%#"PRIxPADDR" to freelist %d\n",
-				tmp.start, tmp.start + segsize, freelist);
+			
+			    (paddr_t)tmp.start, (paddr_t)tmp.start + segsize,
+			    freelist);
 			uvm_page_physload(first, last, first, last, freelist);
 
 			/*

Index: src/sys/arch/pmax/include/vmparam.h
diff -u src/sys/arch/pmax/include/vmparam.h:1.14 src/sys/arch/pmax/include/vmparam.h:1.14.148.1
--- src/sys/arch/pmax/include/vmparam.h:1.14	Fri Aug 24 15:33:17 2001
+++ src/sys/arch/pmax/include/vmparam.h	Thu Dec 31 00:54:09 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.14 2001/08/24 15:33:17 mhitch Exp $	*/
+/*	$NetBSD: vmparam.h,v 1.14.148.1 2009/12/31 00:54:09 matt Exp $	*/
 
 #ifndef _PMAX_VMPARAM_H_
 #define _PMAX_VMPARAM_H_
@@ -11,10 +11,9 @@
  * to DMA into this region, and we want them to have a fighting chance of
  * allocating their DMA memory during autoconfiguration.
  */
+#define	VM_PHYSSEG_MAX		16
+#undef VM_NFREELIST
 #define	VM_NFREELIST		2
-#define	VM_FREELIST_DEFAULT	0
 #define	VM_FREELIST_FIRST8	1
 
-#define	VM_PHYSSEG_MAX		16	/* 15 + 1 free lists */
-
 #endif	/* !_PMAX_VMPARAM_H_ */

Index: src/sys/arch/pmax/pmax/machdep.c
diff -u src/sys/arch/pmax/pmax/machdep.c:1.223.8.1.2.3 src/sys/arch/pmax/pmax/machdep.c:1.223.8.1.2.4
--- src/sys/arch/pmax/pmax/machdep.c:1.223.8.1.2.3	Wed Sep 16 19:23:18 2009
+++ src/sys/arch/pmax/pmax/machdep.c	Thu Dec 31 00:54:09 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.223.8.1.2.3 2009/09/16 19:23:18 matt Exp $	*/
+/*	$NetBSD: machdep.c,v 1.223.8.1.2.4 2009/12/31 00:54:09 matt Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.223.8.1.2.3 2009/09/16 19:23:18 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.223.8.1.2.4 2009/12/31 00:54:09 matt Exp $");
 
 #include "fs_mfs.h"
 #include "opt_ddb.h"
@@ -198,7 +198,6 @@
 {
 	char *cp;
 	const char *bootinfo_msg;
-	u_long first, last;
 	int i;
 	char *kernend;
 #if NKSYMS || defined(DDB) || defined(LKM)
@@ -355,23 +354,6 @@
 #endif
 
 	/*
-	 * Alloc u pages for proc0 stealing KSEG0 memory.
-	 */
-	lwp0.l_addr = proc0paddr = (struct user *)kernend;
-	lwp0.l_md.md_regs = (struct frame *)(kernend + USPACE) - 1;
-	memset(lwp0.l_addr, 0, USPACE);
-#ifdef _LP64
-	lwp0.l_md.md_regs->f_regs[_R_SR] = MIPS_SR_KX;
-#endif
-	lwp0.l_addr->u_pcb.pcb_context.val[_L_SR] =
-#ifdef _LP64
-	    MIPS_SR_KX |
-#endif
-	    MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */
-
-	kernend += USPACE;
-
-	/*
 	 * Initialize physmem_boardmax; assume no SIMM-bank limits.
 	 * Adjust later in model-specific code if necessary.
 	 */
@@ -403,22 +385,18 @@
 	 * allocating their DMA memory during autoconfiguration.
 	 */
 	for (i = 0, physmem = 0; i < mem_cluster_cnt; ++i) {
-		first = mem_clusters[i].start;
-		if (first == 0)
-			first = round_page(MIPS_KSEG0_TO_PHYS(kernend));
-		last = mem_clusters[i].start + mem_clusters[i].size;
 		physmem += atop(mem_clusters[i].size);
-		if (i != 0 || last <= (8 * 1024 * 1024)) {
-			uvm_page_physload(atop(first), atop(last), atop(first),
-			    atop(last), VM_FREELIST_DEFAULT);
-		} else {
-			uvm_page_physload(atop(first), atop(8 * 1024 * 1024),
-			    atop(first), atop(8 * 1024 * 1024), VM_FREELIST_FIRST8);
-			uvm_page_physload(atop(8 * 1024 * 1024), atop(last),
-			    atop(8 * 1024 * 1024), atop(last), VM_FREELIST_DEFAULT);
-		}
 	}
 
+	static const struct mips_vmfreelist first8 = {
+		.fl_start = 0,
+		.fl_end = 8 * 1024 * 1024,
+		.fl_freelist = VM_FREELIST_FIRST8
+	};
+	mips_page_physload(MIPS_KSEG0_START, (vaddr_t)kernend,
+	    mem_clusters, mem_cluster_cnt, &first8, 1);
+		
+
 	/*
 	 * Initialize error message buffer (at end of core).
 	 */
@@ -428,6 +406,11 @@
 	 * Initialize the virtual memory system.
 	 */
 	pmap_bootstrap();
+
+	/*
+	 * Alloc u pages for proc0 stealing KSEG0 memory.
+	 */
+	mips_init_lwp0_uarea();
 }
 
 void

Index: src/sys/arch/sbmips/sbmips/machdep.c
diff -u src/sys/arch/sbmips/sbmips/machdep.c:1.38.10.4 src/sys/arch/sbmips/sbmips/machdep.c:1.38.10.5
--- src/sys/arch/sbmips/sbmips/machdep.c:1.38.10.4	Tue Dec  8 07:44:44 2009
+++ src/sys/arch/sbmips/sbmips/machdep.c	Thu Dec 31 00:54:09 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.38.10.4 2009/12/08 07:44:44 cyber Exp $ */
+/* $NetBSD: machdep.c,v 1.38.10.5 2009/12/31 00:54:09 matt Exp $ */
 
 /*
  * Copyright 2000, 2001
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.38.10.4 2009/12/08 07:44:44 cyber Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.38.10.5 2009/12/31 00:54:09 matt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_ddbparam.h"       /* for SYMTAB_SPACE */
@@ -158,12 +158,11 @@
 void
 mach_init(long fwhandle, long magic, long bootdata, long reserved)
 {
-	void *kernend, *p0;
-	u_long first, last;
+	void *kernend;
 	extern char edata[], end[];
-	int i;
 	uint32_t config;
 	struct bootinfo_v1 *tmp_bi;
+	int i;
 
 	/* XXX this code must run on the target CPU */
 	config = mips3_cp0_config_read();
@@ -172,11 +171,7 @@
 	mips3_cp0_config_write(config);
 
 	/* Zero BSS.  XXXCGD: uh, is this really necessary still?  */
-#ifdef _LP64
-	memset((char *)((vaddr_t)edata | 0xffffffff00000000), 0, end - edata);
-#else
 	memset(edata, 0, end - edata);
-#endif
 
 	/*
 	 * Copy the bootinfo structure from the boot loader.
@@ -316,39 +311,21 @@
 
 	/*
 	 * Load the rest of the available pages into the VM system.
-	 * The first chunk is tricky because we have to avoid the
-	 * kernel, but the rest are easy.
 	 */
-	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);
-
-	for (i = 1; i < mem_cluster_cnt; i++) {
-		first = round_page(mem_clusters[i].start);
-		last = mem_clusters[i].start + mem_clusters[i].size;
-		uvm_page_physload(atop(first), atop(last), atop(first),
-		    atop(last), VM_FREELIST_DEFAULT);
-	}
+	mips_page_physload(MIPS_KSEG0_START, (vaddr_t) kernend,
+	    mem_clusters, mem_cluster_cnt, NULL, 0);
 
 	/*
 	 * Initialize error message buffer (at end of core).
 	 */
 	mips_init_msgbuf();
 
+	pmap_bootstrap();
+
 	/*
 	 * Allocate space for proc0's USPACE
 	 */
-	p0 = (void *)pmap_steal_memory(USPACE, NULL, NULL);
-	lwp0.l_addr = proc0paddr = (struct user *)p0;
-	lwp0.l_md.md_regs = (struct frame *)((char *)p0 + USPACE) - 1;
-	lwp0.l_addr->u_pcb.pcb_context.val[_L_SR] =
-#ifdef _LP64
-	    MIPS_SR_KX |
-#endif
-	    MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */
-
-	pmap_bootstrap();
+	mips_init_lwp0_uarea();
 
 	/*
 	 * Initialize debuggers, and break into them, if appropriate.

Reply via email to