RTL8139: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
No edit summary
No edit summary
Line 5: Line 5:
[[Image:rtl8139.JPG|right|frame|A PCI RTL8139]]
[[Image:rtl8139.JPG|right|frame|A PCI RTL8139]]


=Programming Guide=
== Programming Guide ==


== Turning on the RTL8139 ==
=== Turning on the RTL8139 ===


Send 0x00 to the CONFIG_1 register (0x52) to set the LWAKE + LWPTN to active high.
Send 0x00 to the CONFIG_1 register (0x52) to set the LWAKE + LWPTN to active high.
this should essentially *power on* the device.
this should essentially *power on* the device.


=== Software Reset! ===
==== Software Reset! ====


Next, we should do a software reset to clear the RX and TX buffers and set everything
Next, we should do a software reset to clear the RX and TX buffers and set everything
Line 22: Line 22:
the reset. If the RST bit is high (1), then the reset is still in operation.
the reset. If the RST bit is high (1), then the reset is still in operation.


=== Init Receive buffer ===
==== Init Receive buffer ====


For this part, we will send the chip a memory location to use as its receive buffer start
For this part, we will send the chip a memory location to use as its receive buffer start
Line 32: Line 32:
outportd(0x30, (unsigned long)rx_buffer); // send dword memory location to RBSTART (0x30)
outportd(0x30, (unsigned long)rx_buffer); // send dword memory location to RBSTART (0x30)


== Set IMR + ISR ==
=== Set IMR + ISR ===


The Interrupt Mask Register (IMR) and Interrupt Service Register (ISR) are responsible
The Interrupt Mask Register (IMR) and Interrupt Service Register (ISR) are responsible
Line 50: Line 50:
01000101: Confirmed. In fact, the only way to clear an interrupt is by writing to it. The datasheet says that reading is what you must do, but it is completely wrong.
01000101: Confirmed. In fact, the only way to clear an interrupt is by writing to it. The datasheet says that reading is what you must do, but it is completely wrong.


== Configuring receive buffer (RCR) ==
=== Configuring receive buffer (RCR) ===


Before hoping to see a packet coming to you, you should tell the RTL8139 to '''accept''' packets based on various rules. The configuration register is RCR.
Before hoping to see a packet coming to you, you should tell the RTL8139 to '''accept''' packets based on various rules. The configuration register is RCR.
Line 67: Line 67:
outportl(0x44, 0xf | (1 << 7)); // (1 << 7) is the WRAP bit, 0xf is AB+AM+APM+AAP
outportl(0x44, 0xf | (1 << 7)); // (1 << 7) is the WRAP bit, 0xf is AB+AM+APM+AAP


== Enable Receive and Transmitter ==
=== Enable Receive and Transmitter ===


Now is the time to start up the RX and TX functions.
Now is the time to start up the RX and TX functions.