]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/simple_lock.h
xnu-792.2.4.tar.gz
[apple/xnu.git] / osfmk / ppc / simple_lock.h
CommitLineData
91447636
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * @OSF_COPYRIGHT@
24 */
25/*
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28 * All Rights Reserved.
29 *
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
35 *
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
39 *
40 * Carnegie Mellon requests users of this software to return to
41 *
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
46 *
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
49 */
50
51#ifdef KERNEL_PRIVATE
52
53#ifndef _PPC_SIMPLE_LOCK_TYPES_H_
54#define _PPC_SIMPLE_LOCK_TYPES_H_
55
56#ifdef KERNEL_PRIVATE
57#include <mach/boolean.h>
58#include <kern/kern_types.h>
59
60#include <sys/appleapiopts.h>
61#ifdef MACH_KERNEL_PRIVATE
62#include <ppc/hw_lock_types.h>
63#include <ppc/locks.h>
64#include <mach_ldebug.h>
65#endif
66
67#ifdef MACH_KERNEL_PRIVATE
68
69#if MACH_LDEBUG
70#define USLOCK_DEBUG 1
71#else
72#define USLOCK_DEBUG 0
73#endif
74
75#if !USLOCK_DEBUG
76
77typedef lck_spin_t usimple_lock_data_t, *usimple_lock_t;
78
79#else
80
81typedef struct uslock_debug {
82 void *lock_pc; /* pc where lock operation began */
83 void *lock_thread; /* thread that acquired lock */
84 unsigned long duration[2];
85 unsigned short state;
86 unsigned char lock_cpu;
87 void *unlock_thread; /* last thread to release lock */
88 unsigned char unlock_cpu;
89 void *unlock_pc; /* pc where lock operation ended */
90} uslock_debug;
91
92typedef struct {
93 hw_lock_data_t interlock; /* must be first... see lock.c */
94 unsigned short lock_type; /* must be second... see lock.c */
95#define USLOCK_TAG 0x5353
96 uslock_debug debug;
97} usimple_lock_data_t, *usimple_lock_t;
98
99#endif /* USLOCK_DEBUG */
100
101#else
102
103typedef struct slock {
104 unsigned int lock_data[10];
105} usimple_lock_data_t, *usimple_lock_t;
106
107#endif /* MACH_KERNEL_PRIVATE */
108
109#define USIMPLE_LOCK_NULL ((usimple_lock_t) 0)
110
111#if !defined(decl_simple_lock_data)
112
113typedef usimple_lock_data_t *simple_lock_t;
114typedef usimple_lock_data_t simple_lock_data_t;
115
116#define decl_simple_lock_data(class,name) \
117 class simple_lock_data_t name;
118
119#endif /* !defined(decl_simple_lock_data) */
120
121#ifdef MACH_KERNEL_PRIVATE
122#if !MACH_LDEBUG
123
124#define MACHINE_SIMPLE_LOCK
125
126extern void ppc_usimple_lock_init(simple_lock_t,unsigned short);
127extern void ppc_usimple_lock(simple_lock_t);
128extern void ppc_usimple_unlock_rwmb(simple_lock_t);
129extern void ppc_usimple_unlock_rwcmb(simple_lock_t);
130extern unsigned int ppc_usimple_lock_try(simple_lock_t);
131
132#define simple_lock_init(l,t) ppc_usimple_lock_init(l,t)
133#define simple_lock(l) ppc_usimple_lock(l)
134#define simple_unlock(l) ppc_usimple_unlock_rwcmb(l)
135#define simple_unlock_rwmb(l) ppc_usimple_unlock_rwmb(l)
136#define simple_lock_try(l) ppc_usimple_lock_try(l)
137#define simple_lock_addr(l) (&(l))
138#define thread_sleep_simple_lock(l, e, i) \
139 thread_sleep_fast_usimple_lock((l), (e), (i))
140#endif /* !MACH_LDEBUG */
141
142extern unsigned int hw_lock_bit(
143 unsigned int *,
144 unsigned int,
145 unsigned int);
146
147extern unsigned int hw_cpu_sync(
148 unsigned int *,
149 unsigned int);
150
151extern unsigned int hw_cpu_wcng(
152 unsigned int *,
153 unsigned int,
154 unsigned int);
155
156extern unsigned int hw_lock_mbits(
157 unsigned int *,
158 unsigned int,
159 unsigned int,
160 unsigned int,
161 unsigned int);
162
163void hw_unlock_bit(
164 unsigned int *,
165 unsigned int);
166
167#endif /* MACH_KERNEL_PRIVATE */
168#endif /* KERNEL_PRIVATE */
169
170#endif /* !_PPC_SIMPLE_LOCK_TYPES_H_ */
171
172#endif /* KERNEL_PRIVATE */