Reputation: 731
A PCI card can have some memory associated with it (either mapped to memory space or mapped to IO space).
Now say we have a PCI Ethernet card (and it is using memory-mapped IO), the Ethernet card will have some memory as a buffer to put data to send down the wire in, and whenever the Ethernet driver wants to send the data down the wire, it can ask the Ethernet card to do that.
Now I assume that a part of the mapped memory for the Ethernet card is a "command register", and when you write for example the string "send it"
to this command register, the Ethernet card will send the buffer down the wire.
Now my question is, how does the Ethernet card knows that the memory for the control register has been written to? does the Ethernet card polls the memory content for the control register, or is there some mechanism that is used to send a signal automatically to the Ethernet card whenever the memory address for the control register is written to (so kind of like an interrupt, but in the opposite direction)?
Upvotes: 0
Views: 491
Reputation: 364128
MMIO lets you use load and store instructions instead of IN
and OUT
instructions, but the device still sees commands, not just memory accesses.
That's why it's MMIO, not just memory-mapped device memory.
Upvotes: 0
Reputation: 12435
The address range of memory-mapped IO for a PCI card is controlled by the Base Address Registers (BARs) of the PCI device. When the CPU accesses a memory address within the range of a BAR, the memory access is routed directly to the device (along with the data, if it is a write operation), instead of being routed to memory. When the PCI device receives the memory access it immediately updates the designated control register. If the MMIO access is a read operation, the device responds to the CPU with the appropriate value.
Upvotes: 3