From d35703f70a6c0f89bcec1c97801532ab0d1b945f Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 27 Mar 2007 22:47:11 +0000 Subject: 2007-03-27 Thomas Schwinge Unconditionally use the device driver multiplexing. Suggested by Gianluca Guida . * 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 , but instead include and . * linux/dev/glue/net.c: Don't include , but instead include . * linux/pcmcia-cs/glue/ds.c: Likewise. --- device/dev_hdr.h | 48 +++- device/dev_lookup.c | 29 +-- device/device_emul.h | 64 ++++++ device/device_init.c | 4 +- device/ds_routines.c | 639 +++++++++++++++++++++++++++------------------------ 5 files changed, 448 insertions(+), 336 deletions(-) create mode 100644 device/device_emul.h (limited to 'device') diff --git a/device/dev_hdr.h b/device/dev_hdr.h index b976caf..50e2977 100644 --- a/device/dev_hdr.h +++ b/device/dev_hdr.h @@ -28,6 +28,31 @@ * Date: 3/89 */ +/* + * 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 _DEVICE_DEV_HDR_H_ #define _DEVICE_DEV_HDR_H_ @@ -37,16 +62,17 @@ #include -#ifdef i386 -#include -#else -#define mach_device device -#define mach_device_t device_t -#define MACH_DEVICE_NULL DEVICE_NULL -#define mach_device_reference device_reference -#define mach_device_deallocate device_deallocate -#define mach_convert_device_to_port convert_device_to_port -#endif +/* 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) /* * Generic device header. May be allocated with the device, @@ -72,9 +98,7 @@ struct mach_device { int dev_number; /* device number */ int bsize; /* replacement for DEV_BSIZE */ struct dev_ops *dev_ops; /* and operations vector */ -#ifdef i386 struct device dev; /* the real device structure */ -#endif }; typedef struct mach_device *mach_device_t; #define MACH_DEVICE_NULL ((mach_device_t)0) diff --git a/device/dev_lookup.c b/device/dev_lookup.c index 3243a2c..2391e8d 100644 --- a/device/dev_lookup.c +++ b/device/dev_lookup.c @@ -42,9 +42,7 @@ #include #include -#ifdef i386 -#include -#endif +#include /* * Device structure routines: reference counting, port->device. @@ -255,7 +253,7 @@ dev_port_enter(device) register mach_device_t device; { mach_device_reference(device); -#ifdef i386 + ipc_kobject_set(device->port, (ipc_kobject_t) &device->dev, IKOT_DEVICE); device->dev.emul_data = device; @@ -264,9 +262,6 @@ dev_port_enter(device) device->dev.emul_ops = &mach_device_emulation_ops; } -#else - ipc_kobject_set(device->port, (ipc_kobject_t) device, IKOT_DEVICE); -#endif } /* @@ -296,12 +291,8 @@ dev_port_lookup(port) ip_lock(port); if (ip_active(port) && (ip_kotype(port) == IKOT_DEVICE)) { device = (device_t) port->ip_kobject; -#ifdef i386 if (device->emul_ops->reference) (*device->emul_ops->reference)(device->emul_data); -#else - mach_device_reference(device); -#endif } else device = DEVICE_NULL; @@ -318,26 +309,10 @@ ipc_port_t convert_device_to_port(device) register device_t device; { -#ifndef i386 - register ipc_port_t port; -#endif - if (device == DEVICE_NULL) return IP_NULL; -#ifdef i386 return (*device->emul_ops->dev_to_port) (device->emul_data); -#else - device_lock(device); - if (device->state == DEV_STATE_OPEN) - port = ipc_port_make_send(device->port); - else - port = IP_NULL; - device_unlock(device); - - mach_device_deallocate(device); - return port; -#endif } /* diff --git a/device/device_emul.h b/device/device_emul.h new file mode 100644 index 0000000..957bd50 --- /dev/null +++ b/device/device_emul.h @@ -0,0 +1,64 @@ +/* + * 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 +#include + +/* 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/device/device_init.c b/device/device_init.c index 1208fbf..4f57fc2 100644 --- a/device/device_init.c +++ b/device/device_init.c @@ -39,7 +39,7 @@ -extern void ds_init(); +extern void mach_device_init(); extern void dev_lookup_init(); extern void net_io_init(); extern void device_pager_init(); @@ -57,7 +57,7 @@ device_service_create() if (master_device_port == IP_NULL) panic("can't allocate master device port"); - ds_init(); + mach_device_init(); dev_lookup_init(); net_io_init(); device_pager_init(); diff --git a/device/ds_routines.c b/device/ds_routines.c index 0abd75b..8b5e1e5 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -28,6 +28,31 @@ * Date: 3/89 */ +/* + * 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 #include @@ -64,42 +89,321 @@ #include #include #include +#include #include + +#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 +extern struct device_emulation_ops mach_device_emulation_ops; -#ifdef i386 -#include +/* 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) +{ + /* Refuse if device is dead or not completely open. */ + 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) +{ + /* Refuse if device is dead or not completely open. */ + if (dev == DEVICE_NULL) + return D_NO_SUCH_DEVICE; + + if (data == 0) + 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) +{ + /* Refuse if device is dead or not completely open. */ + if (dev == DEVICE_NULL) + return D_NO_SUCH_DEVICE; + + if (data == 0) + 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) +{ + /* Refuse if device is dead or not completely open. */ + 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) +{ + /* Refuse if device is dead or not completely open. */ + 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) +{ + /* Refuse if device is dead or not completely open. */ + 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) +{ + /* Refuse if device is dead or not completely open. */ + 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) +{ + /* Refuse if device is dead or not completely open. */ + 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) +{ + /* Refuse if device is dead or not completely open. */ + 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) +{ + /* Refuse if device is dead or not completely open. */ + 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) +{ + /* Refuse if device is dead or not completely open. */ + 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) +{ + /* Refuse if device is dead or not completely open. */ + if (dev == DEVICE_NULL) + return; + + if (dev->emul_ops->reference) + (*dev->emul_ops->reference) (dev->emul_data); +} + +void +device_deallocate (device_t dev) +{ + /* Refuse if device is dead or not completely open. */ + if (dev == DEVICE_NULL) + return; + + if (dev->emul_ops->dealloc) + (*dev->emul_ops->dealloc) (dev->emul_data); +} + +/* + * What follows is the interface for the native Mach devices. + */ -#ifdef i386 ipc_port_t -mach_convert_device_to_port (void *d) +mach_convert_device_to_port (mach_device_t device) { ipc_port_t port; - mach_device_t device = d; if (! device) return IP_NULL; + device_lock(device); + if (device->state == DEV_STATE_OPEN) port = ipc_port_make_send(device->port); else port = IP_NULL; + device_unlock(device); + mach_device_deallocate(device); + return port; } -#endif /* i386 */ -#ifdef i386 static io_return_t device_open(reply_port, reply_port_type, mode, name, device_p) -#else -io_return_t -ds_device_open(open_port, reply_port, reply_port_type, - mode, name, device_p) - ipc_port_t open_port; -#endif ipc_port_t reply_port; mach_msg_type_name_t reply_port_type; dev_mode_t mode; @@ -111,24 +415,6 @@ ds_device_open(open_port, reply_port, reply_port_type, register io_req_t ior; ipc_port_t notify; -#ifndef i386 - /* - * 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); /* no sense in doing anything */ - } - -#endif /* ! i386 */ - /* * Find the device. */ @@ -165,11 +451,7 @@ ds_device_open(open_port, reply_port, reply_port_type, device->open_count++; device_unlock(device); -#ifdef i386 *device_p = &device->dev; -#else - *device_p = device; -#endif return (D_SUCCESS); /* * Return deallocates device reference while acquiring @@ -293,32 +575,17 @@ ds_open_done(ior) (void) ds_device_open_reply(ior->io_reply_port, ior->io_reply_port_type, result, -#ifdef i386 - (mach_convert_device_to_port - (device))); -#else - convert_device_to_port(device)); -#endif + mach_convert_device_to_port(device)); } else mach_device_deallocate(device); return (TRUE); } -#ifdef i386 static io_return_t device_close(device) -#else -io_return_t -ds_device_close(device) -#endif register mach_device_t device; { -#ifndef i386 - if (device == DEVICE_NULL) - return (D_NO_SUCH_DEVICE); -#endif - device_lock(device); /* @@ -378,17 +645,10 @@ ds_device_close(device) /* * Write to a device. */ -#ifdef i386 static io_return_t -device_write(d, reply_port, reply_port_type, mode, recnum, +device_write(device, reply_port, reply_port_type, mode, recnum, data, data_count, bytes_written) - void *d; -#else -io_return_t -ds_device_write(device, reply_port, reply_port_type, mode, recnum, - data, data_count, bytes_written) - register mach_device_t device; -#endif + mach_device_t device; ipc_port_t reply_port; mach_msg_type_name_t reply_port_type; dev_mode_t mode; @@ -397,28 +657,12 @@ ds_device_write(device, reply_port, reply_port_type, mode, recnum, unsigned int data_count; int *bytes_written; /* out */ { -#ifdef i386 - register mach_device_t device = d; -#endif register io_req_t ior; register io_return_t result; -#ifndef i386 - /* - * Refuse if device is dead or not completely open. - */ - if (device == DEVICE_NULL) - return (D_NO_SUCH_DEVICE); -#endif - if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); -#ifndef i386 - if (data == 0) - return (D_INVALID_SIZE); -#endif - /* * XXX Need logic to reject ridiculously big requests. */ @@ -492,17 +736,10 @@ ds_device_write(device, reply_port, reply_port_type, mode, recnum, /* * Write to a device, but memory is in message. */ -#ifdef i386 static io_return_t -device_write_inband(d, reply_port, reply_port_type, mode, recnum, +device_write_inband(device, reply_port, reply_port_type, mode, recnum, data, data_count, bytes_written) - void *d; -#else -io_return_t -ds_device_write_inband(device, reply_port, reply_port_type, mode, recnum, - data, data_count, bytes_written) - register mach_device_t device; -#endif + mach_device_t device; ipc_port_t reply_port; mach_msg_type_name_t reply_port_type; dev_mode_t mode; @@ -511,28 +748,12 @@ ds_device_write_inband(device, reply_port, reply_port_type, mode, recnum, unsigned int data_count; int *bytes_written; /* out */ { -#ifdef i386 - register mach_device_t device = d; -#endif register io_req_t ior; register io_return_t result; -#ifndef i386 - /* - * Refuse if device is dead or not completely open. - */ - if (device == DEVICE_NULL) - return (D_NO_SUCH_DEVICE); -#endif - if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); -#ifndef i386 - if (data == 0) - return (D_INVALID_SIZE); -#endif - /* XXX note that a CLOSE may proceed at any point */ /* @@ -713,7 +934,7 @@ device_write_dealloc(ior) * To prevent a possible deadlock with the default pager, * we have to release space in the device_io_map before * we allocate any memory. (Which vm_map_copy_invoke_cont - * might do.) See the discussion in ds_init. + * might do.) See the discussion in mach_device_init. */ kmem_io_map_deallocate(device_io_map, @@ -831,17 +1052,10 @@ ds_write_done(ior) /* * Read from a device. */ -#ifdef i386 static io_return_t -device_read(d, reply_port, reply_port_type, mode, recnum, +device_read(device, reply_port, reply_port_type, mode, recnum, bytes_wanted, data, data_count) - void *d; -#else -io_return_t -ds_device_read(device, reply_port, reply_port_type, mode, recnum, - bytes_wanted, data, data_count) - register mach_device_t device; -#endif + mach_device_t device; ipc_port_t reply_port; mach_msg_type_name_t reply_port_type; dev_mode_t mode; @@ -850,9 +1064,6 @@ ds_device_read(device, reply_port, reply_port_type, mode, recnum, io_buf_ptr_t *data; /* out */ unsigned int *data_count; /* out */ { -#ifdef i386 - register mach_device_t device = d; -#endif register io_req_t ior; register io_return_t result; @@ -861,14 +1072,6 @@ ds_device_read(device, reply_port, reply_port_type, mode, recnum, *data_count = *data_count; #endif /* lint */ -#ifndef i386 - /* - * Refuse if device is dead or not completely open. - */ - if (device == DEVICE_NULL) - return (D_NO_SUCH_DEVICE); -#endif - if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -931,17 +1134,10 @@ ds_device_read(device, reply_port, reply_port_type, mode, recnum, /* * Read from a device, but return the data 'inband.' */ -#ifdef i386 static io_return_t -device_read_inband(d, reply_port, reply_port_type, mode, recnum, +device_read_inband(device, reply_port, reply_port_type, mode, recnum, bytes_wanted, data, data_count) - void *d; -#else -io_return_t -ds_device_read_inband(device, reply_port, reply_port_type, mode, recnum, - bytes_wanted, data, data_count) - register mach_device_t device; -#endif + mach_device_t device; ipc_port_t reply_port; mach_msg_type_name_t reply_port_type; dev_mode_t mode; @@ -950,9 +1146,6 @@ ds_device_read_inband(device, reply_port, reply_port_type, mode, recnum, char *data; /* pointer to OUT array */ unsigned int *data_count; /* out */ { -#ifdef i386 - register mach_device_t device = d; -#endif register io_req_t ior; register io_return_t result; @@ -961,14 +1154,6 @@ ds_device_read_inband(device, reply_port, reply_port_type, mode, recnum, *data_count = *data_count; #endif /* lint */ -#ifndef i386 - /* - * Refuse if device is dead or not completely open. - */ - if (device == DEVICE_NULL) - return (D_NO_SUCH_DEVICE); -#endif - if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1030,7 +1215,6 @@ ds_device_read_inband(device, reply_port, reply_port_type, mode, recnum, return (MIG_NO_REPLY); /* reply has already been sent. */ } - /* * Allocate wired-down memory for device read. */ @@ -1158,31 +1342,13 @@ boolean_t ds_read_done(ior) return (TRUE); } -#ifdef i386 static io_return_t -device_set_status(d, flavor, status, status_count) - void *d; -#else -io_return_t -ds_device_set_status(device, flavor, status, status_count) - register mach_device_t device; -#endif +device_set_status(device, flavor, status, status_count) + mach_device_t device; dev_flavor_t flavor; dev_status_t status; mach_msg_type_number_t status_count; { -#ifdef i386 - register mach_device_t device = d; -#endif - -#ifndef i386 - /* - * Refuse if device is dead or not completely open. - */ - if (device == DEVICE_NULL) - return (D_NO_SUCH_DEVICE); -#endif - if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1194,31 +1360,13 @@ ds_device_set_status(device, flavor, status, status_count) status_count)); } -#ifdef i386 io_return_t -mach_device_get_status(d, flavor, status, status_count) - void *d; -#else -io_return_t -ds_device_get_status(device, flavor, status, status_count) - register mach_device_t device; -#endif +mach_device_get_status(device, flavor, status, status_count) + mach_device_t device; dev_flavor_t flavor; dev_status_t status; /* pointer to OUT array */ mach_msg_type_number_t *status_count; /* out */ { -#ifdef i386 - register mach_device_t device = d; -#endif - -#ifndef i386 - /* - * Refuse if device is dead or not completely open. - */ - if (device == DEVICE_NULL) - return (D_NO_SUCH_DEVICE); -#endif - if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1230,32 +1378,14 @@ ds_device_get_status(device, flavor, status, status_count) status_count)); } -#ifdef i386 static io_return_t -device_set_filter(d, receive_port, priority, filter, filter_count) - void *d; -#else -io_return_t -ds_device_set_filter(device, receive_port, priority, filter, filter_count) - register mach_device_t device; -#endif +device_set_filter(device, receive_port, priority, filter, filter_count) + mach_device_t device; ipc_port_t receive_port; int priority; filter_t filter[]; /* pointer to IN array */ unsigned int filter_count; { -#ifdef i386 - register mach_device_t device = d; -#endif - -#ifndef i386 - /* - * Refuse if device is dead or not completely open. - */ - if (device == DEVICE_NULL) - return (D_NO_SUCH_DEVICE); -#endif - if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1274,39 +1404,21 @@ ds_device_set_filter(device, receive_port, priority, filter, filter_count) filter_count)); } -#ifdef i386 static io_return_t -device_map(d, protection, offset, size, pager, unmap) - void *d; -#else -io_return_t -ds_device_map(device, protection, offset, size, pager, unmap) - register mach_device_t device; -#endif +device_map(device, protection, offset, size, pager, unmap) + mach_device_t device; vm_prot_t protection; vm_offset_t offset; vm_size_t size; ipc_port_t *pager; /* out */ boolean_t unmap; /* ? */ { -#ifdef i386 - register mach_device_t device = d; -#endif - #ifdef lint unmap = unmap; #endif /* lint */ if (protection & ~VM_PROT_ALL) return (KERN_INVALID_ARGUMENT); -#ifndef i386 - /* - * Refuse if device is dead or not completely open. - */ - if (device == DEVICE_NULL) - return (D_NO_SUCH_DEVICE); -#endif - if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1319,11 +1431,7 @@ ds_device_map(device, protection, offset, size, pager, unmap) /* * Doesn't do anything (yet). */ -#ifdef i386 static void -#else -void -#endif ds_no_senders(notification) mach_no_senders_notification_t *notification; { @@ -1332,23 +1440,6 @@ ds_no_senders(notification) notification->not_count); } -#ifndef i386 -boolean_t -ds_notify(msg) - mach_msg_header_t *msg; -{ - switch (msg->msgh_id) { - case MACH_NOTIFY_NO_SENDERS: - ds_no_senders((mach_no_senders_notification_t *) msg); - return TRUE; - - default: - printf("ds_notify: strange notification %d\n", msg->msgh_id); - return FALSE; - } -} -#endif - queue_head_t io_done_list; decl_simple_lock_data(, io_done_list_lock) @@ -1394,7 +1485,7 @@ void io_done_thread_continue() register spl_t s; register io_req_t ior; -#if defined (i386) && defined (LINUX_DEV) && defined (CONFIG_INET) +#if defined (LINUX_DEV) && defined (CONFIG_INET) free_skbuffs (); #endif s = splio(); @@ -1438,9 +1529,9 @@ void io_done_thread() #define DEVICE_IO_MAP_SIZE (2 * 1024 * 1024) -extern void ds_trap_init(void); /* forward */ +static void mach_device_trap_init(void); /* forward */ -void ds_init() +void mach_device_init() { vm_offset_t device_io_min, device_io_max; @@ -1477,7 +1568,7 @@ void ds_init() FALSE, "io inband read buffers"); - ds_trap_init(); + mach_device_trap_init(); } void iowait(ior) @@ -1514,10 +1605,10 @@ void iowait(ior) zone_t io_trap_zone; /* - * Initialization. Called from ds_init(). + * Initialization. Called from mach_device_init(). */ -void -ds_trap_init(void) +static void +mach_device_trap_init(void) { io_trap_zone = zinit(IOTRAP_REQSIZE, 0, 256 * IOTRAP_REQSIZE, @@ -1564,33 +1655,13 @@ ds_trap_write_done(io_req_t ior) /* * Like device_write except that data is in user space. */ -#ifdef i386 static io_return_t -device_write_trap (void *d, dev_mode_t mode, +device_write_trap (mach_device_t device, dev_mode_t mode, recnum_t recnum, vm_offset_t data, vm_size_t data_count) -#else -io_return_t -ds_device_write_trap(device_t device, - dev_mode_t mode, - recnum_t recnum, - vm_offset_t data, - vm_size_t data_count) -#endif { -#ifdef i386 - mach_device_t device = d; -#endif io_req_t ior; io_return_t result; -#ifndef i386 - /* - * Refuse if device is dead or not completely open. - */ - if (device == DEVICE_NULL) - return (D_NO_SUCH_DEVICE); -#endif - if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1652,36 +1723,16 @@ ds_device_write_trap(device_t device, return (result); } -#ifdef i386 static io_return_t -device_writev_trap (void *d, dev_mode_t mode, +device_writev_trap (mach_device_t device, dev_mode_t mode, recnum_t recnum, io_buf_vec_t *iovec, vm_size_t iocount) -#else -io_return_t -ds_device_writev_trap(device_t device, - dev_mode_t mode, - recnum_t recnum, - io_buf_vec_t *iovec, - vm_size_t iocount) -#endif { -#ifdef i386 - mach_device_t device = d; -#endif io_req_t ior; io_return_t result; io_buf_vec_t stack_iovec[16]; /* XXX */ vm_size_t data_count; int i; -#ifndef i386 - /* - * Refuse if device is dead or not completely open. - */ - if (device == DEVICE_NULL) - return (D_NO_SUCH_DEVICE); -#endif - if (device->state != DEV_STATE_OPEN) return (D_NO_SUCH_DEVICE); @@ -1763,7 +1814,6 @@ ds_device_writev_trap(device_t device, return (result); } -#ifdef i386 struct device_emulation_ops mach_device_emulation_ops = { mach_device_reference, @@ -1783,4 +1833,3 @@ struct device_emulation_ops mach_device_emulation_ops = device_write_trap, device_writev_trap }; -#endif -- cgit v1.2.3