2 * The PCI Library -- Access to i386 I/O ports on GNU Hurd
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>
9 * Can be freely distributed and used under the terms of the GNU GPL.
14 #include <mach/machine/mach_i386.h>
15 #include <device/device.h>
20 static mach_port_t io_port;
27 if ((errno = get_privileged_ports(NULL, &device)))
28 perror("intel_setup_io() can't get_privileged_ports()");
30 if (!errno && (errno = device_open(device, D_READ | D_WRITE, "io", &io_port)))
31 perror("intel_setup_io() can't device_open()");
33 mach_port_deallocate(mach_task_self(), device);
35 if (!errno && (errno = i386_io_port_add(mach_thread_self(), io_port)))
36 perror("intel_setup_io() can't i386_io_port_add()");
42 intel_cleanup_io(void)
44 if ((errno = i386_io_port_remove(mach_thread_self(), io_port)))
45 perror("intel_cleanup_io() can't i386_io_port_remove()");
47 mach_port_deallocate(mach_task_self(), io_port);