From: kettenis Date: Mon, 22 Jun 2015 18:57:26 +0000 (+0000) Subject: Make it possible to create write combing mappings through /dev/mem. This is X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e1ad8ac791551d94856dd12b38f2b84b7e1a1f21;p=openbsd 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@ --- 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 * 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;