summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2020-03-30 01:21:26 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2020-03-30 01:23:39 +0200
commit4892303b4b7637bb731ff5f0c28add44a9b841a8 (patch)
treea7fc0773907055129895563649ad0bf3cfeb4f86
parentb946d58eb32f28d20646b79b803af79f069d6f5c (diff)
Make libmachdevdde use libmachdev
-rw-r--r--libmachdevdde/Makefile16
-rw-r--r--libmachdevdde/block.c17
-rw-r--r--libmachdevdde/dev_hdr.h133
-rw-r--r--libmachdevdde/device_emul.h65
-rw-r--r--libmachdevdde/ds_routines.c344
-rw-r--r--libmachdevdde/ds_routines.h57
-rw-r--r--libmachdevdde/io_req.h135
-rw-r--r--libmachdevdde/mach.defs715
-rw-r--r--libmachdevdde/machdevdde.h (renamed from libmachdevdde/machdev.h)13
-rw-r--r--libmachdevdde/mig-decls.h50
-rw-r--r--libmachdevdde/mig-mutate.h36
-rw-r--r--libmachdevdde/misc.c20
-rw-r--r--libmachdevdde/misc.h26
-rw-r--r--libmachdevdde/net.c22
-rw-r--r--libmachdevdde/trivfs_server.c171
-rw-r--r--libmachdevdde/util.h35
16 files changed, 93 insertions, 1762 deletions
diff --git a/libmachdevdde/Makefile b/libmachdevdde/Makefile
index 1ce7d163a..70fdb0ebe 100644
--- a/libmachdevdde/Makefile
+++ b/libmachdevdde/Makefile
@@ -19,17 +19,15 @@ dir := libmachdevdde
makemode := library
libname = libmachdevdde
-SRCS = deviceUser.c machUser.c net.c ds_routines.c queue.c trivfs_server.c \
- device_replyUser.c deviceServer.c notifyServer.c misc.c
+SRCS = device_replyUser.c net.c ds_routines.c queue.c misc.c
#block.c
-LCLHDRS = dev_hdr.h device_emul.h ds_routines.h vm_param.h \
- util.h queue.h io_req.h if_ether.h machdev.h linux-errno.h \
- errno-base.h
-installhdrs = machdev.h
-HURDLIBS = ports trivfs bpf ddekit
+LCLHDRS = vm_param.h misc.h \
+ queue.h if_ether.h if_hdr.h \
+ mach_glue.h machdevdde.h \
+ linux-errno.h errno-base.h
+installhdrs = machdevdde.h
+HURDLIBS = machdev bpf ddekit
LDLIBS += -lpthread
OBJS = $(SRCS:.c=.o) $(MIGSTUBS)
-MIGSFLAGS = -imacros $(srcdir)/mig-mutate.h
-device-MIGSFLAGS="-DMACH_PAYLOAD_TO_PORT=ports_payload_get_name"
include ../Makeconf
diff --git a/libmachdevdde/block.c b/libmachdevdde/block.c
index 799620726..caa3d95d5 100644
--- a/libmachdevdde/block.c
+++ b/libmachdevdde/block.c
@@ -26,9 +26,8 @@
#include <unistd.h>
#include <sys/mman.h>
-#include "mach_U.h"
-
#include <mach.h>
+#include <hurd/machdev.h>
#include <hurd.h>
#define MACH_INCLUDE
@@ -38,8 +37,7 @@
#include "ds_routines.h"
#include "vm_param.h"
#include "device_reply_U.h"
-#include "dev_hdr.h"
-#include "util.h"
+#include "misc.h"
#include "mach_glue.h"
/* for submit_bio(). But it might not be very proper to keep
@@ -65,7 +63,7 @@ dev_to_port (void *nd)
: MACH_PORT_NULL);
}
-static struct device_emulation_ops linux_block_emulation_ops;
+static struct machdev_device_emulation_ops linux_block_emulation_ops;
#define DISK_NAME_LEN 32
@@ -133,10 +131,10 @@ device_open (mach_port_t reply_port, mach_msg_type_name_t reply_port_type,
if (dev_name == NULL)
return D_NO_SUCH_DEVICE;
- err = create_device_port (sizeof (*bd), &bd);
+ err = machdev_create_device_port (sizeof (*bd), &bd);
if (err)
{
- ddekit_printf ("after create_device_port: cannot create a port\n");
+ ddekit_printf ("after machdev_create_device_port: cannot create a port\n");
goto out;
}
bd->dev = open_block_dev (dev_name, slice, mode);
@@ -286,7 +284,7 @@ device_get_status (void *d, dev_flavor_t flavor, dev_status_t status,
return D_SUCCESS;
}
-static struct device_emulation_ops linux_block_emulation_ops =
+static struct machdev_device_emulation_ops linux_block_emulation_ops =
{
NULL,
NULL,
@@ -309,6 +307,5 @@ static struct device_emulation_ops linux_block_emulation_ops =
void register_block()
{
- extern void reg_dev_emul (struct device_emulation_ops *ops);
- reg_dev_emul (&linux_block_emulation_ops);
+ machdev_register (&linux_block_emulation_ops);
}
diff --git a/libmachdevdde/dev_hdr.h b/libmachdevdde/dev_hdr.h
deleted file mode 100644
index 79edc43a3..000000000
--- a/libmachdevdde/dev_hdr.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990,1989 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.
- */
-/*
- * Author: David B. Golub, Carnegie Mellon University
- * 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_
-
-#include <mach.h>
-#include <hurd.h>
-#include <hurd/ports.h>
-#include <pthread.h>
-
-#include "device_emul.h"
-
-/*
- * Operations list for major device types.
- */
-struct dev_ops {
- char * d_name; /* name for major device */
- int (*d_open)(); /* open device */
- int (*d_close)(); /* close device */
- int (*d_read)(); /* read */
- int (*d_write)(); /* write */
- int (*d_getstat)(); /* get status/control */
- int (*d_setstat)(); /* set status/control */
- vm_offset_t (*d_mmap)(); /* map memory */
- int (*d_async_in)();/* asynchronous input setup */
- int (*d_reset)(); /* reset device */
- int (*d_port_death)();
- /* clean up reply ports */
- int d_subdev; /* number of sub-devices per
- unit */
- int (*d_dev_info)(); /* driver info for kernel */
-};
-typedef struct dev_ops *dev_ops_t;
-
-/* This structure is associated with each open device port.
- * The port representing the device points to this structure. */
-struct emul_device
-{
- struct device_emulation_ops *emul_ops;
- void *emul_data;
-};
-
-typedef struct emul_device *emul_device_t;
-
-#define DEVICE_NULL ((device_t) 0)
-
-/*
- * Generic device header. May be allocated with the device,
- * or built when the device is opened.
- */
-struct mach_device {
- struct port_info port;
- struct emul_device dev; /* the real device structure */
-};
-typedef struct mach_device *mach_device_t;
-#define MACH_DEVICE_NULL ((mach_device_t)0)
-
-/*
- * To find and remove device entries
- */
-mach_device_t device_lookup(char *); /* by name */
-
-/*
- * To find and remove port-to-device mappings
- */
-void dev_port_enter(mach_device_t);
-void dev_port_remove(mach_device_t);
-
-/*
- * To call a routine on each device
- */
-boolean_t dev_map(boolean_t (*)(), mach_port_t);
-
-/*
- * To lock and unlock state and open-count
- */
-#define device_lock(device) pthread_mutex_lock(&(device)->lock)
-#define device_unlock(device) pthread_mutex_unlock(&(device)->lock)
-
-#endif /* _DEVICE_DEV_HDR_H_ */
diff --git a/libmachdevdde/device_emul.h b/libmachdevdde/device_emul.h
deleted file mode 100644
index e27799cbd..000000000
--- a/libmachdevdde/device_emul.h
+++ /dev/null
@@ -1,65 +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.h>
-
-/* Each emulation layer provides these operations. */
-struct device_emulation_ops
-{
- void (*init) (void);
- void (*reference) (void *);
- void (*dealloc) (void *);
- mach_port_t (*dev_to_port) (void *);
- io_return_t (*open) (mach_port_t, mach_msg_type_name_t,
- dev_mode_t, char *, device_t *,
- mach_msg_type_name_t *type);
- io_return_t (*close) (void *);
- io_return_t (*write) (void *, mach_port_t, mach_msg_type_name_t,
- dev_mode_t, recnum_t, io_buf_ptr_t, unsigned, int *);
- io_return_t (*write_inband) (void *, mach_port_t, mach_msg_type_name_t,
- dev_mode_t, recnum_t, io_buf_ptr_inband_t,
- unsigned, int *);
- io_return_t (*read) (void *, mach_port_t, mach_msg_type_name_t,
- dev_mode_t, recnum_t, int, io_buf_ptr_t *, unsigned *);
- io_return_t (*read_inband) (void *, mach_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 *, mach_port_t, int, filter_t [], unsigned);
- io_return_t (*map) (void *, vm_prot_t, vm_offset_t,
- vm_size_t, mach_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/libmachdevdde/ds_routines.c b/libmachdevdde/ds_routines.c
index e9fbe9445..5a3cb66c7 100644
--- a/libmachdevdde/ds_routines.c
+++ b/libmachdevdde/ds_routines.c
@@ -1,341 +1,35 @@
/*
- * Mach Operating System
- * Copyright (c) 1993,1991,1990,1989 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.
- */
-/*
- * Author: David B. Golub, Carnegie Mellon University
- * 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 <stdio.h>
-#include <string.h>
-#include <error.h>
-
-#include <hurd.h>
-#include <mach.h>
-
-#include <ddekit/thread.h>
-
-#include "vm_param.h"
-#include "device_S.h"
-#include "notify_S.h"
-#include "io_req.h"
-#include "dev_hdr.h"
-#include "util.h"
-#include "queue.h"
-#include "mach_glue.h"
-
-struct port_bucket *device_bucket;
-struct port_class *dev_class;
-
-#define NUM_EMULATION num_emul
-#define MAX_NUM_EMULATION 32
-
-/* List of emulations. */
-static struct device_emulation_ops *emulation_list[MAX_NUM_EMULATION];
-static int num_emul;
-
-boolean_t is_master_device (mach_port_t port);
-
-/*
- * What follows is the interface for the native Mach devices.
- */
-
-/* Implementation of device interface */
-io_return_t
-ds_device_open (mach_port_t open_port, mach_port_t reply_port,
- mach_msg_type_name_t reply_port_type, dev_mode_t mode,
- char *name, device_t *devp, mach_msg_type_name_t *devicePoly)
-{
- int i;
- io_return_t err = D_NO_SUCH_DEVICE;
-
- /* Open must be called on the master device port. */
- if (!is_master_device (open_port))
- return D_INVALID_OPERATION;
-
- /* There must be a reply port. */
- if (! MACH_PORT_VALID (reply_port))
- {
- fprintf (stderr, "ds_* invalid reply port\n");
- 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, devicePoly);
- if (err != D_NO_SUCH_DEVICE)
- break;
- }
-
- return err;
-}
-
-io_return_t
-ds_device_close (struct mach_device *device)
-{
- io_return_t ret;
-
- if (device == NULL)
- return D_NO_SUCH_DEVICE;
-
- ret = (device->dev.emul_ops->close
- ? (*device->dev.emul_ops->close) (device->dev.emul_data)
- : D_SUCCESS);
- return ret;
-}
-
-io_return_t
-ds_device_write (struct mach_device *device, mach_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)
-{
- io_return_t ret;
-
- if (data == 0)
- return D_INVALID_SIZE;
-
- if (device == NULL)
- return D_NO_SUCH_DEVICE;
-
- if (! device->dev.emul_ops->write)
- return D_INVALID_OPERATION;
-
- ret = (*device->dev.emul_ops->write) (device->dev.emul_data, reply_port,
- reply_port_type, mode, recnum,
- data, count, bytes_written);
- return ret;
-}
-
-io_return_t
-ds_device_write_inband (struct mach_device *device, mach_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)
-{
- io_return_t ret;
-
- if (data == 0)
- return D_INVALID_SIZE;
-
- if (device == NULL)
- return D_NO_SUCH_DEVICE;
-
- if (! device->dev.emul_ops->write_inband)
- return D_INVALID_OPERATION;
-
- ret = (*device->dev.emul_ops->write_inband) (device->dev.emul_data,
- reply_port, reply_port_type,
- mode, recnum,
- data, count, bytes_written);
- return ret;
-}
-
-io_return_t
-ds_device_read (struct mach_device *device, mach_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)
-{
- io_return_t ret;
-
- if (device == NULL)
- return D_NO_SUCH_DEVICE;
-
- if (! device->dev.emul_ops->read)
- return D_INVALID_OPERATION;
+ Copyright (C) 2010 Free Software Foundation, Inc.
+ Written by Zheng Da.
- ret = (*device->dev.emul_ops->read) (device->dev.emul_data, reply_port,
- reply_port_type, mode, recnum,
- count, data, bytes_read);
- return ret;
-}
-
-io_return_t
-ds_device_read_inband (struct mach_device *device, mach_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)
-{
- io_return_t ret;
+ This file is part of the GNU Hurd.
- if (device == NULL)
- return D_NO_SUCH_DEVICE;
-
- if (! device->dev.emul_ops->read_inband)
- return D_INVALID_OPERATION;
-
- ret = (*device->dev.emul_ops->read_inband) (device->dev.emul_data,
- reply_port,
- reply_port_type, mode, recnum,
- count, data, bytes_read);
- return ret;
-}
-
-io_return_t
-ds_device_set_status (struct mach_device *device, dev_flavor_t flavor,
- dev_status_t status, mach_msg_type_number_t status_count)
-{
- io_return_t ret;
+ The GNU Hurd is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
- if (device == NULL)
- return D_NO_SUCH_DEVICE;
+ The GNU Hurd is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- if (! device->dev.emul_ops->set_status)
- return D_INVALID_OPERATION;
-
- ret = (*device->dev.emul_ops->set_status) (device->dev.emul_data, flavor,
- status, status_count);
- return ret;
-}
-
-io_return_t
-ds_device_get_status (struct mach_device *device, dev_flavor_t flavor,
- dev_status_t status,
- mach_msg_type_number_t *status_count)
-{
- io_return_t ret;
-
- if (device == NULL)
- return D_NO_SUCH_DEVICE;
-
- if (! device->dev.emul_ops->get_status)
- return D_INVALID_OPERATION;
-
- ret = (*device->dev.emul_ops->get_status) (device->dev.emul_data, flavor,
- status, status_count);
- return ret;
-}
-
-io_return_t
-ds_device_set_filter (struct mach_device *device, mach_port_t receive_port,
- int priority, filter_t *filter, unsigned filter_count)
-{
- io_return_t ret;
+ You should have received a copy of the GNU General Public License
+ along with the GNU Hurd; see the file COPYING. If not, write to
+ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- if (device == NULL)
- return D_NO_SUCH_DEVICE;
- if (! device->dev.emul_ops->set_filter)
- return D_INVALID_OPERATION;
-
- ret = (*device->dev.emul_ops->set_filter) (device->dev.emul_data,
- receive_port,
- priority, filter, filter_count);
- return ret;
-}
-
-io_return_t
-ds_device_map (struct mach_device *device, vm_prot_t prot, vm_offset_t offset,
- vm_size_t size, mach_port_t *pager, boolean_t unmap)
-{
- /* Refuse if device is dead or not completely open. */
- if (device == NULL)
- return D_NO_SUCH_DEVICE;
-
- return D_INVALID_OPERATION;
-}
-
-error_t
-create_device_port (size_t size, void *result)
-{
- return ports_create_port (dev_class, device_bucket,
- size, result);
-}
-
-void mach_device_init()
-{
- int i;
-
- device_bucket = ports_create_bucket ();
- dev_class = ports_create_class (0, 0);
-
- for (i = 0; i < NUM_EMULATION; i++) {
- if (emulation_list[i]->init)
- emulation_list[i]->init();
- }
-}
+#include <ddekit/thread.h>
+#include <hurd/machdev.h>
-static int
-demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
-{
- mig_routine_t routine;
- if ((routine = device_server_routine (inp)) ||
- (routine = notify_server_routine (inp)))
- {
- (*routine) (inp, outp);
- return TRUE;
- }
- else
- return FALSE;
-}
+#include "machdevdde.h"
-void reg_dev_emul (struct device_emulation_ops *ops)
-{
- emulation_list[num_emul++] = ops;
-}
-void * ds_server(void *arg)
+void * machdevdde_server(void *arg)
{
/* This thread calls Linux functions,
* so I need to make it known to the Linux environment. */
l4dde26_process_from_ddekit (ddekit_thread_myself ());
- /* Launch. */
- do
- {
- ports_manage_port_operations_one_thread (device_bucket, demuxer, 0);
- } while (1);
-
- return NULL;
+ return machdev_server(arg);
}
diff --git a/libmachdevdde/ds_routines.h b/libmachdevdde/ds_routines.h
deleted file mode 100644
index 3706aa586..000000000
--- a/libmachdevdde/ds_routines.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990,1989 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.
- */
-/*
- * Author: David B. Golub, Carnegie Mellon University
- * Date: 8/89
- *
- * Device service utility routines.
- */
-
-#ifndef DS_ROUTINES_H
-#define DS_ROUTINES_H
-
-#include <mach.h>
-
-#include "io_req.h"
-
-/*
- * Map for device IO memory.
- */
-//vm_map_t device_io_map;
-
-kern_return_t device_read_alloc(io_req_t, vm_size_t);
-kern_return_t device_write_get(io_req_t, boolean_t *);
-boolean_t device_write_dealloc(io_req_t);
-
-boolean_t ds_open_done(io_req_t);
-boolean_t ds_read_done(io_req_t);
-boolean_t ds_write_done(io_req_t);
-
-void iowait (io_req_t ior);
-
-error_t create_device_port (size_t size, void *result);
-
-#endif /* DS_ROUTINES_H */
diff --git a/libmachdevdde/io_req.h b/libmachdevdde/io_req.h
deleted file mode 100644
index 9c810542d..000000000
--- a/libmachdevdde/io_req.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990,1989,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.
- */
-/*
- * Author: David B. Golub, Carnegie Mellon University
- * Date: 10/88
- */
-
-#ifndef _IO_REQ_
-#define _IO_REQ_
-
-#include <mach.h>
-#include <pthread.h>
-
-#include "dev_hdr.h"
-
-/*
- * IO request element, queued on device for delayed replies.
- */
-typedef struct io_req *io_req_t;
-struct io_req {
- struct io_req * io_next; /* next, ... */
- struct io_req * io_prev; /* prev pointers: link in done,
- defered, or in-progress list */
- mach_device_t io_device; /* pointer to open-device structure */
- char * io_dev_ptr; /* pointer to driver structure -
- filled in by driver if necessary */
- int io_unit; /* unit number ('minor') of device */
- int io_op; /* IO operation */
- dev_mode_t io_mode; /* operation mode (wait, truncate) */
- recnum_t io_recnum; /* starting record number for
- random-access devices */
-
- union io_un {
- io_buf_ptr_t data; /* data, for IO requests */
- } io_un;
-#define io_data io_un.data
-
- long io_count; /* amount requested */
- long io_alloc_size; /* amount allocated */
- long io_residual; /* amount NOT done */
- io_return_t io_error; /* error code */
- /* call when done - returns TRUE if IO really finished */
- boolean_t (*io_done)(io_req_t);
- mach_port_t io_reply_port; /* reply port, for asynchronous
- messages */
- mach_msg_type_name_t io_reply_port_type;
- /* send or send-once right? */
- struct io_req * io_link; /* forward link (for driver header) */
- struct io_req * io_rlink; /* reverse link (for driver header) */
-// vm_map_copy_t io_copy; /* vm_map_copy obj. for this op. */
- long io_total; /* total op size, for write */
- pthread_mutex_t io_req_lock;
-// decl_simple_lock_data(,io_req_lock)
- /* Lock for this structure */
- long io_physrec; /* mapping to the physical block
- number */
- long io_rectotal; /* total number of blocks to move */
-};
-
-/*
- * LOCKING NOTE: Operations on io_req's are in general single threaded by
- * the invoking code, obviating the need for a lock. The usual IO_CALL
- * path through the code is: Initiating thread hands io_req to device driver,
- * driver passes it to io_done thread, io_done thread sends reply message. No
- * locking is needed in this sequence. Unfortunately, a synchronous wait
- * for a buffer requires a lock to avoid problems if the wait and interrupt
- * happen simultaneously on different processors.
- */
-
-#define ior_lock(ior) pthread_mutex_lock(&(ior)->io_req_lock)
-#define ior_unlock(ior) pthread_mutex_unlock(&(ior)->io_req_lock)
-
-/*
- * Flags and operations
- */
-
-#define IO_WRITE 0x00000000 /* operation is write */
-#define IO_READ 0x00000001 /* operation is read */
-#define IO_OPEN 0x00000002 /* operation is open */
-#define IO_DONE 0x00000100 /* operation complete */
-#define IO_ERROR 0x00000200 /* error on operation */
-#define IO_BUSY 0x00000400 /* operation in progress */
-#define IO_WANTED 0x00000800 /* wakeup when no longer BUSY */
-#define IO_BAD 0x00001000 /* bad disk block */
-#define IO_CALL 0x00002000 /* call io_done_thread when done */
-#define IO_INBAND 0x00004000 /* mig call was inband */
-#define IO_INTERNAL 0x00008000 /* internal, device-driver specific */
-#define IO_LOANED 0x00010000 /* ior loaned by another module */
-
-#define IO_SPARE_START 0x00020000 /* start of spare flags */
-
-/*
- * Standard completion routine for io_requests.
- */
-void iodone(io_req_t);
-
-/*
- * Macros to allocate and free IORs - will convert to zones later.
- */
-#define io_req_alloc(ior,size) \
- MACRO_BEGIN \
- (ior) = (io_req_t)malloc(sizeof(struct io_req)); \
- pthread_mutex_init(&(ior)->io_req_lock, NULL); \
- MACRO_END
-
-#define io_req_free(ior) \
- (free(ior))
-
-
-//zone_t io_inband_zone; /* for inband reads */
-
-#endif /* _IO_REQ_ */
diff --git a/libmachdevdde/mach.defs b/libmachdevdde/mach.defs
deleted file mode 100644
index 2750bcd52..000000000
--- a/libmachdevdde/mach.defs
+++ /dev/null
@@ -1,715 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University.
- * Copyright (c) 1993,1994 The University of Utah and
- * the Computer Systems Laboratory (CSL).
- * 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, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF
- * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM 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.
- */
-/*
- * Matchmaker definitions file for Mach kernel interface.
- */
-
-subsystem
-#if KERNEL_USER
- KernelUser
-#endif /* KERNEL_USER */
-#if KERNEL_SERVER
- KernelServer
-#endif /* KERNEL_SERVER */
- mach 2000;
-
-#ifdef KERNEL_USER
-userprefix r_;
-#endif /* KERNEL_USER */
-
-#include <mach/std_types.defs>
-#include <mach/mach_types.defs>
-
-skip; /* old port_allocate */
-skip; /* old port_deallocate */
-skip; /* old port_enable */
-skip; /* old port_disable */
-skip; /* old port_select */
-skip; /* old port_set_backlog */
-skip; /* old port_status */
-
-/*
- * Create a new task with an empty set of IPC rights,
- * and having an address space constructed from the
- * target task (or empty, if inherit_memory is FALSE).
- */
-routine task_create(
- target_task : task_t;
- inherit_memory : boolean_t;
- out child_task : task_t);
-
-/*
- * Destroy the target task, causing all of its threads
- * to be destroyed, all of its IPC rights to be deallocated,
- * and all of its address space to be deallocated.
- */
-routine task_terminate(
- target_task : task_t);
-
-/*
- * Get user-level handler entry points for all
- * emulated system calls.
- */
-routine task_get_emulation_vector(
- task : task_t;
- out vector_start : int;
- out emulation_vector: emulation_vector_t);
-
-/*
- * Establish user-level handlers for the specified
- * system calls. Non-emulated system calls are specified
- * with emulation_vector[i] == EML_ROUTINE_NULL.
- */
-routine task_set_emulation_vector(
- task : task_t;
- vector_start : int;
- emulation_vector: emulation_vector_t);
-
-
-/*
- * Returns the set of threads belonging to the target task.
- */
-routine task_threads(
- target_task : task_t;
- out thread_list : thread_array_t);
-
-/*
- * Returns information about the target task.
- */
-routine task_info(
- target_task : task_t;
- flavor : int;
- out task_info_out : task_info_t, CountInOut);
-
-
-skip; /* old task_status */
-skip; /* old task_set_notify */
-skip; /* old thread_create */
-
-/*
- * Destroy the target thread.
- */
-routine thread_terminate(
- target_thread : thread_t);
-
-/*
- * Return the selected state information for the target
- * thread. If the thread is currently executing, the results
- * may be stale. [Flavor THREAD_STATE_FLAVOR_LIST provides a
- * list of valid flavors for the target thread.]
- */
-routine thread_get_state(
- target_thread : thread_t;
- flavor : int;
- out old_state : thread_state_t, CountInOut);
-
-/*
- * Set the selected state information for the target thread.
- * If the thread is currently executing, the state change
- * may be ill-defined.
- */
-routine thread_set_state(
- target_thread : thread_t;
- flavor : int;
- new_state : thread_state_t);
-
-/*
- * Returns information about the target thread.
- */
-routine thread_info(
- target_thread : thread_t;
- flavor : int;
- out thread_info_out : thread_info_t, CountInOut);
-
-skip; /* old thread_mutate */
-
-/*
- * Allocate zero-filled memory in the address space
- * of the target task, either at the specified address,
- * or wherever space can be found (if anywhere is TRUE),
- * of the specified size. The address at which the
- * allocation actually took place is returned.
- */
-#ifdef EMULATOR
-skip; /* the emulator redefines vm_allocate using vm_map */
-#else /* EMULATOR */
-routine vm_allocate(
- target_task : vm_task_t;
- inout address : vm_address_t;
- size : vm_size_t;
- anywhere : boolean_t);
-#endif /* EMULATOR */
-
-skip; /* old vm_allocate_with_pager */
-
-/*
- * Deallocate the specified range from the virtual
- * address space of the target task.
- */
-routine vm_deallocate(
- target_task : vm_task_t;
- address : vm_address_t;
- size : vm_size_t);
-
-/*
- * Set the current or maximum protection attribute
- * for the specified range of the virtual address
- * space of the target task. The current protection
- * limits the memory access rights of threads within
- * the task; the maximum protection limits the accesses
- * that may be given in the current protection.
- * Protections are specified as a set of {read, write, execute}
- * *permissions*.
- */
-routine vm_protect(
- target_task : vm_task_t;
- address : vm_address_t;
- size : vm_size_t;
- set_maximum : boolean_t;
- new_protection : vm_prot_t);
-
-/*
- * Set the inheritance attribute for the specified range
- * of the virtual address space of the target task.
- * The inheritance value is one of {none, copy, share}, and
- * specifies how the child address space should acquire
- * this memory at the time of a task_create call.
- */
-routine vm_inherit(
- target_task : vm_task_t;
- address : vm_address_t;
- size : vm_size_t;
- new_inheritance : vm_inherit_t);
-
-/*
- * Returns the contents of the specified range of the
- * virtual address space of the target task. [The
- * range must be aligned on a virtual page boundary,
- * and must be a multiple of pages in extent. The
- * protection on the specified range must permit reading.]
- */
-routine vm_read(
- target_task : vm_task_t;
- address : vm_address_t;
- size : vm_size_t;
- out data : pointer_t);
-
-/*
- * Writes the contents of the specified range of the
- * virtual address space of the target task. [The
- * range must be aligned on a virtual page boundary,
- * and must be a multiple of pages in extent. The
- * protection on the specified range must permit writing.]
- */
-routine vm_write(
- target_task : vm_task_t;
- address : vm_address_t;
- data : pointer_t);
-
-/*
- * Copy the contents of the source range of the virtual
- * address space of the target task to the destination
- * range in that same address space. [Both of the
- * ranges must be aligned on a virtual page boundary,
- * and must be multiples of pages in extent. The
- * protection on the source range must permit reading,
- * and the protection on the destination range must
- * permit writing.]
- */
-routine vm_copy(
- target_task : vm_task_t;
- source_address : vm_address_t;
- size : vm_size_t;
- dest_address : vm_address_t);
-
-/*
- * Returns information about the contents of the virtual
- * address space of the target task at the specified
- * address. The returned protection, inheritance, sharing
- * and memory object values apply to the entire range described
- * by the address range returned; the memory object offset
- * corresponds to the beginning of the address range.
- * [If the specified address is not allocated, the next
- * highest address range is described. If no addresses beyond
- * the one specified are allocated, the call returns KERN_NO_SPACE.]
- */
-routine vm_region(
- target_task : vm_task_t;
- inout address : vm_address_t;
- out size : vm_size_t;
- out protection : vm_prot_t;
- out max_protection : vm_prot_t;
- out inheritance : vm_inherit_t;
- out is_shared : boolean_t;
- /* avoid out-translation of the argument */
- out object_name : memory_object_name_t =
- MACH_MSG_TYPE_MOVE_SEND
- ctype: mach_port_t;
- out offset : vm_offset_t);
-
-/*
- * Return virtual memory statistics for the host
- * on which the target task resides. [Note that the
- * statistics are not specific to the target task.]
- */
-routine vm_statistics(
- target_task : vm_task_t;
- out vm_stats : vm_statistics_data_t);
-
-skip; /* old task_by_u*x_pid */
-skip; /* old vm_pageable */
-
-/*
- * Stash a handful of ports for the target task; child
- * tasks inherit this stash at task_create time.
- */
-routine mach_ports_register(
- target_task : task_t;
- init_port_set : mach_port_array_t =
- ^array[] of mach_port_t);
-
-/*
- * Retrieve the stashed ports for the target task.
- */
-routine mach_ports_lookup(
- target_task : task_t;
- out init_port_set : mach_port_array_t =
- ^array[] of mach_port_t);
-
-skip; /* old u*x_pid */
-skip; /* old netipc_listen */
-skip; /* old netipc_ignore */
-
-/*
- * Provide the data contents of a range of the given memory
- * object, with the access restriction specified. [Only
- * whole virtual pages of data can be accepted; partial pages
- * will be discarded. Data should be provided on request, but
- * may be provided in advance as desired. When data already
- * held by this kernel is provided again, the new data is ignored.
- * The access restriction is the subset of {read, write, execute}
- * which are prohibited. The kernel may not provide any data (or
- * protection) consistency among pages with different virtual page
- * alignments within the same object.]
- */
-simpleroutine memory_object_data_provided(
- memory_control : memory_object_control_t;
- offset : vm_offset_t;
- data : pointer_t;
- lock_value : vm_prot_t);
-
-/*
- * Indicate that a range of the given temporary memory object does
- * not exist, and that the backing memory object should be used
- * instead (or zero-fill memory be used, if no backing object exists).
- * [This call is intended for use only by the default memory manager.
- * It should not be used to indicate a real error --
- * memory_object_data_error should be used for that purpose.]
- */
-simpleroutine memory_object_data_unavailable(
- memory_control : memory_object_control_t;
- offset : vm_offset_t;
- size : vm_size_t);
-
-/*
- * Retrieves the attributes currently associated with
- * a memory object.
- */
-routine memory_object_get_attributes(
- memory_control : memory_object_control_t;
- out object_ready : boolean_t;
- out may_cache : boolean_t;
- out copy_strategy : memory_object_copy_strategy_t);
-
-/*
- * Sets the default memory manager, the port to which
- * newly-created temporary memory objects are delivered.
- * [See (memory_object_default)memory_object_create.]
- * The old memory manager port is returned.
- */
-routine vm_set_default_memory_manager(
- host_priv : host_priv_t;
- inout default_manager : mach_port_make_send_t);
-
-skip; /* old pager_flush_request */
-
-/*
- * Control use of the data associated with the given
- * memory object. For each page in the given range,
- * perform the following operations, in order:
- * 1) restrict access to the page (disallow
- * forms specified by "prot");
- * 2) write back modifications (if "should_return"
- * is RETURN_DIRTY and the page is dirty, or
- * "should_return" is RETURN_ALL and the page
- * is either dirty or precious); and,
- * 3) flush the cached copy (if "should_flush"
- * is asserted).
- * The set of pages is defined by a starting offset
- * ("offset") and size ("size"). Only pages with the
- * same page alignment as the starting offset are
- * considered.
- *
- * A single acknowledgement is sent (to the "reply_to"
- * port) when these actions are complete.
- *
- * There are two versions of this routine because IPC distinguishes
- * between booleans and integers (a 2-valued integer is NOT a
- * boolean). The new routine is backwards compatible at the C
- * language interface.
- */
-
-skip; /* old xxx_memory_object_lock_request */
-
-simpleroutine memory_object_lock_request(
- memory_control : memory_object_control_t;
- offset : vm_offset_t;
- size : vm_size_t;
- should_return : memory_object_return_t;
- should_flush : boolean_t;
- lock_value : vm_prot_t;
- reply_to : mach_port_t =
- MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic);
-
-skip; /* old xxx_task_get_emulation_vector */
-skip; /* old xxx_task_set_emulation_vector */
-skip; /* old xxx_host_info */
-skip; /* old xxx_slot_info */
-skip; /* old xxx_cpu_control */
-skip; /* old thread_statistics */
-skip; /* old task_statistics */
-skip; /* old netport_init */
-skip; /* old netport_enter */
-skip; /* old netport_remove */
-skip; /* old thread_set_priority */
-
-/*
- * Increment the suspend count for the target task.
- * No threads within a task may run when the suspend
- * count for that task is non-zero.
- */
-routine task_suspend(
- target_task : task_t);
-
-/*
- * Decrement the suspend count for the target task,
- * if the count is currently non-zero. If the resulting
- * suspend count is zero, then threads within the task
- * that also have non-zero suspend counts may execute.
- */
-routine task_resume(
- target_task : task_t);
-
-/*
- * Returns the current value of the selected special port
- * associated with the target task.
- */
-routine task_get_special_port(
- task : task_t;
- which_port : int;
- out special_port : mach_port_t);
-
-/*
- * Set one of the special ports associated with the
- * target task.
- */
-routine task_set_special_port(
- task : task_t;
- which_port : int;
- special_port : mach_port_t);
-
-skip; /* old xxx_task_info */
-
-
-/*
- * Create a new thread within the target task, returning
- * the port representing that new thread. The
- * initial execution state of the thread is undefined.
- */
-routine thread_create(
- parent_task : task_t;
- out child_thread : thread_t);
-
-/*
- * Increment the suspend count for the target thread.
- * Once this call has completed, the thread will not
- * execute any further user or meta- instructions.
- * Once suspended, a thread may not execute again until
- * its suspend count is zero, and the suspend count
- * for its task is also zero.
- */
-routine thread_suspend(
- target_thread : thread_t);
-
-/*
- * Decrement the suspend count for the target thread,
- * if that count is not already zero.
- */
-routine thread_resume(
- target_thread : thread_t);
-
-/*
- * Cause any user or meta- instructions currently being
- * executed by the target thread to be aborted. [Meta-
- * instructions consist of the basic traps for IPC
- * (e.g., msg_send, msg_receive) and self-identification
- * (e.g., task_self, thread_self, thread_reply). Calls
- * described by MiG interfaces are not meta-instructions
- * themselves.]
- */
-routine thread_abort(
- target_thread : thread_t);
-
-skip; /* old xxx_thread_get_state */
-skip; /* old xxx_thread_set_state */
-
-/*
- * Returns the current value of the selected special port
- * associated with the target thread.
- */
-routine thread_get_special_port(
- thread : thread_t;
- which_port : int;
- out special_port : mach_port_t);
-
-/*
- * Set one of the special ports associated with the
- * target thread.
- */
-routine thread_set_special_port(
- thread : thread_t;
- which_port : int;
- special_port : mach_port_t);
-
-skip; /* old xxx_thread_info */
-
-/*
- * Establish a user-level handler for the specified
- * system call.
- */
-routine task_set_emulation(
- target_port : task_t;
- routine_entry_pt: vm_address_t;
- routine_number : int);
-
-/*
- * Establish restart pc for interrupted atomic sequences.
- * This reuses the message number for the old task_get_io_port.
- * See task_info.h for description of flavors.
- *
- */
-routine task_ras_control(
- target_task : task_t;
- basepc : vm_address_t;
- boundspc : vm_address_t;
- flavor : int);
-
-
-
-skip; /* old host_ipc_statistics */
-skip; /* old port_names */
-skip; /* old port_type */
-skip; /* old port_rename */
-skip; /* old port_allocate */
-skip; /* old port_deallocate */
-skip; /* old port_set_backlog */
-skip; /* old port_status */
-skip; /* old port_set_allocate */
-skip; /* old port_set_deallocate */
-skip; /* old port_set_add */
-skip; /* old port_set_remove */
-skip; /* old port_set_status */
-skip; /* old port_insert_send */
-skip; /* old port_extract_send */
-skip; /* old port_insert_receive */
-skip; /* old port_extract_receive */
-
-/*
- * Map a user-defined memory object into the virtual address
- * space of the target task. If desired (anywhere is TRUE),
- * the kernel will find a suitable address range of the
- * specified size; else, the specific address will be allocated.
- *
- * The beginning address of the range will be aligned on a virtual
- * page boundary, be at or beyond the address specified, and
- * meet the mask requirements (bits turned on in the mask must not
- * be turned on in the result); the size of the range, in bytes,
- * will be rounded up to an integral number of virtual pages.
- *
- * The memory in the resulting range will be associated with the
- * specified memory object, with the beginning of the memory range
- * referring to the specified offset into the memory object.
- *
- * The mapping will take the current and maximum protections and
- * the inheritance attributes specified; see the vm_protect and
- * vm_inherit calls for a description of these attributes.
- *
- * If desired (copy is TRUE), the memory range will be filled
- * with a copy of the data from the memory object; this copy will
- * be private to this mapping in this target task. Otherwise,
- * the memory in this mapping will be shared with other mappings
- * of the same memory object at the same offset (in this task or
- * in other tasks). [The Mach kernel only enforces shared memory
- * consistency among mappings on one host with similar page alignments.
- * The user-defined memory manager for this object is responsible
- * for further consistency.]
- */
-#ifdef EMULATOR
-routine htg_vm_map(
- target_task : vm_task_t;
- ureplyport reply_port : mach_port_make_send_once_t;
- inout address : vm_address_t;
- size : vm_size_t;
- mask : vm_address_t;
- anywhere : boolean_t;
- memory_object : memory_object_t;
- offset : vm_offset_t;
- copy : boolean_t;
- cur_protection : vm_prot_t;
- max_protection : vm_prot_t;
- inheritance : vm_inherit_t);
-#else /* EMULATOR */
-routine vm_map(
- target_task : vm_task_t;
- inout address : vm_address_t;
- size : vm_size_t;
- mask : vm_address_t;
- anywhere : boolean_t;
- memory_object : memory_object_t;
- offset : vm_offset_t;
- copy : boolean_t;
- cur_protection : vm_prot_t;
- max_protection : vm_prot_t;
- inheritance : vm_inherit_t);
-#endif /* EMULATOR */
-
-/*
- * Indicate that a range of the specified memory object cannot
- * be provided at this time. [Threads waiting for memory pages
- * specified by this call will experience a memory exception.
- * Only threads waiting at the time of the call are affected.]
- */
-simpleroutine memory_object_data_error(
- memory_control : memory_object_control_t;
- offset : vm_offset_t;
- size : vm_size_t;
- error_value : kern_return_t);
-
-/*
- * Make decisions regarding the use of the specified
- * memory object.
- */
-simpleroutine memory_object_set_attributes(
- memory_control : memory_object_control_t;
- object_ready : boolean_t;
- may_cache : boolean_t;
- copy_strategy : memory_object_copy_strategy_t);
-
-/*
- */
-simpleroutine memory_object_destroy(
- memory_control : memory_object_control_t;
- reason : kern_return_t);
-
-/*
- * Provide the data contents of a range of the given memory
- * object, with the access restriction specified, optional
- * precious attribute, and reply message. [Only
- * whole virtual pages of data can be accepted; partial pages
- * will be discarded. Data should be provided on request, but
- * may be provided in advance as desired. When data already
- * held by this kernel is provided again, the new data is ignored.
- * The access restriction is the subset of {read, write, execute}
- * which are prohibited. The kernel may not provide any data (or
- * protection) consistency among pages with different virtual page
- * alignments within the same object. The precious value controls
- * how the kernel treats the data. If it is FALSE, the kernel treats
- * its copy as a temporary and may throw it away if it hasn't been
- * changed. If the precious value is TRUE, the kernel treats its
- * copy as a data repository and promises to return it to the manager;
- * the manager may tell the kernel to throw it away instead by flushing
- * and not cleaning the data -- see memory_object_lock_request. The
- * reply_to port is for a compeletion message; it will be
- * memory_object_supply_completed.]
- */
-
-simpleroutine memory_object_data_supply(
- memory_control : memory_object_control_t;
- offset : vm_offset_t;
- data : pointer_t, Dealloc[];
- lock_value : vm_prot_t;
- precious : boolean_t;
- reply_to : mach_port_t =
- MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic);
-
-simpleroutine memory_object_ready(
- memory_control : memory_object_control_t;
- may_cache : boolean_t;
- copy_strategy : memory_object_copy_strategy_t);
-
-simpleroutine memory_object_change_attributes(
- memory_control : memory_object_control_t;
- may_cache : boolean_t;
- copy_strategy : memory_object_copy_strategy_t;
- reply_to : mach_port_t =
- MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic);
-
-skip; /* old host_callout_statistics_reset */
-skip; /* old port_set_select */
-skip; /* old port_set_backup */
-
-/*
- * Set/Get special properties of memory associated
- * to some virtual address range, such as cachability,
- * migrability, replicability. Machine-dependent.
- */
-routine vm_machine_attribute(
- target_task : vm_task_t;
- address : vm_address_t;
- size : vm_size_t;
- attribute : vm_machine_attribute_t;
- inout value : vm_machine_attribute_val_t);
-
-skip; /* old host_fpa_counters_reset */
-
-/*
- * This routine is created for allocating DMA buffers.
- * We are going to get a contiguous physical memory
- * and its physical address in addition to the virtual address.
- */
-routine vm_allocate_contiguous(
- host_priv : host_priv_t;
- target_task : vm_task_t;
- out vaddr : vm_address_t;
- out paddr : vm_address_t;
- size : vm_size_t);
-
-/*
- * There is no more room in this interface for additional calls.
- */
diff --git a/libmachdevdde/machdev.h b/libmachdevdde/machdevdde.h
index b9186fbaf..2b26a9c90 100644
--- a/libmachdevdde/machdev.h
+++ b/libmachdevdde/machdevdde.h
@@ -20,14 +20,9 @@
/* This file declares interfaces used by driver programs. */
-#ifndef __MACHDEV_H__
-#define __MACHDEV_H__
-
-void * ds_server(void *);
-void mach_device_init(void);
-void register_net(void);
-void register_block(void);
-void trivfs_server(void);
-int trivfs_init(void);
+#ifndef __MACHDEVDDE_H__
+#define __MACHDEVDDE_H__
+
+void * machdevdde_server(void *arg);
#endif
diff --git a/libmachdevdde/mig-decls.h b/libmachdevdde/mig-decls.h
deleted file mode 100644
index 8302029d2..000000000
--- a/libmachdevdde/mig-decls.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- Copyright (C) 2014 Free Software Foundation, Inc.
- Written by Justus Winter.
-
- This file is part of the GNU Hurd.
-
- The GNU Hurd is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2, or (at
- your option) any later version.
-
- The GNU Hurd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef __LIBMACHDEV_MIG_DECLS_H__
-#define __LIBMACHDEV_MIG_DECLS_H__
-
-#include <hurd/ports.h>
-#include "dev_hdr.h"
-
-extern struct port_bucket *device_bucket;
-extern struct port_class *dev_class;
-
-/* Called by server stub functions. */
-
-static inline struct mach_device * __attribute__ ((unused))
-begin_using_device_port (mach_port_t port)
-{
- return ports_lookup_port (device_bucket, port, dev_class);
-}
-
-static inline struct mach_device * __attribute__ ((unused))
-begin_using_device_payload (unsigned long payload)
-{
- return ports_lookup_payload (device_bucket, payload, dev_class);
-}
-
-static inline void __attribute__ ((unused))
-end_using_device (struct mach_device *p)
-{
- if (p)
- ports_port_deref (p);
-}
-
-#endif /* __LIBMACHDEV_MIG_DECLS_H__ */
diff --git a/libmachdevdde/mig-mutate.h b/libmachdevdde/mig-mutate.h
deleted file mode 100644
index 902ff166f..000000000
--- a/libmachdevdde/mig-mutate.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- Copyright (C) 2014 Free Software Foundation, Inc.
- Written by Justus Winter.
-
- This file is part of the GNU Hurd.
-
- The GNU Hurd is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2, or (at
- your option) any later version.
-
- The GNU Hurd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
-
-#define NOTIFY_INTRAN \
- port_info_t begin_using_port_info_port (mach_port_t)
-#define NOTIFY_INTRAN_PAYLOAD \
- port_info_t begin_using_port_info_payload
-#define NOTIFY_DESTRUCTOR \
- end_using_port_info (port_info_t)
-#define NOTIFY_IMPORTS \
- import "libports/mig-decls.h";
-
-#define DEVICE_INTRAN \
- mach_device_t begin_using_device_port (mach_port_t)
-#define DEVICE_INTRAN_PAYLOAD \
- mach_device_t begin_using_device_payload
-#define DEVICE_DESTRUCTOR \
- end_using_device (mach_device_t)
-#define DEVICE_IMPORTS \
- import "libmachdev/mig-decls.h";
diff --git a/libmachdevdde/misc.c b/libmachdevdde/misc.c
index 977159bd3..9dc324cb3 100644
--- a/libmachdevdde/misc.c
+++ b/libmachdevdde/misc.c
@@ -1,3 +1,23 @@
+/*
+ Copyright (C) 2010 Free Software Foundation, Inc.
+ Written by Zheng Da.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the GNU Hurd; see the file COPYING. If not, write to
+ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
#include <mach.h>
#include <device/device.h>
diff --git a/libmachdevdde/misc.h b/libmachdevdde/misc.h
new file mode 100644
index 000000000..a0bb55fd8
--- /dev/null
+++ b/libmachdevdde/misc.h
@@ -0,0 +1,26 @@
+/*
+ Copyright (C) 2010 Free Software Foundation, Inc.
+ Written by Zheng Da.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the GNU Hurd; see the file COPYING. If not, write to
+ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#ifndef __MISC_H__
+#define __MISC_H__
+
+int linux_to_mach_error (int err);
+
+#endif
diff --git a/libmachdevdde/net.c b/libmachdevdde/net.c
index 220121aac..585c97259 100644
--- a/libmachdevdde/net.c
+++ b/libmachdevdde/net.c
@@ -62,20 +62,19 @@
#include <string.h>
#include <arpa/inet.h>
#include <error.h>
-
-#include "mach_U.h"
+#include <stdio.h>
#include <mach.h>
+#include <hurd/machdev.h>
#include <hurd.h>
+#include <hurd/ports.h>
#define MACH_INCLUDE
-#include "ds_routines.h"
#include "vm_param.h"
#include "device_reply_U.h"
-#include "dev_hdr.h"
#include "if_ether.h"
-#include "util.h"
+#include "misc.h"
#include "mach_glue.h"
#include "if_hdr.h"
@@ -85,7 +84,7 @@
struct net_data
{
struct port_info port; /* device port */
- struct emul_device device; /* generic device structure */
+ struct machdev_emul_device device; /* generic device structure */
struct ifnet ifnet; /* Mach ifnet structure (needed for filters) */
struct net_device *dev; /* Linux network device structure */
struct net_data *next;
@@ -102,7 +101,7 @@ static struct net_data *nd_head;
/* Forward declarations. */
-extern struct device_emulation_ops linux_net_emulation_ops;
+static struct machdev_device_emulation_ops linux_net_emulation_ops;
static mach_msg_type_t header_type =
{
@@ -305,10 +304,10 @@ device_open (mach_port_t reply_port, mach_msg_type_name_t reply_port_type,
{
char *name;
- err = create_device_port (sizeof (*nd), &nd);
+ err = machdev_create_device_port (sizeof (*nd), &nd);
if (err)
{
- fprintf (stderr, "after create_device_port: cannot create a port\n");
+ fprintf (stderr, "after machdev_create_device_port: cannot create a port\n");
goto out;
}
@@ -634,7 +633,7 @@ static void linux_net_emulation_init ()
l4dde26_register_rx_callback(netif_rx_handle);
}
-struct device_emulation_ops linux_net_emulation_ops =
+static struct machdev_device_emulation_ops linux_net_emulation_ops =
{
linux_net_emulation_init,
NULL,
@@ -657,6 +656,5 @@ struct device_emulation_ops linux_net_emulation_ops =
void register_net()
{
- extern void reg_dev_emul (struct device_emulation_ops *ops);
- reg_dev_emul (&linux_net_emulation_ops);
+ machdev_register (&linux_net_emulation_ops);
}
diff --git a/libmachdevdde/trivfs_server.c b/libmachdevdde/trivfs_server.c
deleted file mode 100644
index 3c0578fa0..000000000
--- a/libmachdevdde/trivfs_server.c
+++ /dev/null
@@ -1,171 +0,0 @@
-#include <stdio.h>
-#include <fcntl.h>
-#include <pciaccess.h>
-#include <error.h>
-#include <hurd/ports.h>
-#include <hurd/trivfs.h>
-#include <hurd.h>
-
-#include "device_S.h"
-#include "notify_S.h"
-
-static struct port_bucket *port_bucket;
-
-/* Trivfs hooks. */
-int trivfs_fstype = FSTYPE_MISC;
-int trivfs_fsid = 0;
-int trivfs_support_read = 0;
-int trivfs_support_write = 0;
-int trivfs_support_exec = 0;
-int trivfs_allow_open = O_READ | O_WRITE;
-
-/* Our port classes. */
-struct port_class *trivfs_protid_class;
-struct port_class *trivfs_cntl_class;
-
-/* Implementation of notify interface */
-kern_return_t
-do_mach_notify_port_deleted (struct port_info *pi,
- mach_port_t name)
-{
- return EOPNOTSUPP;
-}
-
-kern_return_t
-do_mach_notify_msg_accepted (struct port_info *pi,
- mach_port_t name)
-{
- return EOPNOTSUPP;
-}
-
-kern_return_t
-do_mach_notify_port_destroyed (struct port_info *pi,
- mach_port_t port)
-{
- return EOPNOTSUPP;
-}
-
-kern_return_t
-do_mach_notify_no_senders (struct port_info *pi,
- mach_port_mscount_t mscount)
-{
- return ports_do_mach_notify_no_senders (pi, mscount);
-}
-
-kern_return_t
-do_mach_notify_send_once (struct port_info *pi)
-{
- return EOPNOTSUPP;
-}
-
-kern_return_t
-do_mach_notify_dead_name (struct port_info *pi,
- mach_port_t name)
-{
- return EOPNOTSUPP;
-}
-
-boolean_t
-is_master_device (mach_port_t port)
-{
- struct port_info *pi = ports_lookup_port (port_bucket, port,
- trivfs_protid_class);
- if (pi == NULL)
- return FALSE;
-
- ports_port_deref (pi);
- return TRUE;
-}
-
-error_t
-trivfs_append_args (struct trivfs_control *fsys, char **argz, size_t *argz_len)
-{
- error_t err = 0;
-
-#define ADD_OPT(fmt, args...) \
- do { char buf[100]; \
- if (! err) { \
- snprintf (buf, sizeof buf, fmt , ##args); \
- err = argz_add (argz, argz_len, buf); } } while (0)
-
-#undef ADD_OPT
- return err;
-}
-
-int trivfs_init()
-{
- port_bucket = ports_create_bucket ();
- trivfs_cntl_class = ports_create_class (trivfs_clean_cntl, 0);
- trivfs_protid_class = ports_create_class (trivfs_clean_protid, 0);
- return 0;
-}
-
-error_t
-trivfs_goaway (struct trivfs_control *fsys, int flags)
-{
- int count;
-
- /* Stop new requests. */
- ports_inhibit_class_rpcs (trivfs_cntl_class);
- ports_inhibit_class_rpcs (trivfs_protid_class);
-
- count = ports_count_class (trivfs_protid_class);
-
- if (count && !(flags & FSYS_GOAWAY_FORCE))
- {
- /* We won't go away, so start things going again... */
- ports_enable_class (trivfs_protid_class);
- ports_resume_class_rpcs (trivfs_cntl_class);
- ports_resume_class_rpcs (trivfs_protid_class);
- return EBUSY;
- }
-
- pci_system_cleanup ();
- exit (0);
-}
-
-static int
-demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
-{
- mig_routine_t routine;
- if ((routine = device_server_routine (inp)) ||
- (routine = notify_server_routine (inp)) ||
- (routine = NULL, trivfs_demuxer (inp, outp)))
- {
- if (routine)
- (*routine) (inp, outp);
- return TRUE;
- }
- else
- return FALSE;
-}
-
-void
-trivfs_modify_stat (struct trivfs_protid *cred, io_statbuf_t *stat)
-{
-}
-
-void trivfs_server()
-{
- mach_port_t bootstrap;
- struct trivfs_control *fsys;
- int err;
-
- task_get_bootstrap_port (mach_task_self (), &bootstrap);
- if (bootstrap == MACH_PORT_NULL)
- error (1, 0, "must be started as a translator");
-
- /* Reply to our parent. */
- err = trivfs_startup (bootstrap, 0,
- trivfs_cntl_class, port_bucket,
- trivfs_protid_class, port_bucket, &fsys);
- mach_port_deallocate (mach_task_self (), bootstrap);
- if (err)
- error (1, err, "Contacting parent");
-
- /* Launch. */
- do
- {
- ports_manage_port_operations_one_thread (port_bucket, demuxer, 0);
- } while (trivfs_goaway (fsys, 0));
-}
diff --git a/libmachdevdde/util.h b/libmachdevdde/util.h
deleted file mode 100644
index 1c62b0d6c..000000000
--- a/libmachdevdde/util.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __UTIL_H__
-#define __UTIL_H__
-
-#include <stdio.h>
-
-#define panic(format, ...) do \
-{ \
- char buf[1024]; \
- snprintf (buf, 1024, "devnode: %s", format); \
- fprintf (stderr , buf, ## __VA_ARGS__); \
- fflush (stderr); \
- abort (); \
-} while (0)
-
-#define DEBUG
-
-#ifdef DEBUG
-
-#define debug(format, ...) do \
-{ \
- char buf[1024]; \
- snprintf (buf, 1024, "pcnet32: %s: %s\n", __func__, format); \
- fprintf (stderr , buf, ## __VA_ARGS__); \
- fflush (stderr); \
-} while (0)
-
-#else
-
-#define debug(format, ...) do {} while (0)
-
-#endif
-
-int linux_to_mach_error (int err);
-
-#endif