l1_kal.h 17.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/

/*****************************************************************************
 *
 * Filename:
 * ---------
 * l1_kal.h
 *
 * Project:
 * --------
 *   Maui_Software
 *
 * Description:
 * ------------
 *   Layer 1 system service adaption interface
 *
 * Author:
 * -------
 * -------
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/

#ifndef _L1_KAL_H
#define _L1_KAL_H

#include "kal_release.h"
#include "stack_ltlcom.h"
#include "app_ltlcom.h"
#include "kal_public_api.h"
#include "kal_general_types.h"
#include "stack_config.h"

/* Maruco 20090108, for fix build error of L1 simulation for MONZA2G_GEMINI
 * For target load, codegen and build should not include stdlib.h
 * For MODIS/L1 simulation, codegen should not include stdlib.h 
 * but build should include it (GEN_FOR_PC is enabled when codegen) */
#ifndef GEN_FOR_PC
#ifndef __MTK_TARGET__
#include <stdlib.h>
#endif /* end of __MTK_TARGET__ */
#endif /* end of GEN_FOR_PC */

#ifdef DUMMY_PROTOCOL
#define MOD_MPAL              MOD_DUMMYMPAL
#endif

/*******************************************************************************
 * Destination queue id definition
 *******************************************************************************/
#if 0 /* elly */
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#else
#define GS_QUEUE_LAYER_1      MOD_L1
#define GS_QUEUE_LAYER_2      MOD_MPAL
#define GS_QUEUE_RR           MOD_MPAL
#define GS_QUEUE_CB           MOD_MPAL /* should be supported in another file */
#define GS_QUEUE_RLCMAC       MOD_MPAL
#define GS_QUEUE_L1HISR       MOD_L1HISR
#define GS_MAX_QUEUE          END_OF_MOD_ID
#if defined(__L1_GPS_REF_TIME_SUPPORT__) || defined(__L1_GPS_AUTO_TIMING_SYNC_SUPPORT__)
#define GS_QUEUE_GPS          MOD_GPS   /* Shihyao, add it to support GPS time sync procedure*/
#endif

#ifdef __GEMINI_GSM__ /*Maruco20071030*/
#define GS_QUEUE_LAYER_1_2      MOD_L1_2
#define GS_QUEUE_LAYER_2_2      MOD_MPAL_2
#define GS_QUEUE_RR_2           MOD_MPAL_2
#define GS_QUEUE_CB_2           MOD_MPAL_2 /* should be supported in another file */
#define GS_QUEUE_RLCMAC_2       MOD_MPAL_2
#define GS_QUEUE_RSVAS          MOD_RSVAS   /* Shihyao 20100315, add it becuase suspend procedure is handled by RSVAS instead of MPAL*/
#define GS_MAX_QUEUE_2          END_OF_MOD_ID

#if (GEMINI_PLUS_GSM >= 3)
#define GS_QUEUE_LAYER_1_3      MOD_L1_3
#define GS_QUEUE_LAYER_2_3      MOD_MPAL_3
#define GS_QUEUE_RR_3           MOD_MPAL_3
#define GS_QUEUE_CB_3           MOD_MPAL_3 /* should be supported in another file */
#define GS_QUEUE_RLCMAC_3       MOD_MPAL_3
#define GS_MAX_QUEUE_3          END_OF_MOD_ID

#if (GEMINI_PLUS_GSM >= 4)
#define GS_QUEUE_LAYER_1_4      MOD_L1_4
#define GS_QUEUE_LAYER_2_4      MOD_MPAL_4
#define GS_QUEUE_RR_4           MOD_MPAL_4
#define GS_QUEUE_CB_4           MOD_MPAL_4 /* should be supported in another file */
#define GS_QUEUE_RLCMAC_4       MOD_MPAL_4
#define GS_MAX_QUEUE_4          END_OF_MOD_ID
#endif /* end of (GEMINI_PLUS_GSM >= 4) */

#endif /* end of (GEMINI_PLUS_GSM >= 3) */

#else
#ifdef L1A_SIM
#define GS_QUEUE_RSVAS       MOD_RSVAS   /* Shihyao 20100315, add it becuase suspend procedure is handled by RSVAS instead of MPAL*/
#endif /* end of L1A_SIM */
#endif
#endif

/*******************************************************************************
 * L1 system service related MACRO definition
 *******************************************************************************/
#ifdef __MTK_TARGET__
/*******************************************************************************
 * Destination module id definition
 *******************************************************************************/
#define MOD_MPH_RR      MOD_MPAL
#define MOD_MPH_L2      MOD_MPAL
#define MOD_MPH_CB      MOD_MPAL
#define MOD_MPH_MAC     MOD_MPAL
#define MOD_MPH_L1      MOD_L1
#ifdef __MTK_TARGET__
#ifndef __L1_STANDALONE__
/*  Maruco20081223, add for using RF tool in engineering mode 
 *  L4C sends 4 new primitives(in em_sap.h) to L1A, 
 *  and L1A call L1C's function(in Rftool_types.h) to set parameters
 *  then L1C calls L1A's function to return primitive to MOD_UEM(module of L4C), 
 *  so L1A needs to define module(MOD_UEM) and EM(engineering mode)_SAP */
#define MOD_MPH_UEM   MOD_UEM
#endif /* end of __L1_STANDALONE__*/
#endif /* end of __MTK_TARGET__ */
#if defined(__L1_GPS_REF_TIME_SUPPORT__) || defined(__L1_GPS_AUTO_TIMING_SYNC_SUPPORT__)
/* Shihyao, add it to support GPS time sync procedure*/
#define MOD_MPH_GPS   MOD_GPS
#endif

/*Maruco20071024, define module of Slave*/
#ifdef __GEMINI_GSM__
#define MOD_MPH_RR_2      MOD_MPAL_2
#define MOD_MPH_L2_2      MOD_MPAL_2
#define MOD_MPH_CB_2      MOD_MPAL_2
#define MOD_MPH_MAC_2     MOD_MPAL_2
#define MOD_MPH_L1_2      MOD_L1_2
#define MOD_MPH_RSVAS     MOD_RSVAS   /* Shihyao 20100315, add it becuase suspend procedure is handled by RSVAS instead of MPAL*/

#if (GEMINI_PLUS_GSM >= 3)
#define MOD_MPH_RR_3      MOD_MPAL_3
#define MOD_MPH_L2_3      MOD_MPAL_3
#define MOD_MPH_CB_3      MOD_MPAL_3
#define MOD_MPH_MAC_3     MOD_MPAL_3
#define MOD_MPH_L1_3      MOD_L1_3

#if (GEMINI_PLUS_GSM >= 4)
#define MOD_MPH_RR_4      MOD_MPAL_4
#define MOD_MPH_L2_4      MOD_MPAL_4
#define MOD_MPH_CB_4      MOD_MPAL_4
#define MOD_MPH_MAC_4     MOD_MPAL_4
#define MOD_MPH_L1_4      MOD_L1_4
#endif /* end of (GEMINI_PLUS_GSM >= 4) */

#endif /* end of (GEMINI_PLUS_GSM >= 3) */
#endif

/* elly, already defined in ul1_kal.h */
/* Joy 070401 for MONZA keep the definition*/
#ifndef __MTK_UL1_FDD__
#define MOD_MPH_UL1     MOD_UL1 
#define MOD_MPH_UL1HISR	MOD_UL1HISR
#endif
#define MOD_MPH_L1HISR  MOD_L1HISR

/*******************************************************************************
 * Sap id definition
 *******************************************************************************/
#define MPH_L1_L1_SAP    L1_L1_SAP
#define MPH_L1_RR_SAP    L1_MPAL_SAP
#define MPH_RR_L1_SAP    MPAL_L1_SAP
#define MPH_L1_L2_SAP    L1_MPAL_SAP
#define MPH_L2_L1_SAP    MPAL_L1_SAP
#define MPH_L1_CB_SAP    L1_MPAL_SAP
#define MPH_CB_L1_SAP    MPAL_L1_SAP
#define MPH_L1_MAC_SAP   L1_MPAL_SAP
#define MPH_MAC_L1_SAP   MPAL_L1_SAP
#define MPH_UL1_L1_SAP   UL1_L1_SAP
#ifdef __UMTS_TDD128_MODE__
#define MPH_TL1_L1_SAP   TL1_LL1_SAP
#endif /*__UMTS_TDD128_MODE__*/

#ifdef __GEMINI_GSM__
#define MPH_L1_RSVAS_SAP   RSVAS_SAP   /* Shihyao 20100315, add it becuase suspend procedure is handled by RSVAS instead of MPAL*/
#endif

#if defined(__L1_GPS_REF_TIME_SUPPORT__) || defined(__L1_GPS_AUTO_TIMING_SYNC_SUPPORT__)
/* Shihyao, add it to support GPS time sync procedure*/
#define MPH_L1_GPS_SAP   GPS_L1_SAP
#endif

#ifdef __MTK_TARGET__
#ifndef __L1_STANDALONE__
/*  Maruco20081223, add for using RF tool in engineering mode 
 *  L4C sends 4 new primitives(in em_sap.h) to L1A, 
 *  and L1A call L1C's function(in Rftool_types.h) to set parameters
 *  then L1C calls L1A's function to return primitive to MOD_UEM(module of L4C), 
 *  so L1A needs to define module(MOD_UEM) and EM(engineering mode)_SAP */
#define MPH_L1_UEM_SAP   L1_EM_SAP
#endif /* end of __L1_STANDALONE__*/
#endif /* end of __MTK_TARGET__ */

#define L1_ALLOC_BUF(byte_size)  get_ctrl_buffer(byte_size)

#define L1_FREE_BUF(buf)         free_ctrl_buffer(buf)

#define L1_OPEN_MESSAGE_QUEUE(queue) (KAL_SUCCESS)

#define L1_SEND_MSG(src_mod, dest_mod, sap_id, ilm_ptr) \
      SEND_ILM(src_mod, dest_mod, sap_id, ilm_ptr)
#define LL1_SEND_MSG(src_mod, dest_mod, sap, ilm_ptr)\
{ \
   ilm_ptr->src_mod_id  = src_mod;  \
   ilm_ptr->dest_mod_id = dest_mod; \
   ilm_ptr->sap_id = sap; \
   msg_send_ext_queue(ilm_ptr); \
}

#define L1_RECV_MSG(ilm_ptr) \
      receive_msg_ext_q_for_stack(task_info_g[INDX_L1].task_ext_qid, ilm_ptr)
#ifdef __GEMINI_GSM__
#define L1_RECV_MSG_2(ilm_ptr) \
      receive_msg_ext_q_for_stack(task_info_g[INDX_L1_2].task_ext_qid, ilm_ptr)
#if (GEMINI_PLUS_GSM >= 3)
#define L1_RECV_MSG_3(ilm_ptr) \
      receive_msg_ext_q_for_stack(task_info_g[INDX_L1_3].task_ext_qid, ilm_ptr)
#if (GEMINI_PLUS_GSM >= 4)
#define L1_RECV_MSG_4(ilm_ptr) \
      receive_msg_ext_q_for_stack(task_info_g[INDX_L1_4].task_ext_qid, ilm_ptr)
#endif /* end of (GEMINI_PLUS_GSM >= 4) */
#endif /* end of (GEMINI_PLUS_GSM >= 3) */
#endif

#define L1_FREE_MSG(ilm_ptr)  { free_ilm(ilm_ptr); }

__inline ilm_struct* L1_ALLOC_MSG(module_type mod_id, kal_uint16 size)
{
   ilm_struct *ilm_ptr;
   ilm_ptr = allocate_ilm(mod_id);
   if (size)
     ilm_ptr->local_para_ptr = construct_local_para(size, TD_CTRL);
   return ilm_ptr;
}


#else /* for simulation */

extern ilm_struct simu_ilm_pool[];

typedef unsigned long  dword;        /* 4 byte variable */
typedef unsigned short word;         /* 2 byte variable */
typedef signed short sword;          /* 2 byte variable */
typedef unsigned char  boolean;      /* 1 byte variable */

/*******************************************************************************
 * Destination module id definition
 *******************************************************************************/
#define MOD_MPH_RR      GS_QUEUE_RR
#define MOD_MPH_L2      GS_QUEUE_LAYER_2
#define MOD_MPH_CB      GS_QUEUE_CB
#define MOD_MPH_MAC     GS_QUEUE_RLCMAC
#define MOD_MPH_L1      GS_QUEUE_LAYER_1

/*Maruco20071024, define module of Slave*/
#ifdef __GEMINI_GSM__
#define MOD_MPH_RR_2      GS_QUEUE_RR_2
#define MOD_MPH_L2_2      GS_QUEUE_LAYER_2_2
#define MOD_MPH_CB_2      GS_QUEUE_CB_2
#define MOD_MPH_MAC_2     GS_QUEUE_RLCMAC_2
#define MOD_MPH_L1_2      GS_QUEUE_LAYER_1_2

#if (GEMINI_PLUS_GSM >= 3)
#define MOD_MPH_RR_3      GS_QUEUE_RR_3
#define MOD_MPH_L2_3      GS_QUEUE_LAYER_2_3
#define MOD_MPH_CB_3      GS_QUEUE_CB_3
#define MOD_MPH_MAC_3     GS_QUEUE_RLCMAC_3
#define MOD_MPH_L1_3      GS_QUEUE_LAYER_1_3

#if (GEMINI_PLUS_GSM >= 4)
#define MOD_MPH_RR_4      GS_QUEUE_RR_4
#define MOD_MPH_L2_4      GS_QUEUE_LAYER_2_4
#define MOD_MPH_CB_4      GS_QUEUE_CB_4
#define MOD_MPH_MAC_4     GS_QUEUE_RLCMAC_4
#define MOD_MPH_L1_4      GS_QUEUE_LAYER_1_4
#endif /* end of (GEMINI_PLUS_GSM >= 4) */

#endif /* end of (GEMINI_PLUS_GSM >= 3) */

#endif

#if defined(L1A_SIM) || defined(__GEMINI_GSM__)
#define MOD_MPH_RSVAS      MOD_RSVAS   /* Shihyao 20100315, add it becuase suspend procedure is handled by RSVAS instead of MPAL*/
#endif

#if defined(__L1_GPS_REF_TIME_SUPPORT__) || defined(__L1_GPS_AUTO_TIMING_SYNC_SUPPORT__)
/* Shihyao, add it to support GPS time sync procedure*/
#define MOD_MPH_GPS   GS_QUEUE_GPS
#endif

/* elly, already defined in ul1_kal.h */
//#define MOD_MPH_UL1     GS_QUEUE_UL1
#if 0 /* elly */
/* under construction !*/
#else
#define MOD_MPH_L1HISR  GS_QUEUE_L1HISR
#endif

/*******************************************************************************
 * Sap id definition
 *******************************************************************************/
#define MPH_L1_L1_SAP    L1_L1_SAP
#define MPH_L1_RR_SAP    L1_MPAL_SAP
#define MPH_RR_L1_SAP    MPAL_L1_SAP
#define MPH_L1_L2_SAP    L1_MPAL_SAP
#define MPH_L2_L1_SAP    MPAL_L1_SAP
#define MPH_L1_CB_SAP    L1_MPAL_SAP
#define MPH_CB_L1_SAP    MPAL_L1_SAP
#define MPH_L1_MAC_SAP   L1_MPAL_SAP
#define MPH_MAC_L1_SAP   MPAL_L1_SAP
#define MPH_UL1_L1_SAP   UL1_L1_SAP
#ifdef __UMTS_TDD128_MODE__// for pass compile
#define MPH_TL1_L1_SAP   TL1_LL1_SAP
#endif /*__UMTS_TDD128_MODE__*/

#if defined(L1A_SIM) || defined(__GEMINI_GSM__)
#define MPH_L1_RSVAS_SAP   RSVAS_SAP   /* Shihyao 20100315, add it becuase suspend procedure is handled by RSVAS instead of MPAL*/
#endif

#if defined(__L1_GPS_REF_TIME_SUPPORT__) || defined(__L1_GPS_AUTO_TIMING_SYNC_SUPPORT__)
/* Shihyao, add it to support GPS time sync procedure*/
#define MPH_L1_GPS_SAP   GPS_L1_SAP
#endif

extern kal_status gs_open_message_queue(kal_uint8);
extern void script_send_message(kal_uint8, void *, kal_bool);
extern void script_send_message_byMod(const int dest_mod, void *msg, kal_bool wait);
extern kal_status gs_send_message(kal_uint8, void *, kal_bool);
extern kal_status gs_read_message(kal_uint8, void *, kal_uint16, kal_bool);

#define L1_ALLOC_BUF(byte_size)  malloc(byte_size)

#define L1_FREE_BUF(buf)         free(buf)

#define L1_OPEN_MESSAGE_QUEUE(queue) \
      gs_open_message_queue((queue))

#if 1 //(defined L1A_SIM)
#define L1_SEND_MSG(src_mod, dest_mod, sap, ilm_ptr) \
      ilm_ptr->src_mod_id  = src_mod;  \
      ilm_ptr->dest_mod_id = dest_mod; \
	  ilm_ptr->sap_id  = sap;  \
      gs_send_message((kal_uint8)dest_mod, (void*)ilm_ptr, true);

#define LL1_SEND_MSG L1_SEND_MSG /* elly */

#else /* L1A_SIM */
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* L1A_SIM */

#define L1_RECV_MSG(ilm_ptr) \
      gs_read_message(GS_QUEUE_LAYER_1, ilm_ptr, sizeof(ilm_struct), true)
#ifdef __GEMINI_GSM__
#define L1_RECV_MSG_2(ilm_ptr) \
      gs_read_message(GS_QUEUE_LAYER_1_2, ilm_ptr, sizeof(ilm_struct), true)
#if (GEMINI_PLUS_GSM >= 3)
#define L1_RECV_MSG_3(ilm_ptr) \
      gs_read_message(GS_QUEUE_LAYER_1_3, ilm_ptr, sizeof(ilm_struct), true)
#if (GEMINI_PLUS_GSM >= 4)
#define L1_RECV_MSG_4(ilm_ptr) \
      gs_read_message(GS_QUEUE_LAYER_1_4, ilm_ptr, sizeof(ilm_struct), true)
#endif /* end of (GEMINI_PLUS_GSM >= 4) */
#endif /* end of (GEMINI_PLUS_GSM >= 3) */
#endif

#define L1_FREE_MSG(ilm_ptr)  if ((ilm_ptr)->src_mod_id != MOD_TIMER)  free(ilm_ptr.local_para_ptr[0])

__inline ilm_struct* L1_ALLOC_MSG(module_type mod_id, kal_uint32 size)
{
   ilm_struct *ilm_ptr;

   ilm_ptr = &simu_ilm_pool[mod_id];
   
   if (size == 0)
       size = 4; 

   {
      ilm_ptr->local_para_ptr = (local_para_struct *) malloc(size);
      ilm_ptr->local_para_ptr->msg_len = size;
   }
   return ilm_ptr;
}

#endif /* __MTK_TARGET__ */

#endif /* _L1_KAL_H */