aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar nick <nick@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-02-02 12:14:56 +0000
committerGravatar nick <nick@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-02-02 12:14:56 +0000
commit20af0a9f92ee1e796185a3bfeddc2126d7a676fe (patch)
tree929a7a91874a1b72e29bdee69a5418648ce54fee
parent1e88cc71f2b47bfc9bf6c458027a16abdaa66876 (diff)
MTRR configuring
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4477 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--libdha/Makefile2
-rw-r--r--libdha/libdha.h8
-rw-r--r--libdha/mtrr.c48
3 files changed, 57 insertions, 1 deletions
diff --git a/libdha/Makefile b/libdha/Makefile
index a1d45bf2a6..818cf1cac5 100644
--- a/libdha/Makefile
+++ b/libdha/Makefile
@@ -11,7 +11,7 @@ SHORTNAME = libdha.so
endif
LIBNAME = libdha-$(VERSION).so
-SRCS=libdha.c pci.c pci_names.c
+SRCS=libdha.c mtrr.c pci.c pci_names.c
OBJS=$(SRCS:.c=.o)
CFLAGS = $(OPTFLAGS) -fPIC -I. -I.. -Wall -W
diff --git a/libdha/libdha.h b/libdha/libdha.h
index 18c9770ee4..a3dba42a49 100644
--- a/libdha/libdha.h
+++ b/libdha/libdha.h
@@ -58,6 +58,14 @@ extern void OUTPORT32(unsigned idx,unsigned val);
extern void * map_phys_mem(unsigned base, unsigned size);
extern void unmap_phys_mem(void *ptr, unsigned size);
+/* These are the region types */
+#define MTRR_TYPE_UNCACHABLE 0
+#define MTRR_TYPE_WRCOMB 1
+#define MTRR_TYPE_WRTHROUGH 4
+#define MTRR_TYPE_WRPROT 5
+#define MTRR_TYPE_WRBACK 6
+extern int mtrr_set_type(unsigned base,unsigned size,int type);
+
#ifdef __cplusplus
}
#endif
diff --git a/libdha/mtrr.c b/libdha/mtrr.c
new file mode 100644
index 0000000000..4373b0f808
--- /dev/null
+++ b/libdha/mtrr.c
@@ -0,0 +1,48 @@
+/*
+ mtrr.c - Stuff for optimizing memory access
+ Copyrights:
+ 2002 - Linux version by Nick Kurshev
+ Licence: GPL
+*/
+
+#include "config.h"
+
+#include <stdio.h>
+#include <errno.h>
+#include "libdha.h"
+#include "AsmMacros.h"
+
+
+#if defined( __i386__ )
+int mtrr_set_type(unsigned base,unsigned size,int type)
+{
+#ifdef linux
+ FILE * mtrr_fd;
+ char * stype;
+ switch(type)
+ {
+ case MTRR_TYPE_UNCACHABLE: stype = "uncachable"; break;
+ case MTRR_TYPE_WRCOMB: stype = "write-combining"; break;
+ case MTRR_TYPE_WRTHROUGH: stype = "write-through"; break;
+ case MTRR_TYPE_WRPROT: stype = "write-protect"; break;
+ case MTRR_TYPE_WRBACK: stype = "write-back"; break;
+ default: return EINVAL;
+ }
+ mtrr_fd = fopen("/proc/mtrr","wt");
+ if(mtrr_fd)
+ {
+ fprintf(mtrr_fd,"base=0x%08X size=0x%08X type=%s\n",base,size,stype);
+ printf("base=0x%08X size=0x%08X type=%s\n",base,size,stype);
+ fclose(mtrr_fd);
+ return 0;
+ }
+ return ENOSYS;
+#else
+#warning Please port MTRR stuff!!!
+#endif
+}
+#else
+int mtrr_set_type(unsigned base,unsigned size,int type)
+{
+}
+#endif \ No newline at end of file