Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/shark/ofw Deal with non-4K page sizes.



details:   https://anonhg.NetBSD.org/src/rev/9d529339a5a5
branches:  trunk
changeset: 326932:9d529339a5a5
user:      matt <matt%NetBSD.org@localhost>
date:      Sat Feb 22 18:55:53 2014 +0000

description:
Deal with non-4K page sizes.

diffstat:

 sys/arch/shark/ofw/ofw.c |  36 +++++++++++++++++++++---------------
 1 files changed, 21 insertions(+), 15 deletions(-)

diffs (65 lines):

diff -r bc3e334829b5 -r 9d529339a5a5 sys/arch/shark/ofw/ofw.c
--- a/sys/arch/shark/ofw/ofw.c  Sat Feb 22 18:55:18 2014 +0000
+++ b/sys/arch/shark/ofw/ofw.c  Sat Feb 22 18:55:53 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ofw.c,v 1.62 2013/11/06 02:41:12 christos Exp $        */
+/*     $NetBSD: ofw.c,v 1.63 2014/02/22 18:55:53 matt Exp $    */
 
 /*
  * Copyright 1997
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw.c,v 1.62 2013/11/06 02:41:12 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw.c,v 1.63 2014/02/22 18:55:53 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1047,14 +1047,18 @@
 
                /* Install new mappings. */
                {
-                       pt_entry_t *pte = vtopte(va);
-                       int npages = size >> PGSHIFT;
-
+                       pt_entry_t *ptep = vtopte(va);
+                       KASSERT(ptep + size / L2_S_SIZE == vtopte(va + size));
+                       pt_entry_t npte = pa | L2_TYPE_S | L2_AP(ap_bits)
+                           | cb_bits;
+                       
                        ap_bits >>= 10;
-                       for (; npages > 0; pte++, pa += PAGE_SIZE, npages--)
-                               *pte = (pa | L2_AP(ap_bits) | L2_TYPE_S |
-                                   cb_bits);
-                       PTE_SYNC_RANGE(vtopte(va), size >> PGSHIFT);
+                       for (size_t npages = size >> PGSHIFT;
+                            npages-- > 0;
+                            ptep += PAGE_SIZE / L2_S_SIZE, npte += PAGE_SIZE) {
+                               l2pte_set(ptep, npte, 0);
+                       }
+                       PTE_SYNC_RANGE(vtopte(va), size >> L2_S_SHIFT);
                }
 
                /* Clean out tlb. */
@@ -1091,12 +1095,14 @@
 
                /* Zero the mappings. */
                {
-                       pt_entry_t *pte = vtopte(va);
-                       int npages = size >> PGSHIFT;
-
-                       for (; npages > 0; pte++, npages--)
-                               *pte = 0;
-                       PTE_SYNC_RANGE(vtopte(va), size >> PGSHIFT);
+                       pt_entry_t *ptep = vtopte(va);
+                       
+                       for (size_t npages = size >> PGSHIFT;
+                            npages-- > 0;
+                            ptep += PAGE_SIZE / L2_S_SIZE) {
+                               l2pte_reset(ptep);
+                       }
+                       PTE_SYNC_RANGE(vtopte(va), size >> L2_S_SHIFT);
                }
 
                /* Clean out tlb. */



Home | Main Index | Thread Index | Old Index