svn commit: r201473 - user/kmacy/releng_8_rump/lib/libunet

Kip Macy kmacy at FreeBSD.org
Mon Jan 4 05:39:01 UTC 2010


Author: kmacy
Date: Mon Jan  4 05:39:00 2010
New Revision: 201473
URL: http://svn.freebsd.org/changeset/base/201473

Log:
  add stub locking primitives, interrupts, and taskqueues

Added:
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_intr.c   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_kern_subr.c   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_lock.c   (contents, props changed)
  user/kmacy/releng_8_rump/lib/libunet/unet_subr_taskqueue.c   (contents, props changed)
Modified:
  user/kmacy/releng_8_rump/lib/libunet/Makefile
  user/kmacy/releng_8_rump/lib/libunet/unet_compat.c
  user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c

Modified: user/kmacy/releng_8_rump/lib/libunet/Makefile
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/Makefile	Mon Jan  4 05:27:49 2010	(r201472)
+++ user/kmacy/releng_8_rump/lib/libunet/Makefile	Mon Jan  4 05:39:00 2010	(r201473)
@@ -15,14 +15,12 @@ UNET_KERN_COMMON_OBJS +=	\
 	kern_malloc.o		\
 	kern_mbuf.o		\
 	kern_module.o		\
-	kern_subr.o		\
 	kern_sysctl.o		\
 	md5c.o			\
 	subr_eventhandler.o	\
 	subr_param.o		\
 	subr_pcpu.o		\
 	subr_sbuf.o		\
-	subr_taskqueue.o	\
 	uipc_accf.o		\
 	uipc_mbuf.o		\
 	uipc_mbuf2.o		\
@@ -99,8 +97,12 @@ UNET_GLUE_COMMON_OBJS =		\
 	unet_compat.o		\
 	unet_glue.o		\
 	unet_init_main.c	\
+	unet_lock.o		\
 	unet_uma_core.c		\
-	unet_kern_synch.o
+	unet_kern_intr.o	\
+	unet_kern_synch.o	\
+	unet_kern_subr.o	\
+	unet_subr_taskqueue.o
 
 #	unet_init.o		\
 #	unet_uipc_syscalls.o
@@ -124,6 +126,7 @@ CFLAGS+=	-D_KERNEL
 CFLAGS+=	-DUNET
 CFLAGS+=	-DMAXUSERS=32
 CFLAGS+=	-fno-builtin
+CFLAGS+=	-g
 
 .include <bsd.lib.mk>
 

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_compat.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_compat.c	Mon Jan  4 05:27:49 2010	(r201472)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_compat.c	Mon Jan  4 05:39:00 2010	(r201473)
@@ -50,3 +50,4 @@ panic(const char *fmt, ...)
 	abort();
 }
 
+

Added: user/kmacy/releng_8_rump/lib/libunet/unet_kern_intr.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_kern_intr.c	Mon Jan  4 05:39:00 2010	(r201473)
@@ -0,0 +1,68 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "opt_ddb.h"
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/cpuset.h>
+#include <sys/rtprio.h>
+#include <sys/systm.h>
+#include <sys/interrupt.h>
+#include <sys/kernel.h>
+#include <sys/kthread.h>
+#include <sys/ktr.h>
+#include <sys/limits.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mutex.h>
+#include <sys/priv.h>
+#include <sys/proc.h>
+#include <sys/random.h>
+#include <sys/resourcevar.h>
+#include <sys/sched.h>
+#include <sys/smp.h>
+#include <sys/sysctl.h>
+#include <sys/syslog.h>
+#include <sys/unistd.h>
+
+/*
+ * Bind an interrupt event to the specified CPU.  Note that not all
+ * platforms support binding an interrupt to a CPU.  For those
+ * platforms this request will fail.  For supported platforms, any
+ * associated ithreads as well as the primary interrupt context will
+ * be bound to the specificed CPU.  Using a cpu id of NOCPU unbinds
+ * the interrupt event.
+ */
+int
+intr_event_bind(struct intr_event *ie, u_char cpu)
+{
+
+	panic("");
+	return (0);
+		    
+}
+
+
+/*
+ * Add a software interrupt handler to a specified event.  If a given event
+ * is not specified, then a new event is created.
+ */
+int
+swi_add(struct intr_event **eventp, const char *name, driver_intr_t handler,
+	    void *arg, int pri, enum intr_type flags, void **cookiep)
+{
+	panic("");
+	return (0);
+}
+
+/*
+ * Schedule a software interrupt thread.
+ */
+void
+swi_sched(void *cookie, int flags)
+{
+
+	panic("");
+}

Added: user/kmacy/releng_8_rump/lib/libunet/unet_kern_subr.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_kern_subr.c	Mon Jan  4 05:39:00 2010	(r201473)
@@ -0,0 +1,146 @@
+
+#include <sys/cdefs.h>
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/ktr.h>
+#include <sys/limits.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/proc.h>
+#include <sys/malloc.h>
+#include <sys/resourcevar.h>
+#include <sys/sched.h>
+#include <sys/sysctl.h>
+#include <sys/uio.h>
+
+/*
+ * General routine to allocate a hash table with control of memory flags.
+ */
+void *
+hashinit_flags(int elements, struct malloc_type *type, u_long *hashmask,
+    int flags)
+{
+	long hashsize;
+	LIST_HEAD(generic, generic) *hashtbl;
+	int i;
+
+	if (elements <= 0)
+		panic("hashinit: bad elements");
+
+	/* Exactly one of HASH_WAITOK and HASH_NOWAIT must be set. */
+	KASSERT((flags & HASH_WAITOK) ^ (flags & HASH_NOWAIT),
+	    ("Bad flags (0x%x) passed to hashinit_flags", flags));
+
+	for (hashsize = 1; hashsize <= elements; hashsize <<= 1)
+		continue;
+	hashsize >>= 1;
+
+	if (flags & HASH_NOWAIT)
+		hashtbl = malloc((u_long)hashsize * sizeof(*hashtbl),
+		    type, M_NOWAIT);
+	else
+		hashtbl = malloc((u_long)hashsize * sizeof(*hashtbl),
+		    type, M_WAITOK);
+
+	if (hashtbl != NULL) {
+		for (i = 0; i < hashsize; i++)
+			LIST_INIT(&hashtbl[i]);
+		*hashmask = hashsize - 1;
+	}
+	return (hashtbl);
+}
+
+/*
+ * Allocate and initialize a hash table with default flag: may sleep.
+ */
+void *
+hashinit(int elements, struct malloc_type *type, u_long *hashmask)
+{
+
+	return (hashinit_flags(elements, type, hashmask, HASH_WAITOK));
+}
+
+void
+hashdestroy(void *vhashtbl, struct malloc_type *type, u_long hashmask)
+{
+	LIST_HEAD(generic, generic) *hashtbl, *hp;
+
+	hashtbl = vhashtbl;
+	for (hp = hashtbl; hp <= &hashtbl[hashmask]; hp++)
+		if (!LIST_EMPTY(hp))
+			panic("hashdestroy: hash not empty");
+	free(hashtbl, type);
+}
+void
+uio_yield(void)
+{
+
+	panic("");
+}
+
+int
+uiomove(void *cp, int n, struct uio *uio)
+{
+	struct thread *td = curthread;
+	struct iovec *iov;
+	u_int cnt;
+	int error = 0;
+	int save = 0;
+
+	KASSERT(uio->uio_rw == UIO_READ || uio->uio_rw == UIO_WRITE,
+	    ("uiomove: mode"));
+	KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_td == curthread,
+	    ("uiomove proc"));
+	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
+	    "Calling uiomove()");
+
+	save = td->td_pflags & TDP_DEADLKTREAT;
+	td->td_pflags |= TDP_DEADLKTREAT;
+
+	while (n > 0 && uio->uio_resid) {
+		iov = uio->uio_iov;
+		cnt = iov->iov_len;
+		if (cnt == 0) {
+			uio->uio_iov++;
+			uio->uio_iovcnt--;
+			continue;
+		}
+		if (cnt > n)
+			cnt = n;
+
+		switch (uio->uio_segflg) {
+
+		case UIO_USERSPACE:
+			if (ticks - PCPU_GET(switchticks) >= hogticks)
+				uio_yield();
+			if (uio->uio_rw == UIO_READ)
+				error = copyout(cp, iov->iov_base, cnt);
+			else
+				error = copyin(iov->iov_base, cp, cnt);
+			if (error)
+				goto out;
+			break;
+
+		case UIO_SYSSPACE:
+			if (uio->uio_rw == UIO_READ)
+				bcopy(cp, iov->iov_base, cnt);
+			else
+				bcopy(iov->iov_base, cp, cnt);
+			break;
+		case UIO_NOCOPY:
+			break;
+		}
+		iov->iov_base = (char *)iov->iov_base + cnt;
+		iov->iov_len -= cnt;
+		uio->uio_resid -= cnt;
+		uio->uio_offset += cnt;
+		cp = (char *)cp + cnt;
+		n -= cnt;
+	}
+out:
+	if (save == 0)
+		td->td_pflags &= ~TDP_DEADLKTREAT;
+	return (error);
+}

Added: user/kmacy/releng_8_rump/lib/libunet/unet_lock.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_lock.c	Mon Jan  4 05:39:00 2010	(r201473)
@@ -0,0 +1,258 @@
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kdb.h>
+#include <sys/kernel.h>
+#include <sys/ktr.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mutex.h>
+#include <sys/rmlock.h>
+#include <sys/rwlock.h>
+#include <sys/sx.h>
+#include <sys/proc.h>
+#include <sys/resourcevar.h>
+#include <sys/sched.h>
+#include <sys/sbuf.h>
+#include <sys/sysctl.h>
+#include <sys/turnstile.h>
+#include <sys/vmmeter.h>
+#include <sys/lock_profile.h>
+
+
+
+void
+mtx_init(struct mtx *m, const char *name, const char *type, int opts)
+{
+
+	panic("");
+}
+
+void
+mtx_destroy(struct mtx *m)
+{
+
+	panic("");
+}
+
+void
+mtx_sysinit(void *arg)
+{
+	
+	panic("");
+}
+
+void
+_mtx_lock_sleep(struct mtx *m, uintptr_t tid, int opts,
+    const char *file, int line)
+{
+
+	panic("");
+}
+
+void
+_mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line)
+{
+
+	panic("");
+}
+
+
+
+void
+rm_init_flags(struct rmlock *rm, const char *name, int opts)
+{
+	
+	panic("");
+}
+
+void
+rm_destroy(struct rmlock *rm)
+{
+
+	panic("");
+}
+
+void
+_rm_wlock(struct rmlock *rm)
+{
+
+	panic("");
+}
+
+void
+_rm_wunlock(struct rmlock *rm)
+{
+
+	panic("");
+}
+
+void
+_rm_rlock(struct rmlock *rm, struct rm_priotracker *tracker)
+{
+
+	panic("");
+}
+
+void
+_rm_runlock(struct rmlock *rm,  struct rm_priotracker *tracker)
+{
+
+	panic("");
+}
+
+
+
+void
+rw_sysinit(void *arg)
+{
+
+	panic("");
+}
+
+void
+rw_init_flags(struct rwlock *rw, const char *name, int opts)
+{
+
+	panic("");
+}
+
+void
+rw_destroy(struct rwlock *rw)
+{
+	
+	panic("");
+}
+
+void
+_rw_wlock(struct rwlock *rw, const char *file, int line)
+{
+
+	panic("");
+}
+
+int
+_rw_try_wlock(struct rwlock *rw, const char *file, int line)
+{
+
+	panic("");
+	return (0);
+}
+
+void
+_rw_wunlock(struct rwlock *rw, const char *file, int line)
+{
+	
+	panic("");
+}
+
+void
+_rw_rlock(struct rwlock *rw, const char *file, int line)
+{
+	
+	panic("");
+}
+
+int
+_rw_try_rlock(struct rwlock *rw, const char *file, int line)
+{
+	
+	panic("");
+	return (0);
+}
+
+void
+_rw_runlock(struct rwlock *rw, const char *file, int line)
+{
+	
+	panic("");
+}
+
+void
+_rw_wlock_hard(struct rwlock *rw, uintptr_t tid, const char *file,
+    int line)
+{
+	
+	panic("");
+}
+
+void
+_rw_wunlock_hard(struct rwlock *rw, uintptr_t tid, const char *file,
+    int line)
+{
+	
+	panic("");
+}
+
+int
+_rw_try_upgrade(struct rwlock *rw, const char *file, int line)
+{
+	
+	panic("");
+	return (0);
+}
+
+void
+_rw_downgrade(struct rwlock *rw, const char *file, int line)
+{
+	
+	panic("");
+}
+
+
+
+void
+sx_init_flags(struct sx *sx, const char *description, int opts)
+{
+
+	panic("");
+}
+
+void
+sx_destroy(struct sx *sx)
+{
+
+	panic("");
+}
+
+int
+_sx_xlock_hard(struct sx *sx, uintptr_t tid, int opts,
+    const char *file, int line)
+{
+	
+	panic("");
+	return (0);
+}
+
+int
+_sx_slock_hard(struct sx *sx, int opts, const char *file, int line)
+{
+	
+	panic("");
+	return (0);
+}
+
+void
+_sx_xunlock_hard(struct sx *sx, uintptr_t tid, const char *file, int
+    line)
+{
+	
+	panic("");
+}
+
+void
+_sx_sunlock_hard(struct sx *sx, const char *file, int line)
+{
+	
+	panic("");
+}
+
+int
+_sx_try_xlock(struct sx *sx, const char *file, int line)
+{
+	
+	panic("");
+	return (0);
+}
+

Added: user/kmacy/releng_8_rump/lib/libunet/unet_subr_taskqueue.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_subr_taskqueue.c	Mon Jan  4 05:39:00 2010	(r201473)
@@ -0,0 +1,91 @@
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/interrupt.h>
+#include <sys/kernel.h>
+#include <sys/kthread.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mutex.h>
+#include <sys/proc.h>
+#include <sys/sched.h>
+#include <sys/taskqueue.h>
+#include <sys/unistd.h>
+#include <machine/stdarg.h>
+
+static MALLOC_DEFINE(M_TASKQUEUE, "taskqueue", "Task Queues");
+static void	*taskqueue_giant_ih;
+static void	*taskqueue_ih;
+
+struct taskqueue {
+	STAILQ_HEAD(, task)	tq_queue;
+	const char		*tq_name;
+	taskqueue_enqueue_fn	tq_enqueue;
+	void			*tq_context;
+	struct task		*tq_running;
+	struct mtx		tq_mutex;
+	struct thread		**tq_threads;
+	int			tq_tcount;
+	int			tq_spin;
+	int			tq_flags;
+};
+
+#define	TQ_FLAGS_ACTIVE		(1 << 0)
+#define	TQ_FLAGS_BLOCKED	(1 << 1)
+#define	TQ_FLAGS_PENDING	(1 << 2)
+
+struct taskqueue *
+taskqueue_create(const char *name, int mflags,
+				    taskqueue_enqueue_fn enqueue,
+    void *context)
+{
+
+	panic("");
+	return (NULL);
+	
+}
+
+int
+taskqueue_start_threads(struct taskqueue **tqp, int count, int pri,
+    const char *name, ...)
+{
+
+
+	panic("");
+	return (0);
+}
+
+int
+taskqueue_enqueue(struct taskqueue *queue, struct task *task)
+{
+
+	panic("");
+	return (0);
+}
+
+
+void
+taskqueue_drain(struct taskqueue *queue, struct task *task)
+{
+	
+	panic("");
+}
+
+void
+taskqueue_free(struct taskqueue *queue)
+{
+
+	panic("");	
+}
+
+void
+taskqueue_thread_enqueue(void *context)
+{
+	panic("");
+	
+}
+

Modified: user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c
==============================================================================
--- user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c	Mon Jan  4 05:27:49 2010	(r201472)
+++ user/kmacy/releng_8_rump/lib/libunet/unet_uma_core.c	Mon Jan  4 05:39:00 2010	(r201473)
@@ -92,6 +92,28 @@ __FBSDID("$FreeBSD$");
 
 #undef UMA_MD_SMALL_ALLOC
 
+uma_slab_t
+vtoslab(vm_offset_t va)
+{
+
+	panic("");
+	return (NULL);
+}
+
+void
+vsetslab(vm_offset_t va, uma_slab_t slab)
+{
+
+	panic("");
+}
+
+
+void
+vsetobj(vm_offset_t va, vm_object_t obj)
+{
+
+	panic("");
+}
 /*
  * This is the zone and keg from which all zones are spawned.  The idea is that
  * even the zone & keg heads are allocated from the allocator, so we use the


More information about the svn-src-user mailing list