Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Jun 2018 16:07:35 +0000 (UTC)
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r335446 - in head/sys: arm64/arm64 arm64/include kern
Message-ID:  <201806201607.w5KG7ZvL013716@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: manu
Date: Wed Jun 20 16:07:35 2018
New Revision: 335446
URL: https://svnweb.freebsd.org/changeset/base/335446

Log:
  Add pmap_mapdev_attr for arm64
  
  This is needed for efifb.
  arm and ricv pmap (the two arch with arm64 that uses subr_devmap) have very
  different implementation so for now only add this for arm64.
  
  Tested with efifb on Pine64 with a few other patches.
  
  Reviewed by:	cognet
  Differential Revision:	https://reviews.freebsd.org/D15294

Modified:
  head/sys/arm64/arm64/pmap.c
  head/sys/arm64/include/pmap.h
  head/sys/kern/subr_devmap.c

Modified: head/sys/arm64/arm64/pmap.c
==============================================================================
--- head/sys/arm64/arm64/pmap.c	Wed Jun 20 15:27:09 2018	(r335445)
+++ head/sys/arm64/arm64/pmap.c	Wed Jun 20 16:07:35 2018	(r335446)
@@ -1142,7 +1142,7 @@ pmap_kextract(vm_offset_t va)
  * Low level mapping routines.....
  ***************************************************/
 
-static void
+void
 pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode)
 {
 	pd_entry_t *pde;

Modified: head/sys/arm64/include/pmap.h
==============================================================================
--- head/sys/arm64/include/pmap.h	Wed Jun 20 15:27:09 2018	(r335445)
+++ head/sys/arm64/include/pmap.h	Wed Jun 20 16:07:35 2018	(r335446)
@@ -140,10 +140,12 @@ extern vm_offset_t virtual_end;
 	((((va) | (pa)) & L1_OFFSET) == 0 && (size) >= L1_SIZE)
 
 void	pmap_bootstrap(vm_offset_t, vm_offset_t, vm_paddr_t, vm_size_t);
+void	pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode);
 void	pmap_kenter_device(vm_offset_t, vm_size_t, vm_paddr_t);
 vm_paddr_t pmap_kextract(vm_offset_t va);
 void	pmap_kremove(vm_offset_t);
 void	pmap_kremove_device(vm_offset_t, vm_size_t);
+void	*pmap_mapdev_attr(vm_offset_t pa, vm_size_t size, vm_memattr_t ma);
 
 void	*pmap_mapdev(vm_offset_t, vm_size_t);
 void	*pmap_mapbios(vm_paddr_t, vm_size_t);

Modified: head/sys/kern/subr_devmap.c
==============================================================================
--- head/sys/kern/subr_devmap.c	Wed Jun 20 15:27:09 2018	(r335445)
+++ head/sys/kern/subr_devmap.c	Wed Jun 20 16:07:35 2018	(r335446)
@@ -287,6 +287,37 @@ pmap_mapdev(vm_offset_t pa, vm_size_t size)
 	return ((void *)(va + offset));
 }
 
+#if defined(__aarch64__)
+void *
+pmap_mapdev_attr(vm_offset_t pa, vm_size_t size, vm_memattr_t ma)
+{
+	vm_offset_t va, offset;
+	void * rva;
+
+	/* First look in the static mapping table. */
+	if ((rva = devmap_ptov(pa, size)) != NULL)
+		return (rva);
+
+	offset = pa & PAGE_MASK;
+	pa = trunc_page(pa);
+	size = round_page(size + offset);
+
+	if (early_boot) {
+		akva_devmap_vaddr = trunc_page(akva_devmap_vaddr - size);
+		va = akva_devmap_vaddr;
+		KASSERT(va >= VM_MAX_KERNEL_ADDRESS - L2_SIZE,
+		    ("Too many early devmap mappings"));
+	} else
+		va = kva_alloc(size);
+	if (!va)
+		panic("pmap_mapdev: Couldn't alloc kernel virtual memory");
+
+	pmap_kenter(va, size, pa, ma);
+
+	return ((void *)(va + offset));
+}
+#endif
+
 /*
  * Unmap device memory and free the kva space.
  */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806201607.w5KG7ZvL013716>