I've an easy question for those that have got networking working using the RTL8139 on QEMU...
I'm trying to correctly read the MAC address for the RTL8139 network device using QEMU. I set the MAC using:
qemu ... -net nic, model=rtl8139, macaddr=52:54:00:12:34:56
However, I'm getting 0xFFFFFFFFFFFF as the MAC from my OS. What's going wrong here? I'm reading BAR0 from the PCI config to get the IO base address and then I'm reading the MAC i.e. inl(io_base + 0x00) and inw(io_base + 0x40).
I'm reading 0x3040 as the IO base from BAR0 which has value 0xc101.
Code: Select all
pci_device_t *pci_dev;
u8int cmd;
u8int interrupt_line;
u32int MAC0;
u16int MAC4;
u32int work;
pci_dev = _ki_load_pci_device(0x10ec,0x8139);
if( pci_dev == 0)
{
ki_printf("couldn't load network pci device\n");
return;
}
ki_printf_klog("BAR0 for RTL8139 device is 0x%x\n",pci_dev->config.reg4.bar0);
io_base = (u16int)_ki_get_pci_io_bar(pci_dev->config.reg4.bar0);
ki_printf_klog("IO base for RTL8139 device is 0x%x\n",io_base);
interrupt_line = pci_dev->config.reg15.interrupt_line;
ki_printf_klog("RTL8139 interrupt line nr is %d\n", interrupt_line);
MAC0 = ki_inl(io_base + 0x00);
MAC4 = ki_inw(io_base + 0x04);
ki_printf_klog("RTL8139 MAC: 0x%x%x\n",MAC0,MAC4);