]> git.saurik.com Git - apple/xnu.git/blob - iokit/DriverKit/OSObject.iig
xnu-7195.101.1.tar.gz
[apple/xnu.git] / iokit / DriverKit / OSObject.iig
1 /*
2 * Copyright (c) 2019-2019 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 #if !__IIG
30 #if KERNEL
31 #include <libkern/c++/OSObject.h>
32 #endif
33 #endif
34
35 #ifndef _IOKIT_UOSOBJECT_H
36 #define _IOKIT_UOSOBJECT_H
37
38 #if !KERNEL
39 #include <stddef.h>
40 #include <stdint.h>
41 #include <DriverKit/IOReturn.h>
42 #if DRIVERKIT_PRIVATE
43 #include <mach/port.h>
44 #endif /* DRIVERKIT_PRIVATE */
45 #if !__IIG
46 #include <string.h>
47 #include <DriverKit/OSMetaClass.h>
48 #endif /* !__IIG */
49 class OSObject;
50 typedef OSObject * OSObjectPtr;
51 #endif /* !KERNEL */
52
53 #if !__IIG_ATTRIBUTES_DEFINED__
54
55 #define __IIG_ATTRIBUTES_DEFINED__ 1
56
57 #if __IIG || __DOCUMENTATION__
58
59 #define IIG_KERNEL __attribute__((annotate("kernel")))
60 #define IIG_NATIVE __attribute__((annotate("native")))
61 #define IIG_LOCAL __attribute__((annotate("local")))
62 #define IIG_LOCALONLY __attribute__((annotate("localonly")))
63 #define IIG_REMOTE __attribute__((annotate("remote")))
64 #define IIG_LOCALHOST __attribute__((annotate("localhost")))
65 #define IIG_INVOKEREPLY __attribute__((annotate("invokereply")))
66 #define IIG_REPLY __attribute__((annotate("reply")))
67 #define IIG_PORTMAKESEND __attribute__((annotate("MACH_MSG_TYPE_MAKE_SEND")))
68 #define IIG_PORTCOPYSEND __attribute__((annotate("MACH_MSG_TYPE_COPY_SEND")))
69 #define IIG_TARGET __attribute__((annotate("target")))
70 #define IIG_TYPE(p) __attribute__((annotate("type=" # p)))
71 //#define IIG_ARRAY(maxcount) __attribute__((annotate(# maxcount), annotate("array")))
72 #define IIG_EXTENDS(cls) __attribute__((annotate("extends=" # cls)))
73 //#define IIG_INTERFACE __attribute__((annotate("interface")))
74 //#define IIG_IMPLEMENTS(i) void __implements(i *);
75 #define IIG_QUEUENAME(name) __attribute__((annotate("queuename=" # name)))
76 #define IIG_SERIALIZABLE __attribute__((annotate("serializable")))
77
78 #if __IIG
79 #define KERNEL IIG_KERNEL
80 #endif /* __IIG */
81 #define NATIVE IIG_NATIVE
82 #define LOCAL IIG_LOCAL
83 #define LOCALONLY IIG_LOCALONLY
84 #define REMOTE IIG_REMOTE
85 #define LOCALHOST IIG_LOCALHOST
86 #define INVOKEREPLY IIG_INVOKEREPLY
87 #define REPLY IIG_REPLY
88 #define PORTMAKESEND IIG_PORTMAKESEND
89 #define PORTCOPYSEND IIG_PORTCOPYSEND
90 #define TARGET IIG_TARGET
91 #define TYPE(p) IIG_TYPE(p)
92 //#define ARRAY(maxcount) IIG_ARRAY(maxcount)
93 #define EXTENDS(cls) IIG_EXTENDS(cls)
94 //#define INTERFACE IIG_INTERFACE
95 //#define IMPLEMENTS(i) IIG_IMPLEMENTS(i)
96 #define QUEUENAME(name) IIG_QUEUENAME(name)
97
98 #else /* __IIG || __DOCUMENTATION__ */
99
100 #define IIG_KERNEL
101 #define IIG_NATIVE
102 #define IIG_LOCAL
103 #define IIG_LOCALONLY
104 #define IIG_REMOTE
105 #define IIG_LOCALHOST
106 #define IIG_INVOKEREPLY
107 #define IIG_REPLY
108 #define IIG_PORTMAKESEND
109 #define IIG_PORTCOPYSEND
110 #define IIG_TARGET
111 #define IIG_TYPE(p)
112 //#define IIG_ARRAY(maxcount)
113 #define IIG_EXTENDS(cls)
114 //#define IIG_INTERFACE
115 //#define IIG_IMPLEMENTS(i)
116 #define IIG_QUEUENAME(name)
117 #define IIG_SERIALIZABLE
118
119 #endif /* __IIG || __DOCUMENTATION__ */
120
121 #endif /* __IIG_ATTRIBUTES_DEFINED__ */
122
123
124 #if !__IIG
125 #if KERNEL
126 typedef OSObject OSContainer;
127 #else /* KERNEL */
128 class IIG_SERIALIZABLE OSContainer;
129 #endif /* KERNEL */
130 #else /* !__IIG */
131 class IIG_SERIALIZABLE OSContainer;
132 #endif /* !__IIG */
133
134 class IIG_SERIALIZABLE OSData;
135 class IIG_SERIALIZABLE OSNumber;
136 class IIG_SERIALIZABLE OSString;
137 class IIG_SERIALIZABLE OSBoolean;
138 class IIG_SERIALIZABLE OSDictionary;
139 class IIG_SERIALIZABLE OSArray;
140
141 class OSMetaClass;
142 class IODispatchQueue;
143 typedef char IODispatchQueueName[256];
144
145 #if __IIG
146 class OSMetaClassBase
147 {
148 virtual const OSMetaClass *
149 getMetaClass() const LOCALONLY;
150
151 virtual void
152 retain() const LOCALONLY;
153
154 virtual void
155 release() const LOCALONLY;
156
157 virtual bool
158 isEqualTo(const OSMetaClassBase * anObject) const LOCALONLY;
159 };
160 #endif /* __IIG */
161
162
163 /*!
164 @iig implementation
165 #include <DriverKit/IODispatchQueue.h>
166 @iig end
167 */
168
169 class OSObject : public OSMetaClassBase
170 {
171 public:
172
173 virtual bool
174 init() LOCALONLY;
175
176 virtual void
177 free() LOCALONLY;
178
179 virtual void
180 retain() const override;
181
182 virtual void
183 release() const override;
184
185 virtual kern_return_t
186 SetDispatchQueue(
187 const IODispatchQueueName name,
188 IODispatchQueue * queue) KERNEL = 0;
189
190 virtual kern_return_t
191 CopyDispatchQueue(
192 const IODispatchQueueName name,
193 IODispatchQueue ** queue) KERNEL = 0;
194 };
195
196 #define DEFN(classname, name) \
197 name ## _Impl(classname ## _ ## name ## _Args)
198
199 /*
200 * Use of the IMPL macro is discouraged and should be replaced by a normal c++
201 * method implementation (with the all method arguments) and the name of the method
202 * given a suffix '_Impl'
203 */
204
205 #define IMPL(classname, name) \
206 classname :: DEFN(classname, name)
207
208 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
209
210 #endif /* ! _IOKIT_UOSOBJECT_H */