I know that there have been a lot of post here about the rtl8139 NIC, and I have looked at almost all of them but I can't seem to figure out why i am experiencing this particular problem. The last 2 months I think I have been trying to implement a small networking stack for my os, and this is so far going very good. So far I had only tested it on Qemu and there it worked fine with the driver I wrote for the rtl8139 nic. Luckily I also have one of those in my computers, so of course i wanted to test it on real hardware. As expected by the title, this did not work. Sending and receiving works fine on Qemu, but on my real pc the NIC would only send packets. Even if the led blinks, indicating that there is data arriving my interrupt handler does not get called for some reason. Like I have said, I have looked at many forum posts and existing drivers but I can not seem to figure out why my interrupt handler does not get called for received packets, I do get a interrupt when a packet is successfully send.
This is my code to initialize the card:
Code: Select all
void RTL8139::Activate()
{
printf("Activating RTL8139\n");
outportb(device->portBase + 0x52, 0x0);
Reset();
rx_buffer = (char*) MemoryManager::activeMemoryManager->malloc (8192 + 16 + 1500);
MemoryOperations::memset(rx_buffer, 0x0, 8192 + 16 + 1500);
outportl(device->portBase + 0x30, (uint32_t)rx_buffer);
// Sets the TOK and ROK bits high
outportw(device->portBase + 0x3C, 0x0005);
// (1 << 7) is the WRAP bit, 0xf is AB+AM+APM+AAP
outportl(device->portBase + 0x44, 0xf | (1 << 7));
// Sets the RE and TE bits high
outportb(device->portBase + 0x37, 0x0C);
}
void RTL8139::Reset()
{
printf("Resetting\n");
outportb(device->portBase + 0x37, 0x10);
while((inportb(device->portBase + 0x37) & 0x10) != 0) {
printf(".");
}
}
And my repo: https://github.com/Remco123/CactusOS
Thank you for reading and hope that anyone knows how to fix this.
By the way: sorry if my English isn't perfect