Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/alpha Add latent support for __HAVE_CPU_UAREA_ROUTINES



details:   https://anonhg.NetBSD.org/src/rev/71613986f2fd
branches:  trunk
changeset: 766049:71613986f2fd
user:      matt <matt%NetBSD.org@localhost>
date:      Tue Jun 14 07:53:29 2011 +0000

description:
Add latent support for __HAVE_CPU_UAREA_ROUTINES

diffstat:

 sys/arch/alpha/alpha/vm_machdep.c |  59 +++++++++++++++++++++++++++++++++++++-
 sys/arch/alpha/include/cpu.h      |   4 +-
 2 files changed, 60 insertions(+), 3 deletions(-)

diffs (95 lines):

diff -r 36208c50df2c -r 71613986f2fd sys/arch/alpha/alpha/vm_machdep.c
--- a/sys/arch/alpha/alpha/vm_machdep.c Tue Jun 14 07:49:09 2011 +0000
+++ b/sys/arch/alpha/alpha/vm_machdep.c Tue Jun 14 07:53:29 2011 +0000
@@ -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 */
diff -r 36208c50df2c -r 71613986f2fd sys/arch/alpha/include/cpu.h
--- a/sys/arch/alpha/include/cpu.h      Tue Jun 14 07:49:09 2011 +0000
+++ b/sys/arch/alpha/include/cpu.h      Tue Jun 14 07:53:29 2011 +0000
@@ -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 */
 



Home | Main Index | Thread Index | Old Index