2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 #ifndef _I386_LOCKS_H_
32 #define _I386_LOCKS_H_
34 #include <sys/appleapiopts.h>
35 #include <kern/kern_types.h>
37 #ifdef MACH_KERNEL_PRIVATE
39 #include <i386/hw_lock_types.h>
41 extern unsigned int LcksOpts
;
43 #define enaLkDeb 0x00000001 /* Request debug in default attribute */
44 #define enaLkStat 0x00000002 /* Request statistic in default attribute */
48 #ifdef MACH_KERNEL_PRIVATE
50 unsigned int lck_spin_data
[10]; /* XXX - usimple_lock_data_t */
53 #define LCK_SPIN_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */
58 unsigned int opaque
[10];
61 typedef struct __lck_spin_t__ lck_spin_t
;
65 #ifdef MACH_KERNEL_PRIVATE
66 typedef struct _lck_mtx_
{
69 unsigned int lck_mtxd_ilk
;
70 unsigned int lck_mtxd_locked
;
71 unsigned short lck_mtxd_waiters
;
72 unsigned short lck_mtxd_pri
;
75 unsigned int lck_mtxi_tag
;
76 struct _lck_mtx_ext_
*lck_mtxi_ptr
;
77 unsigned int lck_mtxi_pad8
;
82 #define lck_mtx_ilk lck_mtx_sw.lck_mtxd.lck_mtxd_ilk
83 #define lck_mtx_locked lck_mtx_sw.lck_mtxd.lck_mtxd_locked
84 #define lck_mtx_waiters lck_mtx_sw.lck_mtxd.lck_mtxd_waiters
85 #define lck_mtx_pri lck_mtx_sw.lck_mtxd.lck_mtxd_pri
87 #define lck_mtx_tag lck_mtx_sw.lck_mtxi.lck_mtxi_tag
88 #define lck_mtx_ptr lck_mtx_sw.lck_mtxi.lck_mtxi_ptr
90 #define LCK_MTX_TAG_INDIRECT 0x00001007 /* lock marked as Indirect */
91 #define LCK_MTX_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */
99 #define MUTEX_TAG 0x4d4d
102 unsigned int lck_mtx_stat_data
;
105 typedef struct _lck_mtx_ext_
{
107 struct _lck_grp_
*lck_mtx_grp
;
108 unsigned int lck_mtx_attr
;
109 lck_mtx_deb_t lck_mtx_deb
;
110 lck_mtx_stat_t lck_mtx_stat
;
113 #define LCK_MTX_ATTR_DEBUG 0x1
114 #define LCK_MTX_ATTR_DEBUGb 31
115 #define LCK_MTX_ATTR_STAT 0x2
116 #define LCK_MTX_ATTR_STATb 30
119 #ifdef KERNEL_PRIVATE
121 unsigned int opaque
[3];
124 typedef struct __lck_mtx_t__ lck_mtx_t
;
128 #ifdef MACH_KERNEL_PRIVATE
130 hw_lock_data_t interlock
;
131 volatile unsigned int
132 read_count
:16, /* No. of accepted readers */
133 want_upgrade
:1, /* Read-to-write upgrade waiting */
134 want_write
:1, /* Writer is waiting, or locked for write */
135 waiting
:1, /* Someone is sleeping on lock */
136 can_sleep
:1; /* Can attempts to lock go to sleep? */
137 unsigned int lck_rw_tag
;
140 #define LCK_RW_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */
143 #ifdef KERNEL_PRIVATE
145 unsigned int opaque
[3];
148 typedef struct __lck_rw_t__ lck_rw_t
;
152 #endif /* _I386_LOCKS_H_ */