Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Ethernet Network adapter drivers for Mac OS X 10.3
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Ethernet Network adapter drivers for Mac OS X 10.3



In addition to the general IOKit docs mentioned in other replies you might find the following link useful:
http://episteme.arstechnica.com/6/ubb.x? a=tpc&s=50009562&f=8300945231&m=7480952764
The article's author states "I've just spent the last 2 1/2 months struggling through learning IOKit well enough to write an ethernet driver for the popular tulip line of chips. I thought I would share my experiences and make it less painful for future aspiring driver writers to get bootstrapped."
It's a little old (for example, it mentions that network drivers can't be unloaded but that is no longer true) but useful. It has direct links to many of the documents he used to figure things out.


Also, on a 10.3 System, you'll find /Developer/Documentation/ DeviceDriversIOKit/Conceptual/NetworkDriver/NetDoc.pdf. It was a preliminary doc that apparently never got finished and and has some inaccuracies but is pretty good. I discovered the doc after typing this email, and see that it matches pretty closely with what I described below, and fleshes out the concepts a bit more.

As a starting point, you can get a skeleton going by overriding the following IOEthernetController functions:

virtual bool start( IOService *provider):
You have to override this one. Some typical steps include bringing up the device enough to read and save its MAC address in an instance variable. You'll also do the steps necessary to be able to communicate with your provider, receive interrupts, etc. Most importantly, you must call attachInterface() and save the *IOEthernetInterface it gives you. The attachInterface() triggers the creation of the objects that make your controller visible to the networking stack as an interface.


virtual void stop( IOService *provider ):
Undo whatever you did in the start() method. If you allocated stuff in start(), free it here. In particular remember to release the IOEthernetInterface object that was created in start().


virtual IOReturn enable(IONetworkInterface *netif):
enable is called when the system "UPs" your interface. You should start your hardware's transmit and receive here. As a minor optimization, you might be able to take stuff you do in start() (init ring buffers, allocate buffers, etc.) and do it here instead. That way the resources are only used when the device is actually active. Either here, or in response to info from your hardware in interrupts, call setLinkStatus() so that the system knows when you've got link.


virtual IOReturn disable(IONetworkInterface *netif):
Called when your interface is "DOWNed",(ifconfig en0 down, for example). Stop IO here and undo whatever you did in enable().


virtual IOReturn getHardwareAddress(IOEthernetAddress *addr):
you must override this and return your device's address (typically a saved value that you retrieved in start())


virtual UInt32 outputPacket(mbuf_t , void *):
Override this and transmit your packet here. As you start development you can probably just blast your packet out but this method can and will be called from multiple threads so you will soon need to implement some form of serialization to protect yourself from other transmit threads (and receive packet path). You'll want to look at the IOOutputQueue classes provided in IONetworkingFamily, and also understand IOWorkloop which is fundamental to IOKit Drivers.



With those done, you'll have a decently functional driver. You'll eventually round it out by implementing these methods:
virtual IOReturn setPromiscuousMode(bool active);
virtual IOReturn setMulticastMode(bool active);
virtual IOReturn setMulticastList(IOEthernetAddress *addrs, UInt32 count);
And look into publishMediumDictionary(), setSelectedMedium() and setCurrentMedium() to see how to properly deal with the currently attached medium.



From: rsriram <email@hidden>
Date: April 6, 2005 17:14:14 PDT
To: email@hidden
Subject: Ethernet Network adapter drivers for Mac OS X 10.3


Hi,

I need to write a network adapter driver for Mac OS X 10.3.
I am new to Mac drivers development.
Can somebody give faster way and approach to working for
network driver development for Mac OS 10.3.
Also it would be nice if I can have some sample reference
source code.

- Sriram


_______________________________________________

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-drivers mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
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 © 2011 Apple Inc. All rights reserved.