blob: 1cbf5154949edc16b5ccaac2b01e659593566ecf [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2005
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*****************************************************************************/
35
36/*****************************************************************************
37 *
38 * Filename:
39 * ---------
40 * event_shed.h
41 *
42 * Project:
43 * --------
44 * Maui_Software
45 *
46 * Description:
47 * ------------
48 * Header file for Event Scheduler.
49 *
50 * Author:
51 * -------
52 * -------
53 *
54 *============================================================================
55 * HISTORY
56 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
57 *------------------------------------------------------------------------------
58 * removed!
59 * removed!
60 * removed!
61 *
62 * removed!
63 * removed!
64 *
65 * removed!
66 * removed!
67 * removed!
68 *
69 * removed!
70 * removed!
71 * removed!
72 *
73 * removed!
74 * removed!
75 * removed!
76 *
77 * removed!
78 * removed!
79 * removed!
80 *
81 * removed!
82 * removed!
83 * removed!
84 *
85 * removed!
86 * removed!
87 * removed!
88 *
89 * removed!
90 * removed!
91 * removed!
92 *
93 * removed!
94 * removed!
95 * removed!
96 *
97 * removed!
98 * removed!
99 * removed!
100 *
101 * removed!
102 * removed!
103 * removed!
104 *
105 * removed!
106 * removed!
107 * removed!
108 *
109 * removed!
110 * removed!
111 * removed!
112 *
113 * removed!
114 * removed!
115 * removed!
116 *
117 * removed!
118 * removed!
119 * removed!
120 *
121 * removed!
122 * removed!
123 * removed!
124 *
125 * removed!
126 * removed!
127 * removed!
128 *
129 * removed!
130 * removed!
131 * removed!
132 *
133 * removed!
134 * removed!
135 * removed!
136 *
137 * removed!
138 * removed!
139 * removed!
140 *
141 * removed!
142 * removed!
143 * removed!
144 *
145 * removed!
146 * removed!
147 * removed!
148 * removed!
149 * removed!
150 * removed!
151 * removed!
152 * removed!
153 * removed!
154 * removed!
155 * removed!
156 * removed!
157 * removed!
158 * removed!
159 * removed!
160 * removed!
161 * removed!
162 * removed!
163 * removed!
164 * removed!
165 * removed!
166 * removed!
167 * removed!
168 * removed!
169 * removed!
170 * removed!
171 * removed!
172 * removed!
173 * removed!
174 * removed!
175 * removed!
176 * removed!
177 *------------------------------------------------------------------------------
178 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
179 *============================================================================
180 ****************************************************************************/
181
182/*********************************************************************
183 (C) _____ (year of first publication) Sasken communication
184 Technologies Limited, All rights reserved.
185* This file provides a template for .c files. This space
186* should be used to describe the file contents
187* Component-specific prefix : xxxx
188*********************************************************************/
189
190#ifndef _EVENT_SHED_H
191#define _EVENT_SHED_H
192/*RHR*/
193#include "kal_general_types.h"
194#include "stacklib.h"
195#include "kal_public_defs.h"
196#include "mlib_dll.h"
197/*RHR*/
198
199/*************************************************************************
200 * Type Definitions
201 *************************************************************************/
202typedef void (*start_timer_fptr)(void *, unsigned int);
203typedef void (*stop_timer_fptr)(void *);
204
205typedef enum {
206 ES_TIMER_INITIALIZED,
207 ES_TIMER_NOT_RUNNING = ES_TIMER_INITIALIZED,
208 ES_TIMER_RUNNING,
209 ES_TIMER_NOT_TIMED_OUT = ES_TIMER_RUNNING, /* Backward compatiable */
210 ES_TIMER_EXPIRED,
211 ES_TIMER_TIMED_OUT = ES_TIMER_EXPIRED, /* Backward compatiable */
212 ES_TIMER_STOPPED
213} es_timer_status_type;
214
215typedef struct event_scheduler_int {
216 /* event's double-linked list */
217 list_node *dll;
218 /*introduce the head to prevent fuzz accumulate*/
219 list_node *fuzzhead;
220 /* event's expired dll list split in evshed_timer_handler() */
221 list_node *expired_dllhead;
222
223 /* scheduler's reference time base */
224 kal_uint32 t_ref_ticks;
225
226 /* scheduler's pattern, EVSHED_TIMER_ID */
227 kal_uint8 evshed_timer_id[3];
228
229 /* scheduler's suspend flag */
230 kal_bool is_suspend;
231
232 kal_uint32 fuzz;
233
234 /* kal timer pointer */
235 kal_timerid kal_timer_id;
236
237 /* timer status from event-scheduler's view */
238 es_timer_status_type es_timer_status;
239
240 /* user's destination module id (receiver mod id) */
241 module_type dest_mod_id;
242
243 /* descrimivate multiple event schedulers if same receiver mod id*/
244 kal_uint16 es_user_index;
245
246 /*for avoiding race condition by NU protect or windows mutex*/
247 void *es_protect;
248
249 /*for detecting concurrent operation occurs or not*/
250 kal_int32 cur_owner;
251
252 /* reserved for adding newer feature. bit 0: 1 to enable 1ms tick unit */
253 kal_uint32 es_feature_mask;
254//#if defined(__EVENT_CNT_PROFILING__)
255 /* record active event count */
256 kal_uint32 event_cnt;
257
258 /* record history event max count */
259 kal_uint32 event_cnt_his_max;
260 kal_uint32 event_cnt_his_max_timing;
261//#endif /*__EVENT_CNT_PROFILING__*/
262} event_scheduler_int;
263
264typedef struct event {
265 list_node ev_node;
266 kal_timer_func_ptr event_hf;
267 void * event_hf_param;
268 kal_uint32 abs_time;
269 event_scheduler_int
270 *owneres; /* a pointer points back to the event's onwer(event scheduler) */
271 kal_uint32 event_index;
272} event;
273
274#if defined(__EVENT_CNT_PROFILING__)
275typedef struct {
276 event_scheduler_int *es;
277 event_scheduler_int *es_his;
278 kal_uint32 event_cnt;
279 kal_uint32 event_cnt_his_max;
280 kal_uint32 timing;
281} event_record_int;
282
283#define EVT_CNT_LIMITATION 256
284#define RECORD_NUM 10
285#endif /*__EVENT_CNT_PROFILING__*/
286
287#define node2event(node) List2Container(node, event, ev_node)
288
289#define evshed_update_fuzzhead(es,eid) { es->fuzzhead = eid; }
290
291#define EVSHED_TIMER_ID 0x00545645UL
292
293#define IS_VALID_EVSHED_TIMER(es) \
294 (((kal_uint32) * ((kal_uint32 *)es->evshed_timer_id) & 0x00FFFFFF) == \
295 (EVSHED_TIMER_ID & 0x00FFFFFF))
296
297extern void evshed_msg_send(event_scheduler_int *es);
298#endif /* _EVENT_SHED_H */