1 /*
2  * Copyright (C) 2015-2021 Alibaba Group Holding Limited
3  */
4 
5 #ifndef AOS_RHINO_H
6 #define AOS_RHINO_H
7 
8 #include <stdint.h>
9 
10 #include "kernel.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /**
17  * Get a task pthread control block.
18  *
19  * @param[in]   task        task handle
20  * @param[out]  ptcb        the returned ptcb handle
21  *
22  * @return  0:  success     otherwise failed
23  */
24 aos_status_t aos_task_ptcb_get(aos_task_t *task, void **ptcb);
25 
26 /**
27  * Set a task pthread control block.
28  *
29  * @param[in]   task        task handle
30  * @param[in]   ptcb        the ptcb handle
31  *
32  * @return  0:  success     otherwise failed
33  */
34 aos_status_t aos_task_ptcb_set(aos_task_t *task, void *ptcb);
35 
36 /**
37  * Change a task's schedule priority
38  *
39  * @param[in]   task        task handle
40  * @param[in]   pri         the new task priority
41  * @param[out]  old_pri     the returned old task priority
42  *
43  * @return  0:  success     otherwise failed
44  */
45 aos_status_t aos_task_pri_change(aos_task_t *task, uint8_t pri, uint8_t *old_pri);
46 
47 /**
48  * Get a task's schedule priority
49  *
50  * @param[in]   task        task handle
51  * @param[out]  priority    the returned old task priority
52  *
53  * @return  0:  success     otherwise failed
54  */
55 aos_status_t aos_task_pri_get(aos_task_t *task, uint8_t *priority);
56 
57 /**
58  * Set a task's schedule policy
59  *
60  * @param[in]   task        task handle
61  * @param[in]   policy      the new task's policy
62  * @param[in]   pri         the new task's priority
63  *
64  * @return  0:  success     otherwise failed
65  */
66 aos_status_t aos_task_sched_policy_set(aos_task_t *task, uint8_t policy, uint8_t pri);
67 
68 /**
69  * Get a task's schedule policy
70  *
71  * @param[in]   task        task handle
72  * @param[out]  policy      the returned task's policy
73  *
74  * @return  0:  success     otherwise failed
75  */
76 aos_status_t aos_task_sched_policy_get(aos_task_t *task, uint8_t *policy);
77 
78 /**
79  * Get a task's default schedule policy
80  *
81  * @return  KSCHED_CFS or KSCHED_RR
82  */
83 uint32_t aos_task_sched_policy_get_default();
84 
85 /**
86  * Set a task's schedule time slice
87  *
88  * @param[in]   task        task handle
89  * @param[in]   slice       the new schedule time slice
90  *
91  * @return  0:  success     otherwise failed
92  */
93 aos_status_t aos_task_time_slice_set(aos_task_t *task, uint32_t slice);
94 
95 /**
96  * Get a task's schedule time slice
97  *
98  * @param[in]   task        task handle
99  * @param[out]  slice       the returned task's time slice
100  *
101  * @return  0:  success     otherwise failed
102  */
103 aos_status_t aos_task_time_slice_get(aos_task_t *task, uint32_t *slice);
104 
105 /**
106  * Get the maximum number of system's schedule priority
107  *
108  * @param[in]   task        task handle
109  * @param[in]   policy      the task's schedule policy
110  *
111  * @return  maximum schedule priority
112  */
113 uint32_t aos_sched_get_priority_max(uint32_t policy);
114 
115 /**
116  * Get the minimum number of system's schedule priority
117  *
118  * @param[in]   task        task handle
119  * @param[in]   policy      the task's schedule policy
120  *
121  * @return  minimum schedule priority
122  */
aos_sched_get_priority_min(uint32_t policy)123 static inline uint32_t aos_sched_get_priority_min(uint32_t policy)
124 {
125     return 1;
126 }
127 
128 /**
129  * Get the timer's time vaule.
130  *
131  * @param[in]  timer  pointer to the timer.
132  * @param[out] value  store the returned time.
133  *
134  * @return  0: success, otherwise error.
135  */
136 aos_status_t aos_timer_gettime(aos_hdl_t *timer, uint64_t value[]);
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 #endif /*AOS_RHINO_H*/
142