blob: 98b46708a041a542eea76ca8721d558775ecca60 [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 * kal_hrt_defs.h
41 *
42 * Project:
43 * --------
44 * Maui_Software
45 *
46 * Description:
47 * ------------
48 * This file provides KAL Hard Realtime Domain definitions
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 *
59 * removed!
60 * removed!
61 * removed!
62 *
63 * removed!
64 * removed!
65 * removed!
66 *
67 * removed!
68 * removed!
69 * removed!
70 *
71 * removed!
72 * removed!
73 * removed!
74 * removed!
75 *
76 * removed!
77 * removed!
78 * removed!
79 *
80 * removed!
81 * removed!
82 * removed!
83 *
84 * removed!
85 * removed!
86 * removed!
87 *
88 * removed!
89 * removed!
90 * removed!
91 *
92 * removed!
93 * removed!
94 * removed!
95 *
96 * removed!
97 * removed!
98 * removed!
99 *
100 * removed!
101 * removed!
102 * removed!
103 *
104 * removed!
105 * removed!
106 * removed!
107 *
108 * removed!
109 * removed!
110 * removed!
111 *
112 * removed!
113 * removed!
114 * removed!
115 *
116 * removed!
117 * removed!
118 * removed!
119 *
120 * removed!
121 * removed!
122 * removed!
123 *
124 * removed!
125 * removed!
126 * removed!
127 *
128 *------------------------------------------------------------------------------
129 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
130 *============================================================================
131 ****************************************************************************/
132#ifndef __KAL_HRT_DEFS_H__
133#define __KAL_HRT_DEFS_H__
134
135#if !defined(__PRODUCTION_RELEASE__)
136/* under construction !*/
137#endif /* __PRODUCTION_RELEASE__ */
138
139
140typedef struct kal_workqueue_node {
141 void * func_ptr;
142 void * func_param;
143 kal_uint16 func_index;
144//kal_uint8 reserved0;
145//kal_uint8 reserved1;
146#if defined(MT_FLOW_DEBUG)
147 kal_uint32 insert_timestamp;
148#endif /*MT_FLOW_DEBUG*/
149} kal_workqueue_node_t;
150
151#define MT_Q_HDR \
152 kal_uint32 head; \
153 kal_uint32 tail; \
154 kal_uint32 total_item; \
155 kal_uint32 lock; \
156 kal_bool is_full; \
157 kal_uint8 is_nested_irq_shared;
158
159typedef struct kal_workqueue_struct {
160 MT_Q_HDR
161 kal_workqueue_node_t queue[1];
162} kal_workqueue_struct;
163
164/* Circular queue definition for HRT domain */
165#define HRT_CQUEUE(_q, _length) \
166 struct { \
167 MT_Q_HDR \
168 kal_workqueue_node_t queue[_length]; \
169 } _q = { \
170 .head = 0, \
171 .tail = 0, \
172 .total_item = _length, \
173 .lock = 0, \
174 .is_full = KAL_FALSE, \
175 .is_nested_irq_shared = KAL_FALSE, \
176 }
177#if defined(MT_FLOW_DEBUG)
178#define HRT_CQUEUE_INSERT(_q, _item) \
179 do { \
180 _item.insert_timestamp = ust_get_current_time(); \
181 (_q).queue[(_q).tail] = _item; \
182 (_q).tail++; \
183 if ((_q).tail == (_q).total_item) \
184 (_q).tail = 0; \
185 if ((_q).head == (_q).tail) \
186 (_q).is_full = KAL_TRUE; \
187 } while (0)
188#else
189#define HRT_CQUEUE_INSERT(_q, _item) \
190 do { \
191 (_q).queue[(_q).tail] = _item; \
192 (_q).tail++; \
193 if ((_q).tail == (_q).total_item) \
194 (_q).tail = 0; \
195 if ((_q).head == (_q).tail) \
196 (_q).is_full = KAL_TRUE; \
197 } while (0)
198#endif
199#define HRT_CQUEUE_DISCARD(_q) \
200 do { \
201 (_q).head++; \
202 if ((_q).head == (_q).total_item) \
203 (_q).head = 0; \
204 if ((_q).is_full == KAL_TRUE) \
205 (_q).is_full = KAL_FALSE; \
206 } while (0)
207
208#define HRT_CQUEUE_IS_FULL(_q) ((_q).is_full)
209#define HRT_CQUEUE_IS_EMPTY(_q) (((_q).head == (_q).tail) && !(_q).is_full)
210
211#if defined(__MD97__) || defined(__MD97P__)
212/* 3 vpes/core, each vpe has 1 child tc*/
213#define MT_TCID_TO_WQID(tcid) 0
214/* only parent tc can call this */
215#define MT_WQID_TO_TCID(wqid) (miu_get_current_tc_id() + wqid + 1)
216#else
217#error no MT config yet
218#endif
219
220#define HRT_MT_SHARED_Q KAL_Q_MAX
221
222/* LISR multi-threading structure */
223#define LISR_MT_MAGIC_ID 0x454E4D54 // ENMT
224
225typedef struct {
226 kal_uint32 magic_id;
227 kal_uint32 wait;
228 kal_workqueue_struct *wq[KAL_Q_MAX];
229} kal_lisr_mt;
230
231typedef struct {
232 void *mt_stack_ptr[KAL_Q_MAX];
233} kal_mt_stack_ptr;
234
235#endif /* __KAL_HRT_DEFS_H__ */