Intel 8254x: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
No edit summary
m Bot: Replace deprecated source tag with syntaxhighlight
Line 29:
When using MMIO, reading/writing to/from registers is very straight-forward.
 
<sourcesyntaxhighlight lang="c">
*(uint32_t *)(ioaddr + reg) = val; // writes "val" to an MMIO address
val = *(uint32_t *)(ioaddr + reg); // reads "val" from an MMIO address
</syntaxhighlight>
</source>
 
When using IO, reading/writing to/from registers is a little more complicated as the IO address space for the 8254x is only 8 bytes wide.
Line 38:
IOADDR holds the IO address that the IODATA window operates on. So, basic operation is to set the IOADDR window and then the desired action using the IODATA window.
 
<sourcesyntaxhighlight lang="c">
outl(ioaddr + 0x00, reg); // set the IOADDR window
outl(ioaddr + 0x04, val); // write the value to the IOADDR window which will end up in the register in IOADDR
inl(ioaddr + 0x04); // read back the value
</syntaxhighlight>
</source>
 
== Initialization ==
Line 109:
Obtaining the MAC is quite trivial and only requires reading the first 3-words of the EEPROM.
 
<sourcesyntaxhighlight lang="c">
uint8_t dev_info.mac_addr[6];
 
Line 118:
*((uint16_t *)&dev_info.mac_addr[4]) = i8254x_read_eeprom(0x02);
i8254x_unlock_eeprom();
</syntaxhighlight>
</source>
 
== Emulation ==