annotate libdha/mtrr.c @ 5012:13eacaebe7bb

DX50 worx with ffodivx
author arpi
date Sun, 10 Mar 2002 03:01:06 +0000
parents 1f0282f9a723
children 02576893af2a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
1 /*
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
2 mtrr.c - Stuff for optimizing memory access
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
3 Copyrights:
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
4 2002 - Linux version by Nick Kurshev
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
5 Licence: GPL
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
6 */
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
7
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
8 #include "config.h"
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
9
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
10 #include <stdio.h>
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
11 #include <errno.h>
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
12 #include "libdha.h"
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
13 #include "AsmMacros.h"
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
14
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
15
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
16 #if defined( __i386__ )
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
17 int mtrr_set_type(unsigned base,unsigned size,int type)
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
18 {
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
19 #ifdef linux
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
20 FILE * mtrr_fd;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
21 char * stype;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
22 switch(type)
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
23 {
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
24 case MTRR_TYPE_UNCACHABLE: stype = "uncachable"; break;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
25 case MTRR_TYPE_WRCOMB: stype = "write-combining"; break;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
26 case MTRR_TYPE_WRTHROUGH: stype = "write-through"; break;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
27 case MTRR_TYPE_WRPROT: stype = "write-protect"; break;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
28 case MTRR_TYPE_WRBACK: stype = "write-back"; break;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
29 default: return EINVAL;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
30 }
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
31 mtrr_fd = fopen("/proc/mtrr","wt");
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
32 if(mtrr_fd)
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
33 {
4495
0e4cffa369e4 Be more precise
nick
parents: 4476
diff changeset
34 char sout[256];
0e4cffa369e4 Be more precise
nick
parents: 4476
diff changeset
35 unsigned wr_len;
0e4cffa369e4 Be more precise
nick
parents: 4476
diff changeset
36 sprintf(sout,"base=0x%08X size=0x%08X type=%s\n",base,size,stype);
0e4cffa369e4 Be more precise
nick
parents: 4476
diff changeset
37 wr_len = fprintf(mtrr_fd,sout);
0e4cffa369e4 Be more precise
nick
parents: 4476
diff changeset
38 /*printf("MTRR: %s\n",sout);*/
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
39 fclose(mtrr_fd);
4495
0e4cffa369e4 Be more precise
nick
parents: 4476
diff changeset
40 return wr_len == strlen(sout) ? 0 : EPERM;
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
41 }
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
42 return ENOSYS;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
43 #else
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
44 #warning Please port MTRR stuff!!!
4510
1f0282f9a723 fix typo
nexus
parents: 4495
diff changeset
45 return ENOSYS;
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
46 #endif
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
47 }
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
48 #else
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
49 int mtrr_set_type(unsigned base,unsigned size,int type)
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
50 {
4495
0e4cffa369e4 Be more precise
nick
parents: 4476
diff changeset
51 return ENOSYS;
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
52 }
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
53 #endif