@@ -70,6 +70,33 @@ pub fn get_time_and_caps() -> Result<(Time, TimeCapabilities)> {
7070 unsafe { ( rt. get_time ) ( time_ptr. cast ( ) , & mut caps) } . to_result_with_val ( || ( time, caps) )
7171}
7272
73+ /// Returns the next high 32 bits of the platform's monotonic counter.
74+ ///
75+ /// The high half of the counter is non-volatile and is incremented by this
76+ /// call. It is intended to be used by an operating system to extend the
77+ /// platform monotonic counter after exiting boot services: snapshot the full
78+ /// 64-bit value with [`boot::get_next_monotonic_count`] before
79+ /// `ExitBootServices`, manage the volatile low 32 bits locally, and call this
80+ /// function to bump the high 32 bits when the low half rolls over.
81+ ///
82+ /// # Errors
83+ ///
84+ /// * [`Status::DEVICE_ERROR`]: the counter could not be saved due to a hardware
85+ /// error.
86+ /// * [`Status::UNSUPPORTED`]: this platform does not support the monotonic
87+ /// counter at runtime.
88+ ///
89+ /// [`boot::get_next_monotonic_count`]: crate::boot::get_next_monotonic_count
90+ pub fn get_next_high_monotonic_count ( ) -> Result < u32 > {
91+ let rt = runtime_services_raw_panicking ( ) ;
92+ // SAFETY: The pointer is not null and we assume it to be initialized.
93+ let rt = unsafe { rt. as_ref ( ) } ;
94+
95+ let mut high_count = 0 ;
96+ // SAFETY: The memory is valid.
97+ unsafe { ( rt. get_next_high_monotonic_count ) ( & mut high_count) } . to_result_with_val ( || high_count)
98+ }
99+
73100/// Sets the current local time and date information
74101///
75102/// During runtime, if a PC-AT CMOS device is present in the platform, the
0 commit comments