Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timer abstraction #569

Closed

Conversation

tsoutsman
Copy link
Member

@tsoutsman tsoutsman commented Jul 19, 2022

This pull request abstracts hardware timers behind a generic ClockSource trait.

All existing functionality has been implemented, but there are a couple of additional features that can be addressed either in this PR, or a separate PR:

  • Supporting the APIC timer as a monotonic clock source
  • Supporting 32-bit HPETs
  • A source of randomness. Some of the network drivers were using HPET ticks as a seed for a PRNG which is obviously less than ideal. I replaced them with calls to for now _rdseed64_step but I'm not sure QEMU supports the instruction.
  • Natively calibrating the TSC. As I've written in a comment above the commented out native calibration code: "[Native calibration] does not work on QEMU. It returns a numerator, denominator, and hertz but they are wrong."
  • Supporting the RTC as a monotonic clock source? The code for RTC interrupts is there but I've commented it out for now.
  • Don't double initialise timers (once in register_early_sleeper and again in register_clock_source). This isn't currently an issue as running a source's init function twice happens to not cause problems but is something we should definitely fix.

@tsoutsman tsoutsman marked this pull request as ready for review July 19, 2022 03:08
tsoutsman added 24 commits July 19, 2022 17:43
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
There are still visible bugs.

Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
I've given up on commit messages because they just all blur together

Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
The caller should be able to differentiate between the clock not
existing and an error occuring during initialisation.

Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
@tsoutsman tsoutsman closed this Dec 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant