Hi,
Since I am currently working on network documentation, I think I will try to help you with this one.
First, when my code, network or otherwise, works on the emulator but not on real hardware, I look at things that are related to this idea. For example, an emulator may initialize a register to zero, that's just what software tends to do. However, actual hardware usually does not. Therefore, look at these sort of things.
Next, and looking at your code you posted, it doesn't look like you set the length of the buffer. The RTL8139 has a "Len of Buffer" register as well as FIFO threshold and Burst size. If you don't set this register, the hardware might think you have a zero sized input memory block and won't write anything, therefore, not triggering an interrupt saying it received a packet. (More of a RTL8169 issue).
Code:
// (1 << 7) is the WRAP bit, 0xf is AB+AM+APM+AAP
outportl(device->portBase + 0x44, 0xf | (1 << 7));
What about the field at bit 13 and bit 11? The first being the FIFO threshold and the second being the length of the buffer. Right now you set it to 8K by writing a zero to it. The FIFO is set to 16 bytes, again writing a zero. The FIFO is something the emulator probably won't emulate, hence this would be something to look into. i.e.: Works on the emulator (that doesn't emulate the FIFO) but doesn't work on real hardware (something that does use an FIFO).
Something that I have noticed with other chips, not the RTL8139 (yet) is that reset might reset the current MAC. For example, the E100 will not receive anything but multi's due to it settings its internal MAC to FF FF FF FF FF FF upon reset. You have to actually tell it what MAC to use. Does the RTL8139 reset its MAC upon reset (something I haven't tested for yet. I simply re-assign a MAC after reset by default). Maybe the emulator always uses the same MAC while the hardware needs the MAC re-assigned after the reset. Try re-writting the MAC back to the RTL8139_IDR0 register, remembering to set the RTL8139_CR9346 register to 0xC0 first (and restoring it after done).
So, with this in mind, and thinking about it, I bet you simply need to restore the MAC address after a reset and before telling the NIC to start receiving packets. The NIC is probably receiving packets, comparing it to your MAC (which is probably 00 00 00 00 00 00 or FF FF FF FF FF FF) and rejecting the packet.
Try it.
Ben
-
http://www.fysnet.net/osdesign_book_series.htm