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: PCIATA driver matching



On Sunday, December 22, 2002, at 12:33 AM, Ernesto Corvi wrote:

I'm fudging with a ATA PCI adapter here, and there's something regarding the IOKit ATA family that
I don't quite follow. The hardware is a 2 channel ATA/100 PCI card. So I wrote 2 classes:

com.bleh.ata.controller derived from IOService whose requested provider is a IOPCIDevice.
com.bleh.ata.driver derived from IOPCIATA whose requested provider is a com.bleh.ata.controller.

The .controller class uses the standard IOPCIMatch against the vendor/device id. Once the match
happens, it creates .driver nubs, one per channel, calls the init function on the .driver, attaches the nub
to the .controller class, and finally calls registerService on the nub.

So far so good. The problem is that after running it, the start() function on the .driver never happens,
as if nothing is matched against it. So I end up with a IO registry like this:

+--- pci1234,12 <class IOPCIDevice>
{ ... }
|
+--- com.bleh.ata.controller <class com.bleh.ata.controller>
{ ... }
|
+ --- com.bleh.ata.driver <class com.bleh.ata.driver>
| { ... }
+ --- com.bleh.ata.driver <class com.bleh.ata.driver>
{ ... }

So, my question is what do I need to match the 'com.bleh.ata.driver' against so it gets started and I get to
spawn the IOATADevice nubs? Can it be anything? What is anything? Can I call start() directly?


It is the responsibility of the code that allocates the IOService instance to do everything necessary to start the driver (i.e. init(), attach(), start()). So if you depend on IOKit matching to create your driver instance, IOKit will take care of it since it allocated your class. However if you are allocating nubs yourself, it is your responsibility for calling start(). To make that easier, there's an IOService function startCandidate() that will call both attach() and start() on your nub. It will also clean up by calling detach() if start() fails.

Also, since you are creating your driver nubs, there is no need to set up matching criteria for them. That is only needed for cases like your controller class that need to be automatically created.

Oh, one bug? I found while writing this is that when calling the init() function on my .driver class, after
creating an instance of it with 'new', if I try to IOLog( "%s init", getName() ); as the first piece of code on the
init() routine, it will cause a kernel panic everytime. The culprit being getName() for some reason.



Definitely seems like a bug. I believe that the name information comes from the registry, so it might be that getName() will fail until the service has been attached to its provider. But calling getName() should never cause a panic().

- Eric
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.

References: 
 >PCIATA driver matching (From: Ernesto Corvi <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.