Ne2000: Difference between revisions

2,447 bytes added ,  1 year ago
m
→‎External Links: I'm not sure anymore if this was the NE2000 spec
[unchecked revision][unchecked revision]
m (→‎External Links: I'm not sure anymore if this was the NE2000 spec)
 
(11 intermediate revisions by 7 users not shown)
Line 2:
It is a good first network card to program because it follows a simple design (making it helpful for learning), they're probably dirt-cheap, and it is supported by most PC emulators. Both [[Bochs]] and [[QEMU]] provide ISA and PCI implementations.
 
Ne2000 is not technically a card, it is a standard that several implementors follow. The best available description of the initial standard iswas located [http://www.national.com/pf/DP/DP8390D.html DP8390D/NS32490D NIC Network Interface Controller] ([https://web.archive.org/web/20010612150713/http://www.national.com/ds/DP/DP8390D.pdf archive]) and was published by National Semiconductor.
 
== Quick Overview of the NIC design ==
Line 63:
};
</pre>
 
=== Initialization and MAC Address ===
This wasn't exactly obvious, but by looking at the ''ne2k-pci'' module from Linux I managed to figure out how to initilize the card and read its MAC address:
 
nif->iobase = nif->pcidev->bar[0] & ~0x3;
outb(nif->iobase + 0x1F, inb(nif->iobase + 0x1F)); // write the value of RESET into the RESET register
while ((inb(nif->iobase + 0x07) & 0x80) == 0); // wait for the RESET to complete
outb(nif->iobase + 0x07, 0xFF); // mask interrupts
uint8_t prom[32];
outb(nif->iobase, (1 << 5) | 1); // page 0, no DMA, stop
outb(nif->iobase + 0x0E, 0x49); // set word-wide access
outb(nif->iobase + 0x0A, 0); // clear the count regs
outb(nif->iobase + 0x0B, 0);
outb(nif->iobase + 0x0F, 0); // mask completion IRQ
outb(nif->iobase + 0x07, 0xFF);
outb(nif->iobase + 0x0C, 0x20); // set to monitor
outb(nif->iobase + 0x0D, 0x02); // and loopback mode.
outb(nif->iobase + 0x0A, 32); // reading 32 bytes
outb(nif->iobase + 0x0B, 0); // count high
outb(nif->iobase + 0x08, 0); // start DMA at 0
outb(nif->iobase + 0x09, 0); // start DMA high
outb(nif->iobase, 0x0A); // start the read
int i;
for (i=0; i<32; i++)
{
prom[i] = inb(nif->iobase + 0x10);
};
// program the PAR0..PAR5 registers to listen for packets to our MAC address!
for (i=0; i<6; i++)
{
writeRegister(nif, 1, 0x01+i, prom[i]);
};
 
The first 6 bytes of "prom" extracted here are the MAC address.
 
=== Sending a Packet ===
Line 73 ⟶ 111:
# <tt>RSARx</tt> are loaded with 0x00 (low) and target page number (high) respectively. At this stage, the chip is ready receiving packet data and storing it in the ring buffer for emission.
# <tt>COMMAND</tt> register set to "start" and "remote write DMA" (0x12)
# Packets data is now written to the "data port" (that is register 0x10) of the NIC in a loop (or using an "outsx" if available). The NIC will then update its remote DMA logic after each written word16-bit value/dword32-bit value and places bytes in the transmit ring buffer.
# Poll <tt>ISR</tt> register until bit 6 (Remote DMA completed) is set.
 
Line 93 ⟶ 131:
==See Also==
===External Links===
* [https://web.archive.org/web/20010612150713/http://www.national.com/ds/DP/DP8390D.pdf DP8390D/NS32490D NIC Network Interface Controller (PDF)] datasheet for the 8390 chip on the NE2000
* https://bitsavers.org/components/national/_dataBooks/1988_National_Data_Communications_Local_Area_Networks_UARTs_Handbook.pdf, early description of NE1000(?) boards (including PROM and memory map), starting on page 124 ("DP839EB Network Evaluation Board - Application Note 479")
* [https://web.archive.org/web/20091223070134/http://www.national.com/pf/DP/DP8390D.html#Documents DP8390D Additional application notes] from NatSemi
* http://www.ethernut.de/pdf/8019asds.pdf, the RTL8019 is one of the PCI-based NE2K compliant cards.
* http://www.bcgreen.com/gnu-linux/ne2k-diag.c, a diagnostic tool that needs to be inspected to see if it helps in understanding the manuals
* http://www.cs.usfca.edu/~cruse/cs326/RTL8139_ProgrammersGuide.pdf, saved here for later use.
* https://github.com/torokernel/torokernel/blob/7d6df4c40fa4cc85febd5fd5799404592ffdff53/rtl/drivers/Ne2000.pas, example of a driver for Ne2000 in Freepascal.
 
[[Category:Network devicesHardware]]
[[Category:Standards]]
Anonymous user