Mercurial > mplayer.hg
annotate vidix/mtrr.c @ 36402:2c9356ac0d01
af_volume: optimize for common case where all channels
have same volume.
author | reimar |
---|---|
date | Tue, 29 Oct 2013 19:24:16 +0000 |
parents | 8b160dad46ab |
children |
rev | line source |
---|---|
4476 | 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 * |
26719 | 17 * You should have received a copy of the GNU General Public License along |
18 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
23046
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
20 */ |
4476 | 21 |
22 #include "config.h" | |
23 | |
24 #include <stdio.h> | |
6335
e9bd97d5c5cc
warning & newline fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
6011
diff
changeset
|
25 #include <string.h> |
4476 | 26 #include <errno.h> |
22901 | 27 #include "dha.h" |
4476 | 28 #include "AsmMacros.h" |
29 | |
5872 | 30 #if defined (__i386__) && defined (__NetBSD__) |
6011
5f020e2dc745
patchs for NetBSD by Bernd Ernesti <mplayer@lists.veego.de>:
pl
parents:
5872
diff
changeset
|
31 #include <sys/param.h> |
5f020e2dc745
patchs for NetBSD by Bernd Ernesti <mplayer@lists.veego.de>:
pl
parents:
5872
diff
changeset
|
32 #if __NetBSD_Version__ > 105240000 |
5872 | 33 #include <stdint.h> |
34 #include <stdlib.h> | |
35 #include <machine/mtrr.h> | |
36 #include <machine/sysarch.h> | |
37 #endif | |
6011
5f020e2dc745
patchs for NetBSD by Bernd Ernesti <mplayer@lists.veego.de>:
pl
parents:
5872
diff
changeset
|
38 #endif |
4476 | 39 |
40 int mtrr_set_type(unsigned base,unsigned size,int type) | |
41 { | |
27250
dcf62171257b
Remove -std=gnu99/gnu89/default dialect linux define, as it violates the
michael
parents:
26719
diff
changeset
|
42 #ifdef __linux__ |
4476 | 43 FILE * mtrr_fd; |
32377 | 44 const char *stype; |
4476 | 45 switch(type) |
46 { | |
47 case MTRR_TYPE_UNCACHABLE: stype = "uncachable"; break; | |
48 case MTRR_TYPE_WRCOMB: stype = "write-combining"; break; | |
49 case MTRR_TYPE_WRTHROUGH: stype = "write-through"; break; | |
50 case MTRR_TYPE_WRPROT: stype = "write-protect"; break; | |
51 case MTRR_TYPE_WRBACK: stype = "write-back"; break; | |
52 default: return EINVAL; | |
53 } | |
54 mtrr_fd = fopen("/proc/mtrr","wt"); | |
55 if(mtrr_fd) | |
56 { | |
32376 | 57 int wr_len = fprintf(mtrr_fd, "base=0x%08X size=0x%08X type=%s\n", base, size, stype); |
4476 | 58 fclose(mtrr_fd); |
32376 | 59 return wr_len > 0 ? 0 : EPERM; |
4476 | 60 } |
61 return ENOSYS; | |
16377
243f6f5d0bb9
Make MTRR setup work on AMD64 and simplify some #ifdefs
reimar
parents:
6335
diff
changeset
|
62 #elif defined (__i386__ ) && defined (__NetBSD__) && __NetBSD_Version__ > 105240000 |
5872 | 63 struct mtrr *mtrrp; |
64 int n; | |
65 | |
66 mtrrp = malloc(sizeof (struct mtrr)); | |
67 mtrrp->base = base; | |
68 mtrrp->len = size; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27250
diff
changeset
|
69 mtrrp->type = type; |
5872 | 70 mtrrp->flags = MTRR_VALID | MTRR_PRIVATE; |
71 n = 1; | |
72 | |
73 if (i386_set_mtrr(mtrrp, &n) < 0) { | |
74 free(mtrrp); | |
75 return errno; | |
76 } | |
77 free(mtrrp); | |
78 return 0; | |
4476 | 79 #else |
6011
5f020e2dc745
patchs for NetBSD by Bernd Ernesti <mplayer@lists.veego.de>:
pl
parents:
5872
diff
changeset
|
80 /* 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
|
81 return ENOSYS; |
5f020e2dc745
patchs for NetBSD by Bernd Ernesti <mplayer@lists.veego.de>:
pl
parents:
5872
diff
changeset
|
82 #endif |
4476 | 83 } |