2 mtrr.c - Stuff for optimizing memory access
4 2002 - Linux version by Nick Kurshev
14 #include "AsmMacros.h"
16 #if defined (__i386__) && defined (__NetBSD__)
17 #include <sys/param.h>
18 #if __NetBSD_Version__ > 105240000
21 #include <machine/mtrr.h>
22 #include <machine/sysarch.h>
26 #if defined( __i386__ )
27 int mtrr_set_type(unsigned base
,unsigned size
,int type
)
34 case MTRR_TYPE_UNCACHABLE
: stype
= "uncachable"; break;
35 case MTRR_TYPE_WRCOMB
: stype
= "write-combining"; break;
36 case MTRR_TYPE_WRTHROUGH
: stype
= "write-through"; break;
37 case MTRR_TYPE_WRPROT
: stype
= "write-protect"; break;
38 case MTRR_TYPE_WRBACK
: stype
= "write-back"; break;
39 default: return EINVAL
;
41 mtrr_fd
= fopen("/proc/mtrr","wt");
46 sprintf(sout
,"base=0x%08X size=0x%08X type=%s\n",base
,size
,stype
);
47 wr_len
= fprintf(mtrr_fd
,sout
);
48 /*printf("MTRR: %s\n",sout);*/
50 return wr_len
== strlen(sout
) ? 0 : EPERM
;
53 #elif defined (__NetBSD__)
54 #if __NetBSD_Version__ > 105240000
58 mtrrp
= malloc(sizeof (struct mtrr
));
62 mtrrp
->flags
= MTRR_VALID
| MTRR_PRIVATE
;
65 if (i386_set_mtrr(mtrrp
, &n
) < 0) {
72 /* NetBSD prior to 1.5Y doesn't have MTRR support */
76 #warning Please port MTRR stuff!!!
81 int mtrr_set_type(unsigned base
,unsigned size
,int type
)