Debian Codegraph @

drivers/libdha/sysdep/pci_freebsd.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 #include <sys/file.h>
8 /* machine/console.h seems to be outdated by recent FreeBSD *
9 * however pcvt_ioctl.h seems to exist for very long time */
10 /* #include <machine/console.h>*/
11 #include <machine/pcvt_ioctl.h>
12 #ifndef GCCUSESGAS
13 #define GCCUSESGAS
14 #endif
15
16 static int io_fd;
17
18 static __inline__ int enable_os_io(void)
19 {
20 io_fd = -1 ;
21 if ((io_fd = open("/dev/console", O_RDWR, 0)) < 0) {
22 perror("/dev/console");
23 return(errno);
24 }
25 if (ioctl(io_fd, KDENABIO, 0) < 0) {
26 perror("ioctl(KDENABIO)");
27 return(errno);
28 }
29 return(0);
30 }
31
32 static __inline__ int disable_os_io(void)
33 {
34 if (ioctl(io_fd, KDDISABIO, 0) < 0) {
35 perror("ioctl(KDDISABIO)");
36 close(io_fd);
37 return(errno);
38 }
39 close(io_fd);
40 return(0);
41 }