svn commit: r269331 - in projects/arm64/sys/arm64: arm64 include

Andrew Turner andrew at FreeBSD.org
Thu Jul 31 13:02:57 UTC 2014


Author: andrew
Date: Thu Jul 31 13:02:56 2014
New Revision: 269331
URL: http://svnweb.freebsd.org/changeset/base/269331

Log:
  Fix the attribute, we should now be using normal memory in pmap when backed
  by physical memory. While here add pmap_kenter_device to insert a page of
  device memory.

Modified:
  projects/arm64/sys/arm64/arm64/pmap.c
  projects/arm64/sys/arm64/include/pmap.h

Modified: projects/arm64/sys/arm64/arm64/pmap.c
==============================================================================
--- projects/arm64/sys/arm64/arm64/pmap.c	Thu Jul 31 13:00:42 2014	(r269330)
+++ projects/arm64/sys/arm64/arm64/pmap.c	Thu Jul 31 13:02:56 2014	(r269331)
@@ -56,6 +56,13 @@ __FBSDID("$FreeBSD$");
 #define PMAP_INLINE
 #endif
 
+/*
+ * These are configured by the mair_el1 register. This is set up in locore.S
+ */
+#define	DEVICE_MEMORY	0
+#define	UNCACHED_MEMORY	1
+#define	CACHED_MEMORY	2
+
 vm_offset_t virtual_avail;	/* VA of first avail page (after kernel bss) */
 vm_offset_t virtual_end;	/* VA of last avail page (end of kernel AS) */
 vm_offset_t kernel_vm_end = 0;
@@ -168,7 +175,12 @@ pmap_bootstrap_dmap(vm_offset_t l1pt)
 	    pa += L1_SIZE, va += L1_SIZE, l1_slot++) {
 		KASSERT(l1_slot < Ln_ENTRIES, ("Invalid L1 index"));
 
-		l1[l1_slot] = (pa & ~L1_OFFSET) | ATTR_AF | L1_BLOCK;
+		/*
+		 * TODO: Turn the cache on here when we have cache
+		 * flushing code.
+		 */
+		l1[l1_slot] = (pa & ~L1_OFFSET) | ATTR_AF | L1_BLOCK |
+		    ATTR_IDX(UNCACHED_MEMORY);
 	}
 }
 
@@ -306,7 +318,12 @@ pmap_bootstrap(vm_offset_t l1pt, vm_padd
 			    ("Physical slot too small"));
 		}
 
-		l2[l2_slot] = (pa & ~L2_OFFSET) | ATTR_AF | L2_BLOCK;
+		/*
+		 * TODO: Turn the cache on here when we have cache
+		 * flushing code.
+		 */
+		l2[l2_slot] = (pa & ~L2_OFFSET) | ATTR_AF | L2_BLOCK |
+		    ATTR_IDX(UNCACHED_MEMORY);
 
 		va += L2_SIZE;
 		pa += L2_SIZE;
@@ -472,7 +489,7 @@ pmap_extract_and_hold(pmap_t pmap, vm_of
  * This function may be used before pmap_bootstrap() is called.
  */
 PMAP_INLINE void 
-pmap_kenter(vm_offset_t va, vm_paddr_t pa)
+pmap_kenter_internal(vm_offset_t va, vm_paddr_t pa, int type)
 {
 	pt_entry_t *l3;
 
@@ -482,7 +499,24 @@ pmap_kenter(vm_offset_t va, vm_paddr_t p
 
 	l3 = pmap_l3(kernel_pmap, va);
 	KASSERT(l3 != NULL, ("Invalid page table"));
-	*l3 = (pa & ~L3_OFFSET) | ATTR_AF | L3_PAGE;
+	*l3 = (pa & ~L3_OFFSET) | ATTR_AF | L3_PAGE | ATTR_IDX(type);
+}
+
+void
+pmap_kenter(vm_offset_t va, vm_paddr_t pa)
+{
+
+	/*
+	 * TODO: Turn the cache on here when we have cache flushing code.
+	 */
+	pmap_kenter_internal(va, pa, UNCACHED_MEMORY);
+}
+
+void
+pmap_kenter_device(vm_offset_t va, vm_paddr_t pa)
+{
+
+	pmap_kenter_internal(va, pa, DEVICE_MEMORY);
 }
 
 /*

Modified: projects/arm64/sys/arm64/include/pmap.h
==============================================================================
--- projects/arm64/sys/arm64/include/pmap.h	Thu Jul 31 13:00:42 2014	(r269330)
+++ projects/arm64/sys/arm64/include/pmap.h	Thu Jul 31 13:02:56 2014	(r269331)
@@ -121,7 +121,8 @@ extern vm_offset_t virtual_end;
 	((((va) | (pa)) & L1_OFFSET) == 0 && (size) >= L1_SIZE)
 
 void	pmap_bootstrap(vm_offset_t, vm_paddr_t, vm_size_t);
-void	pmap_kenter(vm_offset_t va, vm_paddr_t pa);
+void	pmap_kenter(vm_offset_t, vm_paddr_t);
+void	pmap_kenter_device(vm_offset_t, vm_paddr_t);
 vm_paddr_t pmap_kextract(vm_offset_t va);
 void	pmap_kremove(vm_offset_t);
 


More information about the svn-src-projects mailing list