02.03.2014 Views

BSP Developer's Guide

BSP Developer's Guide

BSP Developer's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

G<br />

Upgrading 4.3 BSD Network Drivers<br />

The first function pointer references this driver’s init( ) routine, which this driver<br />

does not need or have. The second function pointer references the driver’s ioctl( )<br />

interface, which allows the upper layer to manipulate the device state. The third<br />

function pointer references the routine that outputs packets on the physical<br />

medium. The last function pointer references a routine that can reset the device if<br />

the TCP/IP stack decides that this needs to be done.<br />

In 4.4 BSD, there is a generic output routine called ether_output( ) that all Ethernet<br />

device drivers can use. Thus, to convert the above ether_attach( ) call to a 4.4-style<br />

call, you would call ether_attach( ) as follows:<br />

ether_attach(<br />

(IFNET *) & pDrvCtrl->idr,<br />

unit,<br />

"xx",<br />

(FUNCPTR) NULL,<br />

(FUNCPTR) xxIoctl,<br />

(FUNCPTR) ether_output, /* generic ether_output */<br />

(FUNCPTR) xxReset<br />

);<br />

pDrvCtrl->idr.ac_if.if_start = (FUNCPTR)xxTxStartup;<br />

This time, there is an extra line following the call to ether_attach( ). This line of<br />

code adds a transmit startup routine to the Interface Data Record. The transmit<br />

startup routine is called by the TCP/IP stack after the generic ether_output( )<br />

routine is called. This extra line of code assumes that the driver already has a<br />

transmit startup routine. If a driver lacks a separate transmit startup routine, you<br />

must write one. See the template in G.2.4 Creating a Transmit Startup Routine.<br />

G<br />

G.2.1 Removing the xxOutput( ) Routine<br />

If a 4.3 BSD driver has an xxOutput( ) routine, it should look something like the<br />

following:<br />

static int xxOutput<br />

(<br />

IDR * pIDR,<br />

MBUF * pMbuf,<br />

SOCK * pDestAddr<br />

)<br />

{<br />

return (ether_output ((IFNET *)pIDR,pMbuf, pDestAddr,<br />

(FUNCPTR) xxTxStartup, pIDR));<br />

}<br />

Internally, this routine calls the ether_output( ) routine, which expects a pointer to<br />

the startup routine as one of its arguments. However, in the 4.4 BSD model, all that<br />

261

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!