Module Name:    src
Committed By:   matt
Date:           Tue Jan 10 18:01:09 UTC 2012

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

Log Message:
Allow access to KSEGX from /dev/mem


To generate a diff of this commit:
cvs rdiff -u -r1.35.38.7 -r1.35.38.8 src/sys/arch/mips/mips/mem.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/mem.c
diff -u src/sys/arch/mips/mips/mem.c:1.35.38.7 src/sys/arch/mips/mips/mem.c:1.35.38.8
--- src/sys/arch/mips/mips/mem.c:1.35.38.7	Tue Nov 29 07:48:31 2011
+++ src/sys/arch/mips/mips/mem.c	Tue Jan 10 18:01:09 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem.c,v 1.35.38.7 2011/11/29 07:48:31 matt Exp $	*/
+/*	$NetBSD: mem.c,v 1.35.38.8 2012/01/10 18:01:09 matt Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -44,7 +44,7 @@
 #include "opt_mips_cache.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.35.38.7 2011/11/29 07:48:31 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.35.38.8 2012/01/10 18:01:09 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -107,12 +107,20 @@ mmrw(dev_t dev, struct uio *uio, int fla
 			/*
 			 * XXX Broken; assumes contiguous physical memory.
 			 */
+#ifdef _LP64
 			if (v + c > ctob(physmem))
 				return (EFAULT);
-#ifdef _LP64
 			v = MIPS_PHYS_TO_XKPHYS_CACHED(v);
 #else
-			v = MIPS_PHYS_TO_KSEG0(v);
+			if (MIPS_KSEG0_P(v + c - 1)) {
+				v = MIPS_PHYS_TO_KSEG0(v);
+#ifdef ENABLE_MIPS_KSEGX
+			} else if (mips_ksegx_start <= v
+			    && v + c <= mips_ksegx_start + VM_KSEGX_SIZE) {
+				v += VM_KSEGX_ADDRESS - mips_ksegx_start;
+#endif
+			} else
+				return (EFAULT);
 #endif
 			error = uiomove((void *)v, c, uio);
 #if defined(MIPS3_PLUS)

Reply via email to