Module Name:    src
Committed By:   cliff
Date:           Sun Nov 15 23:09:45 UTC 2009

Modified Files:
        src/sys/arch/mips/mips [matt-nb5-mips64]:
            bus_space_alignstride_chipdep.c

Log Message:
- use (intptr_t) as needed to make int to pointer casts work for N32 and N64
- in BS(map), when not _LP64, if the bus address cannot "fit"
in KSEG0/KSEG1, then use uvm_km_alloc() and pmap_kenter_pa()
to make page table mappings.


To generate a diff of this commit:
cvs rdiff -u -r1.10.18.4 -r1.10.18.5 \
    src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c
diff -u src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c:1.10.18.4 src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c:1.10.18.5
--- src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c:1.10.18.4	Mon Nov  9 09:59:27 2009
+++ src/sys/arch/mips/mips/bus_space_alignstride_chipdep.c	Sun Nov 15 23:09:45 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space_alignstride_chipdep.c,v 1.10.18.4 2009/11/09 09:59:27 cliff Exp $ */
+/* $NetBSD: bus_space_alignstride_chipdep.c,v 1.10.18.5 2009/11/15 23:09:45 cliff Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -81,7 +81,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_space_alignstride_chipdep.c,v 1.10.18.4 2009/11/09 09:59:27 cliff Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_space_alignstride_chipdep.c,v 1.10.18.5 2009/11/15 23:09:45 cliff Exp $");
 
 #ifdef CHIP_EXTENT
 #include <sys/extent.h>
@@ -742,20 +742,43 @@
 
  mapit:
 #endif /* CHIP_EXTENT */
+
+	addr = mbst.mbst_sys_start + (addr - mbst.mbst_bus_start);
+
 #ifdef _LP64
 	if (flags & BUS_SPACE_MAP_CACHEABLE)
-		*hp = MIPS_PHYS_TO_XKPHYS_CACHED(mbst.mbst_sys_start +
-		    (addr - mbst.mbst_bus_start));
+		*hp = MIPS_PHYS_TO_XKPHYS_CACHED(addr);
 	else
-		*hp = MIPS_PHYS_TO_XKPHYS_UNCACHED(mbst.mbst_sys_start +
-		    (addr - mbst.mbst_bus_start));
+		*hp = MIPS_PHYS_TO_XKPHYS_UNCACHED(addr);
 #else
-	if (flags & BUS_SPACE_MAP_CACHEABLE)
-		*hp = MIPS_PHYS_TO_KSEG0(mbst.mbst_sys_start +
-		    (addr - mbst.mbst_bus_start));
-	else
-		*hp = MIPS_PHYS_TO_KSEG1(mbst.mbst_sys_start +
-		    (addr - mbst.mbst_bus_start));
+	if (((addr + size) & ~MIPS_PHYS_MASK) != 0) {
+		vaddr_t va;
+		paddr_t pa;
+		int s;
+
+		size = round_page((addr % PAGE_SIZE) + size);
+		va = uvm_km_alloc(kernel_map, size, PAGE_SIZE,
+			UVM_KMF_VAONLY | UVM_KMF_NOWAIT);
+		if (va == 0)
+			return ENOMEM;
+		*hp = va + (addr & PAGE_MASK);
+		pa = trunc_page(addr);
+
+		s = splhigh();
+		while (size != 0) {
+			pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE);
+			pa += PAGE_SIZE;
+			va += PAGE_SIZE;
+			size -= PAGE_SIZE;
+		}
+		pmap_update(pmap_kernel());
+		splx(s);
+	} else {
+		if (flags & BUS_SPACE_MAP_CACHEABLE)
+			*hp = MIPS_PHYS_TO_KSEG0(addr);
+		else
+			*hp = MIPS_PHYS_TO_KSEG1(addr);
+	}
 #endif
 
 	return (0);
@@ -1251,7 +1274,7 @@
 	volatile uint8_t *ptr;
 #endif	/* CHIP_ACCESS_SIZE > 1 */
 
-	ptr = (void *)(h + CHIP_OFF8(off));
+	ptr = (void *)(intptr_t)(h + CHIP_OFF8(off));
 	return *ptr & 0xff;
 }
 
@@ -1264,7 +1287,7 @@
 	volatile uint16_t *ptr;
 #endif	/* CHIP_ACCESS_SIZE > 2 */
 
-	ptr = (void *)(h + CHIP_OFF16(off));
+	ptr = (void *)(intptr_t)(h + CHIP_OFF16(off));
 	return *ptr & 0xffff;
 }
 
@@ -1277,7 +1300,7 @@
 	volatile uint32_t *ptr;
 #endif
 
-	ptr = (void *)(h + CHIP_OFF32(off));
+	ptr = (void *)(intptr_t)(h + CHIP_OFF32(off));
 	return *ptr & 0xffffffff;
 }
 
@@ -1286,7 +1309,7 @@
 {
 	volatile uint64_t *ptr;
 
-	ptr = (void *)(h + CHIP_OFF64(off));
+	ptr = (void *)(intptr_t)(h + CHIP_OFF64(off));
 	return *ptr;
 }
 
@@ -1333,7 +1356,7 @@
 	volatile uint8_t *ptr;
 #endif	/* CHIP_ACCESS_SIZE > 1 */
 
-	ptr = (void *)(h + CHIP_OFF8(off));
+	ptr = (void *)(intptr_t)(h + CHIP_OFF8(off));
 	*ptr = val;
 }
 
@@ -1347,7 +1370,7 @@
 	volatile uint16_t *ptr;
 #endif	/* CHIP_ACCESS_SIZE > 2 */
 
-	ptr = (void *)(h + CHIP_OFF16(off));
+	ptr = (void *)(intptr_t)(h + CHIP_OFF16(off));
 	*ptr = val;
 }
 
@@ -1361,7 +1384,7 @@
 	volatile uint32_t *ptr;
 #endif	/* CHIP_ACCESS_SIZE > 4 */
 
-	ptr = (void *)(h + CHIP_OFF32(off));
+	ptr = (void *)(intptr_t)(h + CHIP_OFF32(off));
 	*ptr = val;
 }
 
@@ -1371,7 +1394,7 @@
 {
 	volatile uint64_t *ptr;
 
-	ptr = (void *)(h + CHIP_OFF64(off));
+	ptr = (void *)(intptr_t)(h + CHIP_OFF64(off));
 	*ptr = val;
 }
 

Reply via email to