annotate libdha/libdha.c @ 18501:e5b65b94eb73

Fix LDFLAGS vs CPPFLAGS typo noticed by Derek E. Lewis.
author diego
date Sun, 14 May 2006 10:33:27 +0000
parents f525cb411927
children a59deec120cc
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 /*
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
2 libgha.c - Library for direct hardware access
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
3 Copyrights:
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
4 1996/10/27 - Robin Cutshaw (robin@xfree86.org)
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
5 XFree86 3.3.3 implementation
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
6 1999 - Øyvind Aabling.
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
7 Modified for GATOS/win/gfxdump.
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
8
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
9 2002 - library implementation by Nick Kurshev
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
10 - dhahelper and some changes by Alex Beregszaszi
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
11
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
12 supported O/S's: SVR4, UnixWare, SCO, Solaris,
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
13 FreeBSD, NetBSD, 386BSD, BSDI BSD/386,
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
14 Linux, Mach/386, ISC
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
15 DOS (WATCOM 9.5 compiler), Win9x (with mapdev.vxd)
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
16 Licence: GPL
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
17 Original location: www.linuxvideo.org/gatos
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
18 */
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
19
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
20 #include "config.h"
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
21
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
22 #include "libdha.h"
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
23 #include "AsmMacros.h"
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
24 #include <stdio.h>
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
25 #include <stdlib.h>
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
26 #include <string.h>
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
27 #include <fcntl.h>
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
28 #include <sys/stat.h>
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
29 #include <sys/types.h>
5702
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
30 #ifdef ARCH_ALPHA
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
31 #include <sys/io.h>
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
32 #endif
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
33 #include <unistd.h>
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
34
12069
841fd0c2f2e3 fix compilation on cygwin
faust3
parents: 10980
diff changeset
35 #if defined(WIN32)
4164
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
36 #include "sysdep/libdha_win32.c"
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
37 #elif defined (__EMX__)
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
38 #include "sysdep/libdha_os2.c"
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
39 #else
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
40
4164
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
41 #if defined(SVR4) || defined(SCO325)
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
42 # if !(defined(sun) && defined (i386) && defined (SVR4))
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
43 # define DEV_MEM "/dev/pmem"
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
44 # elif defined(PowerMAX_OS)
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
45 # define DEV_MEM "/dev/iomem"
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
46 # endif
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
47 # ifdef SCO325
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
48 # undef DEV_MEM
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
49 # define DEV_MEM "/dev/mem"
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
50 # endif
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
51 # endif /* SVR4 */
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
52
14567
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
53 #if defined(__OpenBSD__)
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
54 #define DEV_APERTURE "/dev/xf86"
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
55 #endif
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
56
4164
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
57 /* Generic version */
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
58 #include <sys/mman.h>
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
59
4164
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
60 #ifndef DEV_MEM
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
61 #define DEV_MEM "/dev/mem"
2e3262002acb Improved readability and new stuffs
nick
parents: 3995
diff changeset
62 #endif
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
63
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
64 #ifdef CONFIG_DHAHELPER
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
65 #include "kernelhelper/dhahelper.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
66 #endif
4938
b782efa10c60 added proper dhahelper includes
alex
parents: 4474
diff changeset
67
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
68 #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
69 #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
70 #endif
4938
b782efa10c60 added proper dhahelper includes
alex
parents: 4474
diff changeset
71
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
72 static int mem_fd = -1;
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
73
5702
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
74 void *map_phys_mem(unsigned long base, unsigned long size)
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
75 {
5702
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
76 #ifdef ARCH_ALPHA
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
77 /* TODO: move it into sysdep */
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
78 base += bus_base();
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
79 #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
80
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
81 #ifdef CONFIG_SVGAHELPER
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
82 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
83 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
84 #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
85 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
86 #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
87 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
88 #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
89 }
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
90 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
91 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
92 #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
93
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
94 #ifdef CONFIG_DHAHELPER
9219
4a5b01c405b6 compiler warning fixes by Domink and some other changes by me
alex
parents: 9025
diff changeset
95 #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
96 dha_helper_way:
9219
4a5b01c405b6 compiler warning fixes by Domink and some other changes by me
alex
parents: 9025
diff changeset
97 #endif
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
98 if ( (mem_fd = open("/dev/dhahelper",O_RDWR)) < 0)
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
99 {
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
100 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
101 goto dev_mem_way;
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
102 }
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
103 else
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
104 {
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
105 dhahelper_memory_t mem_req;
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
106
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
107 mem_req.operation = MEMORY_OP_MAP;
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
108 mem_req.start = base;
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
109 mem_req.offset = 0;
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
110 mem_req.size = size;
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
111
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
112 if (ioctl(mem_fd, DHAHELPER_MEMORY, &mem_req) < 0)
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
113 {
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 perror("libdha: DHA kernelhelper failed");
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
115 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
116 goto dev_mem_way;
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 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
119 goto mmap;
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
120 }
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
121 #endif
4474
05ac3586db02 added support for dhahelper
alex
parents: 4174
diff changeset
122
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
123 dev_mem_way:
14567
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
124 #ifdef DEV_APERTURE
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
125 if ((mem_fd = open(DEV_APERTURE, O_RDWR)) == -1)
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
126 perror("libdha: opening aperture failed");
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
127 else {
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
128 void *p = mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem_fd,base);
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
129
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
130 if (p == MAP_FAILED) {
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
131 perror("libdha: mapping aperture failed");
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
132 close(mem_fd);
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
133 } else
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
134 return p;
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
135 }
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
136 #endif
f525cb411927 openbsd xf86 aperture support
alex
parents: 12069
diff changeset
137
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
138 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
139 {
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
140 perror("libdha: opening /dev/mem failed");
9219
4a5b01c405b6 compiler warning fixes by Domink and some other changes by me
alex
parents: 9025
diff changeset
141 return MAP_FAILED;
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
142 }
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
143
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
144 mmap:
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
145 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
146 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
147
5702
567de708ab3a sync with mplayerxp
nick
parents: 4938
diff changeset
148 void unmap_phys_mem(void *ptr, unsigned long size)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
149 {
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
150 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
151
9219
4a5b01c405b6 compiler warning fixes by Domink and some other changes by me
alex
parents: 9025
diff changeset
152 if (res == (int)MAP_FAILED)
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
153 {
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
154 perror("libdha: unmapping memory failed");
9219
4a5b01c405b6 compiler warning fixes by Domink and some other changes by me
alex
parents: 9025
diff changeset
155 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
156 }
9025
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
157
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
158 close(mem_fd);
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
159 mem_fd = -1;
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
160
ae0507e107b7 cleanup and removal of libdha_exit. forgot to commit this
alex
parents: 8503
diff changeset
161 return;
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
162 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
163
10980
e687fa1d55c6 port libdha to mingw
faust3
parents: 9219
diff changeset
164 #endif /* Generic mmap (not win32, nor os2) */
e687fa1d55c6 port libdha to mingw
faust3
parents: 9219
diff changeset
165
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
166 unsigned char INPORT8(unsigned idx)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
167 {
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
168 return inb(idx);
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
169 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
170
3995
0d9de811e312 minor interface changing
nick
parents: 3973
diff changeset
171 unsigned short INPORT16(unsigned idx)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
172 {
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
173 return inw(idx);
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
174 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
175
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
176 unsigned INPORT32(unsigned idx)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
177 {
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
178 return inl(idx);
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
179 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
180
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
181 void OUTPORT8(unsigned idx,unsigned char val)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
182 {
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
183 outb(idx,val);
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
184 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
185
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
186 void OUTPORT16(unsigned idx,unsigned short val)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
187 {
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
188 outw(idx,val);
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
189 }
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
190
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
191 void OUTPORT32(unsigned idx,unsigned val)
3973
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
192 {
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
193 outl(idx,val);
138800dfbe22 preliminary support of direct hardware access
nick
parents:
diff changeset
194 }