annotate vidix/mtrr.c @ 24896:8133163bd1dd

Add audio filter scaletempo Patch by Robert Juliano, juliano.1 osu edu
author uau
date Thu, 01 Nov 2007 06:52:38 +0000
parents 82216ef041e0
children 3abd1629658b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
1 /*
23046
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
2 * VIDIX Memory access optimization routines.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
3 * Copyright (C) 2002 Nick Kurshev
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
4 *
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
5 * This file is part of MPlayer.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
6 *
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
7 * MPlayer is free software; you can redistribute it and/or modify
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
8 * it under the terms of the GNU General Public License as published by
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
10 * (at your option) any later version.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
11 *
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
12 * MPlayer is distributed in the hope that it will be useful,
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
15 * GNU General Public License for more details.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
16 *
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
17 * You should have received a copy of the GNU General Public License
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
18 * along with MPlayer; if not, write to the Free Software
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
20 *
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22901
diff changeset
21 */
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
22
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
23 #include "config.h"
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
24
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
25 #include <stdio.h>
6335
e9bd97d5c5cc warning & newline fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 6011
diff changeset
26 #include <string.h>
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
27 #include <errno.h>
22901
a7605669b114 renamed libdha.[hc] to dha.[hc]
ben
parents: 22900
diff changeset
28 #include "dha.h"
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
29 #include "AsmMacros.h"
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
30
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
31 #if defined (__i386__) && defined (__NetBSD__)
6011
5f020e2dc745 patchs for NetBSD by Bernd Ernesti <mplayer@lists.veego.de>:
pl
parents: 5872
diff changeset
32 #include <sys/param.h>
5f020e2dc745 patchs for NetBSD by Bernd Ernesti <mplayer@lists.veego.de>:
pl
parents: 5872
diff changeset
33 #if __NetBSD_Version__ > 105240000
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
34 #include <stdint.h>
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
35 #include <stdlib.h>
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
36 #include <machine/mtrr.h>
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
37 #include <machine/sysarch.h>
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
38 #endif
6011
5f020e2dc745 patchs for NetBSD by Bernd Ernesti <mplayer@lists.veego.de>:
pl
parents: 5872
diff changeset
39 #endif
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
40
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
41 int mtrr_set_type(unsigned base,unsigned size,int type)
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
42 {
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
43 #ifdef linux
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
44 FILE * mtrr_fd;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
45 char * stype;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
46 switch(type)
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
47 {
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
48 case MTRR_TYPE_UNCACHABLE: stype = "uncachable"; break;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
49 case MTRR_TYPE_WRCOMB: stype = "write-combining"; break;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
50 case MTRR_TYPE_WRTHROUGH: stype = "write-through"; break;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
51 case MTRR_TYPE_WRPROT: stype = "write-protect"; break;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
52 case MTRR_TYPE_WRBACK: stype = "write-back"; break;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
53 default: return EINVAL;
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
54 }
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
55 mtrr_fd = fopen("/proc/mtrr","wt");
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
56 if(mtrr_fd)
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
57 {
4495
0e4cffa369e4 Be more precise
nick
parents: 4476
diff changeset
58 char sout[256];
0e4cffa369e4 Be more precise
nick
parents: 4476
diff changeset
59 unsigned wr_len;
0e4cffa369e4 Be more precise
nick
parents: 4476
diff changeset
60 sprintf(sout,"base=0x%08X size=0x%08X type=%s\n",base,size,stype);
0e4cffa369e4 Be more precise
nick
parents: 4476
diff changeset
61 wr_len = fprintf(mtrr_fd,sout);
0e4cffa369e4 Be more precise
nick
parents: 4476
diff changeset
62 /*printf("MTRR: %s\n",sout);*/
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
63 fclose(mtrr_fd);
4495
0e4cffa369e4 Be more precise
nick
parents: 4476
diff changeset
64 return wr_len == strlen(sout) ? 0 : EPERM;
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
65 }
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
66 return ENOSYS;
16377
243f6f5d0bb9 Make MTRR setup work on AMD64 and simplify some #ifdefs
reimar
parents: 6335
diff changeset
67 #elif defined (__i386__ ) && defined (__NetBSD__) && __NetBSD_Version__ > 105240000
5872
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
68 struct mtrr *mtrrp;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
69 int n;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
70
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
71 mtrrp = malloc(sizeof (struct mtrr));
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
72 mtrrp->base = base;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
73 mtrrp->len = size;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
74 mtrrp->type = type;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
75 mtrrp->flags = MTRR_VALID | MTRR_PRIVATE;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
76 n = 1;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
77
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
78 if (i386_set_mtrr(mtrrp, &n) < 0) {
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
79 free(mtrrp);
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
80 return errno;
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
81 }
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
82 free(mtrrp);
02576893af2a OpenBSD, NetBSD portability patches by
arpi
parents: 4510
diff changeset
83 return 0;
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
84 #else
6011
5f020e2dc745 patchs for NetBSD by Bernd Ernesti <mplayer@lists.veego.de>:
pl
parents: 5872
diff changeset
85 /* NetBSD prior to 1.5Y doesn't have MTRR support */
5f020e2dc745 patchs for NetBSD by Bernd Ernesti <mplayer@lists.veego.de>:
pl
parents: 5872
diff changeset
86 return ENOSYS;
5f020e2dc745 patchs for NetBSD by Bernd Ernesti <mplayer@lists.veego.de>:
pl
parents: 5872
diff changeset
87 #endif
4476
0d9a096cfd46 MTRR configuring
nick
parents:
diff changeset
88 }