Skip to content

switch to crate arm_pl031 to read the realtime clock #1694

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stlankes
Copy link
Contributor

@stlankes stlankes commented Apr 25, 2025

If the application is running on top of Qemu, the ARM PrimeCell Real Time Clock(PL031) can be used to determine the boot time. By this patch, the crate arm_pl031 is used as interface to the real time clock.

uhyve doesn't support the real-time clock. To detemine the unix timestamp, the boot time from bootinfo is used

@stlankes stlankes requested review from mkroening and fstracke April 25, 2025 21:58
@stlankes stlankes force-pushed the pl031 branch 3 times, most recently from 934645e to c1143d6 Compare April 25, 2025 22:23
@@ -221,27 +207,14 @@ pub fn detect_frequency() {
fn __set_oneshot_timer(wakeup_time: Option<u64>) {
if let Some(wt) = wakeup_time {
// wt is the absolute wakeup time in microseconds based on processor::get_timer_ticks.
let deadline = u128::from(wt) * u128::from(CPU_FREQUENCY.get()) / 1_000_000;
let deadline = u64::try_from(deadline).unwrap();
let deadline = (wt * u64::from(get_frequency())) / 1000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is fine, but I'd suggest double-checking that a u64 is sufficient here (was u128 before).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this part to #1703

@jounathaen
Copy link
Member

In general: LGTM 👍

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.

2 participants