diff options
author | Thomas Schwinge <tschwinge@gnu.org> | 2007-03-27 22:47:11 +0000 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gnu.org> | 2009-06-18 00:27:07 +0200 |
commit | d35703f70a6c0f89bcec1c97801532ab0d1b945f (patch) | |
tree | a7c20e38b9e65384a4637ca1d535d1c5cafb431d /i386/i386at | |
parent | 211fe231c99b8cf1aa3f91c97b1f00c73b857865 (diff) |
2007-03-27 Thomas Schwinge <tschwinge@gnu.org>
Unconditionally use the device driver multiplexing. Suggested by
Gianluca Guida <glguida@gmail.com>.
* i386/i386at/dev_hdr.h: Merge into `device/dev_hdr.h' and remove.
* i386/i386at/device_emul.h: Rename to `device/device_emul.h'. Adapt
all users.
* i386/i386at/i386at_ds_routines.c: Merge into `device/ds_routines.c'
and remove.
* i386/linux/dev/include/linux_emul.h: Remove file.
* Makefrag.am (libkernel_a_SOURCES): Add `device/device_emul.h'.
* i386/Makefrag.am (libkernel_a_SOURCES): Remove
`i386/i386at/dev_hdr.h', `i386/i386at/device_emul.h' and
`i386/i386at/i386at_ds_routines.c'.
* i386/linux/Makefrag.am (liblinux_a_SOURCES): Remove
`i386/linux/dev/include/linux_emul.h'.
* dev/dev_hdr.h: Adapt all users of `i386' as if it were always
defined.
* device/dev_lookup.c: Likewise.
* device/ds_routines.c: Likewise.
* device/device_init.c (ds_init): Rename to `mach_device_init'.
* device/ds_routines.c (ds_init): Likewise.
(ds_trap_init): Rename to `mach_device_trap_init'.
(mach_device_trap_init): Make it `static'.
* linux/dev/glue/block.c: Don't include <linux_emul.h>, but instead
include <device/device_emul.h> and <i386at/disk.h>.
* linux/dev/glue/net.c: Don't include <linux_emul.h>, but instead
include <device/device_emul.h>.
* linux/pcmcia-cs/glue/ds.c: Likewise.
Diffstat (limited to 'i386/i386at')
-rw-r--r-- | i386/i386at/dev_hdr.h | 43 | ||||
-rw-r--r-- | i386/i386at/device_emul.h | 64 | ||||
-rw-r--r-- | i386/i386at/i386at_ds_routines.c | 284 |
3 files changed, 0 insertions, 391 deletions
diff --git a/i386/i386at/dev_hdr.h b/i386/i386at/dev_hdr.h deleted file mode 100644 index 7af644b..0000000 --- a/i386/i386at/dev_hdr.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Mach device definitions (i386at version). - * - * Copyright (c) 1996 The University of Utah and - * the Computer Systems Laboratory at the University of Utah (CSL). - * All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Author: Shantanu Goel, University of Utah CSL - */ - -#ifndef _I386AT_DEV_HDR_H_ -#define _I386AT_DEV_HDR_H_ - -struct device_emulation_ops; - -/* This structure is associated with each open device port. - The port representing the device points to this structure. */ -struct device -{ - struct device_emulation_ops *emul_ops; - void *emul_data; -}; - -typedef struct device *device_t; - -#define DEVICE_NULL ((device_t) 0) - -#endif /* _I386AT_DEV_HDR_H_ */ diff --git a/i386/i386at/device_emul.h b/i386/i386at/device_emul.h deleted file mode 100644 index 957bd50..0000000 --- a/i386/i386at/device_emul.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Mach device emulation definitions (i386at version). - * - * Copyright (c) 1996 The University of Utah and - * the Computer Systems Laboratory at the University of Utah (CSL). - * All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Author: Shantanu Goel, University of Utah CSL - */ - -#ifndef _I386AT_DEVICE_EMUL_H_ -#define _I386AT_DEVICE_EMUL_H_ - -#include <mach/notify.h> -#include <device/net_status.h> - -/* Each emulation layer provides these operations. */ -struct device_emulation_ops -{ - void (*reference) (void *); - void (*dealloc) (void *); - ipc_port_t (*dev_to_port) (void *); - io_return_t (*open) (ipc_port_t, mach_msg_type_name_t, - dev_mode_t, char *, device_t *); - io_return_t (*close) (void *); - io_return_t (*write) (void *, ipc_port_t, mach_msg_type_name_t, - dev_mode_t, recnum_t, io_buf_ptr_t, unsigned, int *); - io_return_t (*write_inband) (void *, ipc_port_t, mach_msg_type_name_t, - dev_mode_t, recnum_t, io_buf_ptr_inband_t, - unsigned, int *); - io_return_t (*read) (void *, ipc_port_t, mach_msg_type_name_t, - dev_mode_t, recnum_t, int, io_buf_ptr_t *, unsigned *); - io_return_t (*read_inband) (void *, ipc_port_t, mach_msg_type_name_t, - dev_mode_t, recnum_t, int, char *, unsigned *); - io_return_t (*set_status) (void *, dev_flavor_t, dev_status_t, - mach_msg_type_number_t); - io_return_t (*get_status) (void *, dev_flavor_t, dev_status_t, - mach_msg_type_number_t *); - io_return_t (*set_filter) (void *, ipc_port_t, int, filter_t [], unsigned); - io_return_t (*map) (void *, vm_prot_t, vm_offset_t, - vm_size_t, ipc_port_t *, boolean_t); - void (*no_senders) (mach_no_senders_notification_t *); - io_return_t (*write_trap) (void *, dev_mode_t, - recnum_t, vm_offset_t, vm_size_t); - io_return_t (*writev_trap) (void *, dev_mode_t, - recnum_t, io_buf_vec_t *, vm_size_t); -}; - -#endif /* _I386AT_DEVICE_EMUL_H_ */ diff --git a/i386/i386at/i386at_ds_routines.c b/i386/i386at/i386at_ds_routines.c deleted file mode 100644 index bd9b08a..0000000 --- a/i386/i386at/i386at_ds_routines.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Mach device server routines (i386at version). - * - * Copyright (c) 1996 The University of Utah and - * the Computer Systems Laboratory at the University of Utah (CSL). - * All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Author: Shantanu Goel, University of Utah CSL - */ - -#include <kern/printf.h> - -#include <mach/boolean.h> -#include <mach/kern_return.h> -#include <mach/mig_errors.h> -#include <mach/port.h> -#include <mach/notify.h> - -#include <device/device_types.h> -#include <device/device_port.h> -#include <device/device.server.h> - -#include <i386at/dev_hdr.h> -#include <i386at/device_emul.h> - -extern struct device_emulation_ops mach_device_emulation_ops; -#ifdef LINUX_DEV -extern struct device_emulation_ops linux_block_emulation_ops; -#ifdef CONFIG_INET -extern struct device_emulation_ops linux_net_emulation_ops; -#ifdef CONFIG_PCMCIA -extern struct device_emulation_ops linux_pcmcia_emulation_ops; -#endif -#endif -#endif - -/* List of emulations. */ -static struct device_emulation_ops *emulation_list[] = -{ -#ifdef LINUX_DEV - &linux_block_emulation_ops, -#ifdef CONFIG_INET - &linux_net_emulation_ops, -#ifdef CONFIG_PCMCIA - &linux_pcmcia_emulation_ops, -#endif -#endif -#endif - &mach_device_emulation_ops, -}; - -#define NUM_EMULATION (sizeof (emulation_list) / sizeof (emulation_list[0])) - -io_return_t -ds_device_open (ipc_port_t open_port, ipc_port_t reply_port, - mach_msg_type_name_t reply_port_type, dev_mode_t mode, - char *name, device_t *devp) -{ - int i; - io_return_t err; - - /* Open must be called on the master device port. */ - if (open_port != master_device_port) - return D_INVALID_OPERATION; - - /* There must be a reply port. */ - if (! IP_VALID (reply_port)) - { - printf ("ds_* invalid reply port\n"); - Debugger ("ds_* reply_port"); - return MIG_NO_REPLY; - } - - /* Call each emulation's open routine to find the device. */ - for (i = 0; i < NUM_EMULATION; i++) - { - err = (*emulation_list[i]->open) (reply_port, reply_port_type, - mode, name, devp); - if (err != D_NO_SUCH_DEVICE) - break; - } - - return err; -} - -io_return_t -ds_device_close (device_t dev) -{ - if (dev == DEVICE_NULL) - return D_NO_SUCH_DEVICE; - return (dev->emul_ops->close - ? (*dev->emul_ops->close) (dev->emul_data) - : D_SUCCESS); -} - -io_return_t -ds_device_write (device_t dev, ipc_port_t reply_port, - mach_msg_type_name_t reply_port_type, dev_mode_t mode, - recnum_t recnum, io_buf_ptr_t data, unsigned int count, - int *bytes_written) -{ - if (dev == DEVICE_NULL) - return D_NO_SUCH_DEVICE; - if (! data) - return D_INVALID_SIZE; - if (! dev->emul_ops->write) - return D_INVALID_OPERATION; - return (*dev->emul_ops->write) (dev->emul_data, reply_port, - reply_port_type, mode, recnum, - data, count, bytes_written); -} - -io_return_t -ds_device_write_inband (device_t dev, ipc_port_t reply_port, - mach_msg_type_name_t reply_port_type, - dev_mode_t mode, recnum_t recnum, - io_buf_ptr_inband_t data, unsigned count, - int *bytes_written) -{ - if (dev == DEVICE_NULL) - return D_NO_SUCH_DEVICE; - if (! data) - return D_INVALID_SIZE; - if (! dev->emul_ops->write_inband) - return D_INVALID_OPERATION; - return (*dev->emul_ops->write_inband) (dev->emul_data, reply_port, - reply_port_type, mode, recnum, - data, count, bytes_written); -} - -io_return_t -ds_device_read (device_t dev, ipc_port_t reply_port, - mach_msg_type_name_t reply_port_type, dev_mode_t mode, - recnum_t recnum, int count, io_buf_ptr_t *data, - unsigned *bytes_read) -{ - if (dev == DEVICE_NULL) - return D_NO_SUCH_DEVICE; - if (! dev->emul_ops->read) - return D_INVALID_OPERATION; - return (*dev->emul_ops->read) (dev->emul_data, reply_port, - reply_port_type, mode, recnum, - count, data, bytes_read); -} - -io_return_t -ds_device_read_inband (device_t dev, ipc_port_t reply_port, - mach_msg_type_name_t reply_port_type, dev_mode_t mode, - recnum_t recnum, int count, char *data, - unsigned *bytes_read) -{ - if (dev == DEVICE_NULL) - return D_NO_SUCH_DEVICE; - if (! dev->emul_ops->read_inband) - return D_INVALID_OPERATION; - return (*dev->emul_ops->read_inband) (dev->emul_data, reply_port, - reply_port_type, mode, recnum, - count, data, bytes_read); -} - -io_return_t -ds_device_set_status (device_t dev, dev_flavor_t flavor, - dev_status_t status, mach_msg_type_number_t status_count) -{ - if (dev == DEVICE_NULL) - return D_NO_SUCH_DEVICE; - if (! dev->emul_ops->set_status) - return D_INVALID_OPERATION; - - return (*dev->emul_ops->set_status) (dev->emul_data, flavor, status, - status_count); -} - -io_return_t -ds_device_get_status (device_t dev, dev_flavor_t flavor, dev_status_t status, - mach_msg_type_number_t *status_count) -{ - if (dev == DEVICE_NULL) - return D_NO_SUCH_DEVICE; - if (! dev->emul_ops->get_status) - return D_INVALID_OPERATION; - - return (*dev->emul_ops->get_status) (dev->emul_data, flavor, status, - status_count); -} - -io_return_t -ds_device_set_filter (device_t dev, ipc_port_t receive_port, int priority, - filter_t *filter, unsigned filter_count) -{ - if (dev == DEVICE_NULL) - return D_NO_SUCH_DEVICE; - if (! dev->emul_ops->set_filter) - return D_INVALID_OPERATION; - return (*dev->emul_ops->set_filter) (dev->emul_data, receive_port, - priority, filter, filter_count); -} - -io_return_t -ds_device_map (device_t dev, vm_prot_t prot, vm_offset_t offset, - vm_size_t size, ipc_port_t *pager, boolean_t unmap) -{ - if (dev == DEVICE_NULL) - return D_NO_SUCH_DEVICE; - if (! dev->emul_ops->map) - return D_INVALID_OPERATION; - return (*dev->emul_ops->map) (dev->emul_data, prot, - offset, size, pager, unmap); -} - -boolean_t -ds_notify (mach_msg_header_t *msg) -{ - if (msg->msgh_id == MACH_NOTIFY_NO_SENDERS) - { - device_t dev; - mach_no_senders_notification_t *ns; - - ns = (mach_no_senders_notification_t *) msg; - dev = dev_port_lookup((ipc_port_t) ns->not_header.msgh_remote_port); - assert(dev); - if (dev->emul_ops->no_senders) - (*dev->emul_ops->no_senders) (ns); - return TRUE; - } - - printf ("ds_notify: strange notification %d\n", msg->msgh_id); - return FALSE; -} - -io_return_t -ds_device_write_trap (device_t dev, dev_mode_t mode, - recnum_t recnum, vm_offset_t data, vm_size_t count) -{ - if (dev == DEVICE_NULL) - return D_NO_SUCH_DEVICE; - if (! dev->emul_ops->write_trap) - return D_INVALID_OPERATION; - return (*dev->emul_ops->write_trap) (dev->emul_data, - mode, recnum, data, count); -} - -io_return_t -ds_device_writev_trap (device_t dev, dev_mode_t mode, - recnum_t recnum, io_buf_vec_t *iovec, vm_size_t count) -{ - if (dev == DEVICE_NULL) - return D_NO_SUCH_DEVICE; - if (! dev->emul_ops->writev_trap) - return D_INVALID_OPERATION; - return (*dev->emul_ops->writev_trap) (dev->emul_data, - mode, recnum, iovec, count); -} - -void -device_reference (device_t dev) -{ - if (dev->emul_ops->reference) - (*dev->emul_ops->reference) (dev->emul_data); -} - -void -device_deallocate (device_t dev) -{ - if (dev == DEVICE_NULL) - return; - if (dev->emul_ops->dealloc) - (*dev->emul_ops->dealloc) (dev->emul_data); -} |