2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _I386_LOCKS_H_
30 #define _I386_LOCKS_H_
32 #include <sys/appleapiopts.h>
33 #include <kern/kern_types.h>
35 #ifdef MACH_KERNEL_PRIVATE
37 #include <i386/hw_lock_types.h>
39 extern unsigned int LcksOpts
;
41 #define enaLkDeb 0x00000001 /* Request debug in default attribute */
42 #define enaLkStat 0x00000002 /* Request statistic in default attribute */
46 #ifdef MACH_KERNEL_PRIVATE
48 unsigned int lck_spin_data
[10]; /* XXX - usimple_lock_data_t */
51 #define LCK_SPIN_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */
56 unsigned int opaque
[10];
59 typedef struct __lck_spin_t__ lck_spin_t
;
63 #ifdef MACH_KERNEL_PRIVATE
64 typedef struct _lck_mtx_
{
67 unsigned int lck_mtxd_ilk
;
68 unsigned int lck_mtxd_locked
;
69 unsigned short lck_mtxd_waiters
;
70 unsigned short lck_mtxd_pri
;
73 unsigned int lck_mtxi_tag
;
74 struct _lck_mtx_ext_
*lck_mtxi_ptr
;
75 unsigned int lck_mtxi_pad8
;
80 #define lck_mtx_ilk lck_mtx_sw.lck_mtxd.lck_mtxd_ilk
81 #define lck_mtx_locked lck_mtx_sw.lck_mtxd.lck_mtxd_locked
82 #define lck_mtx_waiters lck_mtx_sw.lck_mtxd.lck_mtxd_waiters
83 #define lck_mtx_pri lck_mtx_sw.lck_mtxd.lck_mtxd_pri
85 #define lck_mtx_tag lck_mtx_sw.lck_mtxi.lck_mtxi_tag
86 #define lck_mtx_ptr lck_mtx_sw.lck_mtxi.lck_mtxi_ptr
88 #define LCK_MTX_TAG_INDIRECT 0x00001007 /* lock marked as Indirect */
89 #define LCK_MTX_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */
91 /* Adaptive spin before blocking */
92 extern unsigned int MutexSpin
;
93 extern void lck_mtx_lock_spin(lck_mtx_t
*lck
);
95 extern void lck_mtx_interlock_spin(lck_mtx_t
*lck
);
103 #define MUTEX_TAG 0x4d4d
106 unsigned int lck_mtx_stat_data
;
109 typedef struct _lck_mtx_ext_
{
111 struct _lck_grp_
*lck_mtx_grp
;
112 unsigned int lck_mtx_attr
;
113 lck_mtx_deb_t lck_mtx_deb
;
114 lck_mtx_stat_t lck_mtx_stat
;
117 #define LCK_MTX_ATTR_DEBUG 0x1
118 #define LCK_MTX_ATTR_DEBUGb 0
119 #define LCK_MTX_ATTR_STAT 0x2
120 #define LCK_MTX_ATTR_STATb 1
123 #ifdef KERNEL_PRIVATE
125 unsigned int opaque
[3];
128 typedef struct __lck_mtx_t__ lck_mtx_t
;
132 #ifdef MACH_KERNEL_PRIVATE
134 hw_lock_data_t interlock
;
135 volatile unsigned int
136 read_count
:16, /* No. of accepted readers */
137 want_upgrade
:1, /* Read-to-write upgrade waiting */
138 want_write
:1, /* Writer waiting or locked for write */
139 waiting
:1, /* Someone is sleeping on lock */
140 can_sleep
:1, /* Can attempts to lock go to sleep? */
141 read_priority
:1;/* New read takes piority over write */
142 unsigned int lck_rw_tag
;
145 #define LCK_RW_ATTR_DEBUG 0x1
146 #define LCK_RW_ATTR_DEBUGb 0
147 #define LCK_RW_ATTR_STAT 0x2
148 #define LCK_RW_ATTR_STATb 1
149 #define LCK_RW_ATTR_READ_PRI 0x3
150 #define LCK_RW_ATTR_READ_PRIb 2
151 #define LCK_RW_ATTR_DIS_THREAD 0x40000000
152 #define LCK_RW_ATTR_DIS_THREADb 30
153 #define LCK_RW_ATTR_DIS_MYLOCK 0x10000000
154 #define LCK_RW_ATTR_DIS_MYLOCKb 28
156 #define LCK_RW_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */
159 #ifdef KERNEL_PRIVATE
161 unsigned int opaque
[3];
164 typedef struct __lck_rw_t__ lck_rw_t
;
168 #endif /* _I386_LOCKS_H_ */