Module Name:    src
Committed By:   riastradh
Date:           Wed Jul 24 02:03:46 UTC 2013

Modified Files:
        src/sys/external/bsd/drm2/include/asm [riastradh-drm2]: mtrr.h

Log Message:
Partially implement Linux <asm/mtrr.h>.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/external/bsd/drm2/include/asm/mtrr.h

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

Modified files:

Index: src/sys/external/bsd/drm2/include/asm/mtrr.h
diff -u src/sys/external/bsd/drm2/include/asm/mtrr.h:1.1.2.1 src/sys/external/bsd/drm2/include/asm/mtrr.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/asm/mtrr.h:1.1.2.1	Wed Jul 24 00:33:11 2013
+++ src/sys/external/bsd/drm2/include/asm/mtrr.h	Wed Jul 24 02:03:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtrr.h,v 1.1.2.1 2013/07/24 00:33:11 riastradh Exp $	*/
+/*	$NetBSD: mtrr.h,v 1.1.2.2 2013/07/24 02:03:46 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,51 @@
 #ifndef _ASM_MTRR_H_
 #define _ASM_MTRR_H_
 
+#ifdef _KERNEL_OPT
+#include "opt_mtrr.h"
+#endif
+
+#include <machine/mtrr.h>
+
+#define	MTRR_TYPE_WRCOMB	MTRR_TYPE_WC
+
+static inline int
+mtrr_add(unsigned long base, unsigned long size, int type,
+    bool increment __unused)
+{
+#ifdef MTRR
+	struct mtrr mtrr;
+	int n = 1;
+
+	mtrr.base = base;
+	mtrr.len = size;
+	mtrr.type = type;
+	mtrr.flags = MTRR_VALID;
+
+	/* XXX errno NetBSD->Linux */
+	return -mtrr_set(&mtrr, &n, NULL, MTRR_GETSET_KERNEL);
+#else
+	return 0;
+#endif
+}
+
+static inline int
+mtrr_del(int handle __unused, unsigned long base, unsigned long size)
+{
+#ifdef MTRR
+	struct mtrr mtrr;
+	int n = 1;
+
+	mtrr.base = base;
+	mtrr.len = size;
+	mtrr.type = 0;
+	mtrr.flags = 0;		/* not MTRR_VALID */
+
+	/* XXX errno NetBSD->Linux */
+	return -mtrr_set(&mtrr, &n, NULL, MTRR_GETSET_KERNEL);
+#else
+	return 0;
+#endif
+}
+
 #endif  /* _ASM_MTRR_H_ */

Reply via email to