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

hal-x86_64: want API for local APIC timer in oneshot mode #498

Open
hawkw opened this issue Dec 31, 2024 · 0 comments
Open

hal-x86_64: want API for local APIC timer in oneshot mode #498

hawkw opened this issue Dec 31, 2024 · 0 comments
Labels
arch/x86_64 area/hal Related to the hardware abstraction layer kind/enhancement New feature or request

Comments

@hawkw
Copy link
Owner

hawkw commented Dec 31, 2024

currently, the x86_64 HAL has a nice method for configuring the local APIC timer as a periodic timer, but there's no corresponding API for using it as a one-shot timer.

we use the oneshot timer internally for calibrating the local APIC timer frequency, here:

unsafe {
// set timer divisor to 16
self.write_register(TIMER_DIVISOR, 0b11);
// set initial count to -1
self.write_register(TIMER_INITIAL_COUNT, -1i32 as u32);
// start the timer
self.write_register(
LVT_TIMER,
LvtTimer::new().with(LvtTimer::MODE, TimerMode::OneShot),
);
}
// use the PIT to sleep for 10ms
pit.sleep_blocking(Duration::from_millis(10))
.expect("the PIT should be able to send a 10ms interrupt...");
unsafe {
// stop the timer
self.write_register(
LVT_TIMER,
LvtTimer::new().with(LvtTimer::MODE, TimerMode::Periodic),
);
}

but we don't provide an interface for it. we should probably fix that.

@hawkw hawkw added arch/x86_64 kind/enhancement New feature or request area/hal Related to the hardware abstraction layer labels Dec 31, 2024
hawkw added a commit that referenced this issue Jan 5, 2025
This way, we don't re-calibrate every time we call
`start_periodic_timer`. This will also be used when adding the one-shot
timer mode (see #498).
hawkw added a commit that referenced this issue Jan 5, 2025
This is a rudimentary first pass on #498 adding a method to `LocalApic`
to trigger a single oneshot timer interrupt after a given duration. It
would be nice to also have a full-on blocking sleep method, like we do
for the PIT.
hawkw added a commit that referenced this issue Jan 5, 2025
This way, we don't re-calibrate every time we call
`start_periodic_timer`. This will also be used when adding the one-shot
timer mode (see #498).
hawkw added a commit that referenced this issue Jan 5, 2025
This is a rudimentary first pass on #498 adding a method to `LocalApic`
to trigger a single oneshot timer interrupt after a given duration. It
would be nice to also have a full-on blocking sleep method, like we do
for the PIT.
hawkw added a commit that referenced this issue Jan 5, 2025
This way, we don't re-calibrate every time we call
`start_periodic_timer`. This will also be used when adding the one-shot
timer mode (see #498).
hawkw added a commit that referenced this issue Jan 5, 2025
This is a rudimentary first pass on #498 adding a method to `LocalApic`
to trigger a single oneshot timer interrupt after a given duration. It
would be nice to also have a full-on blocking sleep method, like we do
for the PIT.
hawkw added a commit that referenced this issue Jan 11, 2025
This way, we don't re-calibrate every time we call
`start_periodic_timer`. This will also be used when adding the one-shot
timer mode (see #498).
hawkw added a commit that referenced this issue Jan 11, 2025
This is a rudimentary first pass on #498 adding a method to `LocalApic`
to trigger a single oneshot timer interrupt after a given duration. It
would be nice to also have a full-on blocking sleep method, like we do
for the PIT.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch/x86_64 area/hal Related to the hardware abstraction layer kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant