Coverage Report

Created: 2026-05-24 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/spdm-rs/spdmlib/src/watchdog/mod.rs
Line
Count
Source
1
// Copyright (c) 2023 Intel Corporation
2
//
3
// SPDX-License-Identifier: Apache-2.0 or MIT
4
5
mod watchdog_callbacks;
6
7
pub use watchdog_callbacks::SpdmWatchDog;
8
9
use conquer_once::spin::OnceCell;
10
11
static WATCHDOG_INSTANCE: OnceCell<SpdmWatchDog> = OnceCell::uninit();
12
13
static DEFAULT: SpdmWatchDog = SpdmWatchDog {
14
0
    start_watchdog_cb: |_session_id: u32, _seconds: u16| unimplemented!(),
15
0
    stop_watchdog_cb: |_session_id: u32| unimplemented!(),
16
0
    reset_watchdog_cb: |_session_id: u32| unimplemented!(),
17
};
18
19
0
pub fn register(context: SpdmWatchDog) -> bool {
20
0
    WATCHDOG_INSTANCE.try_init_once(|| context).is_ok()
21
0
}
22
23
0
pub fn start_watchdog(session_id: u32, seconds: u16) {
24
0
    (WATCHDOG_INSTANCE
25
0
        .try_get_or_init(|| DEFAULT.clone())
26
0
        .ok()
27
0
        .unwrap()
28
0
        .start_watchdog_cb)(session_id, seconds)
29
0
}
30
31
0
pub fn stop_watchdog(session_id: u32) {
32
0
    (WATCHDOG_INSTANCE
33
0
        .try_get_or_init(|| DEFAULT.clone())
34
0
        .ok()
35
0
        .unwrap()
36
0
        .stop_watchdog_cb)(session_id)
37
0
}
38
39
0
pub fn reset_watchdog(session_id: u32) {
40
0
    (WATCHDOG_INSTANCE
41
0
        .try_get_or_init(|| DEFAULT.clone())
42
0
        .ok()
43
0
        .unwrap()
44
0
        .reset_watchdog_cb)(session_id)
45
0
}