-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit moves the `pit` and `tsc` modules out of `interrupt` and `cpu`, and into a new `time` module. This feels like a better organization of things, IMO.
- Loading branch information
Showing
7 changed files
with
282 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! x86 hardware timers and timekeeping functionality. | ||
pub(crate) mod pit; | ||
mod tsc; | ||
pub use self::{ | ||
pit::{Pit, PIT}, | ||
tsc::Rdtsc, | ||
}; | ||
use core::fmt; | ||
pub use core::time::Duration; | ||
|
||
/// Error indicating that a [`Duration`] was invalid for a particular use. | ||
#[derive(Copy, Clone, Debug, Eq, PartialEq)] | ||
pub struct InvalidDuration { | ||
duration: Duration, | ||
message: &'static str, | ||
} | ||
|
||
// === impl InvalidDuration === | ||
|
||
impl fmt::Display for InvalidDuration { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
let Self { duration, message } = self; | ||
write!(f, "invalid duration {duration:?}: {message}") | ||
} | ||
} | ||
|
||
impl InvalidDuration { | ||
/// Returns the [`Duration`] that was invalid. | ||
#[must_use] | ||
pub fn duration(self) -> Duration { | ||
self.duration | ||
} | ||
|
||
#[must_use] | ||
pub(crate) fn new(duration: Duration, message: &'static str) -> Self { | ||
Self { duration, message } | ||
} | ||
} |
Oops, something went wrong.