[: Re: Help needed regarding Network Device Drivers]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi all,

myself and AnilKumar Vaddineni had continued a kernelnewbies thread in
private for a couple of mails and I just thought it should probably go
back to the list, in case anyone else wanted to read/contribute.

-kev


----- Forwarded message from  -----

Date: Wed, 14 May 2003 11:15:42 +0100
To: AnilKumar Vaddineni <anilkumar_vaddineni@adp.com>
Subject: Re: Help needed regarding Network Device Drivers


Hi Anil,

[snip]


> I have seen the code of ne2k-pci.c but couldn't understand some
> piece of code in ne2k_pci_init_one function. The piece of code is
> given below.

I'm not entirely sure what it's doing here either, but I can make some
guesses: 


> 	/* Do a preliminary verification that we have a 8390. */
> 	{
> 		int regd;
> 		outb(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr+E8390_CMD);
> 		regd = inb(ioaddr + 0x0d);
> 		outb(0xff, ioaddr + 0x0d);
> 		outb(E8390_NODMA+E8390_PAGE0, ioaddr + E8390_CMD);

'ioaddr' looks to be just a variable that addresses the device.  To get
specific functions, the driver addresses specific registers on the
device, which it finds by adding offsets (the E8390_ macros) to
'ioaddr'.

I can't make out what the above is doing, but I reckon the E8390_
macros, in drivers/net/8390.h, should answer that.


> 		inb(ioaddr + EN0_COUNTER0); /* Clear the counter by reading.*/
> 		if (inb(ioaddr + EN0_COUNTER0) != 0) {
> 			outb(reg0, ioaddr);
> 			outb(regd, ioaddr + 0x0d);	/* Restore the old
> values. */
> 			goto err_out_free_res;
> 		}
>     }

All it's doing here is clearing a counter (of what I'm not sure), then
making sure the counter actually has been cleared.  If the counter is
not clear, he goes to some error handling code (err_out_free_res); if
the counter is clear the code just continues on to the next step.


> I didn't get why the above code is written? If you know that, then could you
> please explain step by step? If not, can you refer to some site or book?

I think it's just to make sure that the module is being loaded for the
correct device, in case the user/system mistakenly tries to use this
module for some other device.


> In the function call given below, is the value for second argument is fixed
> to a particular device?
> 
>  request_region (ioaddr, NE_IO_EXTENT, DRV_NAME)

Because of the NE_ prefix, I'd guess that it's fixed to the ne2k
driver/device, but I can't find where the macro is defined.  I'll take a
closer look later, but if you find it in the meantime could you let me
know?


> Where can we get the hardware manual for a particular network card? Do you
> have one? If yes, can you please send it?

No idea where you'd get that.  I think manufacturers are fairly
secretive about such things.


hope that's of some use
-kev


----- End forwarded message -----

-- 
    Writing a haiku
    Is much harder than it looks.
    These lines fall short.
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux