2 * Copyright (c) 2000 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@
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28 * All Rights Reserved.
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.
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.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
53 #ifndef _PPC_SIMPLE_LOCK_TYPES_H_
54 #define _PPC_SIMPLE_LOCK_TYPES_H_
57 #include <mach/boolean.h>
58 #include <kern/kern_types.h>
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>
67 #ifdef MACH_KERNEL_PRIVATE
70 #define USLOCK_DEBUG 1
72 #define USLOCK_DEBUG 0
77 typedef lck_spin_t usimple_lock_data_t
, *usimple_lock_t
;
81 typedef 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];
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 */
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
97 } usimple_lock_data_t
, *usimple_lock_t
;
99 #endif /* USLOCK_DEBUG */
103 typedef struct slock
{
104 unsigned int lock_data
[10];
105 } usimple_lock_data_t
, *usimple_lock_t
;
107 #endif /* MACH_KERNEL_PRIVATE */
109 #define USIMPLE_LOCK_NULL ((usimple_lock_t) 0)
111 #if !defined(decl_simple_lock_data)
113 typedef usimple_lock_data_t
*simple_lock_t
;
114 typedef usimple_lock_data_t simple_lock_data_t
;
116 #define decl_simple_lock_data(class,name) \
117 class simple_lock_data_t name;
119 #endif /* !defined(decl_simple_lock_data) */
121 #ifdef MACH_KERNEL_PRIVATE
124 #define MACHINE_SIMPLE_LOCK
126 extern void ppc_usimple_lock_init(simple_lock_t
,unsigned short);
127 extern void ppc_usimple_lock(simple_lock_t
);
128 extern void ppc_usimple_unlock_rwmb(simple_lock_t
);
129 extern void ppc_usimple_unlock_rwcmb(simple_lock_t
);
130 extern unsigned int ppc_usimple_lock_try(simple_lock_t
);
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 */
142 extern unsigned int hw_lock_bit(
147 extern unsigned int hw_cpu_sync(
151 extern unsigned int hw_cpu_wcng(
156 extern unsigned int hw_lock_mbits(
167 #endif /* MACH_KERNEL_PRIVATE */
168 #endif /* KERNEL_PRIVATE */
170 #endif /* !_PPC_SIMPLE_LOCK_TYPES_H_ */
172 #endif /* KERNEL_PRIVATE */