Search code examples
linux-kernelx86-64pcinic

Programming guide for Intel Corporation 82545EM ethernet card


OS: Centos x86_64
Ethernet Driver: E1000

root@localhost e1000]# cat /proc/ioports | grep e1000
      2000-203f : e1000

[root@localhost e1000]# cat /proc/iomem | grep e1000
      fd5c0000-fd5dffff : e1000
      fdff0000-fdffffff : e1000

Given the above information and the physical card (Intel Corporation 82545EM), how would gain a better understanding of how the io_ports or io_mem relate to the Intel Corporation 82545EM card?

For instance, how would one know under what situation to use an io_port vs an io_mem address? Is there some type of API I can use that lists what each port address is for and how to use them?

How does the io_mem addresses relate to a DMA address?

Thanks


Solution

  • The programming interface (including which ports do what) should be documented by Intel; they're usually fairly good about documenting the programming interface for their hardware (unlike some vendors which only provide drivers. Although open-source Linux drivers usually have pretty decent comments about which ports are what).

    But no, hardware is not self documenting in that level of detail. Instead, HW vendors publish documentation (usually online). It would add extra hardware complexity to have a standard API for hardware to how to tell you how to program it, and just knowing names for each MMIO or programmed-IO port number wouldn't tell you the semantics of how to use them.


    On x86, IO ports are a separate address space from memory, used by the in and out instructions instead of mov load/store.

    Modern hardware mostly uses memory-mapped I/O where plain loads / stores to special addresses access IO registers on the device. (After being translated to PCI / PCIe messages).

    Instead of trying to write a giant answer to this, I'm just to point you at https://en.wikipedia.org/wiki/Memory-mapped_I/O where you can read about that vs. port I/O vs. DMA, with links to more stuff.

    One reasonable-size SO answer won't be able to teach you all the stuff you don't know about how drivers interact with hardware, sorry. There are whole books on the subject, but other than books I'm not sure what resources to point you at. http://wiki.osdev.org/ has lots of good stuff, for example it has the programming details for several kinds of ethernet card. http://wiki.osdev.org/Intel_Ethernet_i217 is quite long. It starts out:

    I am writing this Wiki as a demonstration of my own experience of getting a working driver for the Intel I217 and 82577LM network cards to work, on a real native bare metal hardware,

    It's a card that Linux uses e1000e for, not e1000. Have a look at the other NICs there are articles about and see if one of them is an e1000 card, if you're specifically interested in your own hardware. (Simpler hardware like NE2000 might be a better starting point than a fancy Intel NIC.)