/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
+/*
+ * NOTICE: This file was modified by McAfee Research in 2004 to introduce
+ * support for mandatory and extensible security protections. This notice
+ * is included in support of clause 2.2 (b) of the Apple Public License,
+ * Version 2.0.
+ */
/*
*/
/*
#define _IPC_IPC_OBJECT_H_
#include <mach_rt.h>
-#include <cpus.h>
#include <mach_kdb.h>
#include <mach/kern_return.h>
typedef natural_t ipc_object_type_t;
/*
- * There is no lock in the ipc_object; it is in the enclosing kernel
- * data structure (rpc_common_data) used by both ipc_port and ipc_pset.
* The ipc_object is used to both tag and reference count these two data
* structures, and (Noto Bene!) pointers to either of these or the
* ipc_object at the head of these are freely cast back and forth; hence
* (with which lock size varies).
*/
struct ipc_object {
+ ipc_object_bits_t io_bits;
ipc_object_refs_t io_references;
+ decl_lck_mtx_data(, io_lock_data)
+};
+
+/*
+ * If another object type needs to participate in io_kotype()-based
+ * dispatching, it must include a stub structure as the first
+ * element
+ */
+struct ipc_object_header {
ipc_object_bits_t io_bits;
- port_name_t io_receiver_name;
-#if NCPUS == 1
- usimple_lock_data_t io_lock_data;
-#else
- decl_mutex_data(, io_lock_data)
+#ifdef __LP64__
+ natural_t io_padding; /* pad to natural boundary */
#endif
};
* Legacy defines. Should use IPC_OBJECT_NULL, etc...
*/
#define IO_NULL ((ipc_object_t) 0)
-#define IO_DEAD ((ipc_object_t) -1)
+#define IO_DEAD ((ipc_object_t) ~0UL)
#define IO_VALID(io) (((io) != IO_NULL) && ((io) != IO_DEAD))
/*
#define io_alloc(otype) \
((ipc_object_t) zalloc(ipc_object_zones[(otype)]))
-#if MACH_ASSERT
-/*
- * Call the routine for io_free so that checking can be performed.
- */
extern void io_free(
unsigned int otype,
ipc_object_t object);
-#else /* MACH_ASSERT */
-#define io_free(otype, io) \
- zfree(ipc_object_zones[(otype)], (vm_offset_t) (io))
-#endif /* MACH_ASSERT */
-
/*
- * Here we depend on the ipc_object being first within the ipc_common_data,
- * which is first within the rpc_common_data, which in turn must be first
- * within any kernel data structure needing to lock an ipc_object
+ * Here we depend on the ipc_object being first within the kernel struct
* (ipc_port and ipc_pset).
*/
-#if NCPUS == 1
-
#define io_lock_init(io) \
- usimple_lock_init(&(io)-io_lock_data, ETAP_IPC_OBJECT)
+ lck_mtx_init(&(io)->io_lock_data, &ipc_lck_grp, &ipc_lck_attr)
+#define io_lock_destroy(io) \
+ lck_mtx_destroy(&(io)->io_lock_data, &ipc_lck_grp)
#define io_lock(io) \
- usimple_lock(&(io)->io_lock_data)
+ lck_mtx_lock(&(io)->io_lock_data)
#define io_lock_try(io) \
- usimple_lock_try(&(io)->io_lock_data)
+ lck_mtx_try_lock(&(io)->io_lock_data)
#define io_unlock(io) \
- usimple_unlock(&(io)->io_lock_data)
-
-#else /* NCPUS == 1 */
+ lck_mtx_unlock(&(io)->io_lock_data)
-#define io_lock_init(io) \
- mutex_init(&(io)->io_lock_data, ETAP_IPC_OBJECT)
-#define io_lock(io) \
- mutex_lock(&(io)->io_lock_data)
-#define io_lock_try(io) \
- mutex_try(&(io)->io_lock_data)
-#define io_unlock(io) \
- mutex_unlock(&(io)->io_lock_data)
-
-#endif /* NCPUS == 1 */
-
-#if NCPUS > 1
#define _VOLATILE_ volatile
-#else /* NCPUS > 1 */
-#define _VOLATILE_
-#endif /* NCPUS > 1 */
#define io_check_unlock(io) \
MACRO_BEGIN \
(io)->io_references--; \
MACRO_END
+/*
+ * Retrieve a label for use in a kernel call that takes a security
+ * label as a parameter. If necessary, io_getlabel acquires internal
+ * (not io_lock) locks, and io_unlocklabel releases them.
+ */
+
+struct label;
+extern struct label *io_getlabel (ipc_object_t obj);
+#define io_unlocklabel(obj)
+
/*
* Exported interfaces
*/