1 /*
2  * Copyright (C) 2015-2017 Alibaba Group Holding Limited
3  */
4 
5 #ifndef K_SYS_H
6 #define K_SYS_H
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 /** @addtogroup aos_rhino sys
13  *  OS system functions
14  *
15  *  @{
16  */
17 
18 #define RHINO_VERSION       12000
19 #define RHINO_IDLE_PRI      (RHINO_CONFIG_PRI_MAX - 1)
20 
21 #define RHINO_NO_WAIT       0u
22 #define RHINO_WAIT_FOREVER  ((tick_t)-1)
23 #define RHINO_MAX_TICKS     ((tick_t)-1 >> 1)
24 
25 typedef enum
26 {
27     RHINO_FALSE = 0u,
28     RHINO_TRUE  = 1u
29 } RHINO_BOOL;
30 
31 typedef char     name_t;
32 typedef uint8_t  suspend_nested_t;
33 typedef uint32_t sem_count_t;
34 typedef uint32_t mutex_nested_t;
35 typedef uint64_t sys_time_t;
36 typedef uint64_t tick_t;
37 typedef int64_t  tick_i_t;
38 typedef uint64_t idle_count_t;
39 typedef uint64_t ctx_switch_t;
40 
41 #if (RHINO_CONFIG_INTRPT_STACK_OVF_CHECK > 0)
42 #if (RHINO_CONFIG_CPU_STACK_DOWN > 0)
43 extern cpu_stack_t *g_intrpt_stack_bottom;
44 #else
45 extern cpu_stack_t *g_intrpt_stack_top;
46 #endif
47 #endif /* RHINO_CONFIG_INTRPT_STACK_OVF_CHECK */
48 
49 /**
50  * Init krhino.
51  *
52  * @param[in]  NULL
53  *
54  * @return the operation status, RHINO_SUCCESS is OK, others is error
55  *
56  */
57 kstat_t krhino_init(void);
58 
59 /**
60  * Start krhino.
61  *
62  * @param[in]  NULL
63  *
64  * @return the operation status, RHINO_SUCCESS is OK, others is error
65  */
66 kstat_t krhino_start(void);
67 
68 /**
69  * Interrupt handler starts, called when enter interrupt.
70  *
71  * @param[in]  NULL
72  *
73  * @return the operation status, RHINO_SUCCESS is OK, others is error
74  */
75 kstat_t krhino_intrpt_enter(void);
76 
77 /**
78  * Interrupt handler ends, called when exit interrupt.
79  *
80  * @param[in]  NULL
81  *
82  * @return  NULL
83  */
84 void krhino_intrpt_exit(void);
85 
86 /**
87  * Check system stack (used by interrupt) overflow.
88  *
89  * @param[in]  NULL
90  *
91  * @return  NULL
92  */
93 void krhino_intrpt_stack_ovf_check(void);
94 
95 /**
96  * Get the number of ticks before next os tick event.
97  *
98  * @param[in]  NULL
99  *
100  * @return  RHINO_WAIT_FOREVER or the number of ticks
101  */
102 tick_t krhino_next_sleep_ticks_get(void);
103 
104 /**
105  * Get the whole ram space used by krhino global variable.
106  *
107  * @param[in]  NULL
108  *
109  * @return  the whole ram space used by kernel
110  */
111 size_t krhino_global_space_get(void);
112 
113 /**
114  * Get kernel version.
115  *
116  * @param[in]  NULL
117  *
118  * @return the kernel version
119  */
120 uint32_t krhino_version_get(void);
121 
122 /** @} */
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #endif /* K_SYS_H */
129 
130