2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 #ifndef _I386_LOCKS_H_
24 #define _I386_LOCKS_H_
26 #include <sys/appleapiopts.h>
27 #include <kern/kern_types.h>
29 #ifdef MACH_KERNEL_PRIVATE
31 #include <i386/hw_lock_types.h>
33 extern unsigned int LcksOpts
;
35 #define enaLkDeb 0x00000001 /* Request debug in default attribute */
36 #define enaLkStat 0x00000002 /* Request statistic in default attribute */
40 #ifdef MACH_KERNEL_PRIVATE
42 unsigned int lck_spin_data
[10]; /* XXX - usimple_lock_data_t */
45 #define LCK_SPIN_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */
50 unsigned int opaque
[10];
53 typedef struct __lck_spin_t__ lck_spin_t
;
57 #ifdef MACH_KERNEL_PRIVATE
58 typedef struct _lck_mtx_
{
61 unsigned int lck_mtxd_ilk
;
62 unsigned int lck_mtxd_locked
;
63 unsigned short lck_mtxd_waiters
;
64 unsigned short lck_mtxd_pri
;
67 unsigned int lck_mtxi_tag
;
68 struct _lck_mtx_ext_
*lck_mtxi_ptr
;
69 unsigned int lck_mtxi_pad8
;
74 #define lck_mtx_ilk lck_mtx_sw.lck_mtxd.lck_mtxd_ilk
75 #define lck_mtx_locked lck_mtx_sw.lck_mtxd.lck_mtxd_locked
76 #define lck_mtx_waiters lck_mtx_sw.lck_mtxd.lck_mtxd_waiters
77 #define lck_mtx_pri lck_mtx_sw.lck_mtxd.lck_mtxd_pri
79 #define lck_mtx_tag lck_mtx_sw.lck_mtxi.lck_mtxi_tag
80 #define lck_mtx_ptr lck_mtx_sw.lck_mtxi.lck_mtxi_ptr
82 #define LCK_MTX_TAG_INDIRECT 0x00001007 /* lock marked as Indirect */
83 #define LCK_MTX_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */
91 #define MUTEX_TAG 0x4d4d
94 unsigned int lck_mtx_stat_data
;
97 typedef struct _lck_mtx_ext_
{
99 struct _lck_grp_
*lck_mtx_grp
;
100 unsigned int lck_mtx_attr
;
101 lck_mtx_deb_t lck_mtx_deb
;
102 lck_mtx_stat_t lck_mtx_stat
;
105 #define LCK_MTX_ATTR_DEBUG 0x1
106 #define LCK_MTX_ATTR_DEBUGb 31
107 #define LCK_MTX_ATTR_STAT 0x2
108 #define LCK_MTX_ATTR_STATb 30
111 #ifdef KERNEL_PRIVATE
113 unsigned int opaque
[3];
116 typedef struct __lck_mtx_t__ lck_mtx_t
;
120 #ifdef MACH_KERNEL_PRIVATE
122 hw_lock_data_t interlock
;
123 volatile unsigned int
124 read_count
:16, /* No. of accepted readers */
125 want_upgrade
:1, /* Read-to-write upgrade waiting */
126 want_write
:1, /* Writer is waiting, or locked for write */
127 waiting
:1, /* Someone is sleeping on lock */
128 can_sleep
:1; /* Can attempts to lock go to sleep? */
129 unsigned int lck_rw_tag
;
132 #define LCK_RW_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */
135 #ifdef KERNEL_PRIVATE
137 unsigned int opaque
[3];
140 typedef struct __lck_rw_t__ lck_rw_t
;
144 #endif /* _I386_LOCKS_H_ */