]> mj.ucw.cz Git - pciutils.git/blob - lib/i386-io-hurd.h
i386-*: Cleaned up printing of initialization errors.
[pciutils.git] / lib / i386-io-hurd.h
1 /*
2  *      The PCI Library -- Access to i386 I/O ports on GNU Hurd
3  *
4  *      Copyright (c) 2003 Marco Gerards <metgerards@student.han.nl>
5  *      Copyright (c) 2003 Martin Mares <mj@ucw.cz>
6  *      Copyright (c) 2006 Samuel Thibault <samuel.thibault@ens-lyon.org> and
7  *                         Thomas Schwinge <tschwinge@gnu.org>
8  *
9  *      Can be freely distributed and used under the terms of the GNU GPL.
10  */
11
12 #include <sys/io.h>
13
14 #include <mach/machine/mach_i386.h>
15 #include <device/device.h>
16 #include <hurd.h>
17
18 #include <stdio.h>
19
20 static mach_port_t io_port;
21
22 static inline int
23 intel_setup_io(struct pci_access *a)
24 {
25   mach_port_t device;
26
27   if ((errno = get_privileged_ports(NULL, &device)))
28     a->warn("i386-io-hurd: Can't get_privileged_ports(): %m");
29
30   if (!errno && (errno = device_open(device, D_READ | D_WRITE, "io", &io_port)))
31     a->warn("i386-io-hurd: Can't device_open(): %m");
32
33   mach_port_deallocate(mach_task_self(), device);
34
35   if (!errno && (errno = i386_io_port_add(mach_thread_self(), io_port)))
36     a->warn("i386-io-hurd: Can't i386_io_port_add(): %m");
37
38   return errno ? 0 : 1;
39 }
40
41 static inline int
42 intel_cleanup_io(struct pci_access *a)
43 {
44   if ((errno = i386_io_port_remove(mach_thread_self(), io_port)))
45     a->warn("i386-io-hurd: Can't i386_io_port_remove(): %m");
46
47   mach_port_deallocate(mach_task_self(), io_port);
48
49   return -1;
50 }