xref: /xnu-8792.81.2/iokit/DriverKit/OSObject.iig (revision 19c3b8c28c31cb8130e034cfb5df6bf9ba342d90)
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 */
49class OSObject;
50typedef 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
126typedef OSObject OSContainer;
127#else /* KERNEL */
128class IIG_SERIALIZABLE OSContainer;
129#endif /* KERNEL */
130#else /* !__IIG */
131class IIG_SERIALIZABLE OSContainer;
132#endif  /* !__IIG */
133
134class IIG_SERIALIZABLE OSData;
135class IIG_SERIALIZABLE OSNumber;
136class IIG_SERIALIZABLE OSString;
137class IIG_SERIALIZABLE OSBoolean;
138class IIG_SERIALIZABLE OSDictionary;
139class IIG_SERIALIZABLE OSArray;
140class IIG_SERIALIZABLE OSSet;
141class IIG_SERIALIZABLE OSOrderedSet;
142
143class OSMetaClass;
144class IODispatchQueue;
145typedef char IODispatchQueueName[256];
146
147#if __IIG
148class OSMetaClassBase
149{
150	virtual const OSMetaClass *
151	getMetaClass() const LOCALONLY;
152
153    virtual void
154    retain() const LOCALONLY;
155
156    virtual void
157    release() const LOCALONLY;
158
159	virtual bool
160    isEqualTo(const OSMetaClassBase * anObject) const LOCALONLY;
161};
162#endif /* __IIG */
163
164
165/*!
166@iig implementation
167#include <DriverKit/IODispatchQueue.h>
168@iig end
169*/
170
171class OSObject : public OSMetaClassBase
172{
173public:
174
175	virtual bool
176	init() LOCALONLY;
177
178	virtual void
179	free() LOCALONLY;
180
181    virtual void
182    retain() const override;
183
184    virtual void
185    release() const override;
186
187	virtual kern_return_t
188	SetDispatchQueue(
189		const IODispatchQueueName name,
190		IODispatchQueue         * queue) KERNEL = 0;
191
192	virtual kern_return_t
193	CopyDispatchQueue(
194		const IODispatchQueueName name,
195		IODispatchQueue        ** queue) KERNEL = 0;
196};
197
198#define DEFN(classname, name)                                       \
199name ## _Impl(classname ## _ ## name ## _Args)
200
201/*
202 * Use of the IMPL macro is discouraged and should be replaced by a normal c++
203 * method implementation (with the all method arguments) and the name of the method
204 * given a suffix '_Impl'
205 */
206
207#define IMPL(classname, name)                                       \
208classname :: DEFN(classname, name)
209
210/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
211
212#endif /* ! _IOKIT_UOSOBJECT_H */
213