4476
|
1 /*
|
|
2 mtrr.c - Stuff for optimizing memory access
|
|
3 Copyrights:
|
|
4 2002 - Linux version by Nick Kurshev
|
|
5 Licence: GPL
|
|
6 */
|
|
7
|
|
8 #include "config.h"
|
|
9
|
|
10 #include <stdio.h>
|
|
11 #include <errno.h>
|
|
12 #include "libdha.h"
|
|
13 #include "AsmMacros.h"
|
|
14
|
|
15
|
|
16 #if defined( __i386__ )
|
|
17 int mtrr_set_type(unsigned base,unsigned size,int type)
|
|
18 {
|
|
19 #ifdef linux
|
|
20 FILE * mtrr_fd;
|
|
21 char * stype;
|
|
22 switch(type)
|
|
23 {
|
|
24 case MTRR_TYPE_UNCACHABLE: stype = "uncachable"; break;
|
|
25 case MTRR_TYPE_WRCOMB: stype = "write-combining"; break;
|
|
26 case MTRR_TYPE_WRTHROUGH: stype = "write-through"; break;
|
|
27 case MTRR_TYPE_WRPROT: stype = "write-protect"; break;
|
|
28 case MTRR_TYPE_WRBACK: stype = "write-back"; break;
|
|
29 default: return EINVAL;
|
|
30 }
|
|
31 mtrr_fd = fopen("/proc/mtrr","wt");
|
|
32 if(mtrr_fd)
|
|
33 {
|
4495
|
34 char sout[256];
|
|
35 unsigned wr_len;
|
|
36 sprintf(sout,"base=0x%08X size=0x%08X type=%s\n",base,size,stype);
|
|
37 wr_len = fprintf(mtrr_fd,sout);
|
|
38 /*printf("MTRR: %s\n",sout);*/
|
4476
|
39 fclose(mtrr_fd);
|
4495
|
40 return wr_len == strlen(sout) ? 0 : EPERM;
|
4476
|
41 }
|
|
42 return ENOSYS;
|
|
43 #else
|
|
44 #warning Please port MTRR stuff!!!
|
4510
|
45 return ENOSYS;
|
4476
|
46 #endif
|
|
47 }
|
|
48 #else
|
|
49 int mtrr_set_type(unsigned base,unsigned size,int type)
|
|
50 {
|
4495
|
51 return ENOSYS;
|
4476
|
52 }
|
|
53 #endif |