[Midnightbsd-cvs] src: sys/sys: Sync with FreeBSD 7
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Mon Sep 15 21:18:53 EDT 2008
Log Message:
-----------
Sync with FreeBSD 7
Added Files:
-----------
src/sys/sys:
_bus_dma.h (r1.1)
_elf_solaris.h (r1.1)
_rwlock.h (r1.1)
_semaphore.h (r1.1)
_sx.h (r1.1)
apm.h (r1.1)
elf.h (r1.1)
ipmi.h (r1.1)
ksem.h (r1.1)
lock_profile.h (r1.1)
mqueue.h (r1.1)
posix4.h (r1.1)
rwlock.h (r1.1)
semaphore.h (r1.1)
-------------- next part --------------
--- /dev/null
+++ sys/sys/_rwlock.h
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 2006 John Baldwin <jhb at 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.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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: src/sys/sys/_rwlock.h,v 1.4 2007/06/26 21:31:56 attilio Exp $
+ */
+
+#ifndef _SYS__RWLOCK_H_
+#define _SYS__RWLOCK_H_
+
+/*
+ * Reader/writer lock.
+ */
+struct rwlock {
+ struct lock_object lock_object;
+ volatile uintptr_t rw_lock;
+ volatile unsigned rw_recurse;
+};
+
+#endif /* !_SYS__RWLOCK_H_ */
--- /dev/null
+++ sys/sys/rwlock.h
@@ -0,0 +1,219 @@
+/*-
+ * Copyright (c) 2006 John Baldwin <jhb at 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.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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: src/sys/sys/rwlock.h,v 1.14 2007/07/20 08:43:42 attilio Exp $
+ */
+
+#ifndef _SYS_RWLOCK_H_
+#define _SYS_RWLOCK_H_
+
+#include <sys/_lock.h>
+#include <sys/_rwlock.h>
+#include <sys/lock_profile.h>
+
+#ifdef _KERNEL
+#include <sys/pcpu.h>
+#include <machine/atomic.h>
+#endif
+
+/*
+ * The rw_lock field consists of several fields. The low bit indicates
+ * if the lock is locked with a read (shared) or write (exclusive) lock.
+ * A value of 0 indicates a write lock, and a value of 1 indicates a read
+ * lock. Bit 1 is a boolean indicating if there are any threads waiting
+ * for a read lock. Bit 2 is a boolean indicating if there are any threads
+ * waiting for a write lock. The rest of the variable's definition is
+ * dependent on the value of the first bit. For a write lock, it is a
+ * pointer to the thread holding the lock, similar to the mtx_lock field of
+ * mutexes. For read locks, it is a count of read locks that are held.
+ *
+ * When the lock is not locked by any thread, it is encoded as a read lock
+ * with zero waiters.
+ *
+ * A note about memory barriers. Write locks need to use the same memory
+ * barriers as mutexes: _acq when acquiring a write lock and _rel when
+ * releasing a write lock. Read locks also need to use an _acq barrier when
+ * acquiring a read lock. However, since read locks do not update any
+ * locked data (modulo bugs of course), no memory barrier is needed when
+ * releasing a read lock.
+ */
+
+#define RW_LOCK_READ 0x01
+#define RW_LOCK_READ_WAITERS 0x02
+#define RW_LOCK_WRITE_WAITERS 0x04
+#define RW_LOCK_RECURSED 0x08
+#define RW_LOCK_FLAGMASK \
+ (RW_LOCK_READ | RW_LOCK_READ_WAITERS | RW_LOCK_WRITE_WAITERS | \
+ RW_LOCK_RECURSED)
+
+#define RW_OWNER(x) ((x) & ~RW_LOCK_FLAGMASK)
+#define RW_READERS_SHIFT 4
+#define RW_READERS(x) (RW_OWNER((x)) >> RW_READERS_SHIFT)
+#define RW_READERS_LOCK(x) ((x) << RW_READERS_SHIFT | RW_LOCK_READ)
+#define RW_ONE_READER (1 << RW_READERS_SHIFT)
+
+#define RW_UNLOCKED RW_READERS_LOCK(0)
+#define RW_DESTROYED (RW_LOCK_READ_WAITERS | RW_LOCK_WRITE_WAITERS)
+
+#ifdef _KERNEL
+
+/* Very simple operations on rw_lock. */
+
+/* Try to obtain a write lock once. */
+#define _rw_write_lock(rw, tid) \
+ atomic_cmpset_acq_ptr(&(rw)->rw_lock, RW_UNLOCKED, (tid))
+
+/* Release a write lock quickly if there are no waiters. */
+#define _rw_write_unlock(rw, tid) \
+ atomic_cmpset_rel_ptr(&(rw)->rw_lock, (tid), RW_UNLOCKED)
+
+/*
+ * Full lock operations that are suitable to be inlined in non-debug
+ * kernels. If the lock cannot be acquired or released trivially then
+ * the work is deferred to another function.
+ */
+
+/* Acquire a write lock. */
+#define __rw_wlock(rw, tid, file, line) do { \
+ uintptr_t _tid = (uintptr_t)(tid); \
+ \
+ if (!_rw_write_lock((rw), _tid)) \
+ _rw_wlock_hard((rw), _tid, (file), (line)); \
+ else \
+ lock_profile_obtain_lock_success(&(rw)->lock_object, 0, \
+ 0, (file), (line)); \
+} while (0)
+
+/* Release a write lock. */
+#define __rw_wunlock(rw, tid, file, line) do { \
+ uintptr_t _tid = (uintptr_t)(tid); \
+ \
+ if (!_rw_write_unlock((rw), _tid)) \
+ _rw_wunlock_hard((rw), _tid, (file), (line)); \
+} while (0)
+
+/*
+ * Function prototypes. Routines that start with _ are not part of the
+ * external API and should not be called directly. Wrapper macros should
+ * be used instead.
+ */
+
+#define rw_init(rw, name) rw_init_flags((rw), (name), 0)
+void rw_init_flags(struct rwlock *rw, const char *name, int opts);
+void rw_destroy(struct rwlock *rw);
+void rw_sysinit(void *arg);
+int rw_wowned(struct rwlock *rw);
+void _rw_wlock(struct rwlock *rw, const char *file, int line);
+void _rw_wunlock(struct rwlock *rw, const char *file, int line);
+void _rw_rlock(struct rwlock *rw, const char *file, int line);
+void _rw_runlock(struct rwlock *rw, const char *file, int line);
+void _rw_wlock_hard(struct rwlock *rw, uintptr_t tid, const char *file,
+ int line);
+void _rw_wunlock_hard(struct rwlock *rw, uintptr_t tid, const char *file,
+ int line);
+int _rw_try_upgrade(struct rwlock *rw, const char *file, int line);
+void _rw_downgrade(struct rwlock *rw, const char *file, int line);
+#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
+void _rw_assert(struct rwlock *rw, int what, const char *file, int line);
+#endif
+
+/*
+ * Public interface for lock operations.
+ *
+ * XXX: Missing try locks.
+ */
+
+#ifndef LOCK_DEBUG
+#error LOCK_DEBUG not defined, include <sys/lock.h> before <sys/rwlock.h>
+#endif
+#if LOCK_DEBUG > 0 || defined(RWLOCK_NOINLINE)
+#define rw_wlock(rw) _rw_wlock((rw), LOCK_FILE, LOCK_LINE)
+#define rw_wunlock(rw) _rw_wunlock((rw), LOCK_FILE, LOCK_LINE)
+#else
+#define rw_wlock(rw) \
+ __rw_wlock((rw), curthread, LOCK_FILE, LOCK_LINE)
+#define rw_wunlock(rw) \
+ __rw_wunlock((rw), curthread, LOCK_FILE, LOCK_LINE)
+#endif
+#define rw_rlock(rw) _rw_rlock((rw), LOCK_FILE, LOCK_LINE)
+#define rw_runlock(rw) _rw_runlock((rw), LOCK_FILE, LOCK_LINE)
+#define rw_try_upgrade(rw) _rw_try_upgrade((rw), LOCK_FILE, LOCK_LINE)
+#define rw_downgrade(rw) _rw_downgrade((rw), LOCK_FILE, LOCK_LINE)
+#define rw_sleep(chan, rw, pri, wmesg, timo) \
+ _sleep((chan), &(rw)->lock_object, (pri), (wmesg), (timo))
+
+#define rw_initialized(rw) lock_initalized(&(rw)->lock_object)
+
+struct rw_args {
+ struct rwlock *ra_rw;
+ const char *ra_desc;
+};
+
+#define RW_SYSINIT(name, rw, desc) \
+ static struct rw_args name##_args = { \
+ (rw), \
+ (desc), \
+ }; \
+ SYSINIT(name##_rw_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
+ rw_sysinit, &name##_args); \
+ SYSUNINIT(name##_rw_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
+ rw_destroy, (rw))
+
+/*
+ * Options passed to rw_init_flags().
+ */
+#define RW_DUPOK 0x01
+#define RW_NOPROFILE 0x02
+#define RW_NOWITNESS 0x04
+#define RW_QUIET 0x08
+#define RW_RECURSE 0x10
+
+/*
+ * The INVARIANTS-enabled rw_assert() functionality.
+ *
+ * The constants need to be defined for INVARIANT_SUPPORT infrastructure
+ * support as _rw_assert() itself uses them and the latter implies that
+ * _rw_assert() must build.
+ */
+#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
+#define RA_LOCKED LA_LOCKED
+#define RA_RLOCKED LA_SLOCKED
+#define RA_WLOCKED LA_XLOCKED
+#define RA_UNLOCKED LA_UNLOCKED
+#define RA_RECURSED LA_RECURSED
+#define RA_NOTRECURSED LA_NOTRECURSED
+#endif
+
+#ifdef INVARIANTS
+#define rw_assert(rw, what) _rw_assert((rw), (what), LOCK_FILE, LOCK_LINE)
+#else
+#define rw_assert(rw, what)
+#endif
+
+#endif /* _KERNEL */
+#endif /* !_SYS_RWLOCK_H_ */
--- /dev/null
+++ sys/sys/posix4.h
@@ -0,0 +1,116 @@
+#ifndef _P1003_1B_P1003_1B_H_
+#define _P1003_1B_P1003_1B_H_
+/*-
+ * Copyright (c) 1996, 1997, 1998
+ * HD Associates, Inc. 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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: src/sys/sys/posix4.h,v 1.16 2006/11/11 16:19:12 trhodes Exp $
+ */
+
+#include <sys/param.h>
+#include <sys/ioccom.h>
+#include <sys/malloc.h>
+#include <sys/sched.h>
+
+/* Generate syscall stubs for when something is optionally
+ * loadable as a module. References "syscall_not_present".
+ * XXX Good candidate for sys/syscall.h
+ */
+struct proc;
+struct nosys_args;
+extern int syscall_not_present(struct thread *, const char *, struct nosys_args *);
+
+#define SYSCALL_NOT_PRESENT_GEN(SC) \
+int SC (struct thread *td, struct SC##_args *uap) \
+{ \
+ return syscall_not_present(td, #SC , (struct nosys_args *)uap); \
+}
+
+
+MALLOC_DECLARE(M_P31B);
+
+#define p31b_malloc(SIZE) malloc((SIZE), M_P31B, M_WAITOK)
+#define p31b_free(P) free((P), M_P31B)
+
+int p31b_proc(struct proc *, pid_t, struct proc **);
+
+void p31b_setcfg(int, int);
+int p31b_getcfg(int);
+int p31b_iscfg(int);
+
+#ifdef _KPOSIX_PRIORITY_SCHEDULING
+
+/*
+ * KSCHED_OP_RW is a vector of read/write flags for each entry indexed
+ * by the enum ksched_op.
+ *
+ * 1 means you need write access, 0 means read is sufficient.
+ */
+
+enum ksched_op {
+
+#define KSCHED_OP_RW { 1, 0, 1, 0, 0, 0, 0, 0 }
+
+ SCHED_SETPARAM,
+ SCHED_GETPARAM,
+ SCHED_SETSCHEDULER,
+ SCHED_GETSCHEDULER,
+ SCHED_YIELD,
+ SCHED_GET_PRIORITY_MAX,
+ SCHED_GET_PRIORITY_MIN,
+ SCHED_RR_GET_INTERVAL,
+ SCHED_OP_MAX
+};
+
+struct ksched;
+
+int ksched_attach(struct ksched **);
+int ksched_detach(struct ksched *);
+
+int ksched_setparam(struct ksched *,
+ struct thread *, const struct sched_param *);
+int ksched_getparam(struct ksched *,
+ struct thread *, struct sched_param *);
+
+int ksched_setscheduler(struct ksched *,
+ struct thread *, int, const struct sched_param *);
+int ksched_getscheduler(struct ksched *, struct thread *, int *);
+
+int ksched_yield(struct ksched *);
+
+int ksched_get_priority_max(struct ksched *, int, int *);
+int ksched_get_priority_min(struct ksched *, int, int *);
+
+int ksched_rr_get_interval(struct ksched *,
+ struct thread *, struct timespec *);
+
+#endif /* _KPOSIX_PRIORITY_SCHEDULING */
+
+#endif /* _P1003_1B_P1003_1B_H_ */
--- /dev/null
+++ sys/sys/ipmi.h
@@ -0,0 +1,155 @@
+/*-
+ * Copyright (c) 2006 IronPort Systems Inc. <ambrisko at ironport.com>
+ * 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 AUTHOR 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 AUTHOR 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: src/sys/sys/ipmi.h,v 1.2 2006/09/22 22:11:29 jhb Exp $
+ */
+
+#ifndef __SYS_IPMI_H__
+#define __SYS_IPMI_H__
+
+#define IPMI_MAX_ADDR_SIZE 0x20
+#define IPMI_MAX_RX 1024
+#define IPMI_BMC_SLAVE_ADDR 0x20 /* Linux Default slave address */
+#define IPMI_BMC_CHANNEL 0x0f /* Linux BMC channel */
+
+#define IPMI_BMC_SMS_LUN 0x02
+
+#define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c
+#define IPMI_IPMB_ADDR_TYPE 0x01
+#define IPMI_IPMB_BROADCAST_ADDR_TYPE 0x41
+
+#define IPMI_IOC_MAGIC 'i'
+#define IPMICTL_RECEIVE_MSG_TRUNC _IOWR(IPMI_IOC_MAGIC, 11, struct ipmi_recv)
+#define IPMICTL_RECEIVE_MSG _IOWR(IPMI_IOC_MAGIC, 12, struct ipmi_recv)
+#define IPMICTL_SEND_COMMAND _IOW(IPMI_IOC_MAGIC, 13, struct ipmi_req)
+#define IPMICTL_REGISTER_FOR_CMD _IOW(IPMI_IOC_MAGIC, 14, struct ipmi_cmdspec)
+#define IPMICTL_UNREGISTER_FOR_CMD _IOW(IPMI_IOC_MAGIC, 15, struct ipmi_cmdspec)
+#define IPMICTL_SET_GETS_EVENTS_CMD _IOW(IPMI_IOC_MAGIC, 16, int)
+#define IPMICTL_SET_MY_ADDRESS_CMD _IOW(IPMI_IOC_MAGIC, 17, unsigned int)
+#define IPMICTL_GET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 18, unsigned int)
+#define IPMICTL_SET_MY_LUN_CMD _IOW(IPMI_IOC_MAGIC, 19, unsigned int)
+#define IPMICTL_GET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 20, unsigned int)
+
+#define IPMI_RESPONSE_RECV_TYPE 1
+#define IPMI_ASYNC_EVENT_RECV_TYPE 2
+#define IPMI_CMD_RECV_TYPE 3
+
+#define IPMI_APP_REQUEST 0x06
+#define IPMI_GET_DEVICE_ID 0x01
+#define IPMI_CLEAR_FLAGS 0x30
+#define IPMI_GET_MSG_FLAGS 0x31
+# define IPMI_MSG_AVAILABLE 0x01
+# define IPMI_MSG_BUFFER_FULL 0x02
+# define IPMI_WDT_PRE_TIMEOUT 0x08
+#define IPMI_GET_MSG 0x33
+#define IPMI_SEND_MSG 0x34
+#define IPMI_GET_CHANNEL_INFO 0x42
+#define IPMI_RESET_WDOG 0x22
+#define IPMI_SET_WDOG 0x24
+#define IPMI_GET_WDOG 0x25
+
+#define IPMI_SET_WD_TIMER_SMS_OS 0x04
+#define IPMI_SET_WD_TIMER_DONT_STOP 0x40
+#define IPMI_SET_WD_ACTION_RESET 0x01
+
+struct ipmi_msg {
+ unsigned char netfn;
+ unsigned char cmd;
+ unsigned short data_len;
+ unsigned char *data;
+};
+
+struct ipmi_req {
+ unsigned char *addr;
+ unsigned int addr_len;
+ long msgid;
+ struct ipmi_msg msg;
+};
+
+struct ipmi_recv {
+ int recv_type;
+ unsigned char *addr;
+ unsigned int addr_len;
+ long msgid;
+ struct ipmi_msg msg;
+};
+
+struct ipmi_cmdspec {
+ unsigned char netfn;
+ unsigned char cmd;
+};
+
+
+struct ipmi_addr {
+ int addr_type;
+ short channel;
+ unsigned char data[IPMI_MAX_ADDR_SIZE];
+};
+
+struct ipmi_system_interface_addr {
+ int addr_type;
+ short channel;
+ unsigned char lun;
+};
+
+struct ipmi_ipmb_addr {
+ int addr_type;
+ short channel;
+ unsigned char slave_addr;
+ unsigned char lun;
+};
+
+#if defined(__amd64__)
+/* Compatiblity with 32-bit binaries. */
+
+#define IPMICTL_RECEIVE_MSG_TRUNC_32 _IOWR(IPMI_IOC_MAGIC, 11, struct ipmi_recv32)
+#define IPMICTL_RECEIVE_MSG_32 _IOWR(IPMI_IOC_MAGIC, 12, struct ipmi_recv32)
+#define IPMICTL_SEND_COMMAND_32 _IOW(IPMI_IOC_MAGIC, 13, struct ipmi_req32)
+
+struct ipmi_msg32 {
+ unsigned char netfn;
+ unsigned char cmd;
+ unsigned short data_len;
+ uint32_t data;
+};
+
+struct ipmi_req32 {
+ uint32_t addr;
+ unsigned int addr_len;
+ int32_t msgid;
+ struct ipmi_msg32 msg;
+};
+
+struct ipmi_recv32 {
+ int recv_type;
+ uint32_t addr;
+ unsigned int addr_len;
+ int32_t msgid;
+ struct ipmi_msg32 msg;
+};
+
+#endif
+
+#endif /* !__SYS_IPMI_H__ */
--- /dev/null
+++ sys/sys/apm.h
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2007 Marcel Moolenaar
+ * 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 AUTHOR ``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 AUTHOR 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: src/sys/sys/apm.h,v 1.1.2.1 2007/10/29 00:11:40 marcel Exp $
+ */
+
+#ifndef _SYS_APM_H_
+#define _SYS_APM_H_
+
+/* Driver Descriptor Record. */
+struct apm_ddr {
+ uint16_t ddr_sig;
+#define APM_DDR_SIG 0x4552
+ uint16_t ddr_blksize;
+ uint32_t ddr_blkcount;
+};
+
+/* Partition Map Entry Record. */
+struct apm_ent {
+ uint16_t ent_sig;
+#define APM_ENT_SIG 0x504d
+ uint16_t _pad_;
+ uint32_t ent_pmblkcnt;
+ uint32_t ent_start;
+ uint32_t ent_size;
+ char ent_name[32];
+ char ent_type[32];
+};
+
+#define APM_ENT_TYPE_SELF "Apple_partition_map"
+#define APM_ENT_TYPE_UNUSED "Apple_Free"
+
+#define APM_ENT_TYPE_FREEBSD "FreeBSD"
+#define APM_ENT_TYPE_FREEBSD_SWAP "FreeBSD-swap"
+#define APM_ENT_TYPE_FREEBSD_UFS "FreeBSD-UFS"
+#define APM_ENT_TYPE_FREEBSD_VINUM "FreeBSD-Vinum"
+#define APM_ENT_TYPE_FREEBSD_ZFS "FreeBSD-ZFS"
+
+#define APM_ENT_TYPE_APPLE_HFS "Apple_HFS"
+
+#endif /* _SYS_APM_H_ */
--- /dev/null
+++ sys/sys/_elf_solaris.h
@@ -0,0 +1,143 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * $FreeBSD: src/sys/sys/_elf_solaris.h,v 1.1 2006/10/04 07:19:39 jb Exp $
+ *
+ * ELF compatibility definitions for OpenSolaris source.
+ *
+ */
+
+#ifndef _SYS__ELF_SOLARIS_H_
+#define _SYS__ELF_SOLARIS_H_
+
+#include <sys/elf_generic.h>
+
+#define __sElfN(x) typedef __CONCAT(__CONCAT(__CONCAT(Elf,__ELF_WORD_SIZE),_),x) x
+
+__sElfN(Addr);
+__sElfN(Cap);
+__sElfN(Dyn);
+__sElfN(Ehdr);
+__sElfN(Move);
+__sElfN(Off);
+__sElfN(Phdr);
+__sElfN(Rel);
+__sElfN(Rela);
+__sElfN(Shdr);
+__sElfN(Sym);
+__sElfN(Syminfo);
+__sElfN(Verdaux);
+__sElfN(Verdef);
+__sElfN(Vernaux);
+__sElfN(Verneed);
+__sElfN(Versym);
+
+__sElfN(Half);
+__sElfN(Sword);
+__sElfN(Word);
+
+#if __ELF_WORD_SIZE == 32
+typedef Elf32_Word Xword; /* Xword/Sxword are 32-bits in Elf32 */
+typedef Elf32_Sword Sxword;
+#else
+typedef Elf64_Xword Xword;
+typedef Elf64_Sxword Sxword;
+#endif
+
+#define ELF_M_INFO __ELFN(M_INFO)
+#define ELF_M_SIZE __ELFN(M_SIZE)
+#define ELF_M_SYM __ELFN(M_SYM)
+
+/*
+ * Elf `printf' type-cast macros. These force arguments to be a fixed size
+ * so that Elf32 and Elf64 can share common format strings.
+ */
+#define EC_ADDR(a) ((Elf64_Addr)(a)) /* "ull" */
+#define EC_OFF(a) ((Elf64_Off)(a)) /* "ull" */
+#define EC_HALF(a) ((Elf64_Half)(a)) /* "d" */
+#define EC_WORD(a) ((Elf64_Word)(a)) /* "u" */
+#define EC_SWORD(a) ((Elf64_Sword)(a)) /* "d" */
+#define EC_XWORD(a) ((Elf64_Xword)(a)) /* "ull" */
+#define EC_SXWORD(a) ((Elf64_Sxword)(a)) /* "ll" */
+#define EC_LWORD(a) ((Elf64_Lword)(a)) /* "ull" */
+
+#define elf_checksum __elfN(checksum)
+#define elf_fsize __elfN(fsize)
+#define elf_getehdr __elfN(getehdr)
+#define elf_getphdr __elfN(getphdr)
+#define elf_newehdr __elfN(newehdr)
+#define elf_newphdr __elfN(newphdr)
+#define elf_getshdr __elfN(getshdr)
+#define elf_xlatetof __elfN(xlatetof)
+#define elf_xlatetom __elfN(xlatetom)
+
+#define Elf_cap_entry __ElfN(cap_entry)
+#define Elf_cap_title __ElfN(cap_title)
+#define Elf_demangle_name __ElfN(demangle_name)
+#define Elf_dyn_entry __ElfN(dyn_entry)
+#define Elf_dyn_title __ElfN(dyn_title)
+#define Elf_ehdr __ElfN(ehdr)
+#define Elf_got_entry __ElfN(got_entry)
+#define Elf_got_title __ElfN(got_title)
+#define Elf_reloc_apply_reg __ElfN(reloc_apply_reg)
+#define Elf_reloc_apply_val __ElfN(reloc_apply_val)
+#define Elf_reloc_entry_1 __ElfN(reloc_entry_1)
+#define Elf_reloc_entry_2 __ElfN(reloc_entry_2)
+#define Elf_reloc_title __ElfN(reloc_title)
+#define Elf_phdr __ElfN(phdr)
+#define Elf_shdr __ElfN(shdr)
+#define Elf_syms_table_entry __ElfN(syms_table_entry)
+#define Elf_syms_table_title __ElfN(syms_table_title)
+#define Elf_ver_def_title __ElfN(ver_def_title)
+#define Elf_ver_line_1 __ElfN(ver_line_1)
+#define Elf_ver_line_2 __ElfN(ver_line_2)
+#define Elf_ver_line_3 __ElfN(ver_line_3)
+#define Elf_ver_line_4 __ElfN(ver_line_4)
+#define Elf_ver_line_5 __ElfN(ver_line_5)
+#define Elf_ver_need_title __ElfN(ver_need_title)
+
+#ifdef DOODAD
+void Elf_cap_entry(Lm_list *, Cap *, int, Half);
+void Elf_cap_title(Lm_list *);
+const char *Elf_demangle_name(const char *);
+void Elf_dyn_entry(Lm_list *, Dyn *, int, const char *, Half);
+void Elf_dyn_title(Lm_list *);
+void Elf_ehdr(Lm_list *, Ehdr *, Shdr *);
+void Elf_got_entry(Lm_list *, Sword, Addr, Xword, Half, Word, void *, const char *);
+void Elf_got_title(Lm_list *);
+void Elf_phdr(Lm_list *, Half, Phdr *);
+void Elf_reloc_apply_val(Lm_list *, int, Xword, Xword);
+void Elf_reloc_apply_reg(Lm_list *, int, Half, Xword, Xword);
+void Elf_reloc_entry_1(Lm_list *, int, const char *, Half, Word, void *, const char *, const char *, const char *);
+void Elf_reloc_entry_2(Lm_list *, int, const char *, Word, const char *, Off, Sxword, const char *, const char *, const char *);
+void Elf_reloc_title(Lm_list *, int, Word);
+void Elf_shdr(Lm_list *, Half, Shdr *);
+void Elf_syms_table_entry(Lm_list *, int, const char *, Half, Sym *, Word, const char *, const char *);
+void Elf_syms_table_title(Lm_list *, int);
+void Elf_ver_def_title(Lm_list *);
+void Elf_ver_line_1(Lm_list *, const char *, const char *, const char *, const char *);
+void Elf_ver_line_2(Lm_list *, const char *, const char *);
+void Elf_ver_line_3(Lm_list *, const char *, const char *, const char *);
+void Elf_ver_line_4(Lm_list *, const char *);
+void Elf_ver_line_5(Lm_list *, const char *, const char *);
+void Elf_ver_need_title(Lm_list *);
+#endif
+
+#endif /* !_SYS__ELF_SOLARIS_H_ */
--- /dev/null
+++ sys/sys/_sx.h
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2007 Attilio Rao <attilio at 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(s), this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified other than the possible
+ * addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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: src/sys/sys/_sx.h,v 1.1 2007/03/31 23:23:42 jhb Exp $
+ */
+
+#ifndef _SYS__SX_H_
+#define _SYS__SX_H_
+
+/*
+ * Shared/exclusive lock main structure definition.
+ */
+struct sx {
+ struct lock_object lock_object;
+ volatile uintptr_t sx_lock;
+ volatile unsigned sx_recurse;
+};
+
+#endif /* !_SYS__SX_H_ */
--- /dev/null
+++ sys/sys/_semaphore.h
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2002 Alfred Perlstein <alfred at 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 AUTHOR 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 AUTHOR 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: src/sys/sys/_semaphore.h,v 1.6 2006/11/11 16:15:35 trhodes Exp $
+ */
+#ifndef __SEMAPHORE_H_
+#define __SEMAPHORE_H_
+
+typedef intptr_t semid_t;
+struct timespec;
+
+#ifndef _KERNEL
+
+#include <sys/cdefs.h>
+
+/*
+ * Semaphore definitions.
+ */
+struct sem {
+#define SEM_MAGIC ((u_int32_t) 0x09fa4012)
+ u_int32_t magic;
+ pthread_mutex_t lock;
+ pthread_cond_t gtzero;
+ u_int32_t count;
+ u_int32_t nwaiters;
+#define SEM_USER (NULL)
+ semid_t semid; /* semaphore id if kernel (shared) semaphore */
+ int syssem; /* 1 if kernel (shared) semaphore */
+ LIST_ENTRY(sem) entry;
+ struct sem **backpointer;
+};
+
+__BEGIN_DECLS
+
+int ksem_close(semid_t id);
+int ksem_post(semid_t id);
+int ksem_wait(semid_t id);
+int ksem_trywait(semid_t id);
+int ksem_timedwait(semid_t id, const struct timespec *abstime);
+int ksem_init(semid_t *idp, unsigned int value);
+int ksem_open(semid_t *idp, const char *name, int oflag, mode_t mode,
+ unsigned int value);
+int ksem_unlink(const char *name);
+int ksem_getvalue(semid_t id, int *val);
+int ksem_destroy(semid_t id);
+
+__END_DECLS
+
+#endif /* !_KERNEL */
+
+#endif /* __SEMAPHORE_H_ */
--- /dev/null
+++ sys/sys/elf.h
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2001 David E. O'Brien.
+ * 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 AUTHOR 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 AUTHOR 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: src/sys/sys/elf.h,v 1.1 2006/10/04 07:23:31 jb Exp $
+ */
+
+/*
+ * This is a Solaris compatibility header
+ */
+
+#ifndef _SYS_ELF_H_
+#define _SYS_ELF_H_
+
+#include <sys/types.h>
+#include <machine/elf.h>
+#include <sys/elf32.h>
+#include <sys/elf64.h>
+
+#ifdef _SOLARIS_C_SOURCE
+#include <sys/_elf_solaris.h>
+#endif
+
+#endif /* !_SYS_ELF_H_ */
--- /dev/null
+++ sys/sys/ksem.h
@@ -0,0 +1,59 @@
+/*-
+ * Copyright (c) 2002 Alfred Perlstein <alfred at 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 AUTHOR 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 AUTHOR 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: src/sys/sys/ksem.h,v 1.3 2006/11/11 16:15:35 trhodes Exp $
+ */
+
+#ifndef _POSIX4_KSEM_H_
+#define _POSIX4_KSEM_H_
+
+#ifndef _KERNEL
+#error "no user-servicable parts inside"
+#endif
+
+#include <sys/condvar.h>
+#include <sys/queue.h>
+
+struct kuser {
+ pid_t ku_pid;
+ LIST_ENTRY(kuser) ku_next;
+};
+
+struct ksem {
+ LIST_ENTRY(ksem) ks_entry; /* global list entry */
+ int ks_onlist; /* boolean if on a list (ks_entry) */
+ char *ks_name; /* if named, this is the name */
+ int ks_ref; /* number of references */
+ mode_t ks_mode; /* protection bits */
+ uid_t ks_uid; /* creator uid */
+ gid_t ks_gid; /* creator gid */
+ unsigned int ks_value; /* current value */
+ struct cv ks_cv; /* waiters sleep here */
+ int ks_waiters; /* number of waiters */
+ LIST_HEAD(, kuser) ks_users; /* pids using this sem */
+ struct label *ks_label; /* MAC label */
+};
+
+#endif /* !_POSIX4_KSEM_H_ */
--- /dev/null
+++ sys/sys/semaphore.h
@@ -0,0 +1,67 @@
+/*-
+ * Copyright (c) 1996, 1997
+ * HD Associates, Inc. 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by HD Associates, Inc
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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: src/sys/sys/semaphore.h,v 1.12 2006/11/11 16:15:35 trhodes Exp $
+ */
+
+/* semaphore.h: POSIX 1003.1b semaphores */
+
+#ifndef _SEMAPHORE_H_
+#define _SEMAPHORE_H_
+
+/* Opaque type definition. */
+struct sem;
+typedef struct sem * sem_t;
+
+#define SEM_FAILED ((sem_t *)0)
+#define SEM_VALUE_MAX (~0U) /* Equivalent to UINT_MAX. */
+
+#ifndef _KERNEL
+#include <sys/cdefs.h>
+
+struct timespec;
+
+__BEGIN_DECLS
+int sem_close(sem_t *);
+int sem_destroy(sem_t *);
+int sem_getvalue(sem_t * __restrict, int * __restrict);
+int sem_init(sem_t *, int, unsigned int);
+sem_t *sem_open(const char *, int, ...);
+int sem_post(sem_t *);
+int sem_timedwait(sem_t * __restrict, const struct timespec * __restrict);
+int sem_trywait(sem_t *);
+int sem_unlink(const char *);
+int sem_wait(sem_t *);
+__END_DECLS
+
+#endif
+
+#endif /* !_SEMAPHORE_H_ */
--- /dev/null
+++ sys/sys/_bus_dma.h
@@ -0,0 +1,63 @@
+/*-
+ * Copyright 2006 John-Mark Gurney.
+ * 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 AUTHOR 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 AUTHOR 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: src/sys/sys/_bus_dma.h,v 1.1 2006/09/03 00:26:17 jmg Exp $
+ *
+ */
+
+#ifndef _SYS__BUS_DMA_H_
+#define _SYS__BUS_DMA_H_
+
+typedef int bus_dmasync_op_t;
+
+/*
+ * bus_dma_tag_t
+ *
+ * A machine-dependent opaque type describing the characteristics
+ * of how to perform DMA mappings. This structure encapsultes
+ * information concerning address and alignment restrictions, number
+ * of S/G segments, amount of data per S/G segment, etc.
+ */
+typedef struct bus_dma_tag *bus_dma_tag_t;
+
+/*
+ * bus_dmamap_t
+ *
+ * DMA mapping instance information.
+ */
+typedef struct bus_dmamap *bus_dmamap_t;
+
+/*
+ * A function that performs driver-specific synchronization on behalf of
+ * busdma.
+ */
+typedef enum {
+ BUS_DMA_LOCK = 0x01,
+ BUS_DMA_UNLOCK = 0x02,
+} bus_dma_lock_op_t;
+
+typedef void bus_dma_lock_t(void *, bus_dma_lock_op_t);
+
+#endif /* !_SYS__BUS_DMA_H_ */
--- /dev/null
+++ sys/sys/mqueue.h
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2005 David Xu <davidxu at 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 AUTHOR 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 AUTHOR 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: src/sys/sys/mqueue.h,v 1.2 2005/11/30 05:12:02 davidxu Exp $
+ */
+
+#ifndef _SYS_MQUEUE_H_
+#define _SYS_MQUEUE_H_
+
+struct mq_attr {
+ long mq_flags; /* Message queue flags. */
+ long mq_maxmsg; /* Maximum number of messages. */
+ long mq_msgsize; /* Maximum message size. */
+ long mq_curmsgs; /* Number of messages currently queued. */
+ long __reserved[4]; /* Ignored for input, zeroed for output */
+};
+
+#ifdef _KERNEL
+struct thread;
+struct file;
+extern void (*mq_fdclose)(struct thread *td, int fd, struct file *fp);
+#endif
+#endif
--- /dev/null
+++ sys/sys/lock_profile.h
@@ -0,0 +1,169 @@
+/*-
+ * Copyright (c) 2006 Kip Macy kmacy at FreeBSD.org
+ * Copyright (c) 2006 Kris Kennaway kris at FreeBSD.org
+ * Copyright (c) 2006 Dag-Erling Smorgrav des at des.no
+ *
+ * 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 ``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 SHAL THE AUTHORS 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: src/sys/sys/lock_profile.h,v 1.15 2007/09/14 01:12:39 attilio Exp $
+ */
+
+
+#ifndef _SYS_LOCK_PROFILE_H_
+#define _SYS_LOCK_PROFILE_H_
+
+#ifdef LOCK_PROFILING
+#include <sys/stdint.h>
+#include <sys/ktr.h>
+#include <sys/mutex.h>
+#include <machine/atomic.h>
+#include <machine/cpufunc.h>
+
+#ifndef LPROF_HASH_SIZE
+#define LPROF_HASH_SIZE 4096
+#define LPROF_HASH_MASK (LPROF_HASH_SIZE - 1)
+#endif
+
+#ifndef USE_CPU_NANOSECONDS
+u_int64_t nanoseconds(void);
+#endif
+
+struct lock_prof {
+ const char *name;
+ const char *type;
+ const char *file;
+ u_int namehash;
+ int line;
+ uintmax_t cnt_max;
+ uintmax_t cnt_tot;
+ uintmax_t cnt_wait;
+ uintmax_t cnt_cur;
+ uintmax_t cnt_contest_holding;
+ uintmax_t cnt_contest_locking;
+};
+
+extern struct lock_prof lprof_buf[LPROF_HASH_SIZE];
+#define LPROF_SBUF_SIZE 256 * 400
+
+/* We keep a smaller pool of spin mutexes for protecting the lprof hash entries */
+#define LPROF_LOCK_SIZE 16
+#define LPROF_LOCK_MASK (LPROF_LOCK_SIZE - 1)
+#define LPROF_LHASH(hash) ((hash) & LPROF_LOCK_MASK)
+
+#define LPROF_LOCK(hash) mtx_lock_spin(&lprof_locks[LPROF_LHASH(hash)])
+#define LPROF_UNLOCK(hash) mtx_unlock_spin(&lprof_locks[LPROF_LHASH(hash)])
+
+#ifdef _KERNEL
+extern struct mtx lprof_locks[LPROF_LOCK_SIZE];
+extern int lock_prof_enable;
+
+void _lock_profile_obtain_lock_success(struct lock_object *lo, int contested, uint64_t waittime, const char *file, int line);
+void _lock_profile_update_wait(struct lock_object *lo, uint64_t waitstart);
+void _lock_profile_release_lock(struct lock_object *lo);
+
+static inline void lock_profile_object_init(struct lock_object *lo, struct lock_class *class, const char *name) {
+ const char *p;
+ u_int hash = 0;
+ struct lock_profile_object *l = &lo->lo_profile_obj;
+
+ l->lpo_acqtime = 0;
+ l->lpo_waittime = 0;
+ l->lpo_filename = NULL;
+ l->lpo_lineno = 0;
+ l->lpo_contest_holding = 0;
+ l->lpo_contest_locking = 0;
+ l->lpo_type = class->lc_name;
+
+ /* Hash the mutex name to an int so we don't have to strcmp() it repeatedly */
+ for (p = name; *p != '\0'; p++)
+ hash = 31 * hash + *p;
+ l->lpo_namehash = hash;
+#if 0
+ if (opts & MTX_PROFILE)
+ l->lpo_stack = stack_create();
+#endif
+}
+
+
+static inline void
+lock_profile_object_destroy(struct lock_object *lo)
+{
+#if 0
+ struct lock_profile_object *l = &lo->lo_profile_obj;
+ if (lo->lo_flags & LO_PROFILE)
+ stack_destroy(l->lpo_stack);
+#endif
+}
+
+static inline void lock_profile_obtain_lock_failed(struct lock_object *lo, int *contested,
+ uint64_t *waittime)
+{
+ struct lock_profile_object *l = &lo->lo_profile_obj;
+
+ if (!(lo->lo_flags & LO_NOPROFILE) && lock_prof_enable &&
+ *contested == 0) {
+ *waittime = nanoseconds();
+ atomic_add_int(&l->lpo_contest_holding, 1);
+ *contested = 1;
+ }
+}
+
+static inline void lock_profile_obtain_lock_success(struct lock_object *lo, int contested, uint64_t waittime, const char *file, int line)
+{
+
+ /* don't reset the timer when/if recursing */
+ if (!(lo->lo_flags & LO_NOPROFILE) && lock_prof_enable &&
+ lo->lo_profile_obj.lpo_acqtime == 0) {
+#ifdef LOCK_PROFILING_FAST
+ if (contested == 0)
+ return;
+#endif
+ _lock_profile_obtain_lock_success(lo, contested, waittime, file, line);
+ }
+}
+static inline void lock_profile_release_lock(struct lock_object *lo)
+{
+ struct lock_profile_object *l = &lo->lo_profile_obj;
+
+ if (!(lo->lo_flags & LO_NOPROFILE) && l->lpo_acqtime)
+ _lock_profile_release_lock(lo);
+}
+
+#endif /* _KERNEL */
+
+#else /* !LOCK_PROFILING */
+
+#ifdef _KERNEL
+static inline void lock_profile_update_wait(struct lock_object *lo, uint64_t waitstart) {;}
+static inline void lock_profile_update_contest_locking(struct lock_object *lo, int contested) {;}
+static inline void lock_profile_release_lock(struct lock_object *lo) {;}
+static inline void lock_profile_obtain_lock_failed(struct lock_object *lo, int *contested, uint64_t *waittime) {;}
+static inline void lock_profile_obtain_lock_success(struct lock_object *lo, int contested, uint64_t waittime,
+ const char *file, int line) {;}
+static inline void lock_profile_object_destroy(struct lock_object *lo) {;}
+static inline void lock_profile_object_init(struct lock_object *lo, struct lock_class *class, const char *name) {;}
+
+#endif /* _KERNEL */
+
+#endif /* !LOCK_PROFILING */
+
+#endif /* _SYS_LOCK_PROFILE_H_ */
More information about the Midnightbsd-cvs
mailing list