rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame^] | 1 | /***************************************************************************** |
| 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 | * mmrf_kal.h |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * TK6291 Project |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * MM Layer 1 system service adaption interface |
| 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 | * |
| 72 | * removed! |
| 73 | * removed! |
| 74 | * |
| 75 | * removed! |
| 76 | * removed! |
| 77 | * |
| 78 | * removed! |
| 79 | * removed! |
| 80 | * removed! |
| 81 | * removed! |
| 82 | * |
| 83 | * removed! |
| 84 | * removed! |
| 85 | * |
| 86 | * removed! |
| 87 | * removed! |
| 88 | * removed! |
| 89 | * removed! |
| 90 | * |
| 91 | * removed! |
| 92 | * removed! |
| 93 | * removed! |
| 94 | * |
| 95 | * removed! |
| 96 | * removed! |
| 97 | * removed! |
| 98 | * |
| 99 | * removed! |
| 100 | * removed! |
| 101 | * removed! |
| 102 | * |
| 103 | * removed! |
| 104 | * removed! |
| 105 | * removed! |
| 106 | * removed! |
| 107 | * |
| 108 | * removed! |
| 109 | * removed! |
| 110 | * removed! |
| 111 | * |
| 112 | * removed! |
| 113 | * removed! |
| 114 | * |
| 115 | * removed! |
| 116 | * removed! |
| 117 | * |
| 118 | * removed! |
| 119 | * removed! |
| 120 | * |
| 121 | * removed! |
| 122 | * removed! |
| 123 | * |
| 124 | *------------------------------------------------------------------------------ |
| 125 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 126 | *============================================================================ |
| 127 | ****************************************************************************/ |
| 128 | |
| 129 | #ifndef _MMRF_KAL_H_ |
| 130 | #define _MMRF_KAL_H_ |
| 131 | |
| 132 | #if !defined(GEN_FOR_PC) |
| 133 | //#include <stdarg.h> |
| 134 | #if !defined(__MTK_TARGET__) && ! defined (__UL1_ON_MNT__) |
| 135 | #include <stdlib.h> //[RHR] : malloc function needs this header file in L1 Simulation |
| 136 | #endif |
| 137 | //#include <stdio.h> |
| 138 | //#include <string.h> |
| 139 | #endif // GEN_FOR_PC |
| 140 | |
| 141 | /* auto add by kw_check begin */ |
| 142 | #include "kal_public_api.h" |
| 143 | #include "kal_general_types.h" |
| 144 | #include "kal_public_defs.h" //MSBB change #include "stack_config.h" |
| 145 | /* auto add by kw_check end */ |
| 146 | |
| 147 | #if defined(__MTK_TARGET__) || defined(__UL1_ON_MNT__) || defined(__UE_SIMULATOR__) |
| 148 | /* Task Management */ |
| 149 | #include "task_config.h" |
| 150 | #endif /* __MTK_TARGET__ */ |
| 151 | |
| 152 | #include "sync_data.h" |
| 153 | #include "cache_sw.h" |
| 154 | #include "mmu.h" |
| 155 | |
| 156 | /* YYH : copy from ul1_kal.h and some modification */ |
| 157 | /* define share memory */ |
| 158 | #define MMRF_DEFINE_NC_SHARED_VAR(type, name) DEFINE_NC_SHARED_VAR(type, name) |
| 159 | #define MMRF_DEFINE_NC_SHARED_ARRAY(type, name, size) DEFINE_NC_SHARED_ARRAY(type, name, size) |
| 160 | #define MMRF_DEFINE_NC_SHARED_VAR_ASSIGN(type, name, ...) DEFINE_NC_SHARED_VAR_ASSIGN(type, name, __VA_ARGS__) |
| 161 | #define MMRF_DEFINE_NC_SHARED_ARRAY_ASSIGN(type, name, size, ...) DEFINE_NC_SHARED_ARRAY_ASSIGN(type, name, size, __VA_ARGS__) |
| 162 | #define MMRF_DEFINE_DNC_SHARED_VAR(type, name) DEFINE_DNC_SHARED_VAR(type, name) |
| 163 | #define MMRF_DEFINE_DNC_SHARED_ARRAY(type, name, size) DEFINE_DNC_SHARED_ARRAY(type, name, size) |
| 164 | #define MMRF_DEFINE_DNC_SHARED_VAR_ASSIGN(type, name, ...) DEFINE_DNC_SHARED_VAR_ASSIGN(type, name, __VA_ARGS__) |
| 165 | #define MMRF_DEFINE_DNC_SHARED_ARRAY_ASSIGN(type, name, size, ...) DEFINE_DNC_SHARED_ARRAY_ASSIGN(type, name, size, __VA_ARGS__) |
| 166 | |
| 167 | #define MMRF_DECLARE_SHARED_VAR(type, name) DECLARE_SHARED_VAR(type, name) |
| 168 | #define MMRF_DECLARE_SHARED_ARRAY(type, name, size) DECLARE_SHARED_ARRAY(type, name, size) |
| 169 | |
| 170 | #define MMRF_SHARED_VAR(name) SHARED_VAR(name) |
| 171 | #define MMRF_SHARED_ARRAY(name) SHARED_ARRAY(name) |
| 172 | #define MMRF_SHARED_pVAR(name) SHARED_pVAR(name) |
| 173 | #define MMRF_SHARED_pARRAY(name) SHARED_pARRAY(name) |
| 174 | |
| 175 | #define MMRF_WRITE_SHARED_VAR(a, b)\ |
| 176 | {\ |
| 177 | SHARED_VAR(a) = b;\ |
| 178 | Data_Sync_Barrier();\ |
| 179 | } |
| 180 | |
| 181 | #define MMRF_RCU_MEMORY_SIZE(size, num) RCU_MEMORY_SIZE(size, num) |
| 182 | #define MMRF_RCU_CREATE(buff_addr, allocated_buff_size, buff_size, reserved) rcu_create( buff_addr, allocated_buff_size, buff_size, reserved ) |
| 183 | #define MMRF_RCU_GET_FREE_BUFF(id) rcu_get_free_buff(id) |
| 184 | #define MMRF_RCU_COMMIT_DATA(data) rcu_commit_data(data) |
| 185 | #define MMRF_RCU_GET_READ_LOCK(id) rcu_get_read_lock(id) |
| 186 | #define MMRF_RCU_FREE_READ_LOCK(data) rcu_free_read_lock(data) |
| 187 | |
| 188 | #define MMRF_ALIGNTOCACHELINE(size) ALIGNTOCACHELINE(size) |
| 189 | |
| 190 | /* Marcos for Cross-Core RF custom data*/ |
| 191 | /* SHM Declare Macros for RF data */ |
| 192 | #if (IS_MMRF_MT6291_DUAL_CORE_ARCH) |
| 193 | #define MMRF_CUSTOM_DEFINE_SHARED_ARRAY(type, name, size) MMRF_DEFINE_DNC_SHARED_ARRAY(type, name, size) |
| 194 | #define MMRF_CUSTOM_DEFINE_SHARED_VAR(type, name) MMRF_DEFINE_DNC_SHARED_VAR(type, name) |
| 195 | #define MMRF_CUSTOM_DEFINE_SHARED_ARRAY_ASSIGN(type, name, size, ...) MMRF_DEFINE_DNC_SHARED_ARRAY_ASSIGN(type, name, size, __VA_ARGS__) |
| 196 | #define MMRF_CUSTOM_DEFINE_SHARED_VAR_ASSIGN(type, name, ...) MMRF_DEFINE_DNC_SHARED_VAR_ASSIGN(type, name, __VA_ARGS__) |
| 197 | #else |
| 198 | #define MMRF_CUSTOM_DEFINE_SHARED_ARRAY(type, name, size) type name[size]; |
| 199 | #define MMRF_CUSTOM_DEFINE_SHARED_VAR(type, name) type name; |
| 200 | #define MMRF_CUSTOM_DEFINE_SHARED_ARRAY_ASSIGN(type, name, size, ...) type name[size] = {__VA_ARGS__}; |
| 201 | #define MMRF_CUSTOM_DEFINE_SHARED_VAR_ASSIGN(type, name, ...) type name = {__VA_ARGS__}; |
| 202 | #endif |
| 203 | |
| 204 | /* SHM Extern Macros for RF data */ |
| 205 | #define MMRF_CUSTOM_DECLARE_SHARED_VAR(type, name) MMRF_DECLARE_SHARED_VAR(type, name) |
| 206 | #define MMRF_CUSTOM_DECLARE_SHARED_ARRAY(type, name, size) MMRF_DECLARE_SHARED_ARRAY(type, name, size) |
| 207 | |
| 208 | /* SHM Usage Macros for RF data */ |
| 209 | #define MMRF_CUSTOM_SHARED_VAR(name) MMRF_SHARED_VAR(name) |
| 210 | #define MMRF_CUSTOM_SHARED_ARRAY(name) MMRF_SHARED_ARRAY(name) |
| 211 | #define MMRF_CUSTOM_SHARED_pVAR(name) MMRF_SHARED_pVAR(name) |
| 212 | #define MMRF_CUSTOM_SHARED_pARRAY(name) MMRF_SHARED_pARRAY(name) |
| 213 | |
| 214 | /* SHM Cacheable Macros for RF data*/ |
| 215 | /* Temperarily disbale for calify the usage of cachabel API */ |
| 216 | #if 0//!defined(L1_SIM) && defined(__DYNAMIC_SWITCH_CACHEABILITY__) |
| 217 | /* under construction !*/ |
| 218 | /* under construction !*/ |
| 219 | /* under construction !*/ |
| 220 | /* under construction !*/ |
| 221 | /* under construction !*/ |
| 222 | /* under construction !*/ |
| 223 | /* under construction !*/ |
| 224 | /* under construction !*/ |
| 225 | #else |
| 226 | #define MMRF_CUSTOM_SHARED_DATA_SET_TO_CACHE(ptr, size) |
| 227 | #define MMRF_CUSTOM_SHARED_DATA_SET_TO_NOCACHE(ptr, size) |
| 228 | #define MMRF_CUSTOM_SHARED_DATA_CACHE_FLUSH(ptr, size) |
| 229 | #endif |
| 230 | |
| 231 | /******************************************************************************* |
| 232 | * Destination queue id definition |
| 233 | *******************************************************************************/ |
| 234 | #define GS_QUEUE_MMRF_PCORE MOD_MMRF_PCORE |
| 235 | #define GS_QUEUE_MMRF MOD_MMRF |
| 236 | #define GS_QUEUE_MMRF_XL1TST MOD_MMRF_XL1TST |
| 237 | |
| 238 | |
| 239 | /******************************************************************************* |
| 240 | * L1 compiler version related MACRO definition |
| 241 | *******************************************************************************/ |
| 242 | #if defined(__MTK_TARGET__) |
| 243 | #if defined (__ARMCC_VERSION) |
| 244 | #define INLINE __inline |
| 245 | #elif defined (__GNUC__) |
| 246 | #define INLINE inline |
| 247 | #endif /* ARMCC , GNUC */ |
| 248 | #else /* __MTK_TARGET__ */ |
| 249 | #define INLINE __inline |
| 250 | #endif /* __MTK_TARGET__ */ |
| 251 | |
| 252 | /******************************************************************************* |
| 253 | * L1 system service related MACRO definition |
| 254 | *******************************************************************************/ |
| 255 | #if defined(__MTK_TARGET__) || defined(__UE_SIMULATOR__) || defined(__UL1_ON_MNT__) || defined(UNIT_TEST) |
| 256 | /******************************************************************************* |
| 257 | * Destination module id definition |
| 258 | *******************************************************************************/ |
| 259 | #define MOD_ID_MMRF_PCORE MOD_MMRF_PCORE |
| 260 | #define MOD_ID_MMRF MOD_MMRF |
| 261 | #define MOD_ID_MMRF_XL1TST MOD_MMRF_XL1TST |
| 262 | |
| 263 | |
| 264 | #define MMRF_ALLOC_BUF(byte_size) get_ctrl_buffer(byte_size) |
| 265 | #define MMRF_FREE_BUF(buf) free_ctrl_buffer(buf) |
| 266 | |
| 267 | #define MMRF_OPEN_MESSAGE_QUEUE(queue) (KAL_SUCCESS) |
| 268 | #define MMRF_OPEN_INT_MESSAGE_QUEUE(queue) (KAL_SUCCESS) |
| 269 | |
| 270 | |
| 271 | #define MMRF_SEND_MSG(src_mod, dest_mod, sap, msg, local_para, peer_buf) \ |
| 272 | { msg_send6((src_mod), (dest_mod), (sap), (msg), (local_para_struct*)(local_para), (peer_buff_struct *) (peer_buf)); } |
| 273 | |
| 274 | #define MMRF_SEND_CC_MSG(src_mod, dest_mod, sap, msg, local_para, peer_buf) \ |
| 275 | { \ |
| 276 | msg_send6_cc((src_mod), (dest_mod), (sap), (msg), (local_para_struct*)(local_para), (peer_buff_struct *) (peer_buf)); \ |
| 277 | } |
| 278 | |
| 279 | #define MMRF_RECV_EXT_MSG_PCORE(ilm_ptr) msg_receive_extq(ilm_ptr) |
| 280 | #define MMRF_RECV_INT_MSG_PCORE(ilm_ptr) msg_receive_intq(ilm_ptr) |
| 281 | #define MMRF_RECV_EXT_MSG(ilm_ptr) msg_receive_extq(ilm_ptr) |
| 282 | #define MMRF_RECV_INT_MSG(ilm_ptr) msg_receive_intq(ilm_ptr) |
| 283 | #define MMRF_XL1TST_RECV_EXT_MSG(ilm_ptr) msg_receive_extq(ilm_ptr) |
| 284 | #define MMRF_FREE_MSG(ilm_ptr) { destroy_ilm(ilm_ptr); } |
| 285 | #define MMRF_XL1TST_FREE_MSG(ilm_ptr) { destroy_ilm(ilm_ptr); } |
| 286 | |
| 287 | |
| 288 | #define MMRF_FREE_LOCAL_PARA(a) { free_local_para(a); } |
| 289 | #define MMRF_HOLD_LOCAL_PARA(a) { hold_local_para_r(a); } |
| 290 | |
| 291 | |
| 292 | static INLINE local_para_struct* MMRF_ALLOC_LOCAL_PARA(kal_uint32 size) |
| 293 | { |
| 294 | return construct_local_para(size, TD_RESET); |
| 295 | } |
| 296 | |
| 297 | /* Cross-core API */ |
| 298 | static INLINE local_para_struct* MMRF_ALLOC_CC_LOCAL_PARA(kal_uint32 size) |
| 299 | { |
| 300 | return construct_cc_non_cached_local_para(size, TD_RESET); |
| 301 | } |
| 302 | |
| 303 | static INLINE kal_uint8* MMRF_ALLOC_PEERBUF(kal_uint32 size) |
| 304 | { |
| 305 | kal_uint8 *pPeerBuff; |
| 306 | |
| 307 | pPeerBuff = construct_peer_buff(size, 0, 0, TD_RESET); |
| 308 | |
| 309 | return pPeerBuff; |
| 310 | } |
| 311 | |
| 312 | static INLINE kal_uint8* MMRF_ALLOC_CC_PEERBUF(kal_uint32 size) |
| 313 | { |
| 314 | kal_uint8 *pPeerBuff; |
| 315 | |
| 316 | pPeerBuff = construct_cc_non_cached_peer_buff(size, 0, 0, TD_RESET); |
| 317 | |
| 318 | return pPeerBuff; |
| 319 | } |
| 320 | |
| 321 | static INLINE kal_uint8* MMRF_GET_PEERBUF(void *_pPeerBuff, kal_uint16* buf_length_ptr) |
| 322 | { |
| 323 | kal_uint8 *pPduData; |
| 324 | |
| 325 | if(buf_length_ptr) |
| 326 | { |
| 327 | *buf_length_ptr = ((peer_buff_struct *)_pPeerBuff)->pdu_len; |
| 328 | } |
| 329 | |
| 330 | pPduData = (kal_uint8 *)get_peer_buff_pdu((peer_buff_struct *)_pPeerBuff, buf_length_ptr); |
| 331 | |
| 332 | return pPduData; |
| 333 | } |
| 334 | |
| 335 | #else /* for simulation */ |
| 336 | |
| 337 | extern ilm_struct simu_ilm_pool[]; |
| 338 | |
| 339 | typedef unsigned long dword; /* 4 byte variable */ |
| 340 | typedef unsigned short word; /* 2 byte variable */ |
| 341 | typedef signed short sword; /* 2 byte variable */ |
| 342 | typedef unsigned char boolean; /* 1 byte variable */ |
| 343 | |
| 344 | #define false KAL_FALSE |
| 345 | #define true KAL_TRUE |
| 346 | |
| 347 | /******************************************************************************* |
| 348 | * Destination module id definition |
| 349 | *******************************************************************************/ |
| 350 | #define MOD_ID_MMRF_PCORE MOD_MMRF_PCORE |
| 351 | #define MOD_ID_MMRF MOD_MMRF |
| 352 | #define MOD_ID_MMRF_XL1TST MOD_MMRF_XL1TST |
| 353 | |
| 354 | extern kal_status gs_open_message_queue(kal_uint32); |
| 355 | extern kal_status gs_open_int_message_queue(kal_uint32); |
| 356 | extern kal_status gs_send_message(module_type, module_type, void *, kal_bool); |
| 357 | //extern kal_status gs_send_int_message(module_type, void *, kal_bool); |
| 358 | extern kal_status gs_read_message(kal_uint32, void *, kal_uint16, kal_bool); |
| 359 | extern kal_status gs_read_int_message(kal_uint32, void *, kal_uint16, kal_bool); |
| 360 | |
| 361 | |
| 362 | #define MMRF_ALLOC_BUF(byte_size) malloc(byte_size) |
| 363 | |
| 364 | #define MMRF_FREE_BUF(buf) free(buf) |
| 365 | |
| 366 | #define MMRF_OPEN_MESSAGE_QUEUE(queue) \ |
| 367 | gs_open_message_queue((queue)) |
| 368 | |
| 369 | #define MMRF_OPEN_INT_MESSAGE_QUEUE(queue) \ |
| 370 | gs_open_int_message_queue((queue)) |
| 371 | |
| 372 | |
| 373 | module_type GetQueueID(module_type mod_id); |
| 374 | static INLINE void MMRF_SEND_MSG(module_type src_mod, module_type dest_mod, sap_type sap_id, msg_type msg_id, local_para_struct *local_para, peer_buff_struct *peer_buf) |
| 375 | { |
| 376 | ilm_struct *ilm_ptr; |
| 377 | module_type queue_id; |
| 378 | |
| 379 | ilm_ptr = &simu_ilm_pool[src_mod]; |
| 380 | ilm_ptr->src_mod_id = src_mod; |
| 381 | ilm_ptr->dest_mod_id = dest_mod; |
| 382 | ilm_ptr->sap_id = sap_id; |
| 383 | ilm_ptr->msg_id = msg_id; |
| 384 | ilm_ptr->local_para_ptr = local_para; |
| 385 | ilm_ptr->peer_buff_ptr = peer_buf; |
| 386 | queue_id = GetQueueID(dest_mod); |
| 387 | |
| 388 | #if 0 |
| 389 | /* under construction !*/ |
| 390 | /* under construction !*/ |
| 391 | /* under construction !*/ |
| 392 | /* under construction !*/ |
| 393 | /* under construction !*/ |
| 394 | /* under construction !*/ |
| 395 | /* under construction !*/ |
| 396 | /* under construction !*/ |
| 397 | /* under construction !*/ |
| 398 | /* under construction !*/ |
| 399 | /* under construction !*/ |
| 400 | #endif |
| 401 | gs_send_message(src_mod, queue_id, ilm_ptr, KAL_TRUE); |
| 402 | |
| 403 | } |
| 404 | |
| 405 | static INLINE void MMRF_SEND_CC_MSG(module_type src_mod, module_type dest_mod, sap_type sap_id, msg_type msg_id, local_para_struct *local_para, peer_buff_struct *peer_buf) |
| 406 | { |
| 407 | MMRF_SEND_MSG( src_mod, dest_mod, sap_id, msg_id, local_para, peer_buf); |
| 408 | } |
| 409 | |
| 410 | #define MMRF_RECV_EXT_MSG_PCORE(ilm_ptr) \ |
| 411 | gs_read_message(GS_QUEUE_MMRF_PCORE, ilm_ptr, sizeof(ilm_struct), true) |
| 412 | |
| 413 | #define MMRF_RECV_INT_MSG_PCORE(ilm_ptr) \ |
| 414 | gs_read_int_message(GS_QUEUE_MMRF_PCORE, ilm_ptr, sizeof(ilm_struct), true) |
| 415 | |
| 416 | #define MMRF_RECV_EXT_MSG(ilm_ptr) \ |
| 417 | gs_read_message(GS_QUEUE_MMRF, ilm_ptr, sizeof(ilm_struct), true) |
| 418 | |
| 419 | #define MMRF_RECV_INT_MSG(ilm_ptr) \ |
| 420 | gs_read_int_message(GS_QUEUE_MMRF, ilm_ptr, sizeof(ilm_struct), true) |
| 421 | |
| 422 | #define MMRF_XL1TST_RECV_EXT_MSG(ilm_ptr) \ |
| 423 | gs_read_message(GS_QUEUE_MMRF_XL1TST, ilm_ptr, sizeof(ilm_struct), true) |
| 424 | |
| 425 | #define MMRF_FREE_MSG(ilm_ptr) if ((ilm_ptr)->src_mod_id != MOD_TIMER)\ |
| 426 | {\ |
| 427 | if((ilm_ptr)->local_para_ptr->ref_count == 0)\ |
| 428 | ASSERT(KAL_FALSE);\ |
| 429 | (ilm_ptr)->local_para_ptr->ref_count--;\ |
| 430 | if((ilm_ptr)->local_para_ptr->ref_count == 0)\ |
| 431 | free((ilm_ptr)->local_para_ptr);\ |
| 432 | } |
| 433 | |
| 434 | #define MMRF_XL1TST_FREE_MSG(ilm_ptr) if ((ilm_ptr)->src_mod_id != MOD_TIMER)\ |
| 435 | {\ |
| 436 | if((ilm_ptr)->local_para_ptr!=NULL)\ |
| 437 | {\ |
| 438 | if((ilm_ptr)->local_para_ptr->ref_count == 0)\ |
| 439 | ASSERT(KAL_FALSE);\ |
| 440 | (ilm_ptr)->local_para_ptr->ref_count--;\ |
| 441 | if((ilm_ptr)->local_para_ptr->ref_count == 0)\ |
| 442 | free((ilm_ptr)->local_para_ptr);\ |
| 443 | }\ |
| 444 | if((ilm_ptr)->peer_buff_ptr!=NULL)\ |
| 445 | {\ |
| 446 | if((ilm_ptr)->peer_buff_ptr->ref_count == 0)\ |
| 447 | ASSERT(KAL_FALSE);\ |
| 448 | (ilm_ptr)->peer_buff_ptr->ref_count--;\ |
| 449 | if((ilm_ptr)->peer_buff_ptr->ref_count == 0)\ |
| 450 | free((ilm_ptr)->peer_buff_ptr);\ |
| 451 | }\ |
| 452 | } |
| 453 | |
| 454 | #define MMRF_FREE_LOCAL_PARA(a) if((a)->ref_count == 0)\ |
| 455 | ASSERT(KAL_FALSE);\ |
| 456 | (a)->ref_count--;\ |
| 457 | if((a)->ref_count == 0)\ |
| 458 | free(a) |
| 459 | |
| 460 | static INLINE kal_bool MMRF_HOLD_LOCAL_PARA(local_para_struct *local_para_ptr) |
| 461 | { |
| 462 | if (local_para_ptr != NULL) { |
| 463 | |
| 464 | local_para_ptr->ref_count++; |
| 465 | |
| 466 | return KAL_TRUE; |
| 467 | } |
| 468 | |
| 469 | return KAL_FALSE; |
| 470 | } |
| 471 | |
| 472 | static INLINE local_para_struct* MMRF_ALLOC_LOCAL_PARA(kal_uint32 size) |
| 473 | { |
| 474 | local_para_struct *local_para; |
| 475 | |
| 476 | if (size) |
| 477 | { |
| 478 | local_para = (local_para_struct *) malloc(size); |
| 479 | memset(local_para, 0, size); |
| 480 | local_para->ref_count = 1; |
| 481 | local_para->msg_len = (kal_uint16)size; |
| 482 | } |
| 483 | else |
| 484 | { |
| 485 | local_para = (local_para_struct *) malloc(sizeof(local_para_struct)); |
| 486 | memset(local_para, 0, sizeof(local_para_struct)); |
| 487 | local_para->ref_count = 1; |
| 488 | local_para->msg_len = 0; |
| 489 | } |
| 490 | return local_para; |
| 491 | } |
| 492 | |
| 493 | /* Cross-core API */ |
| 494 | static INLINE local_para_struct* MMRF_ALLOC_CC_LOCAL_PARA(kal_uint32 size) |
| 495 | { |
| 496 | return MMRF_ALLOC_LOCAL_PARA(size); |
| 497 | } |
| 498 | /* Cross-core API */ |
| 499 | |
| 500 | static INLINE kal_uint8* MMRF_ALLOC_PEERBUF(kal_uint32 size) |
| 501 | { |
| 502 | peer_buff_struct *pPduData; |
| 503 | |
| 504 | if( size ) |
| 505 | { |
| 506 | pPduData = (peer_buff_struct *)malloc(size+sizeof(peer_buff_struct)); |
| 507 | pPduData->pdu_len = (kal_uint16)size; |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | pPduData = (peer_buff_struct *)malloc(1+sizeof(peer_buff_struct)); |
| 512 | pPduData->pdu_len = 1; |
| 513 | } |
| 514 | |
| 515 | pPduData->ref_count = 1; |
| 516 | pPduData->pb_resvered = 0; |
| 517 | pPduData->free_header_space = 0; |
| 518 | pPduData->free_tail_space = 0; |
| 519 | |
| 520 | return (kal_uint8*)pPduData; |
| 521 | } |
| 522 | |
| 523 | static INLINE kal_uint8* MMRF_ALLOC_CC_PEERBUF(kal_uint32 size) |
| 524 | { |
| 525 | peer_buff_struct *pPduData; |
| 526 | |
| 527 | if( size ) |
| 528 | { |
| 529 | pPduData = (peer_buff_struct *)malloc(size+sizeof(peer_buff_struct)); |
| 530 | pPduData->pdu_len = (kal_uint16)size; |
| 531 | } |
| 532 | else |
| 533 | { |
| 534 | pPduData = (peer_buff_struct *)malloc(1+sizeof(peer_buff_struct)); |
| 535 | pPduData->pdu_len = 1; |
| 536 | } |
| 537 | |
| 538 | pPduData->ref_count = 1; |
| 539 | pPduData->pb_resvered = 0; |
| 540 | pPduData->free_header_space = 0; |
| 541 | pPduData->free_tail_space = 0; |
| 542 | |
| 543 | return (kal_uint8*)pPduData; |
| 544 | } |
| 545 | |
| 546 | |
| 547 | static INLINE kal_uint8* MMRF_GET_PEERBUF(void *_pPeerBuff, kal_uint16* buf_length_ptr) |
| 548 | { |
| 549 | kal_uint8 *pPduData; |
| 550 | |
| 551 | if(buf_length_ptr) |
| 552 | { |
| 553 | *buf_length_ptr = ((peer_buff_struct *)_pPeerBuff)->pdu_len; |
| 554 | } |
| 555 | |
| 556 | pPduData = (kal_uint8 *)get_peer_buff_pdu((peer_buff_struct *)_pPeerBuff, buf_length_ptr); |
| 557 | |
| 558 | return pPduData; |
| 559 | } |
| 560 | |
| 561 | #endif /* __MTK_TARGET__ */ |
| 562 | |
| 563 | |
| 564 | #endif /* _MMRF_KAL_H_ */ |
| 565 | |
| 566 | |