1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*
18  * Implementation Notes
19  * Platforms must only supply chpp/platform/platform_work_monitor.h if they
20  * set the CHPP_ENABLE_WORK_MONITOR macro in their builds.
21  */
22 
23 #ifndef CHPP_WORK_MONITOR_H_
24 #define CHPP_WORK_MONITOR_H_
25 
26 #ifdef CHPP_ENABLE_WORK_MONITOR
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /*
33  * Platform-specific work monitor struct, defined in the platform's
34  * platform_work_monitor.h file.
35  */
36 struct ChppWorkMonitor;
37 
38 /*
39  * Initializes a specified platform-specific work monitor.
40  *
41  * @param workMonitor points to the ChppWorkMonitor mutex struct.
42  */
43 static void chppWorkMonitorInit(struct ChppWorkMonitor *workMonitor);
44 
45 /*
46  * Deinitializes a specified platform-specific work monitor.
47  *
48  * @param workMonitor points to the ChppWorkMonitor mutex struct.
49  */
50 static void chppWorkMonitorDeinit(struct ChppWorkMonitor *workMonitor);
51 
52 /*
53  * Called before CHPP starts doing work on the transport thread. This allows
54  * platforms to start something like a watchdog to ensure the CHPP thread
55  * is caught if it gets stuck.
56  *
57  * @param workMonitor points to the ChppWorkMonitor mutex struct.
58  */
59 static void chppWorkMonitorPreProcess(struct ChppWorkMonitor *workMonitor);
60 
61 /*
62  * Called after CHPP finished doing work on the transport thread. This allows
63  * platforms to stop any watchdog tracking the thread.
64  *
65  * @param workMonitor points to the ChppWorkMonitor mutex struct.
66  */
67 static void chppWorkMonitorPostProcess(struct ChppWorkMonitor *workMonitor);
68 
69 #ifdef __cplusplus
70 }
71 #endif
72 
73 #include "chpp/platform/platform_work_monitor.h"
74 
75 #endif  // CHPP_ENABLE_WORK_MONITOR
76 #endif  // CHPP_WORK_MONITOR_H_
77