[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnumach, new device
From: |
Samuel Thibault |
Subject: |
Re: gnumach, new device |
Date: |
Sun, 8 Jan 2006 19:23:30 +0100 |
User-agent: |
Mutt/1.5.9i-nntp |
Gianluca Guida, le Sun 08 Jan 2006 18:56:21 +0100, a écrit :
> My only 0.02 euro here is that since io_port_create and
> io_port_destroy are both exported function, it would be nice to have
> the device code (ioopen and ioclose) in a separate, architecture
> independent file, since it is an architecture independent device.
Agreed. Here is an updated patch
gnumach/ChangeLog
2006-01-08 Samuel Thibault <samuel.thibault@ens-lyon.org>
* Makefile.in: Always compile-in new io.c file.
* device/io.c: New file, implements a new "io" device that
represents i/o access to any port.
(iodevice): New variable
(ioopen): New function.
(ioclose): Likewise.
* i386/i386/iopb.c: (io_bitmap_set): Treat special (-1) bit list
as "all ports".
(io_bitmap_clear): Likewise.
* conf.c: New "io" device.
(dev_name_list): Added "io" device.
Index: Makefile.in
===================================================================
RCS file: /cvsroot/hurd/gnumach/Makefile.in,v
retrieving revision 1.31.2.2
diff -u -r1.31.2.2 Makefile.in
--- Makefile.in 12 Jul 2005 23:01:06 -0000 1.31.2.2
+++ Makefile.in 8 Jan 2006 18:17:24 -0000
@@ -120,7 +120,7 @@
buf.h cirbuf.h conf.h cons.h dev_hdr.h dev_master.h device_port.h \
device_types_kernel.h ds_routines.h errno.h if_ether.h if_hdr.h \
io_req.h kmsg.c kmsg.h net_io.h param.h tty.h memory_object_reply.cli \
- dev_forward.defs device_pager.srv device_reply.cli device.srv
+ dev_forward.defs device_pager.srv device_reply.cli device.srv io.c
# IPC implementation
ipc-cfiles = $(addprefix ipc_,$(ipc-names)) \
@@ -183,7 +183,7 @@
# if particular drivers want the routines.
# XXX functions in device/subrs.c should each be moved elsewhere
objfiles += cons.o dev_lookup.o dev_name.o dev_pager.o device_init.o \
- ds_routines.o subrs.o net_io.o blkio.o chario.o
+ ds_routines.o subrs.o net_io.o blkio.o chario.o io.o
ifeq ($(enable_kmsg),yes)
objfiles += kmsg.o
endif
Index: device/io.c
===================================================================
RCS file: device/io.c
diff -N device/io.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ device/io.c 8 Jan 2006 18:17:24 -0000
@@ -0,0 +1,55 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993-1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#include <device/io_req.h>
+
+#include <machine/io_port.h>
+
+/*
+ * Special "all I/O ports" device.
+ */
+
+static mach_device_t iodevice = 0;
+
+int ioopen(dev, flag, ior)
+ int dev;
+ int flag;
+ io_req_t ior;
+{
+ iodevice = ior->io_device;
+
+ io_port_create(iodevice, (io_reg_t *)(-1));
+ return (0);
+}
+
+int ioclose(dev, flags)
+ int dev;
+ int flags;
+{
+ io_port_destroy(iodevice);
+ iodevice = 0;
+ return 0;
+}
Index: i386/i386/iopb.c
===================================================================
RCS file: /cvsroot/hurd/gnumach/i386/i386/Attic/iopb.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 iopb.c
--- i386/i386/iopb.c 25 Feb 1997 21:27:09 -0000 1.1.1.1
+++ i386/i386/iopb.c 8 Jan 2006 18:17:24 -0000
@@ -129,9 +129,12 @@
{
io_reg_t io_bit;
- while ((io_bit = *bit_list++) != IO_REG_NULL) {
- bp[io_bit>>3] &= ~(1 << (io_bit & 0x7));
- }
+ if (bit_list == (io_reg_t *)(-1))
+ memset(bp, 0, IOPB_BYTES);
+ else
+ while ((io_bit = *bit_list++) != IO_REG_NULL) {
+ bp[io_bit>>3] &= ~(1 << (io_bit & 0x7));
+ }
}
/*
@@ -144,9 +147,12 @@
{
io_reg_t io_bit;
- while ((io_bit = *bit_list++) != IO_REG_NULL) {
- bp[io_bit>>3] |= (1 << (io_bit & 0x7));
- }
+ if (bit_list == (io_reg_t *)(-1))
+ memset(bp, ~0, IOPB_BYTES);
+ else
+ while ((io_bit = *bit_list++) != IO_REG_NULL) {
+ bp[io_bit>>3] |= (1 << (io_bit & 0x7));
+ }
}
/*
Index: i386/i386at/conf.c
===================================================================
RCS file: /cvsroot/hurd/gnumach/i386/i386at/Attic/conf.c,v
retrieving revision 1.4
diff -u -r1.4 conf.c
--- i386/i386at/conf.c 5 Apr 2001 06:39:21 -0000 1.4
+++ i386/i386at/conf.c 8 Jan 2006 18:17:25 -0000
@@ -182,6 +182,9 @@
extern vm_offset_t ioplmmap();
#define ioplname "iopl"
+extern int ioopen(), ioclose();
+#define ioname "io"
+
extern int kmsgopen(), kmsgclose(), kmsgread(), kmsggetstat();
#define kmsgname "kmsg"
@@ -367,6 +370,11 @@
nodev, nulldev, nulldev, 0,
nodev },
+ { ioname, ioopen, ioclose, nodev,
+ nodev, nodev, nodev, nodev,
+ nodev, nulldev, nulldev, 0,
+ nodev },
+
#if 0
#if NHD > 0
{ pchdname, pchdopen, hdclose, pchdread,