blob: 4373b0f8080ddefe079cb97f7d5ca3158c53e084 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
|