|
|
1.1.1.2 root 1: /*
1.1 root 2: * Mach Operating System
3: * Copyright (c) 1991,1990,1989 Carnegie Mellon University
4: * All Rights Reserved.
1.1.1.2 root 5: *
1.1 root 6: * Permission to use, copy, modify and distribute this software and its
7: * documentation is hereby granted, provided that both the copyright
8: * notice and this permission notice appear in all copies of the
9: * software, derivative works or modified versions, and any portions
10: * thereof, and that both notices appear in supporting documentation.
1.1.1.2 root 11: *
1.1 root 12: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
1.1.1.2 root 15: *
1.1 root 16: * Carnegie Mellon requests users of this software to return to
1.1.1.2 root 17: *
1.1 root 18: * Software Distribution Coordinator or [email protected]
19: * School of Computer Science
20: * Carnegie Mellon University
21: * Pittsburgh PA 15213-3890
1.1.1.2 root 22: *
1.1 root 23: * any improvements or extensions that they make and grant Carnegie Mellon
24: * the rights to redistribute these changes.
25: */
26: /*
27: * File: ipc/ipc_object.h
28: * Author: Rich Draves
29: * Date: 1989
30: *
31: * Definitions for IPC objects, for which tasks have capabilities.
32: */
33:
34: #ifndef _IPC_IPC_OBJECT_H_
35: #define _IPC_IPC_OBJECT_H_
36:
37: #include <mach/kern_return.h>
38: #include <mach/message.h>
1.1.1.3 root 39: #include <ipc/ipc_types.h>
1.1 root 40: #include <kern/lock.h>
1.1.1.5 ! root 41: #include <kern/macros.h>
1.1.1.3 root 42: #include <kern/slab.h>
1.1 root 43:
44: typedef unsigned int ipc_object_refs_t;
45: typedef unsigned int ipc_object_bits_t;
46: typedef unsigned int ipc_object_type_t;
47:
48: typedef struct ipc_object {
49: decl_simple_lock_data(,io_lock_data)
50: ipc_object_refs_t io_references;
51: ipc_object_bits_t io_bits;
52: } *ipc_object_t;
53:
54: #define IO_NULL ((ipc_object_t) 0)
55: #define IO_DEAD ((ipc_object_t) -1)
56:
57: #define IO_VALID(io) (((io) != IO_NULL) && ((io) != IO_DEAD))
58:
59: #define IO_BITS_KOTYPE 0x0000ffff /* used by the object */
1.1.1.4 root 60: #define IO_BITS_OTYPE 0x3fff0000 /* determines a cache */
61: /* The following masks are used to store attributes of ipc ports. */
62: #define IO_BITS_PROTECTED_PAYLOAD 0x40000000 /* pp set? */
1.1 root 63: #define IO_BITS_ACTIVE 0x80000000U /* is object alive? */
64:
65: #define io_active(io) ((int)(io)->io_bits < 0) /* hack */
66:
67: #define io_otype(io) (((io)->io_bits & IO_BITS_OTYPE) >> 16)
68: #define io_kotype(io) ((io)->io_bits & IO_BITS_KOTYPE)
69:
70: #define io_makebits(active, otype, kotype) \
71: (((active) ? IO_BITS_ACTIVE : 0) | ((otype) << 16) | (kotype))
72:
73: /*
74: * Object types: ports, port sets, kernel-loaded ports
75: */
76: #define IOT_PORT 0
77: #define IOT_PORT_SET 1
78: #define IOT_NUMBER 2 /* number of types used */
79:
1.1.1.3 root 80: extern struct kmem_cache ipc_object_caches[IOT_NUMBER];
1.1 root 81:
82: #define io_alloc(otype) \
1.1.1.3 root 83: ((ipc_object_t) kmem_cache_alloc(&ipc_object_caches[(otype)]))
1.1 root 84:
85: #define io_free(otype, io) \
1.1.1.3 root 86: kmem_cache_free(&ipc_object_caches[(otype)], (vm_offset_t) (io))
1.1 root 87:
88: #define io_lock_init(io) simple_lock_init(&(io)->io_lock_data)
89: #define io_lock(io) simple_lock(&(io)->io_lock_data)
90: #define io_lock_try(io) simple_lock_try(&(io)->io_lock_data)
91: #define io_unlock(io) simple_unlock(&(io)->io_lock_data)
92:
93: #define io_check_unlock(io) \
94: MACRO_BEGIN \
95: ipc_object_refs_t _refs = (io)->io_references; \
96: \
97: io_unlock(io); \
98: if (_refs == 0) \
99: io_free(io_otype(io), io); \
100: MACRO_END
101:
102: #define io_reference(io) \
103: MACRO_BEGIN \
104: (io)->io_references++; \
105: MACRO_END
106:
107: #define io_release(io) \
108: MACRO_BEGIN \
109: (io)->io_references--; \
110: MACRO_END
111:
112: extern void
1.1.1.3 root 113: ipc_object_reference(ipc_object_t);
1.1 root 114:
115: extern void
1.1.1.3 root 116: ipc_object_release(ipc_object_t);
1.1 root 117:
118: extern kern_return_t
1.1.1.3 root 119: ipc_object_translate(ipc_space_t, mach_port_t,
120: mach_port_right_t, ipc_object_t *);
1.1 root 121:
122: extern kern_return_t
1.1.1.3 root 123: ipc_object_alloc_dead(ipc_space_t, mach_port_t *);
1.1 root 124:
125: extern kern_return_t
1.1.1.3 root 126: ipc_object_alloc_dead_name(ipc_space_t, mach_port_t);
1.1 root 127:
128: extern kern_return_t
1.1.1.3 root 129: ipc_object_alloc(ipc_space_t, ipc_object_type_t,
130: mach_port_type_t, mach_port_urefs_t,
131: mach_port_t *, ipc_object_t *);
1.1 root 132:
133: extern kern_return_t
1.1.1.3 root 134: ipc_object_alloc_name(ipc_space_t, ipc_object_type_t,
135: mach_port_type_t, mach_port_urefs_t,
136: mach_port_t, ipc_object_t *);
1.1 root 137:
138: extern mach_msg_type_name_t
1.1.1.3 root 139: ipc_object_copyin_type(mach_msg_type_name_t);
1.1 root 140:
141: extern kern_return_t
1.1.1.3 root 142: ipc_object_copyin(ipc_space_t, mach_port_t,
143: mach_msg_type_name_t, ipc_object_t *);
1.1 root 144:
145: extern void
1.1.1.3 root 146: ipc_object_copyin_from_kernel(ipc_object_t, mach_msg_type_name_t);
1.1 root 147:
148: extern void
1.1.1.3 root 149: ipc_object_destroy(ipc_object_t, mach_msg_type_name_t);
1.1 root 150:
151: extern kern_return_t
1.1.1.3 root 152: ipc_object_copyout(ipc_space_t, ipc_object_t,
153: mach_msg_type_name_t, boolean_t, mach_port_t *);
1.1 root 154:
155: extern kern_return_t
1.1.1.3 root 156: ipc_object_copyout_name(ipc_space_t, ipc_object_t,
157: mach_msg_type_name_t, boolean_t, mach_port_t);
1.1 root 158:
159: extern void
1.1.1.3 root 160: ipc_object_copyout_dest(ipc_space_t, ipc_object_t,
161: mach_msg_type_name_t, mach_port_t *);
1.1 root 162:
163: extern kern_return_t
1.1.1.3 root 164: ipc_object_rename(ipc_space_t, mach_port_t, mach_port_t);
1.1 root 165:
166: extern void
1.1.1.3 root 167: ipc_object_print(ipc_object_t);
1.1 root 168:
1.1.1.2 root 169: #endif /* _IPC_IPC_OBJECT_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.