1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *    http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __TEE_RTC_TIME_API_H
17 #define __TEE_RTC_TIME_API_H
18 
19 /**
20  * @addtogroup TeeTrusted
21  * @{
22  *
23  * @brief TEE(Trusted Excution Environment) API.
24  * Provides security capability APIs such as trusted storage, encryption and decryption,
25  * and trusted time for trusted application development.
26  *
27  * @since 12
28  */
29 
30 /**
31  * @file tee_rtc_time_api.h
32  *
33  * @brief Provides APIs about rtc timer.
34  *
35  * @library NA
36  * @kit TEEKit
37  * @syscap SystemCapability.Tee.TeeClient
38  * @since 12
39  * @version 1.0
40  */
41 
42 #include <tee_defines.h>
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 /**
49  * @brief Create a secure timer.
50  *
51  * @param time_seconds Indicates the security duration.
52  * @param timer_property Indicates the property of the timer, where only need to specify the timer type.
53  *
54  * @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
55  * @return Returns other values if the operation fails.
56  *
57  * @since 12
58  * @version 1.0
59  */
60 TEE_Result tee_ext_create_timer(uint32_t time_seconds, TEE_timer_property *timer_property);
61 
62 /**
63  * @brief Destory a secure timer.
64  *
65  * @param timer_property Indicates the property of the timer, where only need to specify the timer type.
66  *
67  * @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
68  * @return Returns other values if the operation fails.
69  *
70  * @since 12
71  * @version 1.0
72  */
73 TEE_Result tee_ext_destory_timer(TEE_timer_property *timer_property);
74 
75 /**
76  * @brief Obtain the set timing duration.
77  *
78  * @param timer_property Indicates the property of the timer, where only need to specify the timer type.
79  * @param time_seconds Indicates the timing duration.
80  *
81  * @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
82  * @return Returns other values if the operation fails.
83  *
84  * @since 12
85  * @version 1.0
86  */
87 TEE_Result tee_ext_get_timer_expire(TEE_timer_property *timer_property, uint32_t *time_seconds);
88 
89 /**
90  * @brief Obtain the remain timing duration.
91  *
92  * @param timer_property Indicates the property of the timer, where only need to specify the timer type.
93  * @param time_seconds Indicates the remain timing duration.
94  *
95  * @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
96  * @return Returns other values if the operation fails.
97  *
98  * @since 12
99  * @version 1.0
100  */
101 TEE_Result tee_ext_get_timer_remain(TEE_timer_property *timer_property, uint32_t *time_seconds);
102 
103 /**
104  * @brief Obtain the current timing of the RTC clock.
105  * @attention The obtained time is in seconds and cannot be converted to universal time.
106  *
107  * @return The RTC clock count(in seconds).
108  *
109  * @since 12
110  * @version 1.0
111  */
112 unsigned int tee_get_secure_rtc_time(void);
113 #ifdef __cplusplus
114 }
115 #endif
116 /** @} */
117 #endif