RTL8139: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
No edit summary
mNo edit summary
Line 53: Line 53:


ex:
ex:
<source lang="c">
char rx_buffer[8192+16]; // declare the local buffer space (8k + header)
char rx_buffer[8192+16]; // declare the local buffer space (8k + header)
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)
</source>

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


Line 68: Line 69:


ex:
ex:
<source lang="c">
outportw(0x3C, 0x0005); // Sets the TOK and ROK bits high
outportw(0x3C, 0x0005); // Sets the TOK and ROK bits high
</source>

NB: When you handle an interrupt, you ''have'' to write the bit corresponding to the interrupt to reset it. The doc says reading the register is enough to reset the buffer to zero and writing has no effect. ''This is not the case on QEmu'', and probably on some/most hardware too. Writing a bit when it has no effect will probably not hurt.
NB: When you handle an interrupt, you ''have'' to write the bit corresponding to the interrupt to reset it. The doc says reading the register is enough to reset the buffer to zero and writing has no effect. ''This is not the case on QEmu'', and probably on some/most hardware too. Writing a bit when it has no effect will probably not hurt.


Line 89: Line 91:


Example:
Example:
<source lang="c">
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
</source>

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


Line 104: Line 107:


ex:
ex:
<source lang="c">
outportb(0x37, 0x0C); // Sets the RE and TE bits high
outportb(0x37, 0x0C); // Sets the RE and TE bits high
</source>

== Related Articles ==
== Related Articles ==