i386: Copy pmap_mapdev_uncacheable() from x86_64
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 4 May 2011 03:46:05 +0000 (11:46 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 4 May 2011 03:46:05 +0000 (11:46 +0800)
sys/platform/pc32/i386/pmap.c
sys/platform/pc32/include/pmap.h

index 25816c5..a3f5238 100644 (file)
@@ -3313,6 +3313,35 @@ pmap_mapdev(vm_paddr_t pa, vm_size_t size)
        return ((void *)(va + offset));
 }
 
+void *
+pmap_mapdev_uncacheable(vm_paddr_t pa, vm_size_t size)
+{
+       vm_offset_t va, tmpva, offset;
+       unsigned *pte;
+
+       offset = pa & PAGE_MASK;
+       size = roundup(offset + size, PAGE_SIZE);
+
+       va = kmem_alloc_nofault(&kernel_map, size, PAGE_SIZE);
+       if (va == 0) {
+               panic("pmap_mapdev_uncacheable: "
+                   "Couldn't alloc kernel virtual memory");
+       }
+
+       pa = pa & PG_FRAME;
+       for (tmpva = va; size > 0;) {
+               pte = (unsigned *)vtopte(tmpva);
+               *pte = pa | PG_RW | PG_V | PG_N; /* | pgeflag; */
+               size -= PAGE_SIZE;
+               tmpva += PAGE_SIZE;
+               pa += PAGE_SIZE;
+       }
+       cpu_invltlb();
+       smp_invltlb();
+
+       return ((void *)(va + offset));
+}
+
 /*
  * No requirements.
  */
index 37d0355..dbbe40a 100644 (file)
@@ -286,6 +286,7 @@ extern char *ptvmmap;               /* poor name! */
 void   pmap_interlock_wait (struct vmspace *);
 void   pmap_bootstrap (vm_paddr_t, vm_paddr_t);
 void   *pmap_mapdev (vm_paddr_t, vm_size_t);
+void   *pmap_mapdev_uncacheable (vm_paddr_t, vm_size_t);
 void   pmap_unmapdev (vm_offset_t, vm_size_t);
 unsigned *pmap_kernel_pte (vm_offset_t) __pure2;
 struct vm_page *pmap_use_pt (pmap_t, vm_offset_t);