I'm trying to implement HPET on my hobby OS. After I read this article: https://wiki.osdev.org/HPET, I want to ask one thing: Can you explain this line?
Code: Select all
write_register_64(timer_configuration(n), (ioapic_input << 9) | (1 << 2));
Code: Select all
write_register_64(timer_configuration(n), (ioapic_input << 9) | (1 << 2));
That's the problem, I don't know what I should write. I have worked with registers, memory,... but this is my first time with MMIO register. In my case, is that I have to use port and outX/inX?Octocontrabass wrote:It's a function that writes a 64-bit value to a MMIO register.
No, "memory mapped" means you read and write it as if it was memory. Literally just store or read a value from the correct address.NeonLightions wrote:That's the problem, I don't know what I should write. I have worked with registers, memory,... but this is my first time with MMIO register. In my case, is that I have to use port and outX/inX?
The C standard still gives compilers some flexibility in how they implement volatile. GCC seems to handle it in a way that's appropriate for MMIO, but I'm pretty sure Clang does not!davmac314 wrote:You should use a volatile pointer to avoid the compiler re-ordering, collapsing or eliding the loads and stores.
I know that volatile has historically been problematic in both GCC and Clang (https://llvm.org/pubs/2008-10-EMSOFT-Volatiles.pdf) but I'm not aware of any current bugs in code generation around use of volatile in Clang. I'd be interested to see any example.Octocontrabass wrote:The C standard still gives compilers some flexibility in how they implement volatile. GCC seems to handle it in a way that's appropriate for MMIO, but I'm pretty sure Clang does not!