Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Jun 2015 22:01:35 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r284169 - head/tools/bus_space
Message-ID:  <201506082201.t58M1Zdr086934@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Mon Jun  8 22:01:34 2015
New Revision: 284169
URL: https://svnweb.freebsd.org/changeset/base/284169

Log:
  Map the allocated DMA memory into the address space.

Modified:
  head/tools/bus_space/busdma.c

Modified: head/tools/bus_space/busdma.c
==============================================================================
--- head/tools/bus_space/busdma.c	Mon Jun  8 21:47:44 2015	(r284168)
+++ head/tools/bus_space/busdma.c	Mon Jun  8 22:01:34 2015	(r284169)
@@ -61,7 +61,9 @@ struct obj {
 			unsigned long	datarate;
 		} tag;
 		struct {
-		} md;
+			unsigned long	physaddr;
+			void		*virtaddr;
+		} mem;
 	} u;
 };
 
@@ -260,6 +262,10 @@ bd_mem_alloc(int tid, u_int flags)
 	md->parent = tag;
 	tag->refcnt++;
 	md->key = ioc.result;
+	md->u.mem.physaddr = ioc.u.mem.physaddr;
+	md->u.mem.virtaddr = mmap(NULL, tag->u.tag.maxsz,
+	    PROT_READ | PROT_WRITE, MAP_NOCORE | MAP_SHARED, md->fd,
+	    md->u.mem.physaddr);
 	return (md->oid);
 }
 
@@ -273,6 +279,8 @@ bd_mem_free(int mdid)
 	if (md == NULL)
 		return (errno);
 
+	if (md->u.mem.virtaddr != MAP_FAILED)
+		munmap(md->u.mem.virtaddr, md->parent->u.tag.maxsz);
 	memset(&ioc, 0, sizeof(ioc));
 	ioc.request = PROTO_IOC_BUSDMA_MEM_FREE;
 	ioc.key = md->key;



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