Anonymous user
Intel 8254x: Difference between revisions
Jump to navigation
Jump to search
m
Add syntax highlighting.
[unchecked revision] | [unchecked revision] |
No edit summary |
m (Add syntax highlighting.) |
||
Line 27:
There is also a BAR that will contain an I/O base address, this can be detected by looking at each BAR and testing bit 1.
When using MMIO, reading/writing to/from registers is very straight-forward.
*(uint32_t *)(ioaddr + reg) = val; // writes "val" to an MMIO address▼
<source lang="c">
val = *(uint32_t *)(ioaddr + reg); // reads "val" from an MMIO address▼
</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.
The register at offset 0x00 is the "IOADDR" window. The register at offset 0x04 is 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.
<source lang="c">
out32(ioaddr + 0x04, val); // write the value to the IOADDR window which will end up in the register in IOADDR▼
▲
in32(ioaddr + 0x04); // read back the value
</source>
== Emulation ==
|