| 1 | /* iig(DriverKit-286) generated from OSObject.iig */ |
| 2 | |
| 3 | /* OSObject.iig:1-258 */ |
| 4 | /* |
| 5 | * Copyright (c) 2019-2019 Apple Inc. All rights reserved. |
| 6 | * |
| 7 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
| 8 | * |
| 9 | * This file contains Original Code and/or Modifications of Original Code |
| 10 | * as defined in and that are subject to the Apple Public Source License |
| 11 | * Version 2.0 (the 'License'). You may not use this file except in |
| 12 | * compliance with the License. The rights granted to you under the License |
| 13 | * may not be used to create, or enable the creation or redistribution of, |
| 14 | * unlawful or unlicensed copies of an Apple operating system, or to |
| 15 | * circumvent, violate, or enable the circumvention or violation of, any |
| 16 | * terms of an Apple operating system software license agreement. |
| 17 | * |
| 18 | * Please obtain a copy of the License at |
| 19 | * http://www.opensource.apple.com/apsl/ and read it before using this file. |
| 20 | * |
| 21 | * The Original Code and all software distributed under the License are |
| 22 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
| 23 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
| 24 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, |
| 25 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
| 26 | * Please see the License for the specific language governing rights and |
| 27 | * limitations under the License. |
| 28 | * |
| 29 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
| 30 | */ |
| 31 | |
| 32 | #if !__IIG |
| 33 | #if KERNEL |
| 34 | #include <libkern/c++/OSObject.h> |
| 35 | #endif |
| 36 | #endif |
| 37 | |
| 38 | #ifndef _IOKIT_UOSOBJECT_H |
| 39 | #define _IOKIT_UOSOBJECT_H |
| 40 | |
| 41 | #if !KERNEL |
| 42 | #include <stddef.h> |
| 43 | #include <stdint.h> |
| 44 | #include <DriverKit/IOReturn.h> |
| 45 | #if DRIVERKIT_PRIVATE |
| 46 | #include <mach/port.h> |
| 47 | #endif /* DRIVERKIT_PRIVATE */ |
| 48 | #if !__IIG |
| 49 | #include <string.h> |
| 50 | #include <DriverKit/OSMetaClass.h> |
| 51 | #endif /* !__IIG */ |
| 52 | class OSObject; |
| 53 | typedef OSObject * OSObjectPtr; |
| 54 | #endif /* !KERNEL */ |
| 55 | |
| 56 | #if !__IIG_ATTRIBUTES_DEFINED__ |
| 57 | |
| 58 | #define __IIG_ATTRIBUTES_DEFINED__ 1 |
| 59 | |
| 60 | #if __IIG || __DOCUMENTATION__ |
| 61 | |
| 62 | #define IIG_KERNEL __attribute__((annotate("kernel"))) |
| 63 | #define IIG_NATIVE __attribute__((annotate("native"))) |
| 64 | #define IIG_LOCAL __attribute__((annotate("local"))) |
| 65 | #define IIG_LOCALONLY __attribute__((annotate("localonly"))) |
| 66 | #define IIG_REMOTE __attribute__((annotate("remote"))) |
| 67 | #define IIG_LOCALHOST __attribute__((annotate("localhost"))) |
| 68 | #define IIG_INVOKEREPLY __attribute__((annotate("invokereply"))) |
| 69 | #define IIG_REPLY __attribute__((annotate("reply"))) |
| 70 | #define IIG_PORTMAKESEND __attribute__((annotate("MACH_MSG_TYPE_MAKE_SEND"))) |
| 71 | #define IIG_PORTCOPYSEND __attribute__((annotate("MACH_MSG_TYPE_COPY_SEND"))) |
| 72 | #define IIG_TARGET __attribute__((annotate("target"))) |
| 73 | #define IIG_TYPE(p) __attribute__((annotate("type=" # p))) |
| 74 | //#define IIG_ARRAY(maxcount) __attribute__((annotate(# maxcount), annotate("array"))) |
| 75 | #define IIG_EXTENDS(cls) __attribute__((annotate("extends=" # cls))) |
| 76 | //#define IIG_INTERFACE __attribute__((annotate("interface"))) |
| 77 | //#define IIG_IMPLEMENTS(i) void __implements(i *); |
| 78 | #define IIG_QUEUENAME(name) __attribute__((annotate("queuename=" # name))) |
| 79 | #define IIG_SERIALIZABLE __attribute__((annotate("serializable"))) |
| 80 | #define IIG_CONCRETE __attribute__((annotate("concrete"))) |
| 81 | |
| 82 | #if __IIG |
| 83 | #define KERNEL IIG_KERNEL |
| 84 | #endif /* __IIG */ |
| 85 | #define NATIVE IIG_NATIVE |
| 86 | #define LOCAL IIG_LOCAL |
| 87 | #define LOCALONLY IIG_LOCALONLY |
| 88 | #define REMOTE IIG_REMOTE |
| 89 | #define LOCALHOST IIG_LOCALHOST |
| 90 | #define INVOKEREPLY IIG_INVOKEREPLY |
| 91 | #define REPLY IIG_REPLY |
| 92 | #define PORTMAKESEND IIG_PORTMAKESEND |
| 93 | #define PORTCOPYSEND IIG_PORTCOPYSEND |
| 94 | #define TARGET IIG_TARGET |
| 95 | #define TYPE(p) IIG_TYPE(p) |
| 96 | //#define ARRAY(maxcount) IIG_ARRAY(maxcount) |
| 97 | #define EXTENDS(cls) IIG_EXTENDS(cls) |
| 98 | //#define INTERFACE IIG_INTERFACE |
| 99 | //#define IMPLEMENTS(i) IIG_IMPLEMENTS(i) |
| 100 | #define QUEUENAME(name) IIG_QUEUENAME(name) |
| 101 | |
| 102 | #else /* __IIG || __DOCUMENTATION__ */ |
| 103 | |
| 104 | #define IIG_KERNEL |
| 105 | #define IIG_NATIVE |
| 106 | #define IIG_LOCAL |
| 107 | #define IIG_LOCALONLY |
| 108 | #define IIG_REMOTE |
| 109 | #define IIG_LOCALHOST |
| 110 | #define IIG_INVOKEREPLY |
| 111 | #define IIG_REPLY |
| 112 | #define IIG_PORTMAKESEND |
| 113 | #define IIG_PORTCOPYSEND |
| 114 | #define IIG_TARGET |
| 115 | #define IIG_TYPE(p) |
| 116 | //#define IIG_ARRAY(maxcount) |
| 117 | #define IIG_EXTENDS(cls) |
| 118 | //#define IIG_INTERFACE |
| 119 | //#define IIG_IMPLEMENTS(i) |
| 120 | #define IIG_QUEUENAME(name) |
| 121 | #define IIG_SERIALIZABLE |
| 122 | |
| 123 | #endif /* __IIG || __DOCUMENTATION__ */ |
| 124 | |
| 125 | #endif /* __IIG_ATTRIBUTES_DEFINED__ */ |
| 126 | |
| 127 | |
| 128 | #if !__IIG |
| 129 | #if KERNEL |
| 130 | typedef OSObject OSContainer; |
| 131 | #else /* KERNEL */ |
| 132 | class IIG_SERIALIZABLE OSContainer; |
| 133 | #endif /* KERNEL */ |
| 134 | #else /* !__IIG */ |
| 135 | class IIG_SERIALIZABLE OSContainer; |
| 136 | #endif /* !__IIG */ |
| 137 | |
| 138 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 139 | |
| 140 | /* |
| 141 | * DRIVERKIT_ macros below can be used to describe the ownership semantics |
| 142 | * of functions handling subclasses of OSObject. |
| 143 | * The attributes propagate with inheritance, but can be overriden. |
| 144 | * New versions of the Clang Static Analyzer can use this knowledge to |
| 145 | * check the code for leaks or uses-after-free. |
| 146 | */ |
| 147 | |
| 148 | #ifndef KERNEL |
| 149 | /* |
| 150 | * By default, methods returning OSObjects are assumed to have the following |
| 151 | * owneship semantics: |
| 152 | * - Functions and methods that have "Get" in their name are assumed to be |
| 153 | * getters. They return at "+0" and the caller is not responsible for releasing |
| 154 | * the returned object. |
| 155 | * |
| 156 | * - All other methods are assumed to return at "+1", and the caller is |
| 157 | * responsible for releasing the returned object. |
| 158 | * |
| 159 | * The semantics implied by the naming convention described above can be |
| 160 | * overriden using either DRIVERKIT_RETURNS_RETAINED or |
| 161 | * DRIVERKIT_RETURNS_NOT_RETAINED attribute applied to a function. |
| 162 | * In the former case, it stipulates that the function is returning at "+1", |
| 163 | * and in the latter case "+0". |
| 164 | * DRIVERKIT_RETURNS_RETAINED and DRIVERKIT_RETURNS_NOT_RETAINED attributes |
| 165 | * can be also applied to out parameters, in which case they specify |
| 166 | * that an out parameter is written into at +1 or +0 respectively. |
| 167 | * Behavior of out parameters of non-void functions can be additionally |
| 168 | * customized via annotations that explain how a function returns a retained |
| 169 | * or a non-retained value through its out-parameter depending on its |
| 170 | * return value: DRIVERKIT_RETURNS_RETAINED_ON_ZERO and |
| 171 | * DRIVERKIT_RETURNS_RETAINED_ON_NONZERO. |
| 172 | */ |
| 173 | #if __has_attribute(os_returns_retained) |
| 174 | #define DRIVERKIT_RETURNS_RETAINED __attribute__((os_returns_retained)) |
| 175 | #else |
| 176 | #define DRIVERKIT_RETURNS_RETAINED |
| 177 | #endif |
| 178 | #if __has_attribute(os_returns_not_retained) |
| 179 | #define DRIVERKIT_RETURNS_NOT_RETAINED __attribute__((os_returns_not_retained)) |
| 180 | #else |
| 181 | #define DRIVERKIT_RETURNS_NOT_RETAINED |
| 182 | #endif |
| 183 | |
| 184 | /* |
| 185 | * DRIVERKIT_CONSUMED attribute can be applied to parameters. |
| 186 | * It specifies that this function call would consume the reference to the |
| 187 | * annotated parameter. |
| 188 | */ |
| 189 | #if __has_attribute(os_consumed) |
| 190 | #define DRIVERKIT_CONSUMED __attribute__((os_consumed)) |
| 191 | #else |
| 192 | #define DRIVERKIT_CONSUMED |
| 193 | #endif |
| 194 | |
| 195 | /* |
| 196 | * DRIVERKIT_CONSUMES_THIS attribute can be applied to C++ methods. |
| 197 | * It specifies that this method call consumes a reference to "this" (e.g. |
| 198 | * by storing a reference to "this" in a passed parameter). |
| 199 | */ |
| 200 | #if __has_attribute(os_consumes_this) |
| 201 | #define DRIVERKIT_CONSUMES_THIS __attribute__((os_consumes_this)) |
| 202 | #else |
| 203 | #define DRIVERKIT_CONSUMES_THIS |
| 204 | #endif |
| 205 | |
| 206 | /* |
| 207 | * DRIVERKIT_RETURNS_RETAINED_ON_ZERO is an attribute applicable to out |
| 208 | * parameters. |
| 209 | * It specifies that an out parameter at +1 is written into an argument iff |
| 210 | * the function returns a zero return value. |
| 211 | */ |
| 212 | #if __has_attribute(os_returns_retained_on_zero) |
| 213 | #define DRIVERKIT_RETURNS_RETAINED_ON_ZERO __attribute__((os_returns_retained_on_zero)) |
| 214 | #else |
| 215 | #define DRIVERKIT_RETURNS_RETAINED_ON_ZERO |
| 216 | #endif |
| 217 | |
| 218 | /* |
| 219 | * DRIVERKIT_RETURNS_RETAINED_ON_NON_ZERO is an attribute applicable to out |
| 220 | * parameters. |
| 221 | * It specifies that an out parameter at +1 is written into an argument iff |
| 222 | * the function returns a non-zero return value. |
| 223 | */ |
| 224 | #if __has_attribute(os_returns_retained_on_non_zero) |
| 225 | #define DRIVERKIT_RETURNS_RETAINED_ON_NONZERO __attribute__((os_returns_retained_on_non_zero)) |
| 226 | #else |
| 227 | #define DRIVERKIT_RETURNS_RETAINED_ON_NONZERO |
| 228 | #endif |
| 229 | |
| 230 | |
| 231 | /* |
| 232 | * Macros below are equivalent to their DRIVERKIT_ counterparts. |
| 233 | * They are provided for source-compatibility with IOKit code so they can |
| 234 | * be used in code that gets compiled for both platforms. |
| 235 | */ |
| 236 | #define LIBKERN_RETURNS_RETAINED DRIVERKIT_RETURNS_RETAINED |
| 237 | #define LIBKERN_RETURNS_NOT_RETAINED DRIVERKIT_RETURNS_NOT_RETAINED |
| 238 | #define LIBKERN_CONSUMED DRIVERKIT_CONSUMED |
| 239 | #define LIBKERN_CONSUMES_THIS DRIVERKIT_CONSUMES_THIS |
| 240 | #define LIBKERN_RETURNS_RETAINED_ON_ZERO DRIVERKIT_RETURNS_RETAINED_ON_ZERO |
| 241 | #define LIBKERN_RETURNS_RETAINED_ON_NONZERO DRIVERKIT_RETURNS_RETAINED_ON_NONZERO |
| 242 | |
| 243 | #endif /* !defined(KERNEL) */ |
| 244 | |
| 245 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 246 | |
| 247 | |
| 248 | class IIG_SERIALIZABLE OSData; |
| 249 | class IIG_SERIALIZABLE OSNumber; |
| 250 | class IIG_SERIALIZABLE OSString; |
| 251 | class IIG_SERIALIZABLE OSBoolean; |
| 252 | class IIG_SERIALIZABLE OSDictionary; |
| 253 | class IIG_SERIALIZABLE OSArray; |
| 254 | class IIG_SERIALIZABLE OSSet; |
| 255 | class IIG_SERIALIZABLE OSOrderedSet; |
| 256 | |
| 257 | class OSMetaClass; |
| 258 | class IODispatchQueue; |
| 259 | typedef char IODispatchQueueName[256]; |
| 260 | |
| 261 | #if __IIG |
| 262 | /* OSObject.iig:273-275 */ |
| 263 | #endif /* __IIG */ |
| 264 | |
| 265 | |
| 266 | /* source class OSObject OSObject.iig:276-306 */ |
| 267 | |
| 268 | #if __DOCUMENTATION__ |
| 269 | #define KERNEL IIG_KERNEL |
| 270 | |
| 271 | /*! |
| 272 | */ |
| 273 | |
| 274 | class OSObject : public OSMetaClassBase |
| 275 | { |
| 276 | public: |
| 277 | |
| 278 | virtual bool |
| 279 | init() LOCALONLY; |
| 280 | |
| 281 | virtual void |
| 282 | free() LOCALONLY; |
| 283 | |
| 284 | virtual void |
| 285 | retain() const override; |
| 286 | |
| 287 | virtual void |
| 288 | release() const override; |
| 289 | |
| 290 | virtual kern_return_t |
| 291 | SetDispatchQueue( |
| 292 | const IODispatchQueueName name, |
| 293 | IODispatchQueue * queue) KERNEL = 0; |
| 294 | |
| 295 | virtual kern_return_t |
| 296 | CopyDispatchQueue( |
| 297 | const IODispatchQueueName name, |
| 298 | IODispatchQueue ** queue) KERNEL = 0; |
| 299 | }; |
| 300 | |
| 301 | #undef KERNEL |
| 302 | #else /* __DOCUMENTATION__ */ |
| 303 | |
| 304 | /* generated class OSObject OSObject.iig:276-306 */ |
| 305 | |
| 306 | #define OSObject_SetDispatchQueue_ID 0xe608ae8273dae1bcULL |
| 307 | #define OSObject_CopyDispatchQueue_ID 0x95115b48fd29f7c9ULL |
| 308 | |
| 309 | #define OSObject_SetDispatchQueue_Args \ |
| 310 | const char * name, \ |
| 311 | IODispatchQueue * queue |
| 312 | |
| 313 | #define OSObject_CopyDispatchQueue_Args \ |
| 314 | const char * name, \ |
| 315 | IODispatchQueue ** queue |
| 316 | |
| 317 | #define OSObject_Methods \ |
| 318 | \ |
| 319 | public:\ |
| 320 | \ |
| 321 | virtual kern_return_t\ |
| 322 | Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE;\ |
| 323 | \ |
| 324 | static kern_return_t\ |
| 325 | _Dispatch(OSObject * self, const IORPC rpc);\ |
| 326 | \ |
| 327 | kern_return_t\ |
| 328 | SetDispatchQueue(\ |
| 329 | const char * name,\ |
| 330 | IODispatchQueue * queue,\ |
| 331 | OSDispatchMethod supermethod = NULL);\ |
| 332 | \ |
| 333 | kern_return_t\ |
| 334 | CopyDispatchQueue(\ |
| 335 | const char * name,\ |
| 336 | IODispatchQueue ** queue,\ |
| 337 | OSDispatchMethod supermethod = NULL);\ |
| 338 | \ |
| 339 | \ |
| 340 | protected:\ |
| 341 | /* _Impl methods */\ |
| 342 | \ |
| 343 | \ |
| 344 | public:\ |
| 345 | /* _Invoke methods */\ |
| 346 | \ |
| 347 | typedef kern_return_t (*SetDispatchQueue_Handler)(OSMetaClassBase * target, OSObject_SetDispatchQueue_Args);\ |
| 348 | static kern_return_t\ |
| 349 | SetDispatchQueue_Invoke(const IORPC rpc,\ |
| 350 | OSMetaClassBase * target,\ |
| 351 | SetDispatchQueue_Handler func);\ |
| 352 | \ |
| 353 | typedef kern_return_t (*CopyDispatchQueue_Handler)(OSMetaClassBase * target, OSObject_CopyDispatchQueue_Args);\ |
| 354 | static kern_return_t\ |
| 355 | CopyDispatchQueue_Invoke(const IORPC rpc,\ |
| 356 | OSMetaClassBase * target,\ |
| 357 | CopyDispatchQueue_Handler func);\ |
| 358 | \ |
| 359 | |
| 360 | |
| 361 | #define OSObject_KernelMethods \ |
| 362 | \ |
| 363 | protected:\ |
| 364 | /* _Impl methods */\ |
| 365 | \ |
| 366 | |
| 367 | |
| 368 | #define OSObject_VirtualMethods \ |
| 369 | \ |
| 370 | public:\ |
| 371 | \ |
| 372 | virtual bool\ |
| 373 | init(\ |
| 374 | ) APPLE_KEXT_OVERRIDE;\ |
| 375 | \ |
| 376 | virtual void\ |
| 377 | free(\ |
| 378 | ) APPLE_KEXT_OVERRIDE;\ |
| 379 | \ |
| 380 | virtual void\ |
| 381 | retain(\ |
| 382 | ) const APPLE_KEXT_OVERRIDE;\ |
| 383 | \ |
| 384 | virtual void\ |
| 385 | release(\ |
| 386 | ) const APPLE_KEXT_OVERRIDE;\ |
| 387 | \ |
| 388 | |
| 389 | |
| 390 | #if !KERNEL |
| 391 | |
| 392 | extern OSMetaClass * gOSObjectMetaClass; |
| 393 | extern const OSClassLoadInformation OSObject_Class; |
| 394 | |
| 395 | class OSObjectMetaClass : public OSMetaClass |
| 396 | { |
| 397 | public: |
| 398 | virtual kern_return_t |
| 399 | New(OSObject * instance) override; |
| 400 | virtual kern_return_t |
| 401 | Dispatch(const IORPC rpc) override; |
| 402 | }; |
| 403 | |
| 404 | #endif /* !KERNEL */ |
| 405 | |
| 406 | #if !KERNEL |
| 407 | |
| 408 | class OSObjectInterface : public OSInterface |
| 409 | { |
| 410 | public: |
| 411 | virtual bool |
| 412 | init() = 0; |
| 413 | |
| 414 | virtual void |
| 415 | free() = 0; |
| 416 | |
| 417 | bool |
| 418 | init_Call() { return init(); };\ |
| 419 | |
| 420 | void |
| 421 | free_Call() { return free(); };\ |
| 422 | |
| 423 | }; |
| 424 | |
| 425 | struct OSObject_IVars; |
| 426 | struct OSObject_LocalIVars; |
| 427 | |
| 428 | class OSObject : public OSMetaClassBase, public OSObjectInterface |
| 429 | { |
| 430 | #if !KERNEL |
| 431 | friend class OSObjectMetaClass; |
| 432 | #endif /* !KERNEL */ |
| 433 | |
| 434 | #if !KERNEL |
| 435 | public: |
| 436 | #ifdef OSObject_DECLARE_IVARS |
| 437 | OSObject_DECLARE_IVARS |
| 438 | #else /* OSObject_DECLARE_IVARS */ |
| 439 | union |
| 440 | { |
| 441 | OSObject_IVars * ivars; |
| 442 | OSObject_LocalIVars * lvars; |
| 443 | }; |
| 444 | #endif /* OSObject_DECLARE_IVARS */ |
| 445 | #endif /* !KERNEL */ |
| 446 | |
| 447 | #if !KERNEL |
| 448 | static OSMetaClass * |
| 449 | sGetMetaClass() { return gOSObjectMetaClass; }; |
| 450 | #endif /* KERNEL */ |
| 451 | |
| 452 | using super = OSMetaClassBase; |
| 453 | |
| 454 | #if !KERNEL |
| 455 | OSObject_Methods |
| 456 | OSObject_VirtualMethods |
| 457 | #endif /* !KERNEL */ |
| 458 | |
| 459 | }; |
| 460 | #endif /* !KERNEL */ |
| 461 | |
| 462 | |
| 463 | #endif /* !__DOCUMENTATION__ */ |
| 464 | |
| 465 | /* OSObject.iig:308- */ |
| 466 | |
| 467 | #define DEFN(classname, name) \ |
| 468 | name ## _Impl(classname ## _ ## name ## _Args) |
| 469 | |
| 470 | /* |
| 471 | * Use of the IMPL macro is discouraged and should be replaced by a normal c++ |
| 472 | * method implementation (with the all method arguments) and the name of the method |
| 473 | * given a suffix '_Impl' |
| 474 | */ |
| 475 | |
| 476 | #define IMPL(classname, name) \ |
| 477 | classname :: DEFN(classname, name) |
| 478 | |
| 479 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 480 | |
| 481 | #endif /* ! _IOKIT_UOSOBJECT_H */ |
| 482 | |