annotate vidix/dha.c @ 33648:9bb5d229a60b

Cast arg in guiGetEvent() to void * or remove cast where unnecessary.
author ib
date Mon, 27 Jun 2011 10:29:34 +0000
parents 99054ecaf3d9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
1 /*
23046
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 23045
diff changeset
2 * VIDIX Direct Hardware Access (DHA).
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 23045
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: 23045
diff changeset
4 *
26718
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
5 * 1996/10/27 - Robin Cutshaw (robin@xfree86.org)
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
6 * XFree86 3.3.3 implementation
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
7 * 1999 - Øyvind Aabling.
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
8 * Modified for GATOS/win/gfxdump.
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
9 *
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
10 * 2002 - library implementation by Nick Kurshev
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
11 * - dhahelper and some changes by Alex Beregszaszi
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
12 *
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
13 * supported OSes: SVR4, UnixWare, SCO, Solaris,
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
14 * FreeBSD, NetBSD, 386BSD, BSDI BSD/386,
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
15 * Linux, Mach/386, ISC
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
16 * DOS (WATCOM 9.5 compiler), Win9x (with mapdev.vxd)
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
17 * original location: www.linuxvideo.org/gatos
051b2632f121 consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents: 24512
diff changeset
18 *
23046
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 23045
diff changeset
19 * This file is part of MPlayer.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 23045
diff changeset
20 *
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 23045
diff changeset
21 * 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: 23045
diff changeset
22 * 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: 23045
diff changeset
23 * 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: 23045
diff changeset
24 * (at your option) any later version.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 23045
diff changeset
25 *
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 23045
diff changeset
26 * 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: 23045
diff changeset
27 * 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: 23045
diff changeset
28 * 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: 23045
diff changeset
29 * GNU General Public License for more details.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 23045
diff changeset
30 *
26719
3abd1629658b Use standard license headers.
diego
parents: 26718
diff changeset
31 * You should have received a copy of the GNU General Public License along
3abd1629658b Use standard license headers.
diego
parents: 26718
diff changeset
32 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
3abd1629658b Use standard license headers.
diego
parents: 26718
diff changeset
33 * 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: 23045
diff changeset
34 */
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
35
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
36 #include "config.h"
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
37
22901
a7605669b114 renamed libdha.[hc] to dha.[hc]
ben
parents: 22900
diff changeset
38 #include "dha.h"
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
39 #include "AsmMacros.h"
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
40 #include <stdio.h>
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
41 #include <stdlib.h>
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
42 #include <string.h>
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
43 #include <fcntl.h>
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
44 #include <sys/stat.h>
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
45 #include <sys/types.h>
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27727
diff changeset
46 #if ARCH_ALPHA
5702
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
47 #include <sys/io.h>
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
48 #endif
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
49 #include <unistd.h>
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
50
27727
48c1ae64255b Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__.
diego
parents: 27419
diff changeset
51 #if defined(__MINGW32__) || defined(__CYGWIN__)
4164
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
52 #include "sysdep/libdha_win32.c"
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
53 #elif defined (__EMX__)
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
54 #include "sysdep/libdha_os2.c"
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
55 #else
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
56
4164
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
57 #if defined(SVR4) || defined(SCO325)
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
58 # if !(defined(sun) && defined (i386) && defined (SVR4))
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
59 # define DEV_MEM "/dev/pmem"
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
60 # elif defined(PowerMAX_OS)
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
61 # define DEV_MEM "/dev/iomem"
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
62 # endif
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
63 # ifdef SCO325
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
64 # undef DEV_MEM
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
65 # define DEV_MEM "/dev/mem"
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
66 # endif
22817
a59deec120cc in solaris the I/O device to mmap() is /dev/xsvc, not /dev/mem
nicodvb
parents: 14567
diff changeset
67 #elif defined(sun) && defined (i386)
a59deec120cc in solaris the I/O device to mmap() is /dev/xsvc, not /dev/mem
nicodvb
parents: 14567
diff changeset
68 #define DEV_MEM "/dev/xsvc"
4164
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
69 # endif /* SVR4 */
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
70
14567
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
71 #if defined(__OpenBSD__)
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
72 #define DEV_APERTURE "/dev/xf86"
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
73 #endif
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
74
4164
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
75 /* Generic version */
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
76 #include <sys/mman.h>
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
77
4164
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
78 #ifndef DEV_MEM
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
79 #define DEV_MEM "/dev/mem"
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
80 #endif
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
81
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
82 #ifdef CONFIG_DHAHELPER
26901
af5408de478f Rename kernelhelper to dhahelper, that name is more fitting.
diego
parents: 26719
diff changeset
83 #include "dhahelper/dhahelper.h"
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
84 #endif
4938
b782efa10c60 added proper dhahelper includes
alex
parents: 4474
diff changeset
85
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
86 #ifdef CONFIG_SVGAHELPER
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
87 #include <svgalib_helper.h>
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
88 #endif
4938
b782efa10c60 added proper dhahelper includes
alex
parents: 4474
diff changeset
89
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
90 static int mem_fd = -1;
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
91
5702
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
92 void *map_phys_mem(unsigned long base, unsigned long size)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28290
diff changeset
93 {
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27727
diff changeset
94 #if ARCH_ALPHA
5702
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
95 /* TODO: move it into sysdep */
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
96 base += bus_base();
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
97 #endif
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
98
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
99 #ifdef CONFIG_SVGAHELPER
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
100 if ( (mem_fd = open(DEV_SVGA,O_RDWR)) == -1) {
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
101 perror("libdha: SVGAlib kernelhelper failed");
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
102 #ifdef CONFIG_DHAHELPER
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
103 goto dha_helper_way;
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
104 #else
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
105 goto dev_mem_way;
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
106 #endif
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
107 }
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
108 else
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
109 goto mmap;
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
110 #endif
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
111
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
112 #ifdef CONFIG_DHAHELPER
9219
4a5b01c405b6 compiler warning fixes by Domink and some other changes by me
alex
parents: 9025
diff changeset
113 #ifdef CONFIG_SVGAHELPER
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
114 dha_helper_way:
9219
4a5b01c405b6 compiler warning fixes by Domink and some other changes by me
alex
parents: 9025
diff changeset
115 #endif
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
116 if ( (mem_fd = open("/dev/dhahelper",O_RDWR)) < 0)
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
117 {
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
118 perror("libdha: DHA kernelhelper failed");
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
119 goto dev_mem_way;
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
120 }
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
121 else
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
122 {
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
123 dhahelper_memory_t mem_req;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28290
diff changeset
124
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
125 mem_req.operation = MEMORY_OP_MAP;
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
126 mem_req.start = base;
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
127 mem_req.offset = 0;
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
128 mem_req.size = size;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28290
diff changeset
129
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
130 if (ioctl(mem_fd, DHAHELPER_MEMORY, &mem_req) < 0)
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
131 {
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
132 perror("libdha: DHA kernelhelper failed");
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
133 close(mem_fd);
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
134 goto dev_mem_way;
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
135 }
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
136 else
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
137 goto mmap;
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
138 }
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
139 #endif
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
140
23063
cc0627bce6bf fix dha compilation if SVGAHELPER is used (patch by Carl Eugen Hoyos
ben
parents: 23046
diff changeset
141 #if defined(CONFIG_DHAHELPER) || defined (CONFIG_SVGAHELPER)
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
142 dev_mem_way:
23045
212bbe3789e7 kill a few warnings
ben
parents: 22901
diff changeset
143 #endif
14567
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
144 #ifdef DEV_APERTURE
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
145 if ((mem_fd = open(DEV_APERTURE, O_RDWR)) == -1)
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
146 perror("libdha: opening aperture failed");
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
147 else {
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
148 void *p = mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem_fd,base);
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
149
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
150 if (p == MAP_FAILED) {
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
151 perror("libdha: mapping aperture failed");
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
152 close(mem_fd);
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
153 } else
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
154 return p;
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
155 }
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
156 #endif
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
157
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
158 if ( (mem_fd = open(DEV_MEM,O_RDWR)) == -1)
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
159 {
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
160 perror("libdha: opening /dev/mem failed");
9219
4a5b01c405b6 compiler warning fixes by Domink and some other changes by me
alex
parents: 9025
diff changeset
161 return MAP_FAILED;
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
162 }
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
163
23063
cc0627bce6bf fix dha compilation if SVGAHELPER is used (patch by Carl Eugen Hoyos
ben
parents: 23046
diff changeset
164 #if defined(CONFIG_DHAHELPER) || defined (CONFIG_SVGAHELPER)
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
165 mmap:
23045
212bbe3789e7 kill a few warnings
ben
parents: 22901
diff changeset
166 #endif
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
167 return mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem_fd,base);
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
168 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
169
5702
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
170 void unmap_phys_mem(void *ptr, unsigned long size)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
171 {
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
172 int res = munmap(ptr,size);
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
173
33322
99054ecaf3d9 On error munmap returns -1, not MAP_FAILED.
reimar
parents: 29263
diff changeset
174 if (res == -1)
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
175 {
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
176 perror("libdha: unmapping memory failed");
9219
4a5b01c405b6 compiler warning fixes by Domink and some other changes by me
alex
parents: 9025
diff changeset
177 return;
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
178 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28290
diff changeset
179
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
180 close(mem_fd);
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
181 mem_fd = -1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28290
diff changeset
182
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
183 return;
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
184 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
185
10980
e687fa1d55c6 port libdha to mingw
faust3
parents: 9219
diff changeset
186 #endif /* Generic mmap (not win32, nor os2) */
e687fa1d55c6 port libdha to mingw
faust3
parents: 9219
diff changeset
187
27419
3f6d802c6ea8 Add proper VIDIX support for SuperH architecture.
ben
parents: 26901
diff changeset
188 #if !defined(__alpha__) && !defined(__powerpc__) && !defined(__sh__)
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
189 unsigned char INPORT8(unsigned idx)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
190 {
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
191 return inb(idx);
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
192 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
193
3995
0d9de811e312 minor interface changing
nick
parents: 3973
diff changeset
194 unsigned short INPORT16(unsigned idx)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
195 {
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
196 return inw(idx);
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
197 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
198
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
199 unsigned INPORT32(unsigned idx)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
200 {
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
201 return inl(idx);
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
202 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
203
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
204 void OUTPORT8(unsigned idx,unsigned char val)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
205 {
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
206 outb(idx,val);
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
207 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
208
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
209 void OUTPORT16(unsigned idx,unsigned short val)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
210 {
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
211 outw(idx,val);
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
212 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
213
8503
9dbb9c710480 svgalib kernelhelper support (based on patch by Matan Ziv-Av <matan@svgalib.org>) and some reordering/cleanup (part #1 ;)
alex
parents: 5702
diff changeset
214 void OUTPORT32(unsigned idx,unsigned val)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
215 {
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
216 outl(idx,val);
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
217 }
24512
4241e73020bc the IN/OUT PORT 8/16/32 functions rely on inb/inw/inl/outb/outw/outl that are not available on alpha and powerpc architectures
ben
parents: 23734
diff changeset
218 #endif