Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / kernel-module-evklib / agldd / ev_common.h
1 /**
2  * @file ev_common.h
3  * @brief Event library -- User kernel common data structure
4  *
5  * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 #ifndef _ev_common_h_
20 #define _ev_common_h_
21
22 #include <agldd/ev_id.h>
23
24 /** @addtogroup EV
25  * @{ */
26 /** @brief Maximum number of bytes for message event */
27 #define EV_MAX_MESSAGE_LENGTH 2048
28
29 /** @brief -Maximum number of flag queue that can be created within a thread */
30 #define EV_MAX_IDS_IN_THREAD            24
31
32 /** @brief -Muximum number of threads that can be registered to the EV in a process */
33 #define EV_MAX_THREADS_IN_PROCESS       16
34
35 /** @brief -Maximum number of flag queue that can be creat within a process
36  */
37 #define EV_MAX_IDS_IN_PROCESS                                   \
38                 (EV_MAX_IDS_IN_THREAD * EV_MAX_THREADS_IN_PROCESS)
39
40 /** @brief Return values for even library function
41  *
42  * @see EV_ERR
43  */
44 enum ev_err
45 {
46         EV_OK = 0,              /**< Normal completion */
47         EV_ERR_Exist,           /**< The specified flag message queue does exist */
48         EV_ERR_Invalid_ID,      /**< The specified flag message queue does not exist */
49         EV_ERR_Busy,            /**< Message queue full failed to send */
50         EV_ERR_Interrupted,     /**< Waiting function was interrupted by an interrupt */
51         EV_ERR_Thread_Over,     /**< Exceeding the number of threads in the process */
52         EV_ERR_Invalid_Thread,  /**< Invalid thread ID */
53         EV_ERR_Fatal,           /**< Fatal error */
54 };
55 /** @brief Return values type for even library function
56  *
57  * @see ev_err
58  */
59 typedef INT32 EV_ERR;
60
61 /** @brief Event type
62  *
63  * Use in the type of EV_Event structs
64  * @see ev_type
65  */
66 typedef UINT32 EV_Type;
67
68 /** @brief Bit value representing the type of event */
69 enum ev_type {
70   EV_EVENT_None = 0x00000000,
71
72   /** Flag event: Judged by EV_EVENT_IS_FLAG() */
73   EV_EVENT_Flag = 0x0001,
74 #define EV_EVENT_IS_FLAG(tp) (((tp) & EV_EVENT_Flag) != 0)
75
76   /** Message event: Judged by EV_EVENT_IS_MESSAGE() */
77   EV_EVENT_Message = 0x0002,
78 #define EV_EVENT_IS_MESSAGE(tp) (((tp) & EV_EVENT_Message) != 0)
79
80   /** 64bit flag event: Judged by EV_EVENT_IS_FLAG64() */
81   EV_EVENT_Flag64 = 0x0003,
82 #define EV_EVENT_IS_FLAG64(tp) (((tp) & EV_EVENT_Flag64) != 0)
83
84 };
85
86 /** @brief Flag event structure */
87 typedef struct {
88   EV_ID flagID;/**< Flag ID */
89   UINT32 bits;/**< Bit pattern */
90 } EV_Flag;
91
92 /** @brief 64bit flag event structure */
93 typedef struct {
94   EV_ID flagID;/**< Flag ID */
95   UINT64 bits;/**< Bit pattern */
96 } EV_Flag64;
97
98 /** @brief Message event structure */
99 typedef struct {
100   EV_ID queueID;/**< queue ID */
101   UINT32 senderInfo;/**< Source information */
102   UINT32 length;/**< Number of bytes in the message */
103   UINT32 dummy;/** dummy for pading */
104   UINT8  message[EV_MAX_MESSAGE_LENGTH];/**< Message */
105 } EV_Message;
106
107 /** @brief Event structure */
108 typedef struct {
109   EV_Type type; /**< Event type */
110   union {
111     EV_Flag flag; /**< Flag event structure */
112     EV_Flag64 flag64; /**< Flag event structure */
113     EV_Message message; /**< Message event structure */
114   } u; /**< Union of structures per eventtype */
115 } EV_Event;
116
117 /** @brief Message event queue type
118  *
119  * Specify the action to be taken when the queue overflows (more events are received when the queue is full).
120  */
121 enum ev_message_queue_type {
122   EV_MESSAGE_QUEUE_TYPE_BUSY,/**< Return a BUSY to the source */
123   EV_MESSAGE_QUEUE_TYPE_FIFO,/**< Delete the oldest event */
124   EV_MESSAGE_QUEUE_TYPE_REPLACE,/**< Replace the most recent event */
125 };
126
127 /** @brief Messge event queue type
128  *
129  * @see ev_message_queue_type
130  */
131 typedef UINT8 EV_Message_Queue_Type;
132
133 /** @} */
134
135 #endif /* !_ev_common_h_ */