mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-19 12:30:17 +00:00
feat(bootloader-interface): measure time in firmware as well
This commit is contained in:
@@ -11,15 +11,21 @@ impl BootloaderInterface {
|
|||||||
const VENDOR: VariableVendor = VariableVendor(guid!("4a67b082-0a4c-41cf-b6c7-440b29bb8c4f"));
|
const VENDOR: VariableVendor = VariableVendor(guid!("4a67b082-0a4c-41cf-b6c7-440b29bb8c4f"));
|
||||||
|
|
||||||
/// Tell the system that Sprout was initialized at the current time.
|
/// Tell the system that Sprout was initialized at the current time.
|
||||||
pub fn mark_init() -> Result<()> {
|
pub fn mark_init(timer: &PlatformTimer) -> Result<()> {
|
||||||
Self::set_cstr16("LoaderTimeInitUSec", "0")
|
Self::mark_time("LoaderTimeInitUSec", timer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tell the system that Sprout is about to execute the boot entry.
|
/// Tell the system that Sprout is about to execute the boot entry.
|
||||||
pub fn mark_exec(timer: &PlatformTimer) -> Result<()> {
|
pub fn mark_exec(timer: &PlatformTimer) -> Result<()> {
|
||||||
// Measure the elapsed time since the bootloader was started.
|
Self::mark_time("LoaderTimeExecUSec", timer)
|
||||||
let elapsed = timer.elapsed();
|
}
|
||||||
Self::set_cstr16("LoaderTimeExecUSec", &elapsed.as_micros().to_string())
|
|
||||||
|
/// Tell the system about the current time as measured by the platform timer.
|
||||||
|
/// Sets the variable specified by `key` to the number of microseconds.
|
||||||
|
fn mark_time(key: &str, timer: &PlatformTimer) -> Result<()> {
|
||||||
|
// Measure the elapsed time since the hardware timer was started.
|
||||||
|
let elapsed = timer.elapsed_since_lifetime();
|
||||||
|
Self::set_cstr16(key, &elapsed.as_micros().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tell the system what the partition GUID of the ESP Sprout was booted from is.
|
/// Tell the system what the partition GUID of the ESP Sprout was booted from is.
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ fn run() -> Result<()> {
|
|||||||
let timer = PlatformTimer::start();
|
let timer = PlatformTimer::start();
|
||||||
|
|
||||||
// Mark the initialization of Sprout in the bootloader interface.
|
// Mark the initialization of Sprout in the bootloader interface.
|
||||||
BootloaderInterface::mark_init()
|
BootloaderInterface::mark_init(&timer)
|
||||||
.context("unable to mark initialization in bootloader interface")?;
|
.context("unable to mark initialization in bootloader interface")?;
|
||||||
|
|
||||||
// Parse the options to the sprout executable.
|
// Parse the options to the sprout executable.
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
/// timer: Platform timer support code.
|
/// timer: Platform timer support.
|
||||||
pub mod timer;
|
pub mod timer;
|
||||||
|
|||||||
@@ -73,8 +73,13 @@ impl PlatformTimer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Measure the elapsed duration since the hardware started ticking upwards.
|
||||||
|
pub fn elapsed_since_lifetime(&self) -> Duration {
|
||||||
|
self.frequency.duration(arch_ticks())
|
||||||
|
}
|
||||||
|
|
||||||
/// Measure the elapsed duration since the timer was started.
|
/// Measure the elapsed duration since the timer was started.
|
||||||
pub fn elapsed(&self) -> Duration {
|
pub fn elapsed_since_start(&self) -> Duration {
|
||||||
let duration = arch_ticks() - self.start;
|
let duration = arch_ticks() - self.start;
|
||||||
self.frequency.duration(duration)
|
self.frequency.duration(duration)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user