Subject: footbridge vs. mmap
To: None <port-arm@netbsd.org>
From: Valeriy E. Ushakov <uwe@stderr.spb.ru>
List: port-arm
Date: 06/26/2007 15:35:37
--cWoXeonUoKmBZSoM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

netwinder needs this for igsfb @ pci @ footbridge.  This has been
sitting in my tree for quite some time and I forgot to commit it
before 4.0.  Without it mmapping igsfb triggers bs_notimpl panic.

Ok to commit and pull up?

PS: Does anyone run netwinder?  Mine is very unstable.  It boots one
time out of 10, wedging randomly, and mmapping/accessing igsfb usually
causes a hang too.

SY, Uwe
-- 
uwe@stderr.spb.ru                       |       Zu Grunde kommen
http://snark.ptc.spbu.ru/~uwe/          |       Ist zu Grunde gehen

--cWoXeonUoKmBZSoM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="footbridge_io.c-diff"

Index: footbridge_io.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/footbridge/footbridge_io.c,v
retrieving revision 1.12
diff -u --unified -r1.12 footbridge_io.c
--- footbridge_io.c	24 Nov 2005 13:08:32 -0000	1.12
+++ footbridge_io.c	26 Jun 2007 11:29:45 -0000
@@ -56,6 +56,7 @@
 bs_protos(bs_notimpl);
 bs_map_proto(footbridge_mem);
 bs_unmap_proto(footbridge_mem);
+bs_mmap_proto(footbridge_mem);
 
 /* Declare the footbridge bus space tag */
 
@@ -151,6 +152,7 @@
 	*t = footbridge_bs_tag;
 	t->bs_map = footbridge_mem_bs_map;
 	t->bs_unmap = footbridge_mem_bs_unmap;
+	t->bs_mmap = footbridge_mem_bs_mmap;
 	t->bs_cookie = cookie;
 }
 
@@ -329,3 +331,21 @@
 	int flags;
 {
 }	
+
+
+paddr_t
+footbridge_mem_bs_mmap(void *t, bus_addr_t addr, off_t offset,
+		       int prot, int flags)
+{
+	paddr_t pa;
+
+	if (addr >= DC21285_PCI_MEM_SIZE
+	    || offset < 0
+	    || offset >= DC21285_PCI_MEM_SIZE
+	    || addr >= DC21285_PCI_MEM_SIZE - offset)
+		return -1;
+
+	pa = DC21285_PCI_MEM_BASE + addr + offset;
+
+	return arm_ptob(pa);
+}

--cWoXeonUoKmBZSoM--