[Feature][Modem]Update MTK MODEM V1.6 baseline version: MOLY.NR15.R3.MD700.IVT.MP1MR3.MP.V1.6
MTK modem version: MT2735_IVT_MOLY.NR15.R3.MD700.IVT.MP1MR3.MP.V1.6.tar.gz
RF modem version: NA
Change-Id: I45a4c2752fa9d1a618beacd5d40737fb39ab64fb
diff --git a/mcu/interface/service/stacklib/bitop_funcs.h b/mcu/interface/service/stacklib/bitop_funcs.h
new file mode 100644
index 0000000..d59bdb2
--- /dev/null
+++ b/mcu/interface/service/stacklib/bitop_funcs.h
@@ -0,0 +1,202 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * bitop_funcs.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * Functions for putting and getting bit fields into
+ * byte arrays.
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*********************************************************************
+ (C) _____ (year of first publication) Sasken communication
+ Technologies Limited, All rights reserved.
+* This file provides a template for .c files. This space
+* should be used to describe the file contents
+* Component-specific prefix : xxxx
+*********************************************************************/
+
+#ifndef _BITOP_FUNCS_H
+#define _BITOP_FUNCS_H
+/*RHR*/
+#include "kal_general_types.h"
+/*RHR*/
+/***************************************************************************
+ * Exported Function Prototypes
+ ***************************************************************************/
+extern unsigned int mask(unsigned int width);
+
+extern unsigned int get_bits_1_8(
+ kal_uint8 *addr,
+ unsigned int offset,
+ unsigned int width
+ );
+
+extern unsigned int get_bits_9_16(
+ kal_uint8 *addr,
+ unsigned int offset,
+ unsigned int width
+ );
+
+extern unsigned int get_bits_17_24(
+ kal_uint8 *addr,
+ unsigned int offset,
+ unsigned int width
+ );
+
+extern unsigned int get_bits_25_32(
+ kal_uint8 *addr,
+ unsigned int offset,
+ unsigned int width
+ );
+
+
+extern unsigned int get_bits(
+ kal_uint8 *addr,
+ unsigned int offset,
+ unsigned int width
+ );
+
+
+extern void put_bits_1_8(
+ kal_uint8 *addr,
+ unsigned int offset,
+ unsigned int width,
+ unsigned int put_val
+ );
+
+
+extern void put_bits_9_16(
+ kal_uint8 *addr,
+ unsigned int offset,
+ unsigned int width,
+ unsigned int put_val
+ );
+
+
+extern void put_bits_17_24(
+ kal_uint8 *addr,
+ unsigned int offset,
+ unsigned int width,
+ unsigned int put_val
+ );
+
+extern void put_bits_25_32(
+ kal_uint8 *addr,
+ unsigned int offset,
+ unsigned int width,
+ unsigned int put_val
+ );
+
+
+extern void put_bits(
+ kal_uint8 *addr,
+ unsigned int offset,
+ unsigned int width,
+ unsigned int put_val
+ );
+
+/* constants for shift directions */
+#define SHIFT_LEFT 1
+#define SHIFT_RIGHT 2
+
+/* Length of a static buffer */
+#define SHIFT_BUFFER_LEN 255
+
+void copy_bits16(const kal_uint8 *pzSrc,
+ kal_uint16 u16SrcIndex,
+ kal_uint8 *pzDst,
+ kal_uint16 *pu16DstIndex,
+ kal_uint16 u16NumBits);
+
+kal_uint16 shift_bits16(kal_uint8 *pzSrc,
+ kal_uint8 *pzDest,
+ kal_uint16 u16SizeInBytes,
+ kal_uint16 u16ShiftBits,
+ kal_uint16 u16Direction);
+
+/***************************************************************************
+ * Declarations Of Exported Globals
+ ***************************************************************************/
+
+#endif /* _BITOP_FUNCS_H */
+
diff --git a/mcu/interface/service/stacklib/bitop_macros.h b/mcu/interface/service/stacklib/bitop_macros.h
new file mode 100644
index 0000000..504776b
--- /dev/null
+++ b/mcu/interface/service/stacklib/bitop_macros.h
@@ -0,0 +1,270 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * bitop_macros.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * Preprocessor macros for putting and getting bit fields into
+* byte arrays.
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*********************************************************************
+ (C) _____ (year of first publication) Sasken communication
+ Technologies Limited, All rights reserved.
+* This file provides a template for .c files. This space
+* should be used to describe the file contents
+* Component-specific prefix : xxxx
+*********************************************************************/
+
+#ifndef _BITOP_MACROS_H
+#define _BITOP_MACROS_H
+
+/***************************************************************************
+ * Macros With Parameters
+ ***************************************************************************/
+
+#define MASK(_w) ( ((_w)>31) ? 0xffffffff : (0x1u << (_w)) - 1 )
+
+
+/* _uc is the pointer to the byte stream from which bits to be read */
+/* _s is the offset in bits from MSB of the byte stream _uc */
+/* _w is the number of bits to be read */
+
+#define GET_BITS_1_8(_uc, _s, _w) ( \
+ (((_s)+(_w)>8) ? *(_uc) << ((_s)+(_w)-8) | \
+ *((_uc)+1) >> (16-(_s)-(_w)) : \
+ *(_uc) << (_s) >> (8-(_w))) \
+ & MASK(_w) )
+
+#define GET_BITS_9_16(_uc, _s, _w) ( \
+ ((_s+_w>16) ? *_uc << (_s+_w-8) | *(_uc+1) << (_s+_w-16) | \
+ *(_uc+2) >> (24-_s-_w) : \
+ *_uc << (_s+_w-8) | *(_uc+1) >> (16-_s-_w)) \
+ & MASK(_w))
+
+#define GET_BITS_17_24(_uc, _s, _w) ( \
+ (((_s)+(_w)>24) ? *(_uc) << ((_s)+(_w)-8) | \
+ *((_uc)+1) << ((_s)+(_w)-16) | \
+ *((_uc)+2) << ((_s)+(_w)-24) | *((_uc)+3) >> (32-(_s)-(_w)) : \
+ *(_uc) << ((_s)+(_w)-8) | *((_uc)+1) << ((_s)+(_w)-16) | \
+ *((_uc)+2) >> (24-(_s)-(_w))) \
+ & MASK(_w))
+
+#define GET_BITS_25_32(_uc, _s, _w) ( \
+ (((_s)+(_w)>32) ? *(_uc) << ((_s)+(_w)-8) | \
+ *((_uc)+1) << ((_s)+(_w)-16) | \
+ *((_uc)+2) << ((_s)+(_w)-24) | *((_uc)+3) << ((_s)+(_w)-32) | \
+ *((_uc)+4) >> (40-(_s)-(_w)) : *(_uc) << ((_s)+(_w)-8) | \
+ *((_uc)+1) << ((_s)+(_w)-16) | *((_uc)+2) << ((_s)+(_w)-24) | \
+ *((_uc)+3) >> (32-(_s)-(_w))) & MASK(_w))
+
+#define GET_BITS(_uc, _s, _w) ( \
+ ((_w)>8) ? (((_w)>16) ? (((_w)>24) ? \
+ GET_BITS_25_32((_uc), (_s), (_w)) : \
+ GET_BITS_17_24((_uc), (_s), (_w))) : \
+ GET_BITS_9_16((_uc), (_s), (_w))) : \
+ GET_BITS_1_8((_uc), (_s), (_w)) \
+ )
+
+/* _uc is the pointer to the byte stream to which bits to be written */
+/* _s is the offset in bits from MSB of the byte stream _uc */
+/* _w is the number of bits to be written */
+/* _i is the value to be written */
+
+#define PUT_BITS_1_8(_uc, _s, _w, _i) \
+ if ((_s)+(_w)>8) { \
+ *(_uc) &= ~ MASK(8-(_s)); \
+ *(_uc) |= ((_i) & MASK((_w))) >> ((_s)+(_w)- 8); \
+ *((_uc)+1) = (*((_uc)+1) & MASK(16-(_s)-(_w))) | \
+ (_i) << (16-(_s)-(_w)); \
+ } else { \
+ *(_uc) &= ~ (MASK((_w)) << ( 8-(_w)-(_s))); \
+ *(_uc) |= ((_i) & MASK((_w))) << ( 8-(_w)-(_s)); \
+ }
+
+#define PUT_BITS_9_16(_uc, _s, _w, _i) \
+ *(_uc) &= ~ MASK(8-(_s)); \
+ if ((_s)+(_w)>16) { \
+ *(_uc) |= ((_i) & MASK((_w))) >> ((_s)+(_w)- 8); \
+ *((_uc)+1) = (_i) >> ((_s)+(_w)-16); \
+ *((_uc)+2) = (*((_uc)+2) & MASK(24-(_s)-(_w))) | \
+ (_i) << (24-(_s)-(_w)); \
+ } else { \
+ *(_uc) |= ((_i) & MASK((_w))) >> ((_s)+(_w)- 8); \
+ *((_uc)+1) = (*((_uc)+1) & MASK(16-(_s)-(_w))) | \
+ (_i) << (16-(_s)-(_w)); \
+ }
+
+#define PUT_BITS_17_24(_uc, _s, _w, _i) \
+ *(_uc) &= ~ MASK(8-(_s)); \
+ if ((_s)+(_w)>24) { \
+ *(_uc) |= ((_i) & MASK((_w))) >> ((_s)+(_w)- 8); \
+ *((_uc)+1) = (_i) >> ((_s)+(_w)-16); \
+ *((_uc)+2) = (_i) >> ((_s)+(_w)-24); \
+ *((_uc)+3) = (*((_uc)+3) & MASK(32-(_s)-(_w))) | \
+ (_i) << (32-(_s)-(_w)); \
+ } else { \
+ *(_uc) |= ((_i) & MASK((_w))) >> ((_s)+(_w)- 8); \
+ *((_uc)+1) = (_i) >> ((_s)+(_w)-16); \
+ *((_uc)+2) = (*((_uc)+2) & MASK(24-(_s)-(_w))) | \
+ (_i) << (24-(_s)-(_w)); \
+ }
+
+#define PUT_BITS_25_32(_uc, _s, _w, _i) \
+ *(_uc) &= ~MASK(8-(_s)); \
+ if ((_s)+(_w)>32) { \
+ *(_uc) |= ((_i) & MASK((_w))) >> ((_s)+(_w)- 8); \
+ *((_uc)+1) = (_i) >> ((_s)+(_w)-16); \
+ *((_uc)+2) = (_i) >> ((_s)+(_w)-24); \
+ *((_uc)+3) = (_i) >> ((_s)+(_w)-32); \
+ *((_uc)+4) = (*((_uc)+4) & MASK(40-(_s)-(_w))) | \
+ (_i) << (40-(_s)-(_w)); \
+ } else { \
+ *(_uc) |= ((_i) & MASK((_w))) >> ((_s)+(_w)- 8); \
+ *((_uc)+1) = (_i) >> ((_s)+(_w)-16); \
+ *((_uc)+2) = (_i) >> ((_s)+(_w)-24); \
+ *((_uc)+3) = (*((_uc)+3) & MASK(32-(_s)-(_w))) | \
+ (_i) << (32-(_s)-(_w)); \
+ }
+
+#define PUT_BITS(_uc, _s, _w, _i) \
+ if ((_w)<9) { \
+ PUT_BITS_1_8(_uc, _s, _w, _i) \
+ } else if ((_w)<17) { \
+ PUT_BITS_9_16(_uc, _s, _w, _i) \
+ } else if ((_w)<25) { \
+ PUT_BITS_17_24(_uc, _s, _w, _i) \
+ } else { \
+ PUT_BITS_25_32(_uc, _s, _w, _i) \
+ }
+
+
+/********************************************************************/
+/* This macro insert a given number of bits to a bit position
+ * by shifting the existing bits down. */
+
+/* ptr is the pointer to the byte stream
+ * to which bits to be inserted. */
+/* _offset is the offset in bytes from MSB of byte stream ptr. */
+/* length is the number of bits to be inserted. */
+/* _size is the number of bits in the bit stream, after the point
+ * of insertion ,which is to be shifted. */
+/* _value is the value to be inserted. */
+
+
+#define INSERT_BITS(ptr,_offset,length,_size,_value) \
+{ \
+ unsigned int temp,value =_value; \
+ unsigned short int offset=_offset,size=_size; \
+ while(length <= size) { \
+ temp = GET_BITS(ptr,offset,length); \
+ PUT_BITS(ptr,offset,length,value); \
+ ptr = ptr +((offset+length)/8); \
+ offset = (offset+length)%8; \
+ size -=length; \
+ value = temp; \
+ } \
+ temp = GET_BITS(ptr,offset,size); \
+ PUT_BITS(ptr,offset,length,value); \
+ ptr = ptr +(offset+length)/8; \
+ offset = (offset+length)%8; \
+ PUT_BITS(ptr,offset,size,temp); \
+}
+
+/* Conversions for length fields */
+/* BITS_TO_BYTES_INC converts a length in bits, to a length in bytes, */
+/* inclusive of remainder (i.e. rounding up) */
+/* BITS_TO_BYTES_EXC converts a length in bits, to a length in bytes, */
+/* exclusive of remainder (i.e. rounding down) */
+/* These macros work for all types of integer */
+/* but beware sufficient headroom on BYTES_TO_BITS */
+#define BITS_TO_BYTES_INC(bit_length) (((bit_length)+7)/8)
+#define BITS_TO_BYTES_EXC(bit_length) ((bit_length)/8)
+#define BYTES_TO_BITS(length) ((length)*8)
+
+/* Similar to round up to fit U32s */
+/* for buffer size allocation etc. */
+#define BITS_TO_U32S_INC(bit_length) (((bit_length)+31)/32)
+#define BYTES_TO_U32S_INC(length) (((length)+3)/4)
+
+#endif /* _BITOP_MACROS_H */
+
+
diff --git a/mcu/interface/service/stacklib/bitstream.h b/mcu/interface/service/stacklib/bitstream.h
new file mode 100644
index 0000000..02528f2
--- /dev/null
+++ b/mcu/interface/service/stacklib/bitstream.h
@@ -0,0 +1,268 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * bitstream.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * BitStream allows sequential reading and writing of bit fields.
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*********************************************************************
+ (C) _____ (year of first publication) Sasken communication
+ Technologies Limited, All rights reserved.
+* This file provides a template for .c files. This space
+* should be used to describe the file contents
+* Component-specific prefix : xxxx
+*********************************************************************/
+
+#ifndef _BITSTREAM_H
+#define _BITSTREAM_H
+/*RHR*/
+#include "kal_general_types.h"
+/*RHR*/
+/* BitStream
+ *
+ * A bit stream allows bit fields to be read and written to,
+ * just like an byte stream allows byte to be read and written
+ * to. Reading and writing of bit fields is done to an underlying
+ * byte stream, in network byte order.
+ *
+ * bit_stream_init sets the underlying byte stream and the
+ * current read/write position within the byte stream. Can also
+ * be called when a seek to a new position is desired.
+
+ * The values which are read by bit_stream_read are returned as
+ * native unsigned integers.
+ *
+ * Similarly the values which are passed to bit_stream_write for
+ * writing should be passed as native unsigned integers.
+ *
+ * Both bit_stream_read and bit_stream_write, increment the
+ * current position,to facilitate sequential operation.
+ * bit_stream_cur_pos returns the number of bytes, the underlying
+ * byte pointer has been moved since bit_stream_init.
+ *
+ */
+
+typedef struct bit_stream {
+ kal_uint8 *byte_stream; /* Pointer to underlying byte stream. */
+ kal_uint8 *byte_stream_start;
+ kal_uint8 offset; /* Offset in bits from MSB of byte_stream */
+} bit_stream;
+
+/* Initialise Bit stream operations
+ *
+ * offset
+ * |
+ * V
+ * /-------------------------------\
+ * byte_stream-->| | | | | | | | |
+ * |---|---|---|---|---|---|---|---|
+ * | | | | | | | | |
+ * |---|---|---|---|---|---|---|---|
+ * | | | | | | | | |
+ * |---|---|---|---|---|---|---|---|
+ * | . | . | . | . | . | . | . | . |
+ * . . . . . . . .
+ * . . . . . . . .
+ *
+ * If offset is more than eight then, byte_stream is incremented by
+ * offset/8 and offset is taken to be offset modulo 8.
+ */
+extern void bit_stream_init(
+ bit_stream *bs,
+ kal_uint8 *byte_stream,
+ unsigned int offset);
+
+/* Read specified number of bits from current position and return it as
+ * an unsigned integer.
+ *
+ * offset (before)
+ * |
+ * V
+ * /-------------------------------\
+ * byte_stream (before)->| | | | | 1 | 0 | 0 | 0 |
+ * |---|---|---|---|---|---|---|---|
+ * byte_stream (after) ->| 1 | 0 | | | | | | |
+ * |---|---|---|---|---|---|---|---|
+ * | . | . | ^ | . | . | . | . | . |
+ * |
+ * offset (after)
+ *
+ * On the above stream bit_stream_read(bs, 6) will return 34
+ */
+extern unsigned int bit_stream_read(
+ bit_stream *bs,
+ unsigned int width);
+
+
+/* Write specified number of bits from current position into the
+ * underlying byte stream.
+ *
+ * bit_stream_write(bs, 6)
+ *
+ * offset (before)
+ * |
+ * V
+ * /-------------------------------\
+ * byte_stream (before)->| | | | | 1 | 0 | 0 | 0 |
+ * |---|---|---|---|---|---|---|---|
+ * byte_stream (after) ->| 1 | 0 | | | | | | |
+ * |---|---|---|---|---|---|---|---|
+ * | . | . | ^ | . | . | . | . | . |
+ * |
+ * offset (after)
+ *
+ */
+extern void bit_stream_write(
+ bit_stream *bs,
+ unsigned int width,
+ unsigned int value );
+
+/* Return the number of bits the internal pointer has moved since
+ * bit_stream_init */
+extern unsigned int bit_stream_cur_pos(bit_stream *bs);
+
+/* Move pointer back by given number of bits */
+extern void bit_stream_move_back(
+ bit_stream *bs,
+ unsigned int bits);
+
+/* Copy bits from one byte stream to another.
+ * Byte stream is incremented as read operation
+ * is done */
+
+extern void byte_stream_bit_copy(
+ kal_uint8 *s,
+ unsigned int s_offset,
+ unsigned int length,
+ kal_uint8 *d,
+ unsigned int d_offset);
+
+
+/* Read specified number of bits from the bitstream, starting
+ * from a position, width bits before the current position.
+
+ *
+ * offset (after)
+ * |
+ * V
+ * /-------------------------------\
+ * byte_stream (after)-> | | | | | 1 | 0 | 0 | 0 |
+ * |---|---|---|---|---|---|---|---|
+ * byte_stream (before)->| 1 | 0 | | | | | | |
+ * |---|---|---|---|---|---|---|---|
+ * | . | . | ^ | . | . | . | . | . |
+ * |
+ * offset (before)
+ *
+ * On the above stream ,
+ * bit_stream_read_back(bs, 6) will return 34
+ */
+
+extern unsigned int bit_stream_read_back(
+ bit_stream *bs,
+ unsigned int width);
+
+
+
+/* Write specified number of bits to the bitstream starting
+ * from a position width bits before the current position.
+ *
+ * bit_stream_write_back(bs, 6, 34) will return
+ *
+ *
+ * offset (after)
+ * |
+ * V
+ * /-------------------------------\
+ * byte_stream (after) ->| | | | | 1 | 0 | 0 | 0 |
+ * |---|---|---|---|---|---|---|---|
+ * byte_stream (before)->| 1 | 0 | | | | | | |
+ * |---|---|---|---|---|---|---|---|
+ * | . | . | ^ | . | . | . | . | . |
+ * |
+ * offset (before)
+ *
+ */
+extern void bit_stream_write_back(
+ bit_stream *bs,
+ unsigned int width,
+ unsigned int value );
+#endif /* _BITSTREAM_H */
+
diff --git a/mcu/interface/service/stacklib/dlist.h b/mcu/interface/service/stacklib/dlist.h
new file mode 100644
index 0000000..05b9abd
--- /dev/null
+++ b/mcu/interface/service/stacklib/dlist.h
@@ -0,0 +1,482 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * dlist.h
+ *
+ * Project:
+ * --------
+ * Maui
+ *
+ * Description:
+ * ------------
+ * Header file for double linked list facility
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+#ifndef __DLIST_H__
+#define __DLIST_H__
+
+//#include "kal_release.h"
+/*RHR*/
+#include "kal_general_types.h"
+/*RHR*/
+/* TYPES DEFINITIONS ********************************************************/
+/*
+ * DLIST_LINK: The structure used for a link in a doubly linked list.
+ * The pThis field is a generic pointer that points to the item being listed.
+ * The pNext field is a pointer to the next link in the list, and is NULL for
+ * the last link in the list.
+ */
+typedef struct DLIST_LINK_TAG
+{
+ void *pThis; /*
+ * Pointer to the item in the list
+ */
+ struct DLIST_LINK_TAG *pPrev; /*
+ * Pointer to the previous link in the list
+ */
+ struct DLIST_LINK_TAG *pNext; /*
+ * Pointer to the next link in the list
+ */
+} DLIST_LINK;
+
+/*
+ * DLIST_HEAD: The structure used for the head of a doubly linked list.
+ * The ulCount field contains the number of links in the doubly linked list,
+ * and will be zero when the doubly linked list is empty.
+ * The pFirst field is a pointer to the first link in the doubly linked list,
+ * and will be NULL for an empty list.
+ */
+typedef struct DLIST_HEAD_TAG
+{
+ kal_uint32 ulCount; /*
+ * A count of the number of links in
+ * the list
+ */
+ struct DLIST_LINK_TAG *pFirst; /*
+ * A pointer to the first link in the
+ * list
+ */
+ struct DLIST_LINK_TAG *pLast; /*
+ * A pointer to the last link in the
+ * list
+ */
+} DLIST_HEAD;
+
+/*
+ * DLIST_HANDLE: Pointer to DLIST_HEAD structure to be used as a handle for the
+ * doubly linked list.
+ */
+typedef DLIST_HEAD *DLIST_HANDLE;
+
+/*
+ * DLIST_LINK_HANDLE: Pointer to DLIST_LINK structure to be used as a handle for
+ * a link in a doubly linked list.
+ */
+typedef DLIST_LINK *DLIST_LINK_HANDLE;
+
+
+/* GLOBAL VARIABLE DECLARATIONS *********************************************/
+/* The Omitted Storage Class Model is assumed. The storage class
+ * "extern" must be explicitly included on all referencing
+ * declarations, and the storage class must omitted from the single
+ * defining declaration for each external variable. The defining
+ * declaration can include an initializer, but it is not required to
+ * do so. It is invalid to have both an initiliazer and the storage
+ * class extern in a declaration (ref:[4.8.2; A Reference Manual]).
+ *
+ * Use global variables for performance improvement and always provide
+ * MACROS to manipulate them. E.g. SET(v) and GET. */
+
+/* PUBLIC FUNCTION PROTOTYPES ***********************************************/
+
+
+
+/**
+ * Description: Intialises a DLIST_HEAD
+ * structure before first use
+ *
+ * Notes: Sets ulCount to zero and pFirst to
+ * NULL.
+ */
+extern void DlistInit(DLIST_HANDLE hList);
+
+/**
+ * Description: Destroy the link list.
+ *
+ * Notes: Frees all links in the list, but not
+ * their items.
+ *
+ * @param hList
+ * @return kal_bool: TRUE if successful, FALSE is not
+ */
+extern kal_bool DlistDeleteAll_Dbg(DLIST_HANDLE hList,
+ kal_char *filename, kal_uint32 line);
+
+#if defined(DEBUG_KAL) && defined(DEBUG_BUF2)
+#define DlistDeleteAll(hList) \
+ DlistDeleteAll_Dbg(hList, __FILE__, __LINE__)
+#else
+#define DlistDeleteAll(hList) \
+ DlistDeleteAll_Dbg(hList, NULL, 0)
+#endif
+
+/****************************************************************************
+ * Function: DlistInsertAtStart
+ * Description: Adds a new link to the start of the doubly linked list
+ * Parameters: hList: Pointer to a DLIST_HEAD structure
+ * pThis: The item to be added to the doubly linked list
+ * Returns: kal_bool: TRUE if successful, FALSE is not
+ * Notes: Allocates memory for a new DLIST_LINK.
+ * Returns TRUE if the memory was allocated, else FALSE.
+ ****************************************************************************/
+
+extern kal_bool DlistInsertAtStart_Dbg(DLIST_HANDLE hList, void *pThis,
+ kal_char *filename, kal_uint32 line);
+extern kal_bool DlistInsertAtFront(DLIST_HANDLE hList, void *pThis, DLIST_LINK_HANDLE hLink);
+
+#if defined(DEBUG_KAL) && defined(DEBUG_BUF2)
+#define DlistInsertAtStart(hList, pThis) \
+ DlistInsertAtStart_Dbg(hList, pThis, __FILE__, __LINE__)
+#else
+#define DlistInsertAtStart(hList, pThis) \
+ DlistInsertAtStart_Dbg(hList, pThis, NULL, 0)
+#endif
+
+/****************************************************************************
+ * Function: DlistInsertAtEnd
+ * Description: Adds a new link to the end of the doubly linked list
+ * Parameters: hList: Pointer to a DLIST_HEAD structure
+ * pThis: The item to be added to the doubly linked list
+ * Returns: kal_bool: TRUE if successful, FALSE is not
+ * Notes: Allocates memory for a new DLIST_LINK.
+ * Returns TRUE if the memory was allocated, else FALSE.
+ ****************************************************************************/
+
+extern kal_bool DlistInsertAtEnd_Dbg(DLIST_HANDLE hList, void *pThis,
+ kal_char *filename, kal_uint32 line);
+#if defined(DEBUG_KAL) && defined(DEBUG_BUF2)
+#define DlistInsertAtEnd(hList, pThis) \
+ DlistInsertAtEnd_Dbg(hList, pThis, __FILE__, __LINE__)
+#else
+#define DlistInsertAtEnd(hList, pThis) \
+ DlistInsertAtEnd_Dbg(hList, pThis, NULL, 0)
+#endif
+
+/****************************************************************************
+ * Function: DlistInsertAfter
+ * Description: Adds a new link after the given link of the doubly linked list
+ * Parameters: hList: Pointer to a DLIST_HEAD structure
+ * phLink: Pointer to a pointer to the link to insert after
+ * pThis: The item to be added to the doubly linked list
+ * Returns: kal_bool: TRUE if successful, FALSE is not
+ * Notes: Need to use DlistFirst, DlistNext or DlistFind to set phLink
+ * before calling this function.
+ * Allocates memory for a new DLIST_LINK.
+ * Returns TRUE if the memory was allocated, else FALSE.
+ ****************************************************************************/
+
+extern kal_bool DlistInsertAfter_Dbg(DLIST_HANDLE hList,
+ DLIST_LINK_HANDLE *phLink, void *pThis,
+ kal_char *filename, kal_uint32 line);
+
+#if defined(DEBUG_KAL) && defined(DEBUG_BUF2)
+#define DlistInsertAfter(hList, phLink, pThis) \
+ DlistInsertAfter_Dbg(hList, phLink, pThis, __FILE__, __LINE__)
+#else
+#define DlistInsertAfter(hList, phLink, pThis) \
+ DlistInsertAfter_Dbg(hList, phLink, pThis, NULL, 0)
+#endif
+
+/****************************************************************************
+ * Function: DlistInsertBefore
+ * Description: Adds a new link before the given link of the doubly linked list
+ * Parameters: hList: Pointer to a DLIST_HEAD structure
+ * phLink: Pointer to a pointer to the link to insert before
+ * pThis: The item to be added to the doubly linked list
+ * Returns: kal_bool: TRUE if successful, FALSE is not
+ * Notes: Need to use DlistFirst, DlistNext or DlistFind to set phLink
+ * before calling this function.
+ * Allocates memory for a new DLIST_LINK.
+ * Returns TRUE if the memory was allocated, else FALSE.
+ ****************************************************************************/
+
+extern kal_bool DlistInsertBefore_Dbg(DLIST_HANDLE hList,
+ DLIST_LINK_HANDLE *phLink, void *pThis,
+ kal_char *filename, kal_uint32 line);
+
+#if defined(DEBUG_KAL) && defined(DEBUG_BUF2)
+#define DlistInsertBefore(hList, phLink, pThis) \
+ DlistInsertBefore_Dbg(hList, phLink, pThis, __FILE__, __LINE__)
+#else
+#define DlistInsertBefore(hList, phLink, pThis) \
+ DlistInsertBefore_Dbg(hList, phLink, pThis, NULL, 0)
+#endif
+
+/****************************************************************************
+ * Function: DlistSort
+ * Description: Sorts a doubly linked list into item order
+ * Parameters: hList: Pointer to a DLIST_HEAD structure
+ * Compare: Pointer to a function that compares two items,
+ * pThis and pNext, returning an int which is:
+ * zero if pThis == pNext
+ * negative if pThis < pNext
+ * positive if pThis > pNext
+ * Returns: kal_bool: TRUE if successful, FALSE is not
+ * Notes: DlistSort swaps items on Compare returning a positive result.
+ * To sort into the reverse order, use a different Compare
+ * function that inverts the positive and negative results.
+ ****************************************************************************/
+
+extern void DlistSort(DLIST_HANDLE hList, int (*Compare)(void *pThis, void *pNext));
+
+/****************************************************************************
+ * Function: DlistFirst
+ * Description: Gets the first item in the doubly linked list and sets the
+ * pointer at phLink for use by DlistNext, DlistInsertAfter or
+ * DlistDelete.
+ * Parameters: hList: Pointer to a DLIST_HEAD structure
+ * phLink: Pointer to a pointer to be set to the first link
+ * Returns: void *: Pointer to pThis of first link, or NULL if empty list.
+ * Notes: Might return NULL if pThis of first link is NULL pointer, or
+ * if the doubly linked list is empty. The pointer at phLink
+ * will be set to NULL if the doubly linked list is empty.
+ ****************************************************************************/
+
+extern void *DlistFirst(DLIST_HANDLE hList, DLIST_LINK_HANDLE *phLink);
+
+/****************************************************************************
+ * Function: DlistLast
+ * Description: Gets the last item in the doubly linked list and sets the
+ * pointer at phLink for use by DlistPrev, DlistInsertAfter or
+ * DlistDelete.
+ * Parameters: hList: Pointer to a DLIST_HEAD structure
+ * phLink: Pointer to a pointer to be set to the last link
+ * Returns: void *: Pointer to pThis of last link, or NULL if empty list.
+ * Notes: Might return NULL if pThis of last link is NULL pointer, or
+ * if the doubly linked list is empty. The pointer at phLink
+ * will be set to NULL if the doubly linked list is empty.
+ ****************************************************************************/
+
+extern void *DlistLast(DLIST_HANDLE hList, DLIST_LINK_HANDLE *phLink);
+
+/****************************************************************************
+ * Function: DlistNext
+ * Description: Gets the next item in the doubly linked list and sets the
+ * pointer at phLink for use by DlistInsertAfter or DlistDelete.
+ * Parameters: hList: Pointer to a DLIST_HEAD structure
+ * phLink: Pointer to a pointer to be set to the next link
+ * Returns: void *: Pointer to pThis of next link, or NULL if end of list.
+ * Notes: Might return NULL if pThis of first link is NULL pointer, or
+ * if the end of the doubly linked list has been reached. The
+ * pointer at phLink will be set to NULL if the end of the doubly
+ * linked list has been reached.
+ ****************************************************************************/
+
+extern void *DlistNext(DLIST_HANDLE hList, DLIST_LINK_HANDLE *phLink);
+
+/****************************************************************************
+ * Function: DlistThis
+ * Description: Gets the current item in the doubly linked. Useful after a call
+ * to DlistDelete, where DlistNext will skip an item
+ * Parameters: hList: Pointer to a DLIST_HEAD structure
+ * phLink: Pointer to a pointer to be set to the next link
+ * Returns: void *: Pointer to pThis of this link.
+ * Notes: Might return NULL if pThis of this link is NULL pointer.
+ ****************************************************************************/
+
+extern void *DlistThis(DLIST_HANDLE hList, DLIST_LINK_HANDLE *phLink);
+
+/****************************************************************************
+ * Function: DlistPrev
+ * Description: Gets the previous item in the doubly linked list and sets the
+ * pointer at phLink for use by DlistInsertAfter or DlistDelete.
+ * Parameters: hList: Pointer to a DLIST_HEAD structure
+ * phLink: Pointer to a pointer to be set to the previous link
+ * Returns: void *: Pointer to pThis of previous link, or NULL if end of
+ * list.
+ * Notes: Might return NULL if pThis of first link is NULL pointer, or
+ * if the end of the doubly linked list has been reached. The
+ * pointer at phLink will be set to NULL if the end of the doubly
+ * linked list has been reached.
+ ****************************************************************************/
+
+extern void *DlistPrev(DLIST_HANDLE hList, DLIST_LINK_HANDLE *phLink);
+
+/****************************************************************************
+ * Function: DlistFind
+ * Description: Finds a particular item in a doubly linked list
+ * Parameters: hList: Pointer to a DLIST_HEAD structure
+ * phLink: Pointer to a pointer to be set to the found link
+ * pTarget: Pointer to the "value" being sought
+ * Compare: Pointer to a function that compares an item, pThis,
+ * with the "value" being sought, pTarget, returning an int which
+ * is zero if pThis == pTarget, else non-zero.
+ * Returns: void *: Pointer to pThis of link found, or NULL if not found.
+ * Notes: Sets the pointer at phLink to the link found, for use in
+ * subsequent DlistInsertAfter, DlistDelete or DlistNext calls.
+ ****************************************************************************/
+
+extern void *DlistFind(DLIST_HANDLE hList, DLIST_LINK_HANDLE *phLink, void *pTarget,
+ int (*Compare)(void *pThis, void *pTarget));
+
+/****************************************************************************
+ * Function: DlistDelete
+ * Description: Deletes a particular item in a doubly linked list
+ * Parameters: hList: Pointer to a DLIST_HEAD structure
+ * phLink: Pointer to a pointer the link to be deleted
+ * Returns: kal_bool: TRUE if the pointer at phLink was not NULL, else FALSE
+ * Notes: Sets the pointer at phLink to the next link, for use in
+ * subsequent DlistInsertAfter, DlistDelete or DlistNext calls.
+ ****************************************************************************/
+
+extern kal_bool DlistDelete_Dbg(DLIST_HANDLE hList, DLIST_LINK_HANDLE *phLink,
+ kal_char *filename, kal_uint32 line);
+
+#if defined(DEBUG_KAL) && defined(DEBUG_BUF2)
+#define DlistDelete(hList, phLink) \
+ DlistDelete_Dbg(hList, phLink, __FILE__, __LINE__)
+#else
+#define DlistDelete(hList, phLink) \
+ DlistDelete_Dbg(hList, phLink, NULL, 0)
+#endif
+
+/****************************************************************************
+ * Function: DlistCount
+ * Description: Obtains the number of links in the doubly linked list
+ * Parameters: hList: Pointer to a DLIST_HEAD structure
+ * Returns: kal_uint32: the value of the DLIST_HEAD structure's ulCount field
+ * Notes: Enables functions using Dlist to treat DLIST_HEAD as a handle
+ ****************************************************************************/
+
+extern kal_uint32 DlistCount(DLIST_HANDLE hList);
+
+//#define KAREN_TRACE
+
+#ifndef GEN_FOR_PC
+//#include <stdio.h>
+#endif
+
+#endif /* __DLIST_H__ */
diff --git a/mcu/interface/service/stacklib/lcd.h b/mcu/interface/service/stacklib/lcd.h
new file mode 100644
index 0000000..ab00606
--- /dev/null
+++ b/mcu/interface/service/stacklib/lcd.h
@@ -0,0 +1,118 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * lcd.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * Header file for definitions common to the Light weight C Data
+ * structures library.
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*********************************************************************
+ (C) _____ (year of first publication) Sasken communication
+ Technologies Limited, All rights reserved.
+* This file provides a template for .c files. This space
+* should be used to describe the file contents
+* Component-specific prefix : xxxx
+*********************************************************************/
+
+#ifndef _LCD_H
+#define _LCD_H
+/*RHR*/
+#include "kal_general_types.h"
+/*RHR*/
+/*************************************************************************
+ * Type Definitions
+ *************************************************************************/
+/* Comparison function, returns -1, 0, or 1 depending of whether first
+ * argument is less than, equal to or greater than second argument
+ * (like strcmp).
+ */
+typedef int (*lcd_cmpfunc)(const void *, const void *);
+typedef void (*lcd_mapfunc)(void *, void *);
+typedef kal_bool (*lcd_cmapfunc)(void*, void*);
+#endif /* _LCD_H */
+
+
diff --git a/mcu/interface/service/stacklib/lcd_cqueue.h b/mcu/interface/service/stacklib/lcd_cqueue.h
new file mode 100644
index 0000000..57c9819
--- /dev/null
+++ b/mcu/interface/service/stacklib/lcd_cqueue.h
@@ -0,0 +1,163 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * lcdcqueue.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * Light weight C Data structures library: Circular Queue.
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*********************************************************************
+ (C) _____ (year of first publication) Sasken communication
+ Technologies Limited, All rights reserved.
+* This file provides a template for .c files. This space
+* should be used to describe the file contents
+* Component-specific prefix : xxxx
+*********************************************************************/
+
+#ifndef _LCD_CQUEUE_H
+#define _LCD_CQUEUE_H
+/*RHR*/
+#include "kal_general_types.h"
+//#include "stacklib.h"
+#include "lcd.h"
+#include "kal_public_api.h"
+/*RHR*/
+/*******************************************************************************
+ * Data Structure definition
+ *******************************************************************************/
+typedef struct lcd_cqueue {
+ void * * queue;
+ unsigned int size;
+ unsigned int head;
+ unsigned int tail;
+ unsigned int is_full;
+} lcd_cqueue;
+
+/*******************************************************************************
+ * Exported Function Prototypes
+ *******************************************************************************/
+extern kal_uint32 new_lcd_cqueue_mem_size(unsigned int size);
+
+extern void lcd_cqueue_insert(lcd_cqueue *q, void *item);
+
+extern void lcd_cqueue_insert_front(lcd_cqueue *q, void *item);
+
+extern void *lcd_cqueue_remove(lcd_cqueue *q);
+
+extern void *lcd_cqueue_remove_rear(lcd_cqueue *q);
+
+extern kal_bool lcd_cqueue_is_empty(lcd_cqueue *q);
+
+extern kal_bool lcd_cqueue_is_full(lcd_cqueue *q);
+
+extern unsigned int lcd_cqueue_num_of_items(lcd_cqueue *q);
+
+extern void *lcd_cqueue_index(lcd_cqueue *q , unsigned int index);
+
+extern void lcd_cqueue_map(lcd_cqueue *q, lcd_mapfunc f, void *info);
+
+extern void lcd_cqueue_delete_all(lcd_cqueue *q);
+
+extern void lcd_cqueue_init(unsigned int size, lcd_cqueue *q);
+
+#ifdef _DEBUG_LCD_CQUEUE
+extern void lcd_cqueue_print(lcd_cqueue *q);
+#endif
+#endif /* _LCD_CQUEUE_H */
+
+
diff --git a/mcu/interface/service/stacklib/lcd_ip_cqueue.h b/mcu/interface/service/stacklib/lcd_ip_cqueue.h
new file mode 100644
index 0000000..9056c6d
--- /dev/null
+++ b/mcu/interface/service/stacklib/lcd_ip_cqueue.h
@@ -0,0 +1,738 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * lcd_ip_cqueue.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file defines Generic circular queue data structure definition
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+/*******************************************************************************
+* 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) 2002
+*
+*******************************************************************************/
+
+/*********************************************************************
+ (C) _____ (year of first publication) Sasken communication
+ Technologies Limited, All rights reserved.
+* This file provides a template for .c files. This space
+* should be used to describe the file contents
+* Component-specific prefix : xxxx
+*********************************************************************/
+
+#ifndef _LCD_IP_CQUEUE_H
+#define _LCD_IP_CQUEUE_H
+
+/*************************************************************************
+ * Include the common header file
+ *************************************************************************/
+#if defined(__MTK_TARGET__)
+#include "kal_itc.h"
+#else
+#include "kal_hrt_api.h"
+#endif
+
+/*************************************************************************
+ * Macros With Parameters
+ *************************************************************************/
+#if defined(__MTK_TARGET__)
+#define LCD_IP_CQUEUE_MT_LOCK(_lock) \
+ unsigned int irq_status = 0, mt_status = 0, prio = 0; \
+ KAL_ITC_LOCK_TAKE_DI_DMT_PRIO(_lock, irq_status, mt_status, prio)
+
+#define LCD_IP_CQUEUE_MT_UNLOCK(_lock) \
+ KAL_ITC_LOCK_GIVE_EI_EMT_PRIO((_lock), irq_status, mt_status, prio)
+#else
+#define LCD_IP_CQUEUE_MT_LOCK(_lock) \
+ kal_hrt_take_itc_lock(KAL_ITC_ISR_Q, KAL_INFINITE_WAIT)
+
+#define LCD_IP_CQUEUE_MT_UNLOCK(_lock) \
+ kal_hrt_give_itc_lock(KAL_ITC_ISR_Q)
+#endif
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _type is the type of item to be put in queue.
+* _length is the size of the queue.
+*
+* RETURNS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+
+#define LCD_IP_CQUEUE(_type, _length) \
+ struct { \
+ unsigned int head; \
+ unsigned int tail; \
+ unsigned int multiple; \
+ unsigned int max_used_item; \
+ unsigned int total_item; \
+ kal_bool is_full; \
+ _type queue[_length]; \
+ }
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_INIT
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+*
+* RETURNS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+
+#define LCD_IP_CQUEUE_INIT(_q) \
+do{ \
+ (_q).head = (_q).tail = 0; \
+ (_q).multiple = 1; \
+ (_q).max_used_item = 0; \
+ (_q).total_item = (sizeof((_q).queue)*(_q).multiple / sizeof((_q).queue[0])); \
+ (_q).is_full = KAL_FALSE; \
+}while(0)
+
+#define LCD_IP_CQUEUE_INIT_N(_q, n) \
+do{ \
+ (_q).head = (_q).tail = 0; \
+ (_q).multiple = n; \
+ (_q).max_used_item = 0; \
+ (_q).total_item = (sizeof((_q).queue)*(_q).multiple / sizeof((_q).queue[0])); \
+ (_q).is_full = KAL_FALSE; \
+}while(0)
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_INSERT
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+* _item is the item to be inserted to the queue
+*
+* RETURNS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+/* (_q).tail = ((_q).tail + 1) % (sizeof((_q).queue)*(_q).multiple/sizeof((_q).queue[0])); */
+#define LCD_IP_CQUEUE_INSERT(_q, _item) \
+do{ \
+ (_q).queue[(_q).tail] = _item; \
+ (_q).tail++; \
+ if ((_q).tail == (_q).total_item) \
+ (_q).tail = 0; \
+ if ((_q).head == (_q).tail) { (_q).is_full = KAL_TRUE; } \
+}while(0)
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_INSERT_DISCARD
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+*
+* RETURNS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+
+#define LCD_IP_CQUEUE_INSERT_DISCARD(_q) \
+do{ \
+ /* (_q).queue[(_q).tail] = _item; */ \
+ (_q).tail++; \
+ if ((_q).tail == (_q).total_item) \
+ (_q).tail = 0; \
+ if ((_q).head == (_q).tail) { (_q).is_full = KAL_TRUE; } \
+}while(0)
+
+/*************************************************************************
+ * FUNCTION
+ * LCD_IP_CQUEUE_INSERT_HEAD
+ *
+ * DESCRIPTION
+ *
+ * PARAMETERS
+ * _q is the structure variable of the queue
+ * _item is the item to be inserted to the queue
+ *
+ * RETURNS
+ *
+ * GLOBALS AFFECTED
+ *
+ *************************************************************************/
+
+#define LCD_IP_CQUEUE_INSERT_HEAD(_q, _item) \
+do{ \
+ if((_q).head == 0) {(_q).head = (_q).total_item; } \
+ (_q).head--; \
+ (_q).queue[(_q).head] = _item; \
+ if ((_q).head == (_q).tail) { (_q).is_full = KAL_TRUE; } \
+}while(0)
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_REMOVE
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+* _item is the variable to which removed item is stored
+*
+* RETURNS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+/*(_q).head = ((_q).head + 1) % (sizeof((_q).queue)*(_q).multiple/sizeof((_q).queue[0]));*/
+
+#define LCD_IP_CQUEUE_REMOVE(_q, _item) \
+do{ \
+ _item = (_q).queue[(_q).head]; \
+ (_q).head++; \
+ if((_q).head == (_q).total_item) \
+ (_q).head = 0; \
+ if ((_q).is_full == KAL_TRUE) \
+ (_q).is_full = KAL_FALSE; \
+}while(0)
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_DISCARD
+*
+* DESCRIPTION
+* Just for removing last node from CQUEUE
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+*
+* RETURNS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+/*(_q).head = ((_q).head + 1) % (sizeof((_q).queue)*(_q).multiple/sizeof((_q).queue[0]));*/
+#define LCD_IP_CQUEUE_DISCARD(_q) \
+do{ \
+ /*_item = (_q).queue[(_q).head];*/ \
+ (_q).head++; \
+ if((_q).head == (_q).total_item) \
+ (_q).head = 0; \
+ if ((_q).is_full == KAL_TRUE) \
+ (_q).is_full = KAL_FALSE; \
+}while(0)
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_NUM_OF_ITEMS
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+* _num_of_items is the variable to which the
+* number of items in the queue is assigned
+*
+* RETURNS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+
+#define LCD_IP_CQUEUE_NUM_OF_ITEMS(_q,_num_of_items) \
+do{ \
+ if((_q).is_full) \
+ _num_of_items = (_q).total_item; \
+ else if((_q).tail >= (_q).head) \
+ _num_of_items = (_q).tail - (_q).head; \
+ else \
+ _num_of_items = (_q).tail + (_q).total_item - (_q).head; \
+}while(0)
+
+#define LCD_IP_CQUEUE_RETURN_NUM_OF_ITEMS(_q) \
+ ((_q).is_full ? ((_q).total_item) : \
+ ((_q).tail >= (_q).head ? ((_q).tail - (_q).head) : \
+ ((_q).tail + (_q).total_item - (_q).head)))
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_INDEX
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+* _index is the index position of the queue from which queue item to be accessed
+* _item is the variable to which element at index is stored.
+*
+* RETURNS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+
+#define LCD_IP_CQUEUE_INDEX(_q,_index,_item) \
+do{ \
+ if(((_q).head + _index) > ((_q).total_item - 1)) \
+ { \
+ /*user need to ensure index must be in scope [0,q->size-1], which is the valid-scope*/ \
+ ASSERT(((_q).head + _index - (_q).total_item) <= ((_q).total_item - 1)); \
+ _item = (_q).queue[(_q).head + _index - (_q).total_item]; \
+ } \
+ else \
+ _item = (_q).queue[(_q).head + _index]; \
+}while(0)
+
+
+#define LCD_IP_CQUEUE_UPDATE_MAX(_q, _max) \
+do{ \
+ LCD_IP_CQUEUE_NUM_OF_ITEMS(_q, _max); \
+ if (_max > (_q).max_used_item) \
+ { \
+ (_q).max_used_item = _max; \
+ } \
+ else if (_max < (_q).max_used_item) \
+ { \
+ _max = (_q).max_used_item; \
+ } \
+}while(0)
+
+#define LCD_UP_CQUEUE_UPDATE_MAX(_q, _max) LCD_IP_CQUEUE_UPDATE_MAX(_q, _max)
+
+/* _q is the structure variable of the queue */
+#define LCD_IP_CQUEUE_IS_FULL(_q) ((_q).is_full)
+#define LCD_IP_CQUEUE_IS_EMPTY(_q) (((_q).head == (_q).tail) && !(_q).is_full)
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_MT
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _type is the type of item to be put in queue.
+* _length is the size of the queue.
+*
+* RETURNS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+#define LCD_IP_CQUEUE_MT(_type, _length) \
+ struct { \
+ unsigned int head; \
+ unsigned int tail; \
+ unsigned int multiple; \
+ unsigned int max_used_item; \
+ unsigned int total_item; \
+ unsigned int lock_flag; \
+ kal_bool is_full; \
+ _type queue[_length]; \
+ }
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_INIT_MT
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+*
+* RETURNS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+
+#define LCD_IP_CQUEUE_INIT_N_MT(_q, n) \
+ do{ \
+ (_q).head = (_q).tail = 0; \
+ (_q).multiple = n; \
+ (_q).max_used_item = 0; \
+ (_q).total_item = (sizeof((_q).queue)*(_q).multiple / sizeof((_q).queue[0])); \
+ (_q).lock_flag = 0; \
+ (_q).is_full = KAL_FALSE; \
+ }while(0)
+
+#define LCD_IP_CQUEUE_INIT_MT(_q) LCD_IP_CQUEUE_INIT_N_MT(_q, 1)
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_INSERT_MT
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+* _item is the item to be inserted to the queue
+* _is_full is the queue full flag before insert item
+*
+* RETURNS
+* _is_full
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+
+#define LCD_IP_CQUEUE_INSERT_MT(_q, _item, _is_full) \
+do{ \
+ LCD_IP_CQUEUE_MT_LOCK((_q).lock_flag); \
+ if (!LCD_IP_CQUEUE_IS_FULL(_q)) { \
+ _is_full = KAL_FALSE; \
+ LCD_IP_CQUEUE_INSERT(_q, _item); \
+ } else { \
+ _is_full = KAL_TRUE; \
+ } \
+ LCD_IP_CQUEUE_MT_UNLOCK((_q).lock_flag); \
+}while(0)
+
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_INSERT_DISCARD_MT
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+* _is_full is the queue full flag before insert item
+*
+* RETURNS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+
+#define LCD_IP_CQUEUE_INSERT_DISCARD_MT(_q, _is_full) \
+do{ \
+ LCD_IP_CQUEUE_MT_LOCK((_q).lock_flag); \
+ if (!LCD_IP_CQUEUE_IS_FULL(_q)) { \
+ _is_full = KAL_FALSE; \
+ LCD_IP_CQUEUE_INSERT_DISCARD(_q); \
+ } else { \
+ _is_full = KAL_TRUE; \
+ } \
+ LCD_IP_CQUEUE_MT_UNLOCK((_q).lock_flag); \
+}while(0)
+
+
+/*************************************************************************
+ * FUNCTION
+ * LCD_IP_CQUEUE_INSERT_HEAD_MT
+ *
+ * DESCRIPTION
+ *
+ * PARAMETERS
+ * _q is the structure variable of the queue
+ * _item is the item to be inserted to the queue
+ * _is_full is the queue full flag before insert item
+ *
+ * RETURNS
+ * _is_full
+ *
+ * GLOBALS AFFECTED
+ *
+ *************************************************************************/
+
+#define LCD_IP_CQUEUE_INSERT_HEAD_MT(_q, _item, _is_full) \
+do{ \
+ LCD_IP_CQUEUE_MT_LOCK((_q).lock_flag); \
+ if (!LCD_IP_CQUEUE_IS_FULL(_q)) { \
+ _is_full = KAL_FALSE; \
+ LCD_IP_CQUEUE_INSERT_HEAD(_q, _item); \
+ } else { \
+ _is_full = KAL_TRUE; \
+ } \
+ LCD_IP_CQUEUE_MT_UNLOCK((_q).lock_flag); \
+}while(0)
+
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_REMOVE_MT
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+* _item is the variable to which removed item is stored
+* _is_empty is the queue empty flag before remove item
+*
+* RETURNS
+* _is_empty
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+
+#define LCD_IP_CQUEUE_REMOVE_MT(_q, _item, _is_empty) \
+do{ \
+ LCD_IP_CQUEUE_MT_LOCK((_q).lock_flag); \
+ if (!LCD_IP_CQUEUE_IS_EMPTY(_q)) { \
+ _is_empty = KAL_FALSE; \
+ LCD_IP_CQUEUE_REMOVE(_q, _item); \
+ } else { \
+ _is_empty = KAL_TRUE; \
+ } \
+ LCD_IP_CQUEUE_MT_UNLOCK((_q).lock_flag); \
+}while(0)
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_DISCARD_MT
+*
+* DESCRIPTION
+* Just for removing last node from CQUEUE
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+* _is_empty is the queue empty flag before remove item
+*
+* RETURNS
+* _is_empty
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+
+#define LCD_IP_CQUEUE_DISCARD_MT(_q, _is_empty) \
+do{ \
+ LCD_IP_CQUEUE_MT_LOCK((_q).lock_flag); \
+ if (!LCD_IP_CQUEUE_IS_EMPTY(_q)) { \
+ _is_empty = KAL_FALSE; \
+ LCD_IP_CQUEUE_DISCARD(_q); \
+ } else { \
+ _is_empty = KAL_TRUE; \
+ } \
+ LCD_IP_CQUEUE_MT_UNLOCK((_q).lock_flag); \
+}while(0)
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_NUM_OF_ITEMS_MT
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+* _num_of_items is the variable to which the
+* number of items in the queue is assigned
+*
+* RETURNS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+
+#define LCD_IP_CQUEUE_NUM_OF_ITEMS_MT(_q,_num_of_items) \
+do{ \
+ LCD_IP_CQUEUE_MT_LOCK((_q).lock_flag); \
+ if((_q).is_full) \
+ _num_of_items = (_q).total_item; \
+ else if((_q).tail >= (_q).head) \
+ _num_of_items = (_q).tail - (_q).head; \
+ else \
+ _num_of_items = (_q).tail + (_q).total_item - (_q).head; \
+ LCD_IP_CQUEUE_MT_UNLOCK((_q).lock_flag); \
+}while(0)
+
+/*************************************************************************
+* FUNCTION
+* LCD_IP_CQUEUE_INDEX_MT
+*
+* DESCRIPTION
+*
+* PARAMETERS
+* _q is the structure variable of the queue
+* _index is the index position of the queue from which queue item to be accessed
+* _item is the variable to which element at index is stored.
+* _is_full is the queue full flag before insert item
+* _is_empty is the queue empty flag before remove item
+*
+* RETURNS
+* _is_full, _is_empty
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+
+#define LCD_IP_CQUEUE_INDEX_MT(_q,_index,_item, _is_full, _is_empty) \
+do{ \
+ LCD_IP_CQUEUE_MT_LOCK((_q).lock_flag); \
+ if (LCD_IP_CQUEUE_IS_FULL(_q)) \
+ _is_full = KAL_TRUE; \
+ else \
+ _is_full = KAL_FALSE; \
+ if (LCD_IP_CQUEUE_IS_EMPTY(_q) || (_index >= LCD_IP_CQUEUE_RETURN_NUM_OF_ITEMS(_q))) \
+ _is_empty = KAL_TRUE; \
+ else \
+ _is_empty = KAL_FALSE; \
+ LCD_IP_CQUEUE_INDEX(_q,_index,_item); \
+ LCD_IP_CQUEUE_MT_UNLOCK((_q).lock_flag); \
+}while(0)
+
+#define LCD_IP_CQUEUE_IS_FULL_MT(_q, _is_full) \
+do{ \
+ LCD_IP_CQUEUE_MT_LOCK((_q).lock_flag); \
+ _is_full = LCD_IP_CQUEUE_IS_FULL(_q); \
+ LCD_IP_CQUEUE_MT_UNLOCK((_q).lock_flag); \
+}while(0)
+
+#define LCD_IP_CQUEUE_IS_EMPTY_MT(_q, _is_empty) \
+do{ \
+ LCD_IP_CQUEUE_MT_LOCK((_q).lock_flag); \
+ _is_empty = LCD_IP_CQUEUE_IS_EMPTY(_q); \
+ LCD_IP_CQUEUE_MT_UNLOCK((_q).lock_flag); \
+}while(0)
+
+
+#endif /* _LCD_IP_CQUEUE_H */
diff --git a/mcu/interface/service/stacklib/lcd_lqueue.h b/mcu/interface/service/stacklib/lcd_lqueue.h
new file mode 100644
index 0000000..6bb8aca
--- /dev/null
+++ b/mcu/interface/service/stacklib/lcd_lqueue.h
@@ -0,0 +1,238 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * lcd_lqueue.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * Light weight C Data structures library: Linear Queue.
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*********************************************************************
+ (C) _____ (year of first publication) Sasken communication
+ Technologies Limited, All rights reserved.
+* This file provides a template for .c files. This space
+* should be used to describe the file contents
+* Component-specific prefix : xxxx
+*********************************************************************/
+
+#ifndef _LCD_LQUEUE_H
+#define _LCD_LQUEUE_H
+/*RHR*/
+#include "kal_general_types.h"
+//#include "stacklib.h"
+#include "lcd.h"
+#include "kal_public_api.h"
+/*RHR*/
+/*************************************************************************
+ * Macros Without Parameters
+ *************************************************************************/
+#define BIN_OVERHEAD 2
+
+/*************************************************************************
+ * Data structure definition
+ *************************************************************************/
+typedef enum {
+ NOT_SET,
+ BY_FN_P,
+ BY_USR_MEM
+}mem_for_items;
+
+/*************************************************************************
+ * Arbitrary Size Linear Queue
+ *************************************************************************/
+
+/* This queue works by maintaining a doubly linked list of bins of
+ * size bin_size, when the current bin is full a new bin is allocated
+ * and chained to the end of the current bin. Likewise when the last
+ * item in a bin is removed and the next bin is there, the current
+ * bin is freed and the head is moved to the first item in the next
+ * bin. See figure given bellow.
+ *
+ * ____ ____ ____ ____
+ * | | | | | | | |
+ * |____| |____| |____| |____|
+ * head ->| | | | | | | |
+ * |____| |____| |____| |____|
+ * | | | | | | | | <- tail
+ * |____| |____| |____| |____|
+ * | | | | | | | |
+ * |____|<---|____|<---|____|<---|____|
+ * | | | | | | | |
+ * |____| |____| |____| |____|
+ * |______^ |______^ |_______^
+ *
+ */
+
+typedef void * * lcd_lqueue_bin;
+
+typedef struct lcd_lqueue {
+ unsigned int bin_size;
+ /* The first bin. */
+ lcd_lqueue_bin start;
+ /* The position of the head within the bin. */
+ unsigned int head;
+ /* The last bin. */
+ lcd_lqueue_bin end;
+ /* The position of the tail within the bin. */
+ unsigned int tail;
+ /* Number of bins allocated so far. */
+ unsigned int bin_count;
+ /* Indicates the type of memory for items. */
+ mem_for_items item_mem;
+ kal_bool is_empty;
+ malloc_fp_t alloc_fn_p;
+ free_fp_t free_fn_p;
+} lcd_lqueue;
+
+/*************************************************************************
+ * Exported Function Prototypes
+ *************************************************************************/
+extern void lcd_lqueue_init(unsigned int bin_size,
+ malloc_fp_t alloc_fn_p,
+ free_fp_t free_fn_p,
+ lcd_lqueue *q);
+
+extern kal_uint32 lcd_lqueue_mem_size(unsigned int bin_size);
+
+extern kal_bool lcd_lqueue_insert_at_rear(lcd_lqueue *q,
+ void *item);
+
+extern kal_bool lcd_lqueue_insert_at_front(lcd_lqueue *q,
+ void *item);
+
+/* The following function will be removed once variable
+ * length array is implemented.
+ */
+extern void *lcd_lqueue_remove(lcd_lqueue *q, void **mem_to_free);
+
+extern void *lcd_lqueue_remove_rear(lcd_lqueue *q, void **mem_to_free);
+
+extern kal_bool lcd_lqueue_is_empty(lcd_lqueue *q);
+
+extern unsigned int lcd_lqueue_num_of_items(lcd_lqueue *q);
+
+extern void *lcd_lqueue_index(lcd_lqueue *q, unsigned int idx);
+
+extern void lcd_lqueue_map(lcd_lqueue *q, lcd_mapfunc f, void *info);
+
+/* The following function is a conditional map function
+ * which stop mapping items when function 'f' returns
+ * KAL_FALSE.If mapping is done for all items, it returns
+ * KAL_TRUE, else returns KAL_FALSE.
+ */
+extern kal_bool lcd_lqueue_cmap(lcd_lqueue *q, lcd_cmapfunc f, void *info);
+
+extern void lcd_lqueue_delete_all(lcd_lqueue *q);
+
+#ifdef _DEBUG_LCD_LQUEUE
+extern void lcd_lqueue_print(lcd_lqueue *q);
+#endif
+#endif /* _LCD_LQUEUE_H */
+
+
diff --git a/mcu/interface/service/stacklib/stacklib.h b/mcu/interface/service/stacklib/stacklib.h
new file mode 100644
index 0000000..2e27d5c
--- /dev/null
+++ b/mcu/interface/service/stacklib/stacklib.h
@@ -0,0 +1,114 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * stacklib.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * flc_data_struct
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef _STACKLIB_H
+#define _STACKLIB_H
+
+/*************************************************************************
+ * Type Definitions
+ *************************************************************************/
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/*************************************************************************
+ * Type Definitions
+ *************************************************************************/
+#include "lcd.h"
+#include "lcd_cqueue.h"
+// #include "lcd_dll.h" //remove lcd_dll, replaced by ./mcu/kal/mlib/mlib_dll
+#include "lcd_lqueue.h"
+
+#endif /* _STACKLIB_H */
+
+