Debian Codegraph @

drivers/libdha/sysdep/pci_linux.c

raw
1 /*
2 This file is based on:
3 $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $
4 Modified for readability by Nick Kurshev
5 */
6 #include <errno.h>
7 #ifdef __i386__
8 #include <sys/perm.h>
9 #else
10 #ifndef __sparc__
11 #include <sys/io.h>
12 #endif
13 #endif
14
15 #include "config.h"
16
17 #ifdef CONFIG_DHAHELPER
18 #include <fcntl.h>
19 int dhahelper_initialized = 0;
20 int dhahelper_fd = 0;
21 #endif
22
23 #if defined(__sparc__) || defined(__powerpc__)
24 #define iopl(x) (0)
25 #endif
26
27 static __inline__ int enable_os_io(void)
28 {
29 #ifdef CONFIG_DHAHELPER
30 dhahelper_fd = open("/dev/dhahelper", O_RDWR);
31 if (dhahelper_fd > 0)
32 {
33 dhahelper_initialized = 1;
34 return(0);
35 }
36 dhahelper_initialized = -1;
37 #endif
38
39 if (iopl(3) != 0)
40 return(errno);
41 return(0);
42 }
43
44 static __inline__ int disable_os_io(void)
45 {
46 #ifdef CONFIG_DHAHELPER
47 if (dhahelper_initialized == 1)
48 close(dhahelper_fd);
49 else
50 #endif
51 if (iopl(0) != 0)
52 return(errno);
53 return(0);
54 }