Hi Quirck,
Thanks for the quick response. I tried that and got the same response -- empty MMIO.
I had a brainwave a took as look at QEMU's monitor against my original command line...
Code:
info registers
hub0port1: e1000.1: index=0,type=nic,model=e1000,macaddr=52:54:00:12:34:57
hub0port0: e1000.0: index=0,type=nic,model=e1000,macaddr=52:54:00:12:34:56
So the QEMU, or at least the NIC, appears to think it has a MAC addresss.
My init code looks at lot like the others...
Code:
nic_8254_init:
;initializes the NIC, following BareMetal et al.
;contains various debug statements and commented-out code. Debug statements do a full save/restore of the stack.
;inputs:
; RDX - PCI Map entry address of the card
MOV R8, RDX ;save RDX
;write the model into the PCI map
MOV RSI, MSG_8254_MODEL
MOV RDI, RDX
ADD RDI, pci_map_entry.vendor_model
MOV RCX, (pci_map_entry_size - pci_map_entry.vendor_model) ;size of 'class description
REP MOVSB
;get the BAR0 address
XOR RAX, RAX
MOV EAX, [R8 + pci_map_entry.location] ;contains the enable bit and B:D:F already-shifted
OR EAX, PCI_REGISTER_BAR0 << 2
CALL pci_read_register
MOV [nic_8254_base_address], RAX
DEBUG_WRITE_VAR 'BAR0 address is ', [nic_8254_base_address]
XOR RAX, RAX
MOV EAX, [R8 + pci_map_entry.location]
OR EAX, PCI_REGISTER_IRQ << 2
CALL pci_read_register
MOV [nic_8254_irq], AL
DEBUG_WRITE_VAR 'IRQ is ', [nic_8254_irq]
; ;Enable PCI Bus Mastering
; MOV EAX, [R8 + pci_map_entry.location]
; OR EAX, 0x01 << 2 ; Get Status/Command. TODO: replace with constant
; CALL pci_read_register
; BTS EAX, 2
; MOV EBX, EAX
; MOV EAX, [R8 + pci_map_entry.location]
; CALL pci_write_register
;Get the MAC address
MOV RSI, [nic_8254_base_address]
; Low 4 bytes...
MOV EAX, [RSI + 0x5400]
MOV [nic_8254_mac_address], EAX
MOV [nic_8254_mac_address], AL
SHR EAX, 8
MOV [nic_8254_mac_address + 1], AL
SHR EAX, 8
MOV [nic_8254_mac_address + 2], AL
SHR EAX, 8
MOV [nic_8254_mac_address + 3], AL
;and high 2 bytes...
MOV EAX, [RSI + 0x5404]
MOV [nic_8254_mac_address + 4], AL
SHR EAX, 8
MOV [nic_8254_mac_address + 5], AL
DEBUG_WRITE_VAR 'MAC Address from MMIO is ', [nic_8254_mac_address]
;try again from EEPROM
MOV RSI, [nic_8254_base_address]
MOV EAX, 0x00000001
MOV [RSI+0x14], eax
MOV EAX, [rsi+0x14]
SHR EAX, 16
MOV [nic_8254_mac_address], AL
SHR EAX, 8
MOV [nic_8254_mac_address + 1], AL
MOV EAX, 0x00000101
MOV [RSI+0x14], EAX
MOV EAX, [RSI + 0x14]
SHR EAX, 16
MOV [nic_8254_mac_address + 2], AL
SHR EAX, 8
MOV [nic_8254_mac_address + 3], AL
MOV EAX, 0x0000020
MOV [RSI + 0x14], EAX
MOV EAX, [RSI +0x14]
SHR EAX, 16
MOV [nic_8254_mac_address + 4], AL
SHR EAX, 8
MOV [nic_8254_mac_address + 5], AL
DEBUG_WRITE_VAR 'MAC Address from EEPROM is ', [nic_8254_mac_address]
MOV ESI, [R8 + pci_map_entry.location] ;**DEBUG_BREAK**
SHOW_PCI_REGISTERS
WAIT_FOREVER
MOV RDX, R8 ;restore RDX
RET
nic_8254_init_done:
For this NIC family on VMWARE, I get the same results.
I might try another NIC, eg RTL8139(?) and see if I get similar results.
Thanks again!
David