network stack

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Srowen
Member
Member
Posts: 60
Joined: Thu Feb 26, 2009 2:31 pm
Location: Genova, ITALY

network stack

Post by Srowen »

It's time for me to implement the network stack in my os. I found the intel 8254x network card article in the wiki. Anyone have tried to make it work? Is it difficult? Or there is something else easier to use as network card?
For the moment I don't have the dma in my os (reading the article in the wiki at http://wiki.osdev.org/DMA doesn't make it very attractive...)

Thank's for the reply!
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: network stack

Post by pcmattman »

I'd personally suggest the NE2K or RTL8139 for a "first NIC driver" - dead simple to program, and supported by QEMU and Bochs.
For the moment I don't have the dma in my os (reading the article in the wiki at http://wiki.osdev.org/DMA doesn't make it very attractive...)
Note that article is about ISA DMA; the DMA used for network cards is as simple as giving the card one or more physical addresses, usually.
Matthew
Member
Member
Posts: 48
Joined: Wed Jul 01, 2009 11:47 am

Re: network stack

Post by Matthew »

Or the PCnet32 card, which is supported in qemu and vmware, and is also simple. The Intel 8254x isn't too bad in principle, but I found that the real cards are much trickier to initialize than the qemu e1000 emulator. For example, the 82543 and 82544 cards I have do not support the easier "EERD" method of EEPROM-reading that qemu allows, but require using the 4-wire bit-bashing method. All of these cards we are discussing have good programmer's manuals available, some of them from a link on the wiki, or you can find them by Googling the manufacturer's website.

As for the network stack, unless you're dead set on writing it, I recommend integrating the lwip project into your kernel. All you need to do is write an network card driver that can receive and transmit frames, the rest is handled by lwip.
Srowen
Member
Member
Posts: 60
Joined: Thu Feb 26, 2009 2:31 pm
Location: Genova, ITALY

Re: network stack

Post by Srowen »

Matthew wrote:As for the network stack, unless you're dead set on writing it, I recommend integrating the lwip project into your kernel. All you need to do is write an network card driver that can receive and transmit frames, the rest is handled by lwip.
This looks very well! If I'm not wrong, there isn't an article on the pcnet32 on the wiki, but i found the source of his driver for linux! For me it's a better solution because i use vmware and virtual box to test my os...

Thank's a lot for the answer!
Matthew
Member
Member
Posts: 48
Joined: Wed Jul 01, 2009 11:47 am

Re: network stack

Post by Matthew »

The datasheet for AM79C70A is very detailed and will provide just about all the information you could possibly want for programming the card: I googled up a version for you http://www.datasheetsite.com/datasheet/AM79C970A

The Linux drivers can be helpful, do be aware that using Linux code in your kernel will require that you carry the GPL on at least those bits of code, if not all of it. (Don't want to start a license discussion/flamewar, look for info on that elsewhere)

The Linux drivers can be a bit overcomplicated to follow sometimes, you might also want to take a look at GRUB-legacy sources and the gPXE project, both of which incorporate simpler drivers (usually based on Linux too, though).

Another issue I just remembered with the pcnet32 card is that it is backwards compatible with 16-bit machines, or at least it could be, and that you need to make sure the software size 32-bit setting is on (BCR20, see the datasheet), and that GRUB does not necessarily do this.
Post Reply