Page 1 of 1
network stack
Posted: Tue Aug 17, 2010 11:14 am
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!
Re: network stack
Posted: Tue Aug 17, 2010 3:42 pm
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.
Re: network stack
Posted: Tue Aug 17, 2010 6:09 pm
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.
Re: network stack
Posted: Wed Aug 18, 2010 2:27 am
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!
Re: network stack
Posted: Thu Aug 19, 2010 10:20 pm
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.