Module Name:    src
Committed By:   matt
Date:           Tue Jun 14 07:53:29 UTC 2011

Modified Files:
        src/sys/arch/alpha/alpha: vm_machdep.c
        src/sys/arch/alpha/include: cpu.h

Log Message:
Add latent support for __HAVE_CPU_UAREA_ROUTINES


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/alpha/alpha/vm_machdep.c
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/alpha/include/cpu.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/alpha/alpha/vm_machdep.c
diff -u src/sys/arch/alpha/alpha/vm_machdep.c:1.107 src/sys/arch/alpha/alpha/vm_machdep.c:1.108
--- src/sys/arch/alpha/alpha/vm_machdep.c:1.107	Tue Jun  7 00:48:30 2011
+++ src/sys/arch/alpha/alpha/vm_machdep.c	Tue Jun 14 07:53:29 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.107 2011/06/07 00:48:30 matt Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.108 2011/06/14 07:53:29 matt Exp $ */
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.107 2011/06/07 00:48:30 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.108 2011/06/14 07:53:29 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -232,3 +232,58 @@
 	bp->b_data = bp->b_saveaddr;
 	bp->b_saveaddr = NULL;
 }
+
+#ifdef __HAVE_CPU_UAREA_ROUTINES
+void *
+cpu_uarea_alloc(bool system)
+{
+	struct pglist pglist;
+	int error;
+
+	/*
+	 * Allocate a new physically contiguous uarea which can be
+	 * direct-mapped.
+	 */
+	error = uvm_pglistalloc(USPACE, 0, ptoa(physmem), 0, 0, &pglist, 1, 1);
+	if (error) {
+		if (!system)
+			return NULL;
+		panic("%s: uvm_pglistalloc failed: %d", __func__, error);
+	}
+
+	/*
+	 * Get the physical address from the first page.
+	 */
+	const struct vm_page * const pg = TAILQ_FIRST(&pglist);
+	KASSERT(pg != NULL);
+	const paddr_t pa = VM_PAGE_TO_PHYS(pg);
+
+	/*
+	 * We need to return a direct-mapped VA for the pa.
+	 */
+
+	return (void *)PMAP_MAP_POOLPAGE(pa);
+}
+
+/*
+ * Return true if we freed it, false if we didn't.
+ */
+bool
+cpu_uarea_free(void *vva)
+{
+	vaddr_t va = (vaddr_t) vva;
+	if (va >= VM_MIN_KERNEL_ADDRESS && va < VM_MAX_KERNEL_ADDRESS)
+		return false;
+
+	/*
+	 * Since the pages are physically contiguous, the vm_page structurs
+	 * will be as well.
+	 */
+	struct vm_page *pg = PHYS_TO_VM_PAGE(PMAP_UNMAP_POOLPAGE(va));
+	KASSERT(pg != NULL);
+	for (size_t i = 0; i < UPAGES; i++, pg++) {
+		uvm_pagefree(pg);
+	}
+	return true;
+}
+#endif /* __HAVE_CPU_UAREA_ROUTINES */

Index: src/sys/arch/alpha/include/cpu.h
diff -u src/sys/arch/alpha/include/cpu.h:1.76 src/sys/arch/alpha/include/cpu.h:1.77
--- src/sys/arch/alpha/include/cpu.h:1.76	Tue Feb  8 20:20:07 2011
+++ src/sys/arch/alpha/include/cpu.h	Tue Jun 14 07:53:29 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.76 2011/02/08 20:20:07 rmind Exp $ */
+/* $NetBSD: cpu.h,v 1.77 2011/06/14 07:53:29 matt Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -249,6 +249,8 @@
 struct trapframe;
 
 int	badaddr(void *, size_t);
+void *	cpu_uarea_alloc(bool);
+void	cpu_uarea_free(void *);
 
 #define	cpu_idle()	/* nothing */
 

Reply via email to