1*5e3eaea3SApple OSS Distributions #include "TestIOUserClient2022Entitlements.h"
2*5e3eaea3SApple OSS Distributions #include <IOKit/IOService.h>
3*5e3eaea3SApple OSS Distributions #include <IOKit/IOUserClient.h>
4*5e3eaea3SApple OSS Distributions #include <IOKit/IOKitServer.h>
5*5e3eaea3SApple OSS Distributions #include <kern/ipc_kobject.h>
6*5e3eaea3SApple OSS Distributions
7*5e3eaea3SApple OSS Distributions #if (DEVELOPMENT || DEBUG)
8*5e3eaea3SApple OSS Distributions
9*5e3eaea3SApple OSS Distributions OSDefineMetaClassAndStructors(TestIOUserClient2022Entitlements, IOService);
10*5e3eaea3SApple OSS Distributions
11*5e3eaea3SApple OSS Distributions OSDefineMetaClassAndStructors(TestIOUserClient2022EntitlementsUserClient, IOUserClient2022);
12*5e3eaea3SApple OSS Distributions
13*5e3eaea3SApple OSS Distributions bool
start(IOService * provider)14*5e3eaea3SApple OSS Distributions TestIOUserClient2022Entitlements::start(IOService * provider)
15*5e3eaea3SApple OSS Distributions {
16*5e3eaea3SApple OSS Distributions OSString * str = OSString::withCStringNoCopy("TestIOUserClient2022EntitlementsUserClient");
17*5e3eaea3SApple OSS Distributions bool ret = IOService::start(provider);
18*5e3eaea3SApple OSS Distributions if (ret && str != NULL) {
19*5e3eaea3SApple OSS Distributions setProperty(gIOUserClientClassKey, str);
20*5e3eaea3SApple OSS Distributions registerService();
21*5e3eaea3SApple OSS Distributions }
22*5e3eaea3SApple OSS Distributions OSSafeReleaseNULL(str);
23*5e3eaea3SApple OSS Distributions return ret;
24*5e3eaea3SApple OSS Distributions }
25*5e3eaea3SApple OSS Distributions
26*5e3eaea3SApple OSS Distributions bool
start(IOService * provider)27*5e3eaea3SApple OSS Distributions TestIOUserClient2022EntitlementsUserClient::start(IOService * provider)
28*5e3eaea3SApple OSS Distributions {
29*5e3eaea3SApple OSS Distributions if (!IOUserClient2022::start(provider)) {
30*5e3eaea3SApple OSS Distributions return false;
31*5e3eaea3SApple OSS Distributions }
32*5e3eaea3SApple OSS Distributions setProperty(kIOUserClientDefaultLockingKey, kOSBooleanTrue);
33*5e3eaea3SApple OSS Distributions setProperty(kIOUserClientDefaultLockingSetPropertiesKey, kOSBooleanTrue);
34*5e3eaea3SApple OSS Distributions setProperty(kIOUserClientDefaultLockingSingleThreadExternalMethodKey, kOSBooleanTrue);
35*5e3eaea3SApple OSS Distributions
36*5e3eaea3SApple OSS Distributions setProperty(kIOUserClientEntitlementsKey, "com.apple.iokit.test-check-entitlement-open");
37*5e3eaea3SApple OSS Distributions
38*5e3eaea3SApple OSS Distributions return true;
39*5e3eaea3SApple OSS Distributions }
40*5e3eaea3SApple OSS Distributions
41*5e3eaea3SApple OSS Distributions IOReturn
clientClose()42*5e3eaea3SApple OSS Distributions TestIOUserClient2022EntitlementsUserClient::clientClose()
43*5e3eaea3SApple OSS Distributions {
44*5e3eaea3SApple OSS Distributions terminate();
45*5e3eaea3SApple OSS Distributions return kIOReturnSuccess;
46*5e3eaea3SApple OSS Distributions }
47*5e3eaea3SApple OSS Distributions
48*5e3eaea3SApple OSS Distributions IOReturn
extBasicMethod(OSObject * target,void * reference,IOExternalMethodArguments * arguments)49*5e3eaea3SApple OSS Distributions TestIOUserClient2022EntitlementsUserClient::extBasicMethod(OSObject * target, void * reference, IOExternalMethodArguments * arguments)
50*5e3eaea3SApple OSS Distributions {
51*5e3eaea3SApple OSS Distributions return kIOReturnSuccess;
52*5e3eaea3SApple OSS Distributions }
53*5e3eaea3SApple OSS Distributions
54*5e3eaea3SApple OSS Distributions IOReturn
extPerSelectorCheck(OSObject * target,void * reference,IOExternalMethodArguments * arguments)55*5e3eaea3SApple OSS Distributions TestIOUserClient2022EntitlementsUserClient::extPerSelectorCheck(OSObject * target, void * reference, IOExternalMethodArguments * arguments)
56*5e3eaea3SApple OSS Distributions {
57*5e3eaea3SApple OSS Distributions return kIOReturnSuccess;
58*5e3eaea3SApple OSS Distributions }
59*5e3eaea3SApple OSS Distributions
60*5e3eaea3SApple OSS Distributions IOReturn
externalMethod(uint32_t selector,IOExternalMethodArgumentsOpaque * args)61*5e3eaea3SApple OSS Distributions TestIOUserClient2022EntitlementsUserClient::externalMethod(uint32_t selector, IOExternalMethodArgumentsOpaque * args)
62*5e3eaea3SApple OSS Distributions {
63*5e3eaea3SApple OSS Distributions static const IOExternalMethodDispatch2022 dispatchArray[] = {
64*5e3eaea3SApple OSS Distributions [0] {
65*5e3eaea3SApple OSS Distributions .function = &TestIOUserClient2022EntitlementsUserClient::extBasicMethod,
66*5e3eaea3SApple OSS Distributions .checkScalarInputCount = 0,
67*5e3eaea3SApple OSS Distributions .checkStructureInputSize = 0,
68*5e3eaea3SApple OSS Distributions .checkScalarOutputCount = 0,
69*5e3eaea3SApple OSS Distributions .checkStructureOutputSize = 0,
70*5e3eaea3SApple OSS Distributions .allowAsync = false,
71*5e3eaea3SApple OSS Distributions .checkEntitlement = NULL,
72*5e3eaea3SApple OSS Distributions },
73*5e3eaea3SApple OSS Distributions [1] {
74*5e3eaea3SApple OSS Distributions .function = &TestIOUserClient2022EntitlementsUserClient::extPerSelectorCheck,
75*5e3eaea3SApple OSS Distributions .checkScalarInputCount = 0,
76*5e3eaea3SApple OSS Distributions .checkStructureInputSize = 0,
77*5e3eaea3SApple OSS Distributions .checkScalarOutputCount = 0,
78*5e3eaea3SApple OSS Distributions .checkStructureOutputSize = 0,
79*5e3eaea3SApple OSS Distributions .allowAsync = false,
80*5e3eaea3SApple OSS Distributions .checkEntitlement = "com.apple.iokit.test-check-entitlement-per-selector",
81*5e3eaea3SApple OSS Distributions },
82*5e3eaea3SApple OSS Distributions };
83*5e3eaea3SApple OSS Distributions
84*5e3eaea3SApple OSS Distributions return dispatchExternalMethod(selector, args, dispatchArray, sizeof(dispatchArray) / sizeof(dispatchArray[0]), this, NULL);
85*5e3eaea3SApple OSS Distributions }
86*5e3eaea3SApple OSS Distributions
87*5e3eaea3SApple OSS Distributions #endif /* (DEVELOPMENT || DEBUG) */
88