Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: efficient driver/driver communication




On Jul 18, 2008, at 12:04 PM, email@hidden wrote:

What is the most efficient way of moving data between two kexts?Are the
IOService message/messageClient calls the recommended way to do this? Do
they involve memcpy?

The most efficient technique is to use IOService matching to locate the partner kext and then make direct method calls between the two.


Since your kext isn't really discoverable until after your start routine has returned, you are best off using a notification to find the other kext.

Something like this:

class foo ....

        IONotifier      *notify;
	bar			*partner;

	bool		match_routine(void *ref, IOService *newService);
...
};

bool
foo::start(IOService *provider)
{

...
notify = addNotification(gIOPublishNotification, serviceMatching("bar"), match_routine, this, 0);
registerService();
return(true);
}


bool
match_routine(void *ref, IOService *newService)
{
	partner = OSDynamicCast(bar, newService);
	...
}

Once foo has found bar, it can introduce itself with a registration call and you can make direct inter-class calls.

Note that it can be risky doing this if the two have separate workloops, since the potential for deadlock exists. Depending on what you're actually doing, you may find it convenient to have one class defer most of its setup until it finds the other, and then call getWorkLoop() in order to share workloops.

 = Mike

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.