1 /* 2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, this list of 9 * conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 12 * of conditions and the following disclaimer in the documentation and/or other materials 13 * provided with the distribution. 14 * 15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 16 * to endorse or promote products derived from this software without specific prior written 17 * permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifndef _LOS_SWTMR_PRI_H 33 #define _LOS_SWTMR_PRI_H 34 35 #include "los_swtmr.h" 36 #include "los_spinlock.h" 37 #include "los_sched_pri.h" 38 39 #ifdef LOSCFG_SECURITY_VID 40 #include "vid_api.h" 41 #else 42 #define MAX_INVALID_TIMER_VID OS_SWTMR_MAX_TIMERID 43 #endif 44 45 #ifdef __cplusplus 46 #if __cplusplus 47 extern "C" { 48 #endif /* __cplusplus */ 49 #endif /* __cplusplus */ 50 51 /** 52 * @ingroup los_swtmr_pri 53 * Software timer state 54 */ 55 enum SwtmrState { 56 OS_SWTMR_STATUS_UNUSED, /**< The software timer is not used. */ 57 OS_SWTMR_STATUS_CREATED, /**< The software timer is created. */ 58 OS_SWTMR_STATUS_TICKING /**< The software timer is timing. */ 59 }; 60 61 /** 62 * @ingroup los_swtmr_pri 63 * Structure of the callback function that handles software timer timeout 64 */ 65 typedef struct { 66 SWTMR_PROC_FUNC handler; /**< Callback function that handles software timer timeout */ 67 UINTPTR arg; /**< Parameter passed in when the callback function 68 that handles software timer timeout is called */ 69 } SwtmrHandlerItem; 70 71 /** 72 * @ingroup los_swtmr_pri 73 * Type of the pointer to the structure of the callback function that handles software timer timeout 74 */ 75 typedef SwtmrHandlerItem *SwtmrHandlerItemPtr; 76 77 extern SWTMR_CTRL_S *g_swtmrCBArray; 78 79 #define OS_SWT_FROM_SID(swtmrID) ((SWTMR_CTRL_S *)g_swtmrCBArray + ((swtmrID) % LOSCFG_BASE_CORE_SWTMR_LIMIT)) 80 81 /** 82 * @ingroup los_swtmr_pri 83 * @brief Scan a software timer. 84 * 85 * @par Description: 86 * <ul> 87 * <li>This API is used to scan a software timer when a Tick interrupt occurs and determine whether 88 * the software timer expires.</li> 89 * </ul> 90 * @attention 91 * <ul> 92 * <li>None.</li> 93 * </ul> 94 * 95 * @param None. 96 * 97 * @retval None. 98 * @par Dependency: 99 * <ul><li>los_swtmr_pri.h: the header file that contains the API declaration.</li></ul> 100 * @see LOS_SwtmrStop 101 */ 102 103 extern BOOL OsIsSwtmrTask(const LosTaskCB *taskCB); 104 extern VOID OsSwtmrRestart(UINT64 startTime, SortLinkList *sortList); 105 extern VOID OsSwtmrWake(SchedRunQue *rq, UINT64 currTime, SortLinkList *sortList); 106 extern UINT32 OsSwtmrInit(VOID); 107 extern VOID OsSwtmrRecycle(UINT32 processID); 108 extern BOOL OsSwtmrWorkQueueFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg); 109 extern SPIN_LOCK_S g_swtmrSpin; 110 #ifdef __cplusplus 111 #if __cplusplus 112 } 113 #endif /* __cplusplus */ 114 #endif /* __cplusplus */ 115 116 #endif /* _LOS_SWTMR_PRI_H */ 117