summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2015-06-22 18:57:27 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2015-06-22 18:57:27 +0000
commit1846105a39682b697de44a3ef9a9949dcf027e31 (patch)
treec833e706aecf066b27a07f7ca599f461c6ac1763
parentb25f077a9359f739876ecddad42e647692465ec4 (diff)
Make it possible to create write combing mappings through /dev/mem. This is
done by introducining a magic offset. Pages below this offset are mapped with default memory attributes. Above this offset pages are mapped write combining. ok mlarkin@
-rw-r--r--sys/arch/amd64/amd64/mem.c6
-rw-r--r--sys/arch/i386/i386/mem.c6
-rw-r--r--sys/sys/memrange.h5
3 files changed, 14 insertions, 3 deletions
diff --git a/sys/arch/amd64/amd64/mem.c b/sys/arch/amd64/amd64/mem.c
index 49b96c243e1..3ed095ec4c9 100644
--- a/sys/arch/amd64/amd64/mem.c
+++ b/sys/arch/amd64/amd64/mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.c,v 1.24 2015/05/28 20:53:05 jcs Exp $ */
+/* $OpenBSD: mem.c,v 1.25 2015/06/22 18:57:26 kettenis Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1986, 1990, 1993
@@ -205,6 +205,10 @@ mmmmap(dev_t dev, off_t off, int prot)
#ifdef APERTURE
/* minor device 4 is aperture driver */
case 4:
+ /* Check if a write combining mapping is requested. */
+ if (off >= MEMRANGE_WC_RANGE)
+ off = (off - MEMRANGE_WC_RANGE) | PMAP_WC;
+
switch (allowaperture) {
case 1:
/* Allow mapping of the VGA framebuffer & BIOS only */
diff --git a/sys/arch/i386/i386/mem.c b/sys/arch/i386/i386/mem.c
index b45e8e04df3..d6cb3aa1879 100644
--- a/sys/arch/i386/i386/mem.c
+++ b/sys/arch/i386/i386/mem.c
@@ -1,5 +1,5 @@
/* $NetBSD: mem.c,v 1.31 1996/05/03 19:42:19 christos Exp $ */
-/* $OpenBSD: mem.c,v 1.44 2015/05/28 20:53:05 jcs Exp $ */
+/* $OpenBSD: mem.c,v 1.45 2015/06/22 18:57:26 kettenis Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1986, 1990, 1993
@@ -219,6 +219,10 @@ mmmmap(dev_t dev, off_t off, int prot)
#ifdef APERTURE
/* minor device 4 is aperture driver */
case 4:
+ /* Check if a write combining mapping is requested. */
+ if (off >= MEMRANGE_WC_RANGE)
+ off = (off - MEMRANGE_WC_RANGE) | PMAP_WC;
+
switch (allowaperture) {
case 1:
/* Allow mapping of the VGA framebuffer & BIOS only */
diff --git a/sys/sys/memrange.h b/sys/sys/memrange.h
index fc7c707361d..fe3d74725fc 100644
--- a/sys/sys/memrange.h
+++ b/sys/sys/memrange.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: memrange.h,v 1.8 2013/12/19 21:30:02 deraadt Exp $ */
+/* $OpenBSD: memrange.h,v 1.9 2015/06/22 18:57:26 kettenis Exp $ */
/*-
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
* All rights reserved.
@@ -63,6 +63,9 @@ struct mem_range_op {
#define MEMRANGE_GET _IOWR('m', 50, struct mem_range_op)
#define MEMRANGE_SET _IOW('m', 51, struct mem_range_op)
+/* Offset indicating a write combining mapping is requested. */
+#define MEMRANGE_WC_RANGE 0x4000000000000000ULL
+
#ifdef _KERNEL
struct mem_range_softc;