summaryrefslogtreecommitdiff
path: root/hw/kdrive/src
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2000-11-29 08:42:25 +0000
committerKeith Packard <keithp@keithp.com>2000-11-29 08:42:25 +0000
commit5f8e75f27d49719f5fd07d48481435f93779da6c (patch)
tree96558e45d0498c22dbf32820e33a7cf016d13c13 /hw/kdrive/src
parent02568ec5a8f278faaa26c973fcb424da3fd31f2b (diff)
kdrive: add MTRR support, add clock support to trident driverxf-4_0_1g
Diffstat (limited to 'hw/kdrive/src')
-rw-r--r--hw/kdrive/src/kdrive.h12
-rw-r--r--hw/kdrive/src/kmap.c70
2 files changed, 81 insertions, 1 deletions
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index e6dedbafb..c9e53fe3d 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.8 2000/09/22 06:25:29 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.10 2000/09/27 20:47:37 keithp Exp $ */
#include <stdio.h>
#include "X.h"
@@ -562,12 +562,22 @@ extern KdKeyboardFuncs VxWorksKeyboardFuncs;
extern KdOsFuncs VxWorksFuncs;
/* kmap.c */
+
+#define KD_MAPPED_MODE_REGISTERS 0
+#define KD_MAPPED_MODE_FRAMEBUFFER 1
+
void *
KdMapDevice (CARD32 addr, CARD32 size);
void
KdUnmapDevice (void *addr, CARD32 size);
+void
+KdSetMappedMode (CARD32 addr, CARD32 size, int mode);
+
+void
+KdResetMappedMode (CARD32 addr, CARD32 size, int mode);
+
/* kmode.c */
const KdMonitorTiming *
KdFindMode (KdScreenInfo *screen,
diff --git a/hw/kdrive/src/kmap.c b/hw/kdrive/src/kmap.c
index 5dc0481a4..e0d615576 100644
--- a/hw/kdrive/src/kmap.c
+++ b/hw/kdrive/src/kmap.c
@@ -29,6 +29,7 @@
#include <errno.h>
#include <unistd.h>
#include <sys/mman.h>
+#include <asm/mtrr.h>
#endif
void *
@@ -90,3 +91,72 @@ KdUnmapDevice (void *addr, CARD32 size)
#endif
}
+#ifdef linux
+static int mtrr;
+#endif
+
+void
+KdSetMappedMode (CARD32 addr, CARD32 size, int mode)
+{
+#ifdef linux
+ struct mtrr_sentry sentry;
+ unsigned long base, bound;
+ unsigned int type;
+
+ if (addr < 0x100000)
+ return;
+ if (!mtrr)
+ mtrr = open ("/proc/mtrr", 2);
+ if (mtrr > 0)
+ {
+ base = addr & ~((1<22)-1);
+ bound = ((addr + size) + ((1<<22) - 1)) & ~((1<<22) - 1);
+ switch (mode) {
+ case KD_MAPPED_MODE_REGISTERS:
+ type = MTRR_TYPE_UNCACHABLE;
+ break;
+ case KD_MAPPED_MODE_FRAMEBUFFER:
+ type = MTRR_TYPE_WRCOMB;
+ break;
+ }
+ sentry.base = base;
+ sentry.size = bound - base;
+ sentry.type = type;
+
+ ioctl (mtrr, MTRRIOC_ADD_ENTRY, &sentry);
+ }
+#endif
+}
+
+void
+KdResetMappedMode (CARD32 addr, CARD32 size, int mode)
+{
+#ifdef linux
+ struct mtrr_sentry sentry;
+ unsigned long base, bound;
+ unsigned int type;
+
+ if (addr < 0x100000)
+ return;
+ if (!mtrr)
+ mtrr = open ("/proc/mtrr", 2);
+ if (mtrr > 0)
+ {
+ base = addr & ~((1<22)-1);
+ bound = ((addr + size) + ((1<<22) - 1)) & ~((1<<22) - 1);
+ switch (mode) {
+ case KD_MAPPED_MODE_REGISTERS:
+ type = MTRR_TYPE_UNCACHABLE;
+ break;
+ case KD_MAPPED_MODE_FRAMEBUFFER:
+ type = MTRR_TYPE_WRCOMB;
+ break;
+ }
+ sentry.base = base;
+ sentry.size = bound - base;
+ sentry.type = type;
+
+ ioctl (mtrr, MTRRIOC_DEL_ENTRY, &sentry);
+ }
+#endif
+}