Source-Changes-HG archive

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

[src/yamt-km]: src/sys/arch/pc532/pc532 - convert arch/pc532 to new apis.



details:   https://anonhg.NetBSD.org/src/rev/46d3ce38f862
branches:  yamt-km
changeset: 573320:46d3ce38f862
user:      yamt <yamt%NetBSD.org@localhost>
date:      Mon Jan 31 12:34:04 2005 +0000

description:
- convert arch/pc532 to new apis.
- simplify pmap bootstrap and pvpage allocation, following the i386 version.

diffstat:

 sys/arch/pc532/pc532/machdep.c    |   7 +-
 sys/arch/pc532/pc532/pmap.c       |  94 +++++++-------------------------------
 sys/arch/pc532/pc532/vm_machdep.c |   8 +-
 3 files changed, 26 insertions(+), 83 deletions(-)

diffs (225 lines):

diff -r 9bb851b063f2 -r 46d3ce38f862 sys/arch/pc532/pc532/machdep.c
--- a/sys/arch/pc532/pc532/machdep.c    Mon Jan 31 12:25:33 2005 +0000
+++ b/sys/arch/pc532/pc532/machdep.c    Mon Jan 31 12:34:04 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.158 2004/03/24 15:34:51 atatat Exp $     */
+/*     $NetBSD: machdep.c,v 1.158.10.1 2005/01/31 12:34:04 yamt Exp $  */
 
 /*-
  * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.158 2004/03/24 15:34:51 atatat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.158.10.1 2005/01/31 12:34:04 yamt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -194,7 +194,8 @@
        /*
         * Initialize error message buffer (at end of core).
         */
-       msgbuf_vaddr =  uvm_km_valloc(kernel_map, ns532_round_page(MSGBUFSIZE));
+       msgbuf_vaddr =  uvm_km_alloc(kernel_map, ns532_round_page(MSGBUFSIZE),
+           0, UVM_KMF_VAONLY);
        if (msgbuf_vaddr == 0)
                panic("failed to valloc msgbuf_vaddr");
 
diff -r 9bb851b063f2 -r 46d3ce38f862 sys/arch/pc532/pc532/pmap.c
--- a/sys/arch/pc532/pc532/pmap.c       Mon Jan 31 12:25:33 2005 +0000
+++ b/sys/arch/pc532/pc532/pmap.c       Mon Jan 31 12:34:04 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.75 2005/01/01 21:00:06 yamt Exp $   */
+/*     $NetBSD: pmap.c,v 1.75.4.1 2005/01/31 12:34:04 yamt Exp $       */
 
 /*
  *
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.75 2005/01/01 21:00:06 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.75.4.1 2005/01/31 12:34:04 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -302,8 +302,6 @@
 static struct pv_pagelist pv_freepages;        /* list of pv_pages with free entrys */
 static struct pv_pagelist pv_unusedpgs; /* list of unused pv_pages */
 static int pv_nfpvents;                        /* # of free pv entries */
-static struct pv_page *pv_initpage;    /* bootstrap page from kernel_map */
-static vaddr_t pv_cachedva;            /* cached VA for later use */
 
 #define PVE_LOWAT (PVE_PER_PVPAGE / 2) /* free pv_entry low water mark */
 #define PVE_HIWAT (PVE_LOWAT + (PVE_PER_PVPAGE * 2))
@@ -807,7 +805,8 @@
        s = (vsize_t) (sizeof(struct pv_head) * npages +
                       sizeof(*(vm_physmem[0].pmseg.attrs)) * npages);
        s = round_page(s); /* round up */
-       addr = (vaddr_t) uvm_km_zalloc(kernel_map, s);
+       addr = (vaddr_t) uvm_km_alloc(kernel_map, s, 0,
+           UVM_KMF_WIRED | UVM_KMF_ZERO);
        if (addr == 0)
                panic("pmap_init: unable to allocate pv_heads");
 
@@ -834,20 +833,7 @@
                                 (vm_physmem[lcv].end - vm_physmem[lcv].start));
        }
 
-       /*
-        * now we need to free enough pv_entry structures to allow us to get
-        * the kmem_map/kmem_object allocated and inited (done after this
-        * function is finished).  to do this we allocate one bootstrap page out
-        * of kernel_map and use it to provide an initial pool of pv_entry
-        * structures.   we never free this page.
-        */
-
-       pv_initpage = (struct pv_page *) uvm_km_alloc(kernel_map, PAGE_SIZE);
-       if (pv_initpage == NULL)
-               panic("pmap_init: pv_initpage");
-       pv_cachedva = 0;   /* a VA we have allocated but not used yet */
        pv_nfpvents = 0;
-       (void) pmap_add_pvpage(pv_initpage, FALSE);
 
        /*
         * done: pmap module is up (and ready for business)
@@ -945,7 +931,6 @@
        struct pmap *pmap;
        int mode;
 {
-       struct vm_page *pg;
        struct pv_page *pvpage;
        struct pv_entry *pv;
        int s;
@@ -975,36 +960,19 @@
        }
 
        /*
-        *  see if we've got a cached unmapped VA that we can map a page in.
-        * if not, try to allocate one.
-        */
-
-       if (pv_cachedva == 0) {
-               s = splvm();   /* must protect kmem_map with splvm! */
-               pv_cachedva = uvm_km_kmemalloc(kmem_map, NULL, PAGE_SIZE,
-                   UVM_KMF_TRYLOCK|UVM_KMF_VALLOC);
-               splx(s);
-               if (pv_cachedva == 0) {
-                       return (NULL);
-               }
-       }
-       pg = uvm_pagealloc(NULL, pv_cachedva - vm_map_min(kernel_map), NULL,
-           UVM_PGA_USERESERVE);
-       if (pg == NULL)
-               return (NULL);
-       pg->flags &= ~PG_BUSY;  /* never busy */
-
-       /*
         * add a mapping for our new pv_page and free its entrys (save one!)
         *
         * NOTE: If we are allocating a PV page for the kernel pmap, the
         * pmap is already locked!  (...but entering the mapping is safe...)
         */
 
-       pmap_kenter_pa(pv_cachedva, VM_PAGE_TO_PHYS(pg), VM_PROT_ALL);
-       pmap_update(pmap_kernel());
-       pvpage = (struct pv_page *)pv_cachedva;
-       pv_cachedva = 0;
+       s = splvm();   /* must protect kmem_map with splvm! */
+       pvpage = (struct pv_page *)uvm_km_alloc(kmem_map, PAGE_SIZE, 0,
+           UVM_KMF_TRYLOCK|UVM_KMF_NOWAIT|UVM_KMF_WIRED);
+       splx(s);
+       if (pvpage == NULL)
+               return NULL;
+
        return (pmap_add_pvpage(pvpage, mode != ALLOCPV_NONEED));
 }
 
@@ -1146,43 +1114,17 @@
 pmap_free_pvpage()
 {
        int s;
-       struct vm_map *map;
-       struct vm_map_entry *dead_entries;
        struct pv_page *pvp;
 
-       s = splvm(); /* protect kmem_map */
        pvp = TAILQ_FIRST(&pv_unusedpgs);
-
-       /*
-        * note: watch out for pv_initpage which is allocated out of
-        * kernel_map rather than kmem_map.
-        */
-
-       if (pvp == pv_initpage)
-               map = kernel_map;
-       else
-               map = kmem_map;
-       if (vm_map_lock_try(map)) {
-
-               /* remove pvp from pv_unusedpgs */
-               TAILQ_REMOVE(&pv_unusedpgs, pvp, pvinfo.pvpi_list);
-
-               /* unmap the page */
-               dead_entries = NULL;
-               uvm_unmap_remove(map, (vaddr_t)pvp, ((vaddr_t)pvp) + PAGE_SIZE,
-                   &dead_entries, NULL);
-               vm_map_unlock(map);
-
-               if (dead_entries != NULL)
-                       uvm_unmap_detach(dead_entries, 0);
-
-               pv_nfpvents -= PVE_PER_PVPAGE;  /* update free count */
-       }
-       if (pvp == pv_initpage)
-               /* no more initpage, we've freed it */
-               pv_initpage = NULL;
-
+       /* remove pvp from pv_unusedpgs */
+       TAILQ_REMOVE(&pv_unusedpgs, pvp, pvinfo.pvpi_list);
+
+       s = splvm();
+       uvm_km_free(kmem_map, (vaddr_t)pvp, PAGE_SIZE, UVM_KMF_WIRED);
        splx(s);
+
+       pv_nfpvents -= PVE_PER_PVPAGE;  /* update free count */
 }
 
 /*
diff -r 9bb851b063f2 -r 46d3ce38f862 sys/arch/pc532/pc532/vm_machdep.c
--- a/sys/arch/pc532/pc532/vm_machdep.c Mon Jan 31 12:25:33 2005 +0000
+++ b/sys/arch/pc532/pc532/vm_machdep.c Mon Jan 31 12:34:04 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vm_machdep.c,v 1.62 2004/09/17 14:11:21 skrll Exp $    */
+/*     $NetBSD: vm_machdep.c,v 1.62.6.1 2005/01/31 12:34:04 yamt Exp $ */
 
 /*-
  * Copyright (c) 1982, 1986 The Regents of the University of California.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.62 2004/09/17 14:11:21 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.62.6.1 2005/01/31 12:34:04 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -357,7 +357,7 @@
        faddr = trunc_page((vaddr_t)bp->b_saveaddr = bp->b_data);
        off = (vaddr_t)bp->b_data - faddr;
        len = round_page(off + len);
-       taddr= uvm_km_valloc_wait(phys_map, len);
+       taddr= uvm_km_alloc(phys_map, len, 0, UVM_KMF_VAONLY | UVM_KMF_WAITVA);
        bp->b_data = (caddr_t)(taddr + off);
        /*
         * The region is locked, so we expect that pmap_pte() will return
@@ -399,7 +399,7 @@
        len = round_page(off + len);
        pmap_kremove(addr, len);
        pmap_update(pmap_kernel());
-       uvm_km_free_wakeup(phys_map, addr, len);
+       uvm_km_free(phys_map, addr, len, UVM_KMF_VAONLY);
        bp->b_data = bp->b_saveaddr;
        bp->b_saveaddr = 0;
 }



Home | Main Index | Thread Index | Old Index