summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/sys/osd.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-10-09 22:42:09 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-10-10 09:06:58 +0200
commitbceabc95c1c85d793200446fa85f1ddc6313ea29 (patch)
tree973c8bd8deca9fd69913f2895cc91e0e6114d46c /freebsd/sys/sys/osd.h
parentAdd FreeBSD sources as a submodule (diff)
downloadrtems-libbsd-bceabc95c1c85d793200446fa85f1ddc6313ea29.tar.bz2
Move files to match FreeBSD layout
Diffstat (limited to 'freebsd/sys/sys/osd.h')
-rw-r--r--freebsd/sys/sys/osd.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/freebsd/sys/sys/osd.h b/freebsd/sys/sys/osd.h
new file mode 100644
index 00000000..a1989de0
--- /dev/null
+++ b/freebsd/sys/sys/osd.h
@@ -0,0 +1,101 @@
+/*-
+ * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_OSD_HH_
+#define _SYS_OSD_HH_
+
+#include <freebsd/sys/queue.h>
+
+/*
+ * Lock key:
+ * (c) container lock (e.g. jail's pr_mtx) and/or osd_object_lock
+ * (l) osd_list_lock
+ */
+struct osd {
+ u_int osd_nslots; /* (c) */
+ void **osd_slots; /* (c) */
+ LIST_ENTRY(osd) osd_next; /* (l) */
+};
+
+#ifdef _KERNEL
+
+#define OSD_THREAD 0
+#define OSD_JAIL 1
+
+#define OSD_FIRST OSD_THREAD
+#define OSD_LAST OSD_JAIL
+
+typedef void (*osd_destructor_t)(void *value);
+typedef int (*osd_method_t)(void *obj, void *data);
+
+int osd_register(u_int type, osd_destructor_t destructor,
+ osd_method_t *methods);
+void osd_deregister(u_int type, u_int slot);
+
+int osd_set(u_int type, struct osd *osd, u_int slot, void *value);
+void *osd_get(u_int type, struct osd *osd, u_int slot);
+void osd_del(u_int type, struct osd *osd, u_int slot);
+int osd_call(u_int type, u_int method, void *obj, void *data);
+
+void osd_exit(u_int type, struct osd *osd);
+
+#define osd_thread_register(destructor) \
+ osd_register(OSD_THREAD, (destructor), NULL)
+#define osd_thread_deregister(slot) \
+ osd_deregister(OSD_THREAD, (slot))
+#define osd_thread_set(td, slot, value) \
+ osd_set(OSD_THREAD, &(td)->td_osd, (slot), (value))
+#define osd_thread_get(td, slot) \
+ osd_get(OSD_THREAD, &(td)->td_osd, (slot))
+#define osd_thread_del(td, slot) do { \
+ KASSERT((td) == curthread, ("Not curthread.")); \
+ osd_del(OSD_THREAD, &(td)->td_osd, (slot)); \
+} while (0)
+#define osd_thread_call(td, method, data) \
+ osd_call(OSD_THREAD, (method), (td), (data))
+#define osd_thread_exit(td) \
+ osd_exit(OSD_THREAD, &(td)->td_osd)
+
+#define osd_jail_register(destructor, methods) \
+ osd_register(OSD_JAIL, (destructor), (methods))
+#define osd_jail_deregister(slot) \
+ osd_deregister(OSD_JAIL, (slot))
+#define osd_jail_set(pr, slot, value) \
+ osd_set(OSD_JAIL, &(pr)->pr_osd, (slot), (value))
+#define osd_jail_get(pr, slot) \
+ osd_get(OSD_JAIL, &(pr)->pr_osd, (slot))
+#define osd_jail_del(pr, slot) \
+ osd_del(OSD_JAIL, &(pr)->pr_osd, (slot))
+#define osd_jail_call(pr, method, data) \
+ osd_call(OSD_JAIL, (method), (pr), (data))
+#define osd_jail_exit(pr) \
+ osd_exit(OSD_JAIL, &(pr)->pr_osd)
+
+#endif /* _KERNEL */
+
+#endif /* !_SYS_OSD_HH_ */