]>
Commit | Line | Data |
---|---|---|
91447636 A |
1 | /* |
2 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. | |
3 | * | |
8f6c56a5 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
91447636 | 5 | * |
8f6c56a5 A |
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. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
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 | |
8ad349bb | 24 | * limitations under the License. |
8f6c56a5 A |
25 | * |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
91447636 A |
27 | */ |
28 | ||
29 | #ifndef _I386_LOCKS_H_ | |
30 | #define _I386_LOCKS_H_ | |
31 | ||
32 | #include <sys/appleapiopts.h> | |
33 | #include <kern/kern_types.h> | |
34 | ||
35 | #ifdef MACH_KERNEL_PRIVATE | |
36 | ||
37 | #include <i386/hw_lock_types.h> | |
38 | ||
39 | extern unsigned int LcksOpts; | |
40 | ||
41 | #define enaLkDeb 0x00000001 /* Request debug in default attribute */ | |
42 | #define enaLkStat 0x00000002 /* Request statistic in default attribute */ | |
43 | ||
44 | #endif | |
45 | ||
46 | #ifdef MACH_KERNEL_PRIVATE | |
47 | typedef struct { | |
48 | unsigned int lck_spin_data[10]; /* XXX - usimple_lock_data_t */ | |
49 | } lck_spin_t; | |
50 | ||
51 | #define LCK_SPIN_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */ | |
52 | ||
53 | #else | |
54 | #ifdef KERNEL_PRIVATE | |
55 | typedef struct { | |
56 | unsigned int opaque[10]; | |
57 | } lck_spin_t; | |
58 | #else | |
59 | typedef struct __lck_spin_t__ lck_spin_t; | |
60 | #endif | |
61 | #endif | |
62 | ||
63 | #ifdef MACH_KERNEL_PRIVATE | |
64 | typedef struct _lck_mtx_ { | |
65 | union { | |
66 | struct { | |
67 | unsigned int lck_mtxd_ilk; | |
68 | unsigned int lck_mtxd_locked; | |
69 | unsigned short lck_mtxd_waiters; | |
70 | unsigned short lck_mtxd_pri; | |
71 | } lck_mtxd; | |
72 | struct { | |
73 | unsigned int lck_mtxi_tag; | |
74 | struct _lck_mtx_ext_ *lck_mtxi_ptr; | |
75 | unsigned int lck_mtxi_pad8; | |
76 | } lck_mtxi; | |
77 | } lck_mtx_sw; | |
78 | } lck_mtx_t; | |
79 | ||
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 | |
84 | ||
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 | |
87 | ||
88 | #define LCK_MTX_TAG_INDIRECT 0x00001007 /* lock marked as Indirect */ | |
89 | #define LCK_MTX_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */ | |
90 | ||
91 | typedef struct { | |
92 | unsigned int type; | |
93 | vm_offset_t pc; | |
94 | vm_offset_t thread; | |
95 | } lck_mtx_deb_t; | |
96 | ||
97 | #define MUTEX_TAG 0x4d4d | |
98 | ||
99 | typedef struct { | |
100 | unsigned int lck_mtx_stat_data; | |
101 | } lck_mtx_stat_t; | |
102 | ||
103 | typedef struct _lck_mtx_ext_ { | |
104 | lck_mtx_t lck_mtx; | |
105 | struct _lck_grp_ *lck_mtx_grp; | |
106 | unsigned int lck_mtx_attr; | |
107 | lck_mtx_deb_t lck_mtx_deb; | |
108 | lck_mtx_stat_t lck_mtx_stat; | |
109 | } lck_mtx_ext_t; | |
110 | ||
111 | #define LCK_MTX_ATTR_DEBUG 0x1 | |
8f6c56a5 | 112 | #define LCK_MTX_ATTR_DEBUGb 31 |
91447636 | 113 | #define LCK_MTX_ATTR_STAT 0x2 |
8f6c56a5 | 114 | #define LCK_MTX_ATTR_STATb 30 |
91447636 A |
115 | |
116 | #else | |
117 | #ifdef KERNEL_PRIVATE | |
118 | typedef struct { | |
119 | unsigned int opaque[3]; | |
120 | } lck_mtx_t; | |
121 | #else | |
122 | typedef struct __lck_mtx_t__ lck_mtx_t; | |
123 | #endif | |
124 | #endif | |
125 | ||
126 | #ifdef MACH_KERNEL_PRIVATE | |
127 | typedef struct { | |
128 | hw_lock_data_t interlock; | |
129 | volatile unsigned int | |
130 | read_count:16, /* No. of accepted readers */ | |
131 | want_upgrade:1, /* Read-to-write upgrade waiting */ | |
8f6c56a5 | 132 | want_write:1, /* Writer is waiting, or locked for write */ |
91447636 | 133 | waiting:1, /* Someone is sleeping on lock */ |
8f6c56a5 | 134 | can_sleep:1; /* Can attempts to lock go to sleep? */ |
91447636 A |
135 | unsigned int lck_rw_tag; |
136 | } lck_rw_t; | |
137 | ||
138 | #define LCK_RW_TAG_DESTROYED 0x00002007 /* lock marked as Destroyed */ | |
139 | ||
140 | #else | |
141 | #ifdef KERNEL_PRIVATE | |
142 | typedef struct { | |
143 | unsigned int opaque[3]; | |
144 | } lck_rw_t; | |
145 | #else | |
146 | typedef struct __lck_rw_t__ lck_rw_t; | |
147 | #endif | |
148 | #endif | |
149 | ||
150 | #endif /* _I386_LOCKS_H_ */ |