Intel 8254x: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content added Content deleted
No edit summary |
m (Bot: Replace deprecated source tag with syntaxhighlight) |
||
Line 29: | Line 29: | ||
When using MMIO, reading/writing to/from registers is very straight-forward. |
When using MMIO, reading/writing to/from registers is very straight-forward. |
||
< |
<syntaxhighlight lang="c"> |
||
*(uint32_t *)(ioaddr + reg) = val; // writes "val" to an MMIO address |
*(uint32_t *)(ioaddr + reg) = val; // writes "val" to an MMIO address |
||
val = *(uint32_t *)(ioaddr + reg); // reads "val" from 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. |
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: | 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. |
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. |
||
< |
<syntaxhighlight lang="c"> |
||
outl(ioaddr + 0x00, reg); // set the IOADDR window |
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 |
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 |
inl(ioaddr + 0x04); // read back the value |
||
</syntaxhighlight> |
|||
</source> |
|||
== Initialization == |
== Initialization == |
||
Line 109: | Line 109: | ||
Obtaining the MAC is quite trivial and only requires reading the first 3-words of the EEPROM. |
Obtaining the MAC is quite trivial and only requires reading the first 3-words of the EEPROM. |
||
< |
<syntaxhighlight lang="c"> |
||
uint8_t dev_info.mac_addr[6]; |
uint8_t dev_info.mac_addr[6]; |
||
Line 118: | Line 118: | ||
*((uint16_t *)&dev_info.mac_addr[4]) = i8254x_read_eeprom(0x02); |
*((uint16_t *)&dev_info.mac_addr[4]) = i8254x_read_eeprom(0x02); |
||
i8254x_unlock_eeprom(); |
i8254x_unlock_eeprom(); |
||
</syntaxhighlight> |
|||
</source> |
|||
== Emulation == |
== Emulation == |