Use different class for .iig

My .iig file looks like this, I need to use different class IOUserHIDEventService and IOUserClient.

How to modify the class of .llg? Use two different class functions in

public:

DriverKit.iig

#ifndef DriverKit_h
#define DriverKit_h

#include <Availability.h>
#include <DriverKit/IOService.iig>
#include <HIDDriverKit/IOUserHIDEventService.iig>

class IOHIDElement;
class IOHIDDigitizerCollection;

class DriverKit: public IOUserHIDEventService
{
public:
  virtual bool init() override;
  virtual void free() override;
  virtual kern_return_t Start(IOService * provider) override;
  .......
  .......

#endif /* DriverKit_h */
Answered by in 698459022

DriverKit doesn't support multiple inheritance. In order to implement a userclient, you should make a second class. The class that subclasses IOUserHIDEventService will implement NewUserClient. This function will create a new userclient class instance and store it. Then the second class will handle communication.

Accepted Answer

DriverKit doesn't support multiple inheritance. In order to implement a userclient, you should make a second class. The class that subclasses IOUserHIDEventService will implement NewUserClient. This function will create a new userclient class instance and store it. Then the second class will handle communication.

Your dext driver needs to create two iigs, one for your user space driver and one for your iouserclient. Your user space driver can be written like this. . . . kern_return_t IMPL( MyUserSpaceDriver, NewUserClient ) { if(ivars->MyIoUserClient==NULL) { IOService *client = nullptr;

    if(IOService::Create(this /* provider */, "MyIOUserClientProperty" /* IOPropertyName */, &client)!=kIOReturnSuccess)
    {

return (kIOReturnError); } ivars->MyIoUserClient = (MyIOUserClient *) OSDynamicCast(IOUserClient, client); if(ivars->MyIoUserClient==NULL) { client->release(); return kIOReturnError; } } *userClient = ivars->MyIoUserClient; return (kIOReturnSuccess); }

kern_return_t IMPL( MyUserSpaceDriver, Start ) { ........ if(ivars->MyIoUserClient==NULL) { IOService *client = nullptr;

            if(IOService::Create(this /* provider */, "MyIOUserClientProperty" /* IOPropertyName */, &client)!=kIOReturnSuccess)
            {

goto start_fail; } ivars->MyIoUserClient = (MyIOUserClient *) OSDynamicCast(IOUserClient, client); if(ivars->MyIoUserClient==NULL) { client->release(); goto start_fail; } ivars->MyIoUserClient->Start(this); } ..... }

If it is simply the Class used by the user space driver, it can be called in the form of namespace.

namespace { class RingBuffer { public: void init(int desiredSize) { size=desiredSize + 1; data=(char *)IOMalloc(size); head=0; tail=0; return; } void deinit(void) { if(data != NULL) { IOFree(data, size); data=NULL; } return; } private: int head, tail, size; char *data; } }

Use different class for .iig
 
 
Q