[Feature]Upload Modem source code

Change-Id: Id4294f30faced84d3e6fd6d5e61e1111bf287a37
diff --git a/mcu/service/mtf/base/mt_dispatcher.c b/mcu/service/mtf/base/mt_dispatcher.c
new file mode 100644
index 0000000..d9a37dd
--- /dev/null
+++ b/mcu/service/mtf/base/mt_dispatcher.c
@@ -0,0 +1,154 @@
+/*****************************************************************************
+*  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) 2012
+*
+*  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:
+ * ---------
+ * mt_task.c
+ *
+ * Project:
+ * --------
+ * UMOLYA
+ *
+ * Description:
+ * ------------
+ * MT_Framework task implement 
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *
+ * ==========================================================================
+ * $Log$ 
+ *
+ * 
+ ****************************************************************************/
+
+/*****************************************************************************/
+/*                            Includes                                       */
+/*****************************************************************************/
+
+#include "mt.h"
+#include "mt_dispatcher.h"
+
+/*****************************************************************************/
+/*                               Define                                      */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Global variables                                  */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         External functions                                */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Internal functions                                */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Function Body                                     */
+/*****************************************************************************/
+
+int
+mt_dispatcher_entry_init(void* entry, kal_uint16 magic, kal_uint32 dispatch_key, kal_uint32 dispatch_key_mask)
+{
+	mt_dispatcher_entry_head_t *h = entry;
+	if (h->inited) {
+		return -1;
+	}
+	
+	h->magic = magic;
+	h->inited = KAL_TRUE;
+	h->dispatch_key = dispatch_key;
+	h->next = NULL;
+    h->dispatch_key_mask= dispatch_key_mask;
+	
+	return 0;
+}
+
+int
+mt_dispatcher_add_entry(mt_dispatcher_list_t *list, kal_uint32 code, void* entry)
+{
+	mt_dispatcher_entry_head_t *e = entry;
+	e->next = NULL;
+	e->dispatch_key = code;
+	if (list->tail == NULL) {
+		list->head = list->tail = e;
+	} else {
+		list->tail = ((mt_dispatcher_entry_head_t *)list->tail)->next = e;
+	}
+    
+    return 0;
+}
+
+void*
+mt_dispatcher_find_entry(mt_dispatcher_list_t *list, kal_uint32 code, void* last_entry)
+{
+	mt_dispatcher_entry_head_t *e = (last_entry?((mt_dispatcher_entry_head_t *)last_entry)->next:list->head);
+	while(e) {
+        if (e->dispatch_key_mask == RULE_CODE_MASK_FLAG_ALL_ON && e->dispatch_key == code)
+        {
+			return e;
+        }
+        else if (e->dispatch_key_mask == RULE_CODE_MASK_FLAG_ALL_OFF)
+        {
+            return e;
+        }
+        else if(((e->dispatch_key_mask & RULE_CODE_MASK_ICD_TYPE_FLAG_ON)?(GET_ICD_TYPE_FROM_RULE_CODE(e->dispatch_key) == GET_ICD_TYPE_FROM_RULE_CODE(code)):KAL_TRUE)
+            && ((e->dispatch_key_mask & RULE_CODE_MASK_ICD_CODE_FLAG_ON)?(GET_ICD_CODE_FROM_RULE_CODE(e->dispatch_key) == GET_ICD_CODE_FROM_RULE_CODE(code)):KAL_TRUE)
+            && ((e->dispatch_key_mask & RULE_CODE_MASK_ICD_PROTOCOL_FLAG_ON)?(GET_ICD_PROTOCOL_FROM_RULE_CODE(e->dispatch_key) == GET_ICD_PROTOCOL_FROM_RULE_CODE(code)):KAL_TRUE))
+        {
+            return e;
+        }
+        e = e->next;
+	}
+	return NULL;
+}
+void 
+mt_dispatcher_verify(void* d, kal_uint16 magic)
+{
+	mt_dispatcher_entry_head_t *e = d;
+	EXT_ASSERT(e->magic == magic, e->magic, magic, 0);
+}
+
+void
+mt_dispatcher_init()
+{
+	EXT_ASSERT(MT_DISPATCHER_ENTRY_RESERVED_SIZE >= sizeof(mt_dispatcher_entry_head_t), MT_DISPATCHER_ENTRY_RESERVED_SIZE, sizeof(mt_dispatcher_entry_head_t), 0);
+}
diff --git a/mcu/service/mtf/base/mt_task.c b/mcu/service/mtf/base/mt_task.c
new file mode 100644
index 0000000..0947dcd
--- /dev/null
+++ b/mcu/service/mtf/base/mt_task.c
@@ -0,0 +1,294 @@
+/*****************************************************************************
+*  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) 2012
+*
+*  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:
+ * ---------
+ * mt_task.c
+ *
+ * Project:
+ * --------
+ * UMOLYA
+ *
+ * Description:
+ * ------------
+ * MT_Framework task implement 
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *
+ * ==========================================================================
+ * $Log$ 
+ *
+ * 
+ ****************************************************************************/
+
+/*****************************************************************************/
+/*                            Includes                                       */
+/*****************************************************************************/
+#include "mt.h"
+#include "mte_if.h"
+#include "mt_dispatcher.h"
+#include "mtf_msgid.h"
+#include "em_msgid.h"
+#include "dhl_trace.h"
+#include "dhl_def.h"
+
+#include "srv_modid.h"
+
+#include "tst_msgid.h"
+#include "tst_sap.h"
+
+#include "nvram_defs.h"
+#include "nvram_interface.h"
+#include "nvram_msgid.h"
+
+
+/*****************************************************************************/
+/*                               Define                                      */
+/*****************************************************************************/
+
+#define MT_MAGIC_FORMATTER (0x8877)
+#define MT_MAGIC_ELEMENT (0x5566)
+
+#define MT_FORMATTER_MASK (0x1111)
+
+/*****************************************************************************/
+/*                         Global variables                                  */
+/*****************************************************************************/
+mt_context_t mt;
+event_scheduler *mtf_event_scheduler;
+/*****************************************************************************/
+/*                         External functions                                */
+/*****************************************************************************/
+extern nvram_ltable_entry_struct logical_data_item_table_mtf[];
+
+/*****************************************************************************/
+/*                         Internal functions                                */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Function Body                                     */
+/*****************************************************************************/
+
+
+void
+mt_register_formatter(mt_formatter_t *formatter)
+{
+	int result;
+	EXT_ASSERT(formatter, 0, 0, 0);
+	EXT_ASSERT(formatter->fmt_id < MT_FMT_MAX, formatter->fmt_id, MT_FMT_MAX, 0);
+	
+	result = mt_dispatcher_entry_init(formatter, MT_MAGIC_FORMATTER, formatter->ilm_msg_id, MT_FORMATTER_MASK);
+	EXT_ASSERT(result == 0, result, 0, formatter->ilm_msg_id);
+	
+	mt.formatter[formatter->fmt_id] = formatter;
+	
+	if (formatter->fmt_id != MT_FMT_ILM) {
+		result = mt_dispatcher_add_entry(&mt.formatter_list, formatter->ilm_msg_id, formatter);	
+		EXT_ASSERT(result == 0, result, formatter->fmt_id, 0);
+	}
+}
+
+void 
+mt_register_mte_rule(mte_rule_t *mte_rule)
+{
+	mt_register_mte_rule_with_mask(mte_rule, RULE_CODE_MASK_FLAG_ALL_ON);
+}
+
+void 
+mt_register_mte_rule_with_mask(mte_rule_t *mte_rule, kal_uint32 rule_code_mask)
+{
+	int result;
+	mt_formatter_t *f;
+    
+	EXT_ASSERT(mte_rule, 0, 0, 0);
+	EXT_ASSERT(mte_rule->fmt_id < MT_FMT_MAX, mte_rule, mte_rule->fmt_id, mte_rule->code);
+	EXT_ASSERT(mte_rule->execute, mte_rule, mte_rule->fmt_id, mte_rule->code);
+	
+	result = mt_dispatcher_entry_init(mte_rule, MT_MAGIC_ELEMENT, mte_rule->code, rule_code_mask);
+	EXT_ASSERT(result == 0, result, mte_rule->fmt_id, mte_rule->code);
+	
+	f = mt.formatter[mte_rule->fmt_id];
+	EXT_ASSERT(f, mte_rule->fmt_id, mte_rule, 0);
+	
+	result = mt_dispatcher_add_entry(&f->element_list, mte_rule->code, mte_rule);
+	EXT_ASSERT(result == 0, result, mte_rule->code, mte_rule);
+}
+
+
+kal_bool mt_send_to_framework(ilm_struct *ilm_ptr)
+{
+    if(ilm_ptr->msg_id == MSG_ID_DHL_MT_ICD_IND || 
+        ilm_ptr->msg_id == MSG_ID_DHL_MT_PEER_TRACE_IND ||
+#ifdef __IMS_SUPPORT__
+        ilm_ptr->msg_id == MSG_ID_EM_IMC_SIP_INFO_IND ||
+#endif
+        ilm_ptr->msg_id == MSG_ID_EM_RRCE_NW_PEER_MSG_INFO_IND)
+    {
+        //ICD or PEER_TRACE formatter would use Peer buffer
+        hold_peer_buff(ilm_ptr->peer_buff_ptr);
+    }
+    
+    hold_local_para(ilm_ptr->local_para_ptr);
+    ilm_ptr->dest_mod_id = MOD_MT;   
+    ilm_ptr->sap_id = MTF_SAP; 
+    //provide temp solution wariting for DMF confirm how to handle peer_buff == NULL
+    if(ilm_ptr->msg_id == MSG_ID_DHL_MT_ICD_IND && NULL == ilm_ptr->peer_buff_ptr){
+        dhl_print(TRACE_INFO, DHL_USER_FLAG_NONE, MOD_MT, "[MT][Warning] cancel to DMF: null ICD info");
+        return KAL_FALSE;
+    }
+    msg_send(ilm_ptr);
+    return KAL_TRUE;
+}
+
+kal_bool 
+mt_task_init()
+{
+    mtf_event_scheduler = evshed_create("MTFEvs", MOD_MT, 0, MAX_DELAY_UNLIMITED);
+    evshed_set_index(mtf_event_scheduler, MTF_USER_TIMER_ID);
+
+    mt_dispatcher_init();
+    mt_formatters_init();
+    mt_elements_init();
+
+	nvram_ltable_register(logical_data_item_table_mtf);
+    return KAL_TRUE;
+}
+
+kal_bool 
+mt_task_reset(void)
+{
+    evshed_delete_all_events(mtf_event_scheduler);
+    mt_elements_reset();
+    return KAL_TRUE;
+}
+
+
+extern void mte_att_set_em_filters();
+extern void mte_att_set_icd_filters();
+void mt_tst_inject_string_hdlr(ilm_struct *ilm_ptr)
+{
+    tst_module_string_inject_struct *msg_ptr;
+
+    msg_ptr = (tst_module_string_inject_struct*) ilm_ptr->local_para_ptr;
+
+    switch(msg_ptr->index)
+    {
+
+        default:
+            break;
+    }
+}
+
+void 
+mt_task_main(task_entry_struct* task_entry_ptr)
+{
+	ilm_struct current_ilm;
+
+	kal_set_active_module_id(MOD_MT);
+	dhl_print(TRACE_STATE, DHL_USER_FLAG_NONE, MOD_MT, "enter mt_task_main");
+
+	mt_elements_init_proc();
+    
+	while(1) {
+		mt_formatter_t *f;		
+		mt_msginfo_t m;
+		mte_rule_t *r = NULL;
+        
+		msg_receive_extq(&current_ilm);
+
+
+		if (current_ilm.msg_id == MSG_ID_TST_INJECT_STRING)
+		{
+			mt_tst_inject_string_hdlr(&current_ilm);
+			continue;
+		}
+
+        if(current_ilm.msg_id == MSG_ID_TIMER_EXPIRY)
+        {
+           kal_uint16 timer_indx = evshed_get_index(&current_ilm);
+           if(timer_indx == MTF_USER_TIMER_ID)
+           {
+              evshed_timer_handler(mtf_event_scheduler);
+           }
+           continue;
+        }
+		 if(current_ilm.msg_id == MSG_ID_NVRAM_WRITE_CNF)
+        {
+           mt_nvram_write_cnf_hdlr(&current_ilm);
+		   destroy_ilm(&current_ilm);
+		   continue;
+        }
+  
+		if (!(f = mt_dispatcher_find_entry(&mt.formatter_list, current_ilm.msg_id, NULL))) {
+			f = mt.formatter[MT_FMT_ILM];
+		}
+		if (!f) {
+			continue;
+		}
+		mt_dispatcher_verify(f, MT_MAGIC_FORMATTER);
+		
+
+		f->extract_msginfo(&current_ilm, &m);// put current ilm content to msginfo
+
+
+        while ((r = mt_dispatcher_find_entry(&f->element_list, m.code, r))) {
+    		mt_dispatcher_verify(r, MT_MAGIC_ELEMENT);
+		    r->code = m.code;// for masking code user to get current code
+    		r->execute(r, m.msg, m.msg_size);
+        }
+		destroy_ilm(&current_ilm);
+	}
+}
+
+#ifndef STANDALONE_TEST
+kal_bool
+mt_create(comptask_handler_struct **handle)
+{
+	static const comptask_handler_struct task_handler_info =
+	{
+		mt_task_main,    /* task entry function */
+		mt_task_init,    /* task initialization function */
+		mt_task_reset    /* task reset handler */
+	};
+
+	*handle = (comptask_handler_struct *)&task_handler_info;
+	return KAL_TRUE;
+}
+#endif 
diff --git a/mcu/service/mtf/base/mt_task_clean.c b/mcu/service/mtf/base/mt_task_clean.c
new file mode 100644
index 0000000..a6a5a75
--- /dev/null
+++ b/mcu/service/mtf/base/mt_task_clean.c
@@ -0,0 +1,100 @@
+/*****************************************************************************
+*  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) 2012
+*
+*  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:
+ * ---------
+ * mt_task_clean.c
+ *
+ * Project:
+ * --------
+ * UMOLYA
+ *
+ * Description:
+ * ------------
+ * implementation for cleanning of MT_Framework task
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *
+ * ==========================================================================
+ * $Log$ 
+ *
+ * 
+ ****************************************************************************/
+
+/*****************************************************************************/
+/*                            Includes                                       */
+/*****************************************************************************/
+#include "kal_public_defs.h"
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+
+
+/*****************************************************************************/
+/*                               Define                                      */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Global variables                                  */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         External functions                                */
+/*****************************************************************************/
+extern void dmf_module_clean(void);
+
+/*****************************************************************************/
+/*                         Internal functions                                */
+/*****************************************************************************/
+void mt_task_clean_handler(void);
+
+/*****************************************************************************/
+/*                         Function Body                                     */
+/*****************************************************************************/
+
+
+void mt_task_clean_handler(void)
+{
+
+#ifdef __DMF_SUPPORT__
+    dmf_module_clean();
+#endif
+
+}
+
diff --git a/mcu/service/mtf/formatter/mtf_base.c b/mcu/service/mtf/formatter/mtf_base.c
new file mode 100644
index 0000000..57bbd11
--- /dev/null
+++ b/mcu/service/mtf/formatter/mtf_base.c
@@ -0,0 +1,77 @@
+/*****************************************************************************
+*  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) 2012
+*
+*  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:
+ * ---------
+ * mtf_base.c
+ *
+ * Project:
+ * --------
+ * UMOLYA
+ *
+ * Description:
+ * ------------
+ * MT_Framework formatter init function 
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *
+ * ==========================================================================
+ * $Log$ 
+ *
+ * 
+ ****************************************************************************/
+
+/*****************************************************************************/
+/*                            Includes                                       */
+/*****************************************************************************/
+
+#include "mt.h"
+
+void mtf_ilm_create();
+void mtf_icd_create();
+void mtf_peer_trace_create();
+
+void
+mt_formatters_init()
+{
+	mtf_ilm_create();
+	mtf_icd_create();
+    mtf_peer_trace_create();
+}
diff --git a/mcu/service/mtf/formatter/mtf_icd.c b/mcu/service/mtf/formatter/mtf_icd.c
new file mode 100644
index 0000000..4b7b20a
--- /dev/null
+++ b/mcu/service/mtf/formatter/mtf_icd.c
@@ -0,0 +1,121 @@
+/*****************************************************************************
+*  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) 2012
+*
+*  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:
+ * ---------
+ * mtf_icd.c
+ *
+ * Project:
+ * --------
+ * UMOLYA
+ *
+ * Description:
+ * ------------
+ * MT_Framework icd formatter implement 
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *
+ * ==========================================================================
+ * $Log$ 
+ *
+ * 
+ ****************************************************************************/
+
+/*****************************************************************************/
+/*                            Includes                                       */
+/*****************************************************************************/
+
+#include "mtf_if.h"
+#include "mtf_msgid.h"
+#include "kal_public_api.h"
+#include "mtf_struct.h" //wait for icd_logging.h check in
+
+/*****************************************************************************/
+/*                               Define                                      */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Global variables                                  */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         External functions                                */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Internal functions                                */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Function Body                                     */
+/*****************************************************************************/
+#include "dhl_trace.h"
+int
+mtf_icd_extract_msginfo(const ilm_struct *ilm, mt_msginfo_t *msginfo)
+{
+
+    kal_uint16 length;
+    dhl_mt_icd_ind_struct *icd_header;
+    icd_header = (dhl_mt_icd_ind_struct*)ilm->local_para_ptr;
+    msginfo->code = GET_RULE_CODE(icd_header->icd_type, icd_header->code, icd_header->protocol_id);
+    dhl_print(TRACE_INFO, DHL_USER_FLAG_NONE, MOD_MT, "[MT] msginfo->code= %d", msginfo->code);
+    if(ilm->peer_buff_ptr == NULL)
+    {
+        msginfo->msg = NULL;
+        msginfo->msg_size = 0;
+    }
+    else
+    {
+        msginfo->msg = get_peer_buff_pdu(ilm->peer_buff_ptr, &length);
+        msginfo->msg_size = icd_header->raw_data_len;
+    }
+
+	return 0;
+}
+
+void
+mtf_icd_create()
+{
+	static mt_formatter_t fmt;
+	fmt.fmt_id = MT_FMT_ICD;
+	fmt.ilm_msg_id = MSG_ID_DHL_MT_ICD_IND;
+	fmt.extract_msginfo = mtf_icd_extract_msginfo;
+	mt_register_formatter(&fmt);	
+}
diff --git a/mcu/service/mtf/formatter/mtf_ilm.c b/mcu/service/mtf/formatter/mtf_ilm.c
new file mode 100644
index 0000000..d0490f3
--- /dev/null
+++ b/mcu/service/mtf/formatter/mtf_ilm.c
@@ -0,0 +1,105 @@
+/*****************************************************************************
+*  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) 2012
+*
+*  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:
+ * ---------
+ * mtf_ilm.c
+ *
+ * Project:
+ * --------
+ * UMOLYA
+ *
+ * Description:
+ * ------------
+ * MT_Framework ilm formatter implement 
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *
+ * ==========================================================================
+ * $Log$ 
+ *
+ * 
+ ****************************************************************************/
+
+/*****************************************************************************/
+/*                            Includes                                       */
+/*****************************************************************************/
+
+#include "mtf_if.h"
+
+/*****************************************************************************/
+/*                               Define                                      */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Global variables                                  */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         External functions                                */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Internal functions                                */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Function Body                                     */
+/*****************************************************************************/
+
+int
+mtf_ilm_extract_msginfo(const ilm_struct *ilm, mt_msginfo_t *msginfo)
+{
+	msginfo->code = ilm->msg_id; 
+	msginfo->msg = (void *)ilm;
+	msginfo->msg_size = sizeof(ilm_struct);
+	
+	return 0;
+}
+
+void
+mtf_ilm_create()
+{
+	static mt_formatter_t fmt;
+	fmt.fmt_id = MT_FMT_ILM;
+	fmt.ilm_msg_id = 0; // not used for MT_SRC_ILM
+	fmt.extract_msginfo = mtf_ilm_extract_msginfo;
+	mt_register_formatter(&fmt);
+}
diff --git a/mcu/service/mtf/formatter/mtf_peer_trace.c b/mcu/service/mtf/formatter/mtf_peer_trace.c
new file mode 100644
index 0000000..3f0333a
--- /dev/null
+++ b/mcu/service/mtf/formatter/mtf_peer_trace.c
@@ -0,0 +1,109 @@
+/*****************************************************************************
+*  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) 2012
+*
+*  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:
+ * ---------
+ * mtf_peer_trace.c
+ *
+ * Project:
+ * --------
+ * UMOLYA
+ *
+ * Description:
+ * ------------
+ * MT_Framework peer_trace formatter implement 
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *
+ * ==========================================================================
+ * $Log$ 
+ *
+ * 
+ ****************************************************************************/
+
+/*****************************************************************************/
+/*                            Includes                                       */
+/*****************************************************************************/
+
+#include "mtf_if.h"
+#include "mtf_msgid.h"
+#include "mtf_struct.h" //wait for icd_logging.h check in
+
+/*****************************************************************************/
+/*                               Define                                      */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Global variables                                  */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         External functions                                */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Internal functions                                */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Function Body                                     */
+/*****************************************************************************/
+
+int
+mtf_peer_trace_extract_msginfo(const ilm_struct *ilm, mt_msginfo_t *msginfo)
+{
+    dhl_mt_peer_trace_ind_struct *peer_trace_header;
+    peer_trace_header = (dhl_mt_peer_trace_ind_struct *)ilm->local_para_ptr;
+    msginfo->code = peer_trace_header->global_peer_msg_id;
+    msginfo->msg = (void *)ilm;
+    msginfo->msg_size = sizeof(ilm_struct);
+	return 0;
+}
+
+void
+mtf_peer_trace_create()
+{
+	static mt_formatter_t fmt;
+	fmt.fmt_id = MT_FMT_PEER_TRACE;
+	fmt.ilm_msg_id = MSG_ID_DHL_MT_PEER_TRACE_IND;
+	fmt.extract_msginfo = mtf_peer_trace_extract_msginfo;
+	mt_register_formatter(&fmt);	
+}
+
diff --git a/mcu/service/mtf/inc/mt.h b/mcu/service/mtf/inc/mt.h
new file mode 100644
index 0000000..57cfb92
--- /dev/null
+++ b/mcu/service/mtf/inc/mt.h
@@ -0,0 +1,95 @@
+/*****************************************************************************
+*  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) 2012
+*
+*  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:
+ * ---------
+ * mt.h
+ *
+ * Project:
+ * --------
+ * UMOLYA
+ *
+ * Description:
+ * ------------
+ * MT Framework data structures
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *
+ * ==========================================================================
+ * $Log$ 
+ *
+ * 
+ ****************************************************************************/
+#ifndef _MT_H_
+#define _MT_H_
+
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "syscomp_config.h"
+#include "mtf_if.h"
+
+
+#define MSG_ID_OF_INCOMING_ICD (999)
+#define MTF_USER_TIMER_ID (0)
+extern event_scheduler *mtf_event_scheduler;
+
+typedef struct _mt_context_t
+{
+    mt_formatter_t* formatter[MT_FMT_MAX];
+	mt_dispatcher_list_t formatter_list;
+} mt_context_t;
+
+typedef struct _mt_dispatcher_entry_head_t
+{
+    kal_uint16 magic;
+    kal_bool inited;
+    struct _mt_dispatcher_entry_head_t *next;
+    kal_uint32 dispatch_key;
+    kal_uint32 dispatch_key_mask;
+} mt_dispatcher_entry_head_t;
+
+/// enum for metric destination ID
+typedef enum _mt_dest_id {
+  MT_CIQ, ///< ilm_struct format
+  MT_DEST_MAX
+} mt_dest_id;
+
+#endif
+
diff --git a/mcu/service/mtf/inc/mt_dispatcher.h b/mcu/service/mtf/inc/mt_dispatcher.h
new file mode 100644
index 0000000..0a70d12
--- /dev/null
+++ b/mcu/service/mtf/inc/mt_dispatcher.h
@@ -0,0 +1,92 @@
+/*****************************************************************************
+*  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) 2012
+*
+*  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:
+ * ---------
+ * mt_dispathcer.h
+ *
+ * Project:
+ * --------
+ * UMOLYA
+ *
+ * Description:
+ * ------------
+ * MT Framework dispatcher prototyes
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *
+ * ==========================================================================
+ * $Log$ 
+ *
+ * 
+ ****************************************************************************/
+#ifndef _MT_DISPATCHER_H_
+#define _MT_DISPATCHER_H_
+
+#include "kal_general_types.h"
+
+#ifdef __MTK_TARGET__
+#define MT_DISPATCHER_ENTRY_RESERVED_SIZE	(16)
+#else
+#define MT_DISPATCHER_ENTRY_RESERVED_SIZE	(20)
+#endif
+
+#define GET_RULE_CODE(type, code, protocol)   ( 0xFFFFFFFF & (protocol | code << 2 | type << 18) )
+#define GET_ICD_TYPE_FROM_RULE_CODE(code)     ( 0x00000003 & (code) >> 18)
+#define GET_ICD_CODE_FROM_RULE_CODE(code)     ( 0x0000FFFF & (code) >> 2)
+#define GET_ICD_PROTOCOL_FROM_RULE_CODE(code) ( 0x00000003 & (code) )
+#define RULE_CODE_MASK_ICD_TYPE_FLAG_ON       (0x1)    // check icd type match the rule code
+#define RULE_CODE_MASK_ICD_CODE_FLAG_ON       (0x10)   // check icd code match the rule code
+#define RULE_CODE_MASK_ICD_PROTOCOL_FLAG_ON   (0x100)  // check protocol match the rule code
+#define RULE_CODE_MASK_FLAG_ALL_ON            (0x1111) //default: type, icd code and protocol must match the rule code
+#define RULE_CODE_MASK_FLAG_ALL_OFF           (0x0000) // no need to check icd type, code and protocl match the rule code 
+
+typedef struct _mt_dispatcher_list_t {
+	void *head;
+	void *tail;
+} mt_dispatcher_list_t;
+
+int mt_dispatcher_entry_init(void* entry, kal_uint16 magic, kal_uint32 dispatch_key, kal_uint32 dispatch_key_mask);
+int mt_dispatcher_add_entry(mt_dispatcher_list_t *tbl, kal_uint32 code, void* entry);
+void* mt_dispatcher_find_entry(mt_dispatcher_list_t *tbl, kal_uint32 code, void* last_entry);
+void mt_dispatcher_init();
+void mt_dispatcher_verify(void* e, kal_uint16 magic);
+
+#endif // _MT_DISPATCHER_H_
\ No newline at end of file
diff --git a/mcu/service/mtf/inc/mte_if.h b/mcu/service/mtf/inc/mte_if.h
new file mode 100644
index 0000000..5754bcf
--- /dev/null
+++ b/mcu/service/mtf/inc/mte_if.h
@@ -0,0 +1,222 @@
+/*****************************************************************************
+*  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) 2012
+*
+*  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:
+ * ---------
+ * mte_if.h
+ *
+ * Project:
+ * --------
+ * UMOLYA
+ *
+ * Description:
+ * ------------
+ * MT Framework element prototyes
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *
+ * ==========================================================================
+ * $Log$ 
+ *
+ * 
+ ****************************************************************************/
+
+ 
+#ifndef _MTE_IF_
+#define _MTE_IF_
+
+#include "mt.h"
+#include "mt_dispatcher.h" 
+
+
+#define MT_METRICS_UNIT_TEST
+
+/**
+ * @name mt_set_timer_event
+ *
+ * @brief set an timer event from mtf event scheduler
+ * 
+ * @param [in] callback         the callback function when event timeout
+ * @param [in] callbackparam    the user supplied argument for callback function
+ * @param [in] delaytime        how many system ticks elapses before this event timeout
+ *
+ * @retval ret                  Successful: return set eventid.
+ *                              Fail: return NULL.   
+ */
+#define mt_set_timer_event(callback, callbackparam, delaytime) \
+            evshed_set_event(mtf_event_scheduler, callback, callbackparam, delaytime)
+
+/**
+ * @name mt_cancel_timer_event
+ *
+ * @brief cancel a timer event freom mtf event scheduler
+ * 
+ * @param [in] eventID         pointer to eventID
+ *
+ * @retval ret                 Successful: remain ticks before this event expires
+ *                             Fail: -1 
+ */
+#define mt_cancel_timer_event(eventID) \
+            evshed_cancel_event(mtf_event_scheduler, eventID)
+
+/**
+ * @name mt_get_remaining_time
+ *
+ * @brief get remain ticks before this event expires
+ * 
+ * @param [in] eventID         pointer to eventID
+ *
+ * @retval ret                 Successful: remain ticks before this event expires
+ *
+ */
+#define mt_get_remaining_time(eventID) \
+            evshed_get_remaining_time(mtf_event_scheduler, eventID)
+    
+/**
+ * @name mte_execute_func
+ *
+ * @brief Prototype of MTE routine entry function, all MTE should implement this and pass as an argument in register call
+ * 
+ * @param [in] mte_rule  mte_rule_t instance of the matched rule which triggers this element
+ * @param [in] msg       Raw content of source message, use source to determine the format of this msg
+ * @param [in] msg_size  Length of the content in pointed by msg
+ *
+ */
+typedef struct _mte_rule_t mte_rule_t;
+ 
+typedef void (*mte_execute_func)(const mte_rule_t *mte_rule, void* msg, kal_uint32 msg_size);
+
+/// Structure of the Metrics Translation Element (MTE) rule descriptor
+typedef struct _mte_rule_t
+{
+    char reserved[MT_DISPATCHER_ENTRY_RESERVED_SIZE];  ///< reserved fields
+    
+    mt_fmt_id fmt_id;             ///< Source of the message to be registered with
+    kal_uint32 code;              ///< Code of the source. When incoming source message matches this code, 
+                                  ///  this MTE_execute_func will be called. See definition of each source for detail format of code
+    mte_execute_func execute;     ///< Pointer to the mte_execute_func which is called when incoming message matches
+    void* context;                ///< Context to be passed when calling mte_entry
+} mte_rule_t;
+
+/**
+ * @name mt_register_mte_rule
+ *
+ * @brief Register a metrics translation element (MTE) to framework. This function should be only called in mte_init()
+ *        The framework will dispatch message to the registered MTE based on the given source/code 
+ *
+ * @param [in] mte_rule   Pointer to the descriptor of the MTE rule to be registered
+ *                        Caller should allocate the memory pointed by this pointer and let callee to keep this memory
+ */
+void mt_register_mte_rule(mte_rule_t *mte_rule);
+/**
+ * @name mt_register_mte_rule_with_mask
+ *
+ * @brief Register a metrics translation element (MTE) to framework. This function should be only called in mte_init()
+ *        The framework will dispatch message to the registered MTE based on the given source/code and mask 
+ *
+ * @param [in] mte_rule   Pointer to the descriptor of the MTE rule to be registered
+ *                        Caller should allocate the memory pointed by this pointer and let callee to keep this memory
+ * @param [in] rule_code_mask  mask on will dispatch message when code match, mask off will dispatch all message.
+ *                                             also can only on of special flag, 
+ *                                             i.e RULE_CODE_MASK_ICD_TYPE_FLAG_ON, RULE_CODE_MASK_ICD_CODE_FLAG_ON
+ *                                                 RULE_CODE_MASK_ICD_PROTOCOL_FLAG_ON
+ */
+void mt_register_mte_rule_with_mask(mte_rule_t *mte_rule, kal_uint32 rule_code_mask);
+
+
+#define GEN_MSG_ID(destID, metricID)        MSG_ID_##destID##_##metricID##_IND
+
+extern int
+mt_ext_ut_submit_metrics(msg_type msg_id, void* payload, kal_uint32 payload_size);
+
+/**
+ * @name mt_submit_metric
+ *
+ * @brief Submit metric value to the dedicated destination module
+ *
+ * @param [in] dest_id    Destination module name
+ * @param [in] metric_id  Destination specified metric ID
+ * @param [in] payload    Pointer to the payload content
+ * @param [in] payload    Size of payload content pointed by payload
+ *
+ * @retval ret            Return value specified by the destination module
+ * 
+ * @code
+ * auto r = mt_submit_metric(MT_DEST_CIQ, 10, struct_for_metric_10);
+ */
+//#ifdef __MTK_TARGET__
+#define mt_submit_metric(_dest_id, _metric_id, _payload, _payload_size) mt_ext_ut_submit_metrics(GEN_MSG_ID(_dest_id, _metric_id), (_payload), (_payload_size))
+
+//#endif
+/**
+ * @name mt_format_return
+ *
+ * @brief Translate destination specified return code to standard result code
+ *
+ * @param [in] dest_id    Destination module ID
+ * @param [in] ret        Return code given by the destination module
+ *
+ * @retval 0              Success
+ * @retval EINVAL         Invalid argument
+ * @retval ENOMEM         Out of memory
+ * @retval EINVAL         Invalid argument
+ * @retval EAGAIN         Try again
+ * @retval EIO            I/O error (channeel error)
+ * @retval EPERM          Operation not permitted (all other errors)
+ *
+ * @code
+ * int ret = mt_format_return(MT_DEST_CIQ, mt_submit_metric(MT_DEST_CIQ, 10, struct_for_metric_10));
+ */
+#ifdef MT_METRICS_UNIT_TEST
+#define mt_format_return(_dest_id, _ret) (_ret)
+#else
+#define mt_format_return(_dest_id, _ret) \
+	_dest_id ## _format_return(_ret)
+#endif
+
+void mt_elements_reset();
+
+void mt_elements_init();
+
+void mt_elements_init_proc();
+void mt_nvram_write_cnf_hdlr(ilm_struct *ilm_ptr);
+
+
+#endif // _MTE_IF_
diff --git a/mcu/service/mtf/inc/mtf_if.h b/mcu/service/mtf/inc/mtf_if.h
new file mode 100644
index 0000000..16f0e90
--- /dev/null
+++ b/mcu/service/mtf/inc/mtf_if.h
@@ -0,0 +1,95 @@
+/*****************************************************************************
+*  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) 2012
+*
+*  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:
+ * ---------
+ * mtf_if.h
+ *
+ * Project:
+ * --------
+ * UMOLYA
+ *
+ * Description:
+ * ------------
+ * MT Framework formatter prototyes
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *
+ * ==========================================================================
+ * $Log$ 
+ *
+ * 
+ ****************************************************************************/
+#ifndef _MTF_IF_
+#define _MTF_IF_
+
+#include "mt_dispatcher.h"
+#include "syscomp_config.h"
+/// enum for metric source ID
+typedef enum _mt_fmt_id {
+  MT_FMT_ILM, ///< ilm_struct format
+  MT_FMT_ICD, ///< ICD packet format
+  MT_FMT_PEER_TRACE, ///< Peer Trace Format
+  MT_FMT_MAX
+} mt_fmt_id;
+
+typedef struct _mt_msginfo_t
+{
+	kal_uint32 code;
+	void* msg;
+	kal_uint32 msg_size;
+} mt_msginfo_t;
+
+typedef int (*mt_formatter_msginfo_extract_func)(const ilm_struct *ilm, mt_msginfo_t *msginfo);
+
+typedef struct _mt_formatter_t
+{
+	char reserved[MT_DISPATCHER_ENTRY_RESERVED_SIZE];  ///< reserved fields
+	
+	mt_fmt_id fmt_id;
+	kal_uint32 ilm_msg_id;
+	mt_dispatcher_list_t element_list;
+	mt_formatter_msginfo_extract_func extract_msginfo;
+} mt_formatter_t;
+
+void mt_formatters_init();
+void mt_register_formatter(mt_formatter_t *formatter);
+
+#endif
\ No newline at end of file
diff --git a/mcu/service/mtf/translate_elements/mte_base.c b/mcu/service/mtf/translate_elements/mte_base.c
new file mode 100644
index 0000000..01c339d
--- /dev/null
+++ b/mcu/service/mtf/translate_elements/mte_base.c
@@ -0,0 +1,141 @@
+/*****************************************************************************
+*  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) 2012
+*
+*  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:
+ * ---------
+ * mte_base.c
+ *
+ * Project:
+ * --------
+ * UMOLYA
+ *
+ * Description:
+ * ------------
+ * MT_Framework mte init implement 
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *
+ * ==========================================================================
+ * $Log$ 
+ *
+ * 
+ ****************************************************************************/
+
+/*****************************************************************************/
+/*                            Includes                                       */
+/*****************************************************************************/
+
+#include "mte_if.h"
+
+
+/*****************************************************************************/
+/*                               Define                                      */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         Global variables                                  */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*                         External functions                                */
+/*****************************************************************************/
+extern void dmf_init_proc();
+extern void dmf_create();
+extern void dmf_reset();
+extern kal_bool dmf_needed_peer_trace(kal_uint32 global_peer_msg_id);
+extern void dmf_nvram_write_cnf_hdlr(ilm_struct *ilm_ptr);
+
+
+/*****************************************************************************/
+/*                         Internal functions                                */
+/*****************************************************************************/
+
+    
+
+
+
+/*****************************************************************************/
+/*                         Function Body                                     */
+/*****************************************************************************/
+
+void mt_elements_init()
+{
+    //need call mte create function here
+    #ifdef __DMF_SUPPORT__
+    dmf_create();
+    #endif
+}
+
+
+void mt_elements_reset()
+{
+    //need call mte reset function here
+    #ifdef __DMF_SUPPORT__
+    dmf_reset();
+    #endif
+}
+
+void mt_elements_init_proc()
+{
+    //need call mte init proc here
+    #ifdef __DMF_SUPPORT__
+    dmf_init_proc();
+    #endif
+
+}
+
+kal_bool mt_elements_is_needed_peer_trace(kal_uint32 global_peer_msg_id)
+{
+    kal_bool result = KAL_FALSE;
+
+    #ifdef __DMF_SUPPORT__
+    result |= dmf_needed_peer_trace(global_peer_msg_id);
+    #endif
+
+
+    return result;
+}
+void mt_nvram_write_cnf_hdlr(ilm_struct *ilm_ptr)
+{
+	#ifdef __DMF_SUPPORT__
+    dmf_nvram_write_cnf_hdlr(ilm_ptr);
+    #endif
+
+}