# HG changeset patch # User nick # Date 1012652096 0 # Node ID 0d9a096cfd465b4e94cb7cc05078a45cd5bd36bf # Parent fc81767343ea083d3730f7f9cafec3e552af5afc MTRR configuring diff -r fc81767343ea -r 0d9a096cfd46 libdha/Makefile --- a/libdha/Makefile Sat Feb 02 07:19:34 2002 +0000 +++ b/libdha/Makefile Sat Feb 02 12:14:56 2002 +0000 @@ -11,7 +11,7 @@ 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 -r fc81767343ea -r 0d9a096cfd46 libdha/libdha.h --- a/libdha/libdha.h Sat Feb 02 07:19:34 2002 +0000 +++ b/libdha/libdha.h Sat Feb 02 12:14:56 2002 +0000 @@ -58,6 +58,14 @@ 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 -r fc81767343ea -r 0d9a096cfd46 libdha/mtrr.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libdha/mtrr.c Sat Feb 02 12:14:56 2002 +0000 @@ -0,0 +1,48 @@ +/* + mtrr.c - Stuff for optimizing memory access + Copyrights: + 2002 - Linux version by Nick Kurshev + Licence: GPL +*/ + +#include "config.h" + +#include +#include +#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