1 #include "TestIOConnectMapMemoryPortLeak45265408.h"
2 #include <IOKit/IOKitKeys.h>
3 
4 #if DEVELOPMENT || DEBUG
5 
6 #define super IOService
7 OSDefineMetaClassAndStructors(TestIOConnectMapMemoryPortLeak45265408, IOService);
8 
9 bool
start(IOService * provider)10 TestIOConnectMapMemoryPortLeak45265408::start(IOService *provider)
11 {
12 	bool ret = super::start(provider);
13 	if (ret) {
14 		OSString * className = OSString::withCStringNoCopy("TestIOConnectMapMemoryPortLeak45265408UserClient");
15 		setProperty(gIOUserClientClassKey, className);
16 		OSSafeReleaseNULL(className);
17 		registerService();
18 	}
19 	return ret;
20 }
21 
22 #undef super
23 #define super IOUserClient
24 OSDefineMetaClassAndStructors(TestIOConnectMapMemoryPortLeak45265408UserClient, IOUserClient);
25 
26 bool
start(IOService * provider)27 TestIOConnectMapMemoryPortLeak45265408UserClient::start(IOService *provider)
28 {
29 	bool ret = super::start(provider);
30 	if (ret) {
31 		setProperty(kIOUserClientSharedInstanceKey, kOSBooleanTrue);
32 		this->sharedMemory = IOBufferMemoryDescriptor::withOptions(kIOMemoryKernelUserShared, PAGE_SIZE);
33 		if (this->sharedMemory == NULL) {
34 			ret = false;
35 		}
36 	}
37 
38 	return ret;
39 }
40 
41 void
stop(IOService * provider)42 TestIOConnectMapMemoryPortLeak45265408UserClient::stop(IOService *provider)
43 {
44 	if (this->sharedMemory) {
45 		this->sharedMemory->release();
46 		this->sharedMemory = NULL;
47 	}
48 	super::stop(provider);
49 }
50 
51 IOReturn
clientClose()52 TestIOConnectMapMemoryPortLeak45265408UserClient::clientClose()
53 {
54 	if (!isInactive()) {
55 		terminate();
56 	}
57 	return kIOReturnSuccess;
58 }
59 
60 IOReturn
clientMemoryForType(UInt32 type,IOOptionBits * flags,IOMemoryDescriptor ** memory)61 TestIOConnectMapMemoryPortLeak45265408UserClient::clientMemoryForType(UInt32 type, IOOptionBits *flags, IOMemoryDescriptor **memory)
62 {
63 	*memory = this->sharedMemory;
64 	this->sharedMemory->retain();
65 	return kIOReturnSuccess;
66 }
67 
68 #endif /* DEVELOPMENT || DEBUG */
69