[Pkg-pciutils-discuss] Bug#379407: I/O access on GNU/Hurd
Thomas Schwinge
tschwinge at gnu.org
Sun Jul 23 11:36:46 UTC 2006
Package: pciutils
Version: 2.2.1-2
Tags: patch
Hello!
The attached patch is needed to make the pciutils package usable on
GNU/Hurd systems with the current Debian gnumach kernel packages.
Regards,
Thomas
-------------- next part --------------
2006-01-20 Thomas Schwinge <tschwinge at gnu.org>
* lib/Makefile [PCI_OS_GNU]: Define _GNU_SOURCE.
* lib/i386-io-hurd.h: Implement request and release of IO port access
rights.
diff -ru pciutils-2.2.1.orig/lib/Makefile pciutils-2.2.1/lib/Makefile
--- pciutils-2.2.1.orig/lib/Makefile 2004-08-13 22:29:06.000000000 +0200
+++ pciutils-2.2.1/lib/Makefile 2006-01-20 01:53:05.000000000 +0100
@@ -45,6 +45,10 @@
PCILIB=libpciutils.a
endif
+ifdef PCI_OS_GNU
+CFLAGS += -D_GNU_SOURCE
+endif
+
all: $(PCILIB)
$(PCILIB): $(OBJS)
diff -ru pciutils-2.2.1.orig/lib/i386-io-hurd.h pciutils-2.2.1/lib/i386-io-hurd.h
--- pciutils-2.2.1.orig/lib/i386-io-hurd.h 2003-12-27 00:04:38.000000000 +0100
+++ pciutils-2.2.1/lib/i386-io-hurd.h 2006-01-20 02:08:58.000000000 +0100
@@ -3,19 +3,46 @@
*
* Copyright (c) 2003 Marco Gerards <metgerards at student.han.nl>
* Copyright (c) 2003 Martin Mares <mj at ucw.cz>
+ * Copyright (c) 2006 Samuel Thibault <samuel.thibault at ens-lyon.org> and
+ * Thomas Schwinge <tschwinge at gnu.org>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include <sys/io.h>
+#include <mach/machine/mach_i386.h>
+#include <device/device.h>
+#include <hurd.h>
+
+#include <stdio.h>
+
+static mach_port_t io_port;
+
static inline int
intel_setup_io(void)
{
- return 1;
+ mach_port_t device;
+
+ if ((errno = get_privileged_ports(NULL, &device)))
+ perror("intel_setup_io() can't get_privileged_ports()");
+
+ if (!errno && (errno = device_open(device, D_READ | D_WRITE, "io", &io_port)))
+ perror("intel_setup_io() can't device_open()");
+
+ mach_port_deallocate(mach_task_self(), device);
+
+ if (!errno && (errno = i386_io_port_add(mach_thread_self(), io_port)))
+ perror("intel_setup_io() can't i386_io_port_add()");
+
+ return errno ? 0 : 1;
}
-static inline int
+static inline void
intel_cleanup_io(void)
{
+ if ((errno = i386_io_port_remove(mach_thread_self(), io_port)))
+ perror("intel_cleanup_io() can't i386_io_port_remove()");
+
+ mach_port_deallocate(mach_task_self(), io_port);
}
More information about the Pkg-pciutils-discuss
mailing list