[Feature]Upload Modem source code
Change-Id: Id4294f30faced84d3e6fd6d5e61e1111bf287a37
diff --git a/mcu/middleware/meta/ft/src/ft_dummy.c b/mcu/middleware/meta/ft/src/ft_dummy.c
new file mode 100644
index 0000000..095cb91
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_dummy.c
@@ -0,0 +1,160 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * ft_dummy.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * Dummy function for ft lib in MAUI only configuration
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+/*************************************************************************
+ * Include Statements for task config
+ *************************************************************************/
+#include "syscomp_config.h"
+/*************************************************************************
+ * Include Statements for KAL
+ *************************************************************************/
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+#include "kal_public_defs.h"
+/*************************************************************************
+ * Include Statements for L1
+ *************************************************************************/
+#include "l1_types_public.h"
+/*************************************************************************
+ * FUNCTION
+ * ft_create
+ *
+ * DESCRIPTION
+ *
+ * PARAMETERS
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ *
+ *************************************************************************/
+kal_bool
+ft_create(comptask_handler_struct **handle)
+{
+ static const comptask_handler_struct ft_handler_info =
+ {
+ NULL, /* task entry function */
+ NULL, /* task initialization function */
+ NULL, /* task configuration function */
+ NULL, /* task reset handler */
+ NULL, /* task termination handler */
+ };
+
+ *handle = (comptask_handler_struct *)&ft_handler_info;
+ return KAL_TRUE;
+}
+/*******************************************************************************
+* FUNCTION
+* FT_DispatchReports
+*
+* DESCRIPTION
+* Dispatch report
+*
+* CALLS
+* FT_ReportPowerScanDone
+* FT_ReportFCB
+*
+* PARAMETERS
+* None
+*
+* RETURNS
+* None
+*
+* GLOBALS AFFECTED
+* None
+*******************************************************************************/
+void FT_DispatchReports( Report_FT *report )
+{
+}
+/*******************************************************************************
+ * FUNCTION
+ * FT_META_IsBasicOperation
+ *
+ * DESCRIPTION
+ * Check the message ID belongs to one of the basic META mode operation
+ *
+ * CALLS
+ * none
+ *
+ * PARAMETERS
+ * msg_id the message ID of the request message
+ *
+ * RETURNS
+ * The indicator of the operation is basic META mode operation cross any state (MODE_ENTRY_SRC)
+ *
+ *******************************************************************************/
+kal_bool FT_META_IsBasicOperation(kal_uint16 msg_id)
+{
+ return KAL_FALSE;
+}
diff --git a/mcu/middleware/meta/ft/src/ft_fnc.c b/mcu/middleware/meta/ft/src/ft_fnc.c
new file mode 100644
index 0000000..a75aac4
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc.c
@@ -0,0 +1,2505 @@
+/*****************************************************************************
+* 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).
+*
+*****************************************************************************/
+/*******************************************************************************
+* Modification Notice:
+* --------------------------
+* This software is modified by MediaTek Inc. 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) 2001
+*
+*******************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * ft_fnc_r.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Factory testing function 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!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ *
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * 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!!
+ *==============================================================================
+ *******************************************************************************/
+/*************************************************************************
+* Include Statements for KAL
+ *************************************************************************/
+#include "kal_public_defs.h" //MSBB change #include "stack_common.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_msgs.h"
+#ifndef L1_SIM
+#include "task_config.h"
+#endif // #ifndef L1_SIM
+#include "svc_sap.h"
+#include "ft_msgid.h"
+/*************************************************************************
+* Include Statements for MAUI
+ *************************************************************************/
+/**************************************************************************
+ * System Service header
+ *************************************************************************/
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+#include "kal_public_defs.h"
+#include "string.h"
+#ifndef L1_SIM
+#include "fs_type.h"
+#include "fs_func.h"
+#include "fs_errcode.h"
+#endif // #ifndef L1_SIM
+#include "kal_public_defs.h" //MSBB change #include "stack_config.h"
+#ifndef L1_SIM
+#include "init.h"
+#endif // #ifndef L1_SIM
+/**************************************************************************
+ * HAL header
+ *************************************************************************/
+#ifndef L1_SIM
+#include "dcl.h"
+#include "drv_comm.h"
+#include "l1audio.h"
+// include the device.h for the GPIO_DEV_LED_KEY definition
+// (Baseband tool LED, vibrator definitions)
+#include "device.h"
+#endif // #ifndef L1_SIM
+#include "tst_hal_internal_wrapper_defs.h"
+/**************************************************************************
+ * FT header
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_public.h"
+#include "ft_private.h"
+#ifndef L1_SIM
+#include "ft_fnc_misc.h"
+#endif //#ifndef L1_SIM
+#include "ft_fnc_l1rf.h"
+#include "ft_fnc_wcdma.h"
+/**************************************************************************
+ * custom header
+ *************************************************************************/
+#ifndef L1_SIM
+#include "meta_customize.h"
+#include "custom_em.h"
+//#include "usb_custom.h"
+#include "custom_equipment.h"
+#endif // #ifndef L1_SIM
+/**************************************************************************
+ * UL1 RF header
+ *************************************************************************/
+#if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+#include "ul1cal.h"
+#endif // #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+//MSBB remove #include "fctycomp_config.h"
+/**************************************************************************
+ * NVRAM header
+ *************************************************************************/
+#ifndef L1_SIM
+#include "nvram_data_items.h"
+#include "ft_nvram_def.h"
+#endif // #ifndef L1_SIM
+/**************************************************************************
+ * audio (MED) header
+ *************************************************************************/
+#ifndef MED_NOT_PRESENT
+#include "aud_defs.h"
+#include "med_struct.h"
+#endif // MED_NOT_PRESENT
+#include "tst_def.h"
+/**************************************************************************
+ * SLA header
+ *************************************************************************/
+#include "meta_sec_support.h"
+/*************************************************************************
+ * Non-MODEM BSP
+ *************************************************************************/
+kal_uint32 ft_event_group_ptr; /**< \brief ft event group pointer */
+
+extern kal_bool Drv_ReadReg(kal_uint32 addr, kal_uint16 *data);
+extern kal_bool Drv_WriteReg(kal_uint32 addr, kal_uint16 data);
+extern void tst_log_primitive_without_filter_check(ilm_struct*,
+ kal_uint8,
+ kal_uint32);
+extern void dhl_FT_log_primitive(ilm_struct *ilm);
+/*******************************************************************************
+ *
+ * Utility Functions
+ *
+ *******************************************************************************/
+void _FT_ALLOC_MSG(ilm_struct* ilm_ptr, kal_uint16 size, kal_bool IsFtMsg, kal_bool IsCcMsg)
+{
+ if( ilm_ptr == NULL )
+ {
+ ASSERT(0); // assert it!
+ }
+
+ ilm_ptr->local_para_ptr = NULL;
+ ilm_ptr->peer_buff_ptr = NULL;
+ if( 0 < size ) {
+ if( KAL_TRUE == IsCcMsg ) {
+ if( NULL == (ilm_ptr->local_para_ptr=construct_cc_non_cached_local_para(size, TD_RESET)) ) {
+ ASSERT(0); // assert it!
+ }
+ }
+ else {
+ if( NULL == (ilm_ptr->local_para_ptr=construct_local_para(size, TD_RESET)) ) {
+ ASSERT(0); // assert it!
+ }
+ }
+ }
+ if( KAL_TRUE == IsFtMsg ) {
+ // reset content of FT primitive first
+ if(size > sizeof(FT_H) && NULL != ((char *)ilm_ptr->local_para_ptr)+sizeof(FT_H))
+ {
+ kal_mem_set(((char *)ilm_ptr->local_para_ptr)+sizeof(FT_H), 0, size-sizeof(FT_H));
+ }
+ }
+}
+
+void _FT_CONSTRUCT_CC_MSG(const ilm_struct* ilm_ptr, ilm_struct* ilm_cc_ptr)
+{
+ if(ilm_ptr == NULL || ilm_cc_ptr == NULL)
+ {
+ ASSERT(0);
+ }
+ _FT_ALLOC_MSG(ilm_cc_ptr, ilm_ptr->local_para_ptr->msg_len, KAL_FALSE, KAL_TRUE);
+ kal_mem_cpy(ilm_cc_ptr->local_para_ptr, ilm_ptr->local_para_ptr, ilm_ptr->local_para_ptr->msg_len);
+ if( ilm_ptr->peer_buff_ptr != NULL )
+ {
+ kal_uint8 *pdu_ptr, *pdu_cc_ptr;
+ kal_uint16 size;
+ if( NULL == (ilm_cc_ptr->peer_buff_ptr=construct_cc_non_cached_peer_buff(ilm_ptr->peer_buff_ptr->pdu_len,
+ 0,
+ 0,
+ TD_RESET)) ) {
+ ASSERT(0); // assert it!
+ }
+ pdu_ptr = (kal_uint8*) get_peer_buff_pdu(ilm_ptr->peer_buff_ptr, &size);
+ pdu_cc_ptr = (kal_uint8*) get_peer_buff_pdu(ilm_cc_ptr->peer_buff_ptr, &size);
+ kal_mem_cpy(pdu_cc_ptr, pdu_ptr, size);
+ }
+}
+
+void _FT_SendFtMsgToPcByToken(ilm_struct *ilm_ptr, kal_uint16 token)
+{
+#if !defined(__DHL_MODULE__)
+ _FT_SendFtMsgByToken(MOD_FT, MOD_TST, FT_TST_SAP, MSG_ID_FT_TO_TST, ilm_ptr, token);
+#else
+ _FT_SendFtMsgByToken(MOD_FT, MOD_DHL, FT_TST_SAP, MSG_ID_FT_TO_TST, ilm_ptr, token);
+#endif // #if !defined(__DHL_MODULE__)
+}
+
+void _FT_SendFtMsgByToken(module_type src_mod, module_type dest_mod, sap_type sap, msg_type msg, ilm_struct *ilm_ptr, kal_uint16 token)
+{
+ ilm_ptr->src_mod_id = src_mod;
+ ilm_ptr->dest_mod_id = dest_mod;
+ ilm_ptr->msg_id = msg;
+ ilm_ptr->sap_id = sap;
+#if !defined(__DHL_MODULE__)
+ if (dest_mod == MOD_TST) {
+#else
+ if (dest_mod == MOD_DHL) {
+#endif // #if !defined(__DHL_MODULE__)
+ ((FT_H *)(ilm_ptr->local_para_ptr))->token=token;
+ tst_log_primitive(ilm_ptr);
+ ilm_ptr->src_mod_id = (module_type)0xA1;
+ ilm_ptr->dest_mod_id = (module_type)0;
+ ilm_ptr->sap_id = (sap_type)0xA3;
+ ilm_ptr->msg_id = (msg_type)2;
+#if !defined(__DHL_MODULE__)
+ // directly copy primitive to TST ring buffer
+ tst_log_primitive_without_filter_check(
+ ilm_ptr,
+ RS232_LOGGED_PRIMITIVE_TYPE,
+ MSG_ID_LOGGED_PRIMITIVE);
+#else
+ dhl_FT_log_primitive(ilm_ptr);
+#endif // #if !defined(__DHL_MODULE__)
+ // cancel ilm, because we directly access TST ring buffer, no need to send primitive to TST
+ destroy_ilm(ilm_ptr);
+ return;
+ }
+ msg_send6(src_mod, dest_mod, sap, msg, ilm_ptr->local_para_ptr, ilm_ptr->peer_buff_ptr);
+}
+
+void FT_SendDeniedMsgIdCnf(kal_uint16 deniedMsgId, kal_uint32 status)
+{
+ ilm_struct ilm_ptr;
+ FT_DENIED_MSG_ID_CNF *ft_cnf;
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(FT_DENIED_MSG_ID_CNF));
+ ft_cnf = (FT_DENIED_MSG_ID_CNF *)ilm_ptr.local_para_ptr;
+ ft_cnf->header.ft_msg_id = FT_CMD_DENIED_CNF_ID;
+ ft_cnf->deniedMsgId = deniedMsgId;
+ ft_cnf->status = status;
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+
+/*******************************************************************************
+ *
+ * FT Module Initialization Functions
+ *
+ *******************************************************************************/
+/*******************************************************************************
+ * FUNCTION
+ * FT_InitFtData
+ *
+ * DESCRIPTION
+ *
+ * CALLS
+ *
+ * PARAMETERS
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ *******************************************************************************/
+#ifndef L1_SIM
+extern kal_int8 FT_FAT_Handle_Clear(void);
+#endif //#ifndef L1_SIM
+void FT_InitFtData()
+{
+#ifndef L1_SIM
+ FT_FAT_Handle_Clear();
+#endif //#ifndef L1_SIM
+ // init event group
+ ft_event_group_ptr = (kal_uint32) kal_create_event_group("FtEvent");
+}
+#ifndef L1_SIM
+/**
+ * This function calls Dcl PMU interface to read PMIC register
+ * @register_index the index of the register to be written
+ */
+kal_bool ft_pmic_reg_read(kal_uint16 *data, kal_uint16 register_index)
+{
+ kal_bool status;
+ DCL_HANDLE handle;
+ PMU_CTRL_MISC_GET_REGISTER_VALUE val;
+ val.offset=register_index;
+ handle=DclPMU_Open(DCL_PMU, FLAGS_NONE);
+ if(DclPMU_Control(handle, MISC_GET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&val) != STATUS_OK)
+ {
+ // in this case, there might be not supported (if the driver did not support yet, usually in development phase)
+ status = KAL_FALSE;
+ }
+ else
+ {
+ status = KAL_TRUE;
+ }
+ DclPMU_Close(handle);
+ *data = val.value;
+ return status;
+}
+/**
+ * This function calls Dcl PMU interface to read PMIC register
+ * @param data the register value to be written to PMIC
+ * @param register_index the index of the register to be written
+ */
+kal_bool ft_pmic_reg_write(kal_uint16 data, kal_uint16 register_index)
+{
+ kal_bool status;
+ DCL_HANDLE handle;
+ PMU_CTRL_MISC_SET_REGISTER_VALUE val;
+ val.offset=register_index;
+ val.value=data;
+ handle=DclPMU_Open(DCL_PMU, FLAGS_NONE);
+ if(DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&val) != STATUS_OK)
+ {
+ // in this case, there might be not supported (if the driver did not support yet, usually in development phase)
+ status = KAL_FALSE;
+ }
+ else
+ {
+ status = KAL_TRUE;
+ }
+ DclPMU_Close(handle);
+ return status;
+}
+/**
+ * This function handles the PMIC register read operation
+ * @param req FT task PMIC register read request
+ * @param Regtype register type
+ */
+void FT_FtPMICRegisterRead(ft_PMICRegisterRead_req_T* req,unsigned char RegType) // for build warning
+{
+ ilm_struct ilm_ptr;
+ ft_PMICRegisterRead_cnf_T* ptrMsg;
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(ft_PMICRegisterRead_cnf_T));
+ ptrMsg = (ft_PMICRegisterRead_cnf_T *)ilm_ptr.local_para_ptr;
+ ptrMsg->status = KAL_FALSE;
+ if(RegType ==FT_PMICReg)
+ {
+ ptrMsg->header.ft_msg_id = FT_PMIC_REG_READ_CNF_ID;
+ /*
+ * Note: The custom_pmic_reg_read interface is changed due to HAL,
+ * the reference is changed to ft_pmic_reg_read
+ */
+ ptrMsg->status = ft_pmic_reg_read(&(ptrMsg->value), (kal_uint16)req->addr);
+ }
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+/**
+ * This function handles the PMIC register write operation
+ * @param req FT task PMIC register write request
+ * @param Regtype register type
+ */
+void FT_FtPMICRegisterWrite(ft_PMICRegisterWrite_req_T* req,unsigned char RegType)
+{
+ ilm_struct ilm_ptr;
+ ft_PMICRegisterWrite_cnf_T *ptrMsg ;
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(ft_PMICRegisterWrite_cnf_T));
+ ptrMsg = (ft_PMICRegisterWrite_cnf_T *)ilm_ptr.local_para_ptr;
+ ptrMsg->status = KAL_FALSE;
+ if(RegType ==FT_PMICReg)
+ {
+ ptrMsg->header.ft_msg_id = FT_PMIC_REG_WRITE_CNF_ID;
+ /*
+ * Note: The custom_pmic_reg_write interface is changed due to HAL,
+ * the reference is changed to ft_pmic_reg_write
+ */
+ ptrMsg->status = ft_pmic_reg_write(req->value, (kal_uint16)req->addr);
+ }
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+
+/*******************************************************************************
+ * FUNCTION
+ * FT_FtRegisterRead()
+ *
+ * DESCRIPTION
+ * Handle the request of reading Register Req
+ *
+ * CALLS
+ * Drv_ReadReg(.)
+ *
+ * PARAMETERS
+ * *req
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ * None
+ *******************************************************************************/
+void FT_FtRegisterRead(ft_RegisterRead_req_T* req,unsigned char RegType)
+{
+ kal_uint8 status;
+ ilm_struct ilm_ptr;
+ ft_RegisterRead_cnf_T* ptrMsg;
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(ft_RegisterRead_cnf_T));
+ /* if ptrMsg != NULL*/
+ ptrMsg = (ft_RegisterRead_cnf_T *)ilm_ptr.local_para_ptr;
+ status = KAL_FALSE; // for build warning
+ if(RegType ==FT_BaseBandReg)
+ {
+ ptrMsg->header.ft_msg_id = FT_REG_READ_CNF_ID;
+ status=Drv_ReadReg(req->addr,&ptrMsg->value);
+ }
+ if(status==KAL_TRUE)
+ { status=FT_CNF_OK; }
+ else
+ { status=FT_CNF_FAIL; }
+ ptrMsg->status = status;
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+
+
+/*******************************************************************************
+ * FUNCTION
+ * FT_FtRegisterWrite()
+ *
+ * DESCRIPTION
+ * Handle the request of Writing Register Req
+ *
+ * CALLS
+ * Drv_WriteReg(.)
+ *
+ * PARAMETERS
+ * *req
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ * None
+ *******************************************************************************/
+void FT_FtRegisterWrite(ft_RegisterWrite_req_T* req,unsigned char RegType)
+{
+ kal_uint8 status;
+ ilm_struct ilm_ptr;
+ ft_RegisterWrite_cnf_T *ptrMsg ;
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(ft_RegisterWrite_cnf_T));
+ status = KAL_FALSE; // for build warning
+ /* if ptrMsg != NULL*/
+ ptrMsg = (ft_RegisterWrite_cnf_T *)ilm_ptr.local_para_ptr;
+ if(RegType ==FT_BaseBandReg)
+ {
+ ptrMsg->header.ft_msg_id = FT_REG_WRITE_CNF_ID;
+ status=Drv_WriteReg(req->addr,req->value);
+ }
+ if(status==KAL_TRUE)
+ { status=FT_CNF_OK; }
+ else
+ { status=FT_CNF_FAIL; }
+ ptrMsg->status = status;
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+
+/*******************************************************************************
+ * FUNCTION
+ * FT_FtADC_GetMeaData()
+ *
+ * DESCRIPTION
+ * Handle the request of Getting MeaData
+ *
+ * CALLS
+ * ADC_GetData2Meta(.)
+ *
+ * PARAMETERS
+ * *req
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ * None
+ *******************************************************************************/
+void FT_FtADC_GetMeaData(ft_FtADC_GetMeaData_req_T* req)
+{
+ ilm_struct ilm_ptr;
+ ft_FtADC_GetMeaData_cnf_T *ptrMsg ;
+ ADC_CTRL_GET_DATA_2_META_T data2meta;
+ DCL_HANDLE adc_handle;
+ memset(&data2meta, 0, sizeof(ADC_CTRL_GET_DATA_2_META_T));
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(ft_FtADC_GetMeaData_cnf_T));
+ ptrMsg = (ft_FtADC_GetMeaData_cnf_T *)ilm_ptr.local_para_ptr;
+ ptrMsg->status=FT_CNF_OK;
+ ptrMsg->header.ft_msg_id = FT_ADC_GETMEADATA_CNF_ID;
+ adc_handle = DclHADC_Open(DCL_ADC, FLAGS_NONE);
+ data2meta.u1Channel = req->Sel;
+ data2meta.u2MeaCount = req->Meacount;
+ if(DclHADC_Control(adc_handle, ADC_CMD_GET_DATA_2_META, (DCL_CTRL_DATA_T *)& data2meta) != STATUS_OK)
+ {
+ ptrMsg->status = FT_CNF_FAIL;
+ }
+ ptrMsg->value = data2meta.u4ADCData;
+ if(DclHADC_Close(adc_handle) != STATUS_OK)
+ {
+ ptrMsg->status = FT_CNF_FAIL;
+ }
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+#endif // #ifndef L1_SIM
+/*******************************************************************************
+ *
+ * Version Info functionality
+ *
+ *******************************************************************************/
+void FT_GetVersionInfo(void) {
+
+ ilm_struct ilm_ptr;
+ FT_VER_INFO_CNF *ptrMsg;
+
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(FT_VER_INFO_CNF));
+ // if ptrMsg != NULL
+ ptrMsg = (FT_VER_INFO_CNF *)ilm_ptr.local_para_ptr;
+ // assign primitive id
+ ptrMsg->header.ft_msg_id = FT_VER_INFO_CNF_ID;
+
+ #ifndef L1_SIM
+ version_struct ver_struct;
+ memset(&ver_struct, 0, sizeof(version_struct));
+
+ // get version info
+ INT_VersionNumbers(&ver_struct);
+ // check
+ if( NULL == ver_struct.bb_chip ) {
+ ver_struct.bb_chip = "Unknown";
+ }
+ if( NULL == ver_struct.dsp_fw ) {
+ ver_struct.dsp_fw = "Unknown";
+ }
+ if( NULL == ver_struct.dsp_ptch ) {
+ ver_struct.dsp_ptch = "Unknown";
+ }
+ if( NULL == ver_struct.mcu_sw ) {
+ ver_struct.mcu_sw = "Unknown";
+ }
+ if( NULL == ver_struct.bb_board ) {
+ ver_struct.bb_board = "Unknown";
+ }
+ if( NULL == ver_struct.mcu_sw_flavor ) {
+ ver_struct.mcu_sw_flavor = "Unknown";
+ }
+ // assign BaseBand chip version string
+ strncpy((kal_char *)ptrMsg->bb_chip, ver_struct.bb_chip, 64);
+ // assign ECO version
+ kal_mem_set(ptrMsg->eco_ver, 0, 4);
+ // assign DSP firmware version string
+ strncpy((kal_char *)ptrMsg->dsp_fw, ver_struct.dsp_fw, 64);
+ // assign DSP patch version string
+ strncpy((kal_char *)ptrMsg->dsp_patch, ver_struct.dsp_ptch, 64);
+ // assign S/W version string
+ strncpy((kal_char *)ptrMsg->sw_ver, ver_struct.mcu_sw, 64);
+ // assign H/W version string
+ strncpy((kal_char *)ptrMsg->hw_ver, ver_struct.bb_board, 64);
+ // assign Melody version string
+ strncpy((kal_char *)ptrMsg->melody_ver, "Unknown", 64);
+ // assign S/W flavor version string
+ strncpy((kal_char *)ptrMsg->sw_flavor, ver_struct.mcu_sw_flavor, 64);
+#else // #ifndef L1_SIM
+ strcpy((kal_char *)ptrMsg->bb_chip, "Unknown");
+ kal_mem_set(ptrMsg->eco_ver, 0, 4);
+ kal_mem_set(ptrMsg->dsp_fw, 0, 64);
+ kal_mem_set(ptrMsg->dsp_patch, 0, 64);
+ strcpy((kal_char *)ptrMsg->sw_ver, "xl1 Sim");
+ kal_mem_set(ptrMsg->hw_ver, 0, 64);
+ kal_mem_set(ptrMsg->melody_ver, 0, 64);
+ strcpy((kal_char *)ptrMsg->sw_flavor, "Unknown");
+#endif // #ifdef L1_SIM
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+/*******************************************************************************
+ *
+ * FT task test alive
+ *
+ *******************************************************************************/
+void FT_TestAlive(void) {
+
+ FT_IS_ALIVE_CNF *pMsg;
+ ilm_struct ilm_ptr;
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(FT_IS_ALIVE_CNF));
+ pMsg=(FT_IS_ALIVE_CNF *)ilm_ptr.local_para_ptr;
+ pMsg->header.ft_msg_id = FT_IS_ALIVE_CNF_ID;
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+#ifndef L1_SIM
+/**
+ * This api calls the DCL interface to check and clear the PDN1 bit 7 set by flashtool
+ * and scrambles theh powerkey1
+ */
+ #if (!defined(__SMART_PHONE_MODEM__))
+static kal_bool FT_ClearPowerKey(void)
+{
+ /// Driver RTC FT Power Off request
+ RTC_CTRL_FT_POWEROFF_T ft_cmd_data;
+ DCL_HANDLE rtc_handle = DclRTC_Open(DCL_RTC, FLAGS_NONE);
+ memset(&ft_cmd_data, 0, sizeof(RTC_CTRL_FT_POWEROFF_T));
+ DclRTC_Control(rtc_handle, RTC_CMD_FT_POWEROFF, (DCL_CTRL_DATA_T *) &ft_cmd_data);
+ DclRTC_Close(rtc_handle);
+ return (kal_bool)ft_cmd_data.fgMetaReset;
+}
+ #endif
+/*******************************************************************************
+ *
+ * FUNCTION
+ * FT_PowerOff
+ *
+ * DESCRIPTION
+ * Power off sequence in META mode
+ *
+ * CALLS
+ * custom_ft_util_check_if_usb_enable_support for check the USB_ENABLE compile option
+ * USB_PowerControl
+ * DclRTC_Open/DclRTC_Control (RTC_CMD_FT_POWEROFF command)/DclRTC_Close for RTC power off sequence (scramble PDN1 bit 7 for flashtool entering META mode)
+ * DclPW_Open/DclPW_Control (PW_CMD_POWEROFF command)/DclPW_Close for Driver power off sequence
+ * DclWDT_Open/DclWDT_Control (WDT_CMD_DRV_RESET command)/DclWDT_Close for Driver reset sequence
+ *
+ * PARAMETERS
+ * void
+ *
+ * RETURNS
+ * void
+ *
+ * GLOBALS AFFECTED
+ * N/A
+ *
+ *******************************************************************************/
+void FT_PowerOff(void)
+{
+#if (!defined(__SMART_PHONE_MODEM__))
+ if(KAL_TRUE == custom_ft_util_check_if_usb_enable_support())
+ {
+ // shutdown USB module
+ /**
+ * USB_PowerControl(KAL_FALSE) is no longer
+ * to disable the usb power anymore.
+ **/
+ }
+ Custom_META_USBVirtualComDisconnect();
+ FT_ClearPowerKey();
+#endif // #if (!defined(__SMART_PHONE_MODEM__))
+}
+#endif // #ifndef L1_SIM
+#ifndef L1_SIM
+/***********************************************
+ * FT task self message API
+ * This API is called in other task context
+ * or HISR conext!
+ **********************************************/
+void ft_send_in_proc_call_req(ft_in_proc_call_type func, kal_uint32 func_arg1, void *func_arg2)
+{
+ ft_in_proc_call_req_struct *ptrMsg;
+ ptrMsg = (ft_in_proc_call_req_struct *)construct_local_para(sizeof(ft_in_proc_call_req_struct), TD_RESET);
+ if(NULL == ptrMsg)
+ {
+ ASSERT(0);
+ }
+ ptrMsg->func = func;
+ ptrMsg->func_arg1 = func_arg1;
+ ptrMsg->func_arg2 = func_arg2;
+ msg_send5(kal_get_active_module_id(), MOD_FT, FT_TST_SAP, (msg_type)MSG_ID_FT_IN_PROC_CALL_REQ, (local_para_struct*)ptrMsg);
+}
+/***********************************************
+ * FT task self message (In Proc Call handler)
+ **********************************************/
+void ft_in_proc_call_handler(ilm_struct *ilm_ptr)
+{
+ /*----------------------------------------------------------------*/
+ /* Local Variables */
+ /*----------------------------------------------------------------*/
+ ft_in_proc_call_req_struct *ptrMsg = (ft_in_proc_call_req_struct*) ilm_ptr->local_para_ptr;
+
+ /*----------------------------------------------------------------*/
+ /* Code Body */
+ /*----------------------------------------------------------------*/
+ ASSERT(ptrMsg->func != NULL);
+ ptrMsg->func(ptrMsg->func_arg1, ptrMsg->func_arg2);
+}
+
+
+/*******************************************************************************
+ *
+ * SLA functionality
+ *
+ *******************************************************************************/
+kal_bool FT_MetaSLA_Is_Enabled(void)
+{
+ return MetaSLA_Is_Enabled();
+}
+
+void FT_GetSlaStatus(void)
+{
+ ilm_struct ilm_ptr;
+ FT_GET_SLA_STATUS_CNF *ptrMsg;
+
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(FT_GET_SLA_STATUS_CNF));
+ // if ptrMsg != NULL
+ ptrMsg = (FT_GET_SLA_STATUS_CNF *)ilm_ptr.local_para_ptr;
+ // assign primitive id
+ ptrMsg->header.ft_msg_id = FT_GET_SLA_STATUS_CNF_ID;
+ ptrMsg->sla_config = (kal_uint16) FT_MetaSLA_Is_Enabled();
+ ptrMsg->sla_verified= (kal_uint16) MetaSLA_Is_Verified();
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+
+extern kal_uint16 Custom_META_CheckSlaVer(kal_uint32 sla_ver_from_pc);
+void FT_CheckSlaVer(FT_CHECK_SLA_VER_REQ *ft_check_sla_ver_op)
+{
+ ilm_struct ilm_ptr;
+ FT_CHECK_SLA_VER_CNF *ptrMsg;
+
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(FT_CHECK_SLA_VER_CNF));
+ // if ptrMsg != NULL
+ ptrMsg = (FT_CHECK_SLA_VER_CNF *)ilm_ptr.local_para_ptr;
+ // assign primitive id
+ ptrMsg->header.ft_msg_id = FT_CHECK_SLA_VER_CNF_ID;
+ ptrMsg->status = Custom_META_CheckSlaVer(ft_check_sla_ver_op->sla_ver_from_pc);
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+
+extern kal_bool Custom_META_GetSlaPara(kal_uint8* para, kal_uint32 para_len);
+void FT_GetSlaPara(void)
+{
+ ilm_struct ilm_ptr;
+ FT_GET_SLA_PARA_CNF *ptrMsg;
+ kal_uint8 para[META_SLA_RND_LEN];
+ kal_uint32 ret = 0;
+ kal_uint8 cust_para[256];
+ kal_bool bRet = 0;
+
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(FT_GET_SLA_PARA_CNF));
+
+ ptrMsg = (FT_GET_SLA_PARA_CNF *)ilm_ptr.local_para_ptr;
+ ptrMsg->header.ft_msg_id = FT_GET_SLA_PARA_CNF_ID;
+
+ if (META_SLA_RND_LEN > RND_BUF_LEN)
+ {
+ // ft message buffer is not enough
+ ptrMsg->status = FT_CNF_FAIL;
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+ return;
+ }
+
+ kal_mem_set(para, 0, META_SLA_RND_LEN);
+
+ ret = MetaSLA_Rnd_Gen(para, RND_BUF_LEN);
+ if (0 == ret)
+ {
+ kal_mem_cpy(ptrMsg->rand_num, para, META_SLA_RND_LEN);
+ ptrMsg->rand_num_len = META_SLA_RND_LEN;
+ }
+ else
+ {
+ ptrMsg->status = ret;
+ ptrMsg->rand_num_len = 0;
+ }
+
+ bRet = Custom_META_GetSlaPara(cust_para, 256);
+ if (true == bRet)
+ {
+ kal_mem_cpy(ptrMsg->cust_para, cust_para, 256);
+ }
+ else
+ {
+ ptrMsg->status = -1;
+ }
+
+ if (ret == 0 && bRet == true)
+ {
+ ptrMsg->status = FT_CNF_OK;
+ }
+
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+
+void FT_VerifySla(FT_VERIFY_SLA_RND_REQ *ft_verify_sla_op)
+{
+ ilm_struct ilm_ptr;
+ FT_VERIFY_SLA_RND_CNF *ptrMsg;
+ kal_uint32 ret = 0;
+
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(FT_VERIFY_SLA_RND_CNF));
+
+ ptrMsg = (FT_VERIFY_SLA_RND_CNF *)ilm_ptr.local_para_ptr;
+ ptrMsg->header.ft_msg_id = FT_VERIFY_SLA_RND_CNF_ID;
+
+ ret = MetaSLA_Rnd_Verify(ft_verify_sla_op->encrypted, ft_verify_sla_op->encrypted_len);
+ if (ret == 0)
+ {
+ if (FT_MetaSLA_Is_Enabled())
+ {
+ ptrMsg->status = FT_CNF_OK;
+ }
+ else
+ {
+ ptrMsg->status = -1;
+ }
+ }
+ else
+ {
+ ptrMsg->status = ret;
+ }
+
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+
+#endif // #ifndef L1_SIM
+
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_aux.c b/mcu/middleware/meta/ft/src/ft_fnc_aux.c
new file mode 100644
index 0000000..dca6dad
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_aux.c
@@ -0,0 +1,200 @@
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * ft_fnc_aux.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Auxiliary Function
+ *
+ * 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!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*************************************************************************
+ * Include Statements for KAL
+ *************************************************************************/
+#if defined(__UMTS_TDD128_MODE__) && defined(__AST_TL1_TDD__)
+
+#include "kal_public_defs.h" //MSBB change #include "stack_common.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_msgs.h"
+
+#include "md_mw_sap.h"
+#include "svc_sap.h"
+#include "ft_msgid.h"
+
+#ifdef __MTK_TARGET__
+#include <stdio.h>
+
+#endif
+
+/*************************************************************************
+ * Include Statements for MAUI
+ *************************************************************************/
+
+#include "fta_msg.h"
+#include "ft_private.h"
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+#include "kal_public_defs.h"
+
+void FT_Aux_Operation(ilm_struct *ptrMsg)
+{
+ ilm_struct ilm_ptr;
+ kal_uint16 pdu_length;
+ kal_uint8 *pdu_ptr = NULL;
+ //peer_buff_struct *p_peer_buff_ptr;
+ // for debug
+
+ kal_uint16 pdu_length_new;
+ kal_uint8 *pdu_ptr_new;
+ peer_buff_struct *peer_buff_new;
+
+ FT_AUX_REQ *p_req = (FT_AUX_REQ *)ptrMsg->local_para_ptr;
+
+ if(ptrMsg->peer_buff_ptr == NULL) // do nothing
+ return;
+
+ switch(p_req->type)
+ {
+ case FT_AUX_OP_BASIC:
+ {
+
+ pdu_ptr = get_peer_buff_pdu( ptrMsg->peer_buff_ptr, &pdu_length );
+
+ // construct a peer buffer to send to NVRAM
+ if( NULL != (peer_buff_new=construct_peer_buff(pdu_length, 0, 0, TD_CTRL)) )
+ {
+ pdu_ptr_new = get_peer_buff_pdu( peer_buff_new, &pdu_length_new );
+ kal_mem_cpy(pdu_ptr_new, pdu_ptr, pdu_length);
+ peer_buff_new->pdu_len = pdu_length;
+ }
+ FT_ALLOC_OTHER_MSG(&ilm_ptr, sizeof(fta_basic_req_struct) );
+ ilm_ptr.peer_buff_ptr = peer_buff_new;
+
+ FT_SEND_MSG(MOD_FT, MOD_FTA, FT_FTA_SAP , (msg_type)MSG_ID_FTA_BASIC_REQ, &ilm_ptr);
+
+ peer_buff_new=NULL;/* make sure FTA will release the mem*/
+
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+void FT_Handle_FTA_CNF(ilm_struct *ptrMsg)
+{
+ ilm_struct ilm_ptr;
+ FT_AUX_CNF *ptrMsg2; // send back to PC
+
+ switch (ptrMsg->msg_id)
+ {
+ case MSG_ID_FTA_BASIC_CNF:
+ {
+ fta_basic_cnf_struct *tmp_local_para = NULL; // from FTA Task
+ tmp_local_para = (fta_basic_cnf_struct*)ptrMsg->local_para_ptr;
+
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(FT_AUX_CNF) );
+
+ ilm_ptr.peer_buff_ptr = ptrMsg->peer_buff_ptr;
+ ptrMsg2 = (FT_AUX_CNF*)ilm_ptr.local_para_ptr;
+
+ ptrMsg2->header.ft_msg_id = FT_AUX_CNF_ID;
+ ptrMsg2->type = FT_AUX_OP_BASIC;
+ ptrMsg2->status = tmp_local_para->status; //FTA_CNF_OK;
+ break;
+ }
+ default:
+ return;
+
+ }
+ // send confirm to PC
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+
+#endif // end of #if defined(__UMTS_TDD128_MODE__) && defined(__AST_TL1_TDD__)
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_c2krf.c b/mcu/middleware/meta/ft/src/ft_fnc_c2krf.c
new file mode 100644
index 0000000..5a911ff
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_c2krf.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) 2016
+*
+* 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).
+*
+*****************************************************************************/
+/*******************************************************************************
+* Modification Notice:
+* --------------------------
+* This software is modified by MediaTek Inc. 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) 2016
+*
+*******************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * ft_fnc_c2krf.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Factory testing function for C2K
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(__C2K_RAT__)
+/*************************************************************************
+* Include Statements for KAL
+ *************************************************************************/
+#include "kal_public_defs.h"
+#include "svc_sap.h"
+#include "tst_msgid.h"
+#include "ft_msgid.h"
+/*************************************************************************
+ * FT header
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_private.h"
+#include "ft_fnc_c2krf.h"
+
+/**
+ * @param metaMessage the input message from META tool for CRF test command processing
+ */
+void FT_Crf_Operation(ilm_struct* ptrMsg)
+{
+ ilm_struct crfMessage;
+ FT_CONSTRUCT_CC_MSG(ptrMsg, &crfMessage);
+ FT_SEND_MSG(MOD_FT, MOD_CL1TST, DHL_CL1TST_SAP, MSG_ID_DHL_TO_CL1TST, &crfMessage);
+}
+
+/**
+ * Confirm message handler for MOD_CL1TST
+ */
+void FT_Crf_ConfirmHandler(ilm_struct* crfMessage)
+{
+ FT_SEND_MSG_TO_PC(crfMessage);
+}
+
+#endif // #if defined(__C2K_RAT__)
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_custom.c b/mcu/middleware/meta/ft/src/ft_fnc_custom.c
new file mode 100644
index 0000000..0f5d054
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_custom.c
@@ -0,0 +1,161 @@
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * ft_fnc_custom.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Misc Function
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*************************************************************************
+ * Include Statements for KAL
+ *************************************************************************/
+#include "kal_public_defs.h" //MSBB change #include "stack_common.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_msgs.h"
+#include "md_mw_sap.h"
+#include "svc_sap.h"
+#include "ft_msgid.h"
+#include "nvram_msgid.h"
+#ifdef __MTK_TARGET__
+#include <stdio.h>
+#endif
+/*************************************************************************
+ * Include Statements for MAUI
+ *************************************************************************/
+#include "ftc_msg.h"
+#include "ft_private.h"
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "kal_public_defs.h"
+void FT_Custom_Operation(ilm_struct *ptrMsg)
+{
+ ilm_struct ilm_ptr;
+ FT_CUSTOMER_REQ *p_req = (FT_CUSTOMER_REQ *)ptrMsg->local_para_ptr;
+ if(ptrMsg->peer_buff_ptr == NULL)
+ {
+ return;
+ }
+ switch(p_req->type)
+ {
+ case FT_CUSTOMER_OP_BASIC:
+ {
+ FT_ALLOC_OTHER_MSG(&ilm_ptr, sizeof(ftc_basic_req_struct));
+ ilm_ptr.peer_buff_ptr = ptrMsg->peer_buff_ptr;
+ /* hold this peer buffer so that we don't need to duplicate the buffer */
+ hold_peer_buff(ptrMsg->peer_buff_ptr);
+ FT_SEND_MSG(MOD_FT, MOD_FTC, FT_FTC_SAP , (msg_type)MSG_ID_FTC_BASIC_REQ, &ilm_ptr);
+ break;
+ }
+ default:
+ break;
+ }
+}
+void FT_Handle_FTC_CNF(ilm_struct *ptrMsg)
+{
+ ilm_struct ilm_ptr;
+ FT_CUSTOMER_CNF *ptrMsg2;
+ switch (ptrMsg->msg_id)
+ {
+ case MSG_ID_FTC_BASIC_CNF:
+ {
+ ftc_basic_cnf_struct *tmp_local_para = NULL;
+ tmp_local_para = (ftc_basic_cnf_struct*)ptrMsg->local_para_ptr;
+
+ FT_ALLOC_MSG(&ilm_ptr ,sizeof(FT_CUSTOMER_CNF));
+
+ ilm_ptr.peer_buff_ptr = ptrMsg->peer_buff_ptr;
+ ptrMsg2 = (FT_CUSTOMER_CNF*)ilm_ptr.local_para_ptr;
+
+ ptrMsg2->header.ft_msg_id = FT_CUSTOM_CNF_ID;
+ ptrMsg2->type = FT_CUSTOMER_OP_BASIC;
+ ptrMsg2->status = tmp_local_para->status;
+ break;
+ }
+ default:
+ return;
+ }
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_fat.c b/mcu/middleware/meta/ft/src/ft_fnc_fat.c
new file mode 100644
index 0000000..5b0e9d5
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_fat.c
@@ -0,0 +1,1400 @@
+/*****************************************************************************
+* 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).
+*
+*****************************************************************************/
+/*******************************************************************************
+* Modification Notice:
+* --------------------------
+* This software is modified by MediaTek Inc. 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) 2001
+*
+*******************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * ft_fnc_fat.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * FT FAT operations
+ *
+ * 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!!
+ *==============================================================================
+ *******************************************************************************/
+/*************************************************************************
+ * FT header
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_private.h"
+#include "ft_fnc_fat.h"
+#include "svc_sap.h"
+#include "ft_msgid.h"
+/*************************************************************************
+ * NVRAM header
+ *************************************************************************/
+#include "nvram_interface.h"
+#include "fs_gprot.h"
+/*******************************************************************************
+ *
+ * Dynamic allocated stack
+ *
+ *******************************************************************************/
+#define FT_STACK_MAGIC 12345
+
+typedef void (*FT_STACK_RELEASE_CALLBACK)(void *data, void *usr_arg);
+
+typedef struct {
+ kal_uint8 *stack; // used to remember the FindNext calling times,not FS_HANDLE
+
+ kal_uint16 max_node_size;
+ kal_uint16 max_depth;
+ kal_uint16 depth; // 1 ~ N , 0 -> empty
+
+ kal_uint16 magic; // used to mark if the stack is created or not.
+
+}ft_stack_handle;
+
+kal_uint8 ft_stack_destroy(ft_stack_handle *p_ft_stack_hdl)
+{
+
+ if( NULL==p_ft_stack_hdl)
+ {
+ return 1;
+ }
+
+ // free buffer
+ free_ctrl_buffer(p_ft_stack_hdl->stack);
+ // reset
+ kal_mem_set(p_ft_stack_hdl, 0, sizeof(ft_stack_handle));
+
+ return 0;
+}
+
+kal_uint8 ft_stack_create(ft_stack_handle *p_ft_stack_hdl, kal_uint16 max_node_size, kal_uint16 max_depth) {
+
+ if( NULL==p_ft_stack_hdl || 0==max_node_size || 0==max_depth ) {
+ return 1;
+ }
+
+ // if un-release handle, destroy first
+ if( FT_STACK_MAGIC == p_ft_stack_hdl->magic ) {
+ if(ft_stack_destroy(p_ft_stack_hdl))
+ {
+ return 2;
+ }
+ }
+
+ // allocate memory
+ if( NULL == (p_ft_stack_hdl->stack=(kal_uint8 *)get_ctrl_buffer(max_node_size*max_depth)) ) {
+ return 2;
+ }
+
+ // initialize
+ p_ft_stack_hdl->max_node_size = max_node_size;
+ p_ft_stack_hdl->max_depth = max_depth;
+ p_ft_stack_hdl->depth = 0;
+ p_ft_stack_hdl->magic = FT_STACK_MAGIC;
+
+ return 0;
+}
+
+kal_uint8 ft_stack_push(ft_stack_handle *p_ft_stack_hdl, kal_uint16 cur_width) {
+
+ if( NULL==p_ft_stack_hdl || FT_STACK_MAGIC!=p_ft_stack_hdl->magic)
+ {
+ return 1;
+ }
+
+ /*
+ if( data_size > p_ft_stack_hdl->max_node_size ) {
+ return 2;
+ }
+ */
+ if( (p_ft_stack_hdl->depth+1) > p_ft_stack_hdl->max_depth ) {
+ return 3;
+ }
+
+ p_ft_stack_hdl->depth++;
+
+ //kal_mem_cpy(p_ft_stack_hdl->stack+p_ft_stack_hdl->max_node_size*(p_ft_stack_hdl->depth-1), data, data_size);
+
+ (*(p_ft_stack_hdl->stack+p_ft_stack_hdl->max_node_size*(p_ft_stack_hdl->depth-1))) = cur_width;
+ return 0;
+}
+
+kal_uint8 ft_stack_pop(ft_stack_handle *p_ft_stack_hdl, kal_uint16 *pWidth) {
+
+ if( NULL==p_ft_stack_hdl || FT_STACK_MAGIC!=p_ft_stack_hdl->magic || NULL == pWidth)
+ {
+ return 1;
+ }
+ /*
+ if( data_size > p_ft_stack_hdl->max_node_size ) {
+ return 2;
+ }
+ */
+ if( 1 > p_ft_stack_hdl->depth ) {
+ return 3;
+ }
+
+ //kal_mem_cpy(data, p_ft_stack_hdl->stack+p_ft_stack_hdl->max_node_size*(p_ft_stack_hdl->depth-1), data_size);
+ (*pWidth) = (*(p_ft_stack_hdl->stack+p_ft_stack_hdl->max_node_size*(p_ft_stack_hdl->depth-1)));
+
+ p_ft_stack_hdl->depth--;
+
+ return 0;
+}
+
+kal_uint16 ft_stack_get_cur_depth(ft_stack_handle *p_ft_stack_hdl) {
+ if( NULL==p_ft_stack_hdl || FT_STACK_MAGIC!=p_ft_stack_hdl->magic ) {
+ return 0;
+ }
+
+ return p_ft_stack_hdl->depth;
+}
+/*******************************************************************************
+ *
+ * FAT functionality
+ *
+ *******************************************************************************/
+#define FT_FAT_MAX_PEER_SIZE 2048
+#define FT_FAT_MAX_FRAME_SIZE FT_FAT_MAX_PEER_SIZE/64*56
+
+/**
+ * Get Disk free space
+ */
+kal_int32 FT_GetDiskFreeSpace(const WCHAR* pathname)
+{
+ FS_DiskInfo fs_diskinfo;
+ kal_int32 status;
+ kal_int32 cluster_size = FS_GetClusterSize(pathname[0]);
+ if(FS_DRIVE_NOT_FOUND == cluster_size)
+ {
+ return cluster_size;
+ }
+ if( (status=FS_GetDiskInfo(pathname, &fs_diskinfo, FS_DI_BASIC_INFO|FS_DI_FREE_SPACE)) < 0 )
+ {
+ return status;
+ }
+ return cluster_size * fs_diskinfo.FreeClusters;
+}
+kal_uint8 FT_FAT_SendCnf(FT_FAT_OPERATION *ft_fat_ret, peer_buff_struct *peer_buff) {
+
+ ilm_struct ilm_ptr;
+ FT_FAT_OPERATION *ptrMsg;
+
+ FT_ALLOC_MSG(&ilm_ptr,sizeof(FT_FAT_OPERATION));
+
+ /* if ptrMsg != NULL*/
+ ptrMsg = (FT_FAT_OPERATION *)ilm_ptr.local_para_ptr;
+
+ // assign primitive id
+ ptrMsg->header.ft_msg_id = FT_FAT_OPERATION_ID;
+
+ // assign return structure
+ ptrMsg->fs_handle = ft_fat_ret->fs_handle;
+ ptrMsg->fat_op = ft_fat_ret->fat_op;
+ ptrMsg->offset = ft_fat_ret->offset;
+ ptrMsg->last_frame = ft_fat_ret->last_frame;
+ ptrMsg->status = ft_fat_ret->status;
+
+ // assign peer buffer
+ if( NULL != peer_buff ) {
+ ilm_ptr.peer_buff_ptr = peer_buff;
+ }
+
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+ return 0;
+}
+
+WCHAR * ft_wstrnpbrk(const WCHAR *s, const WCHAR *char_set) {
+ const WCHAR *p;
+ kal_int32 char_set_len;
+ kal_int32 i;
+
+ if( NULL == s || NULL == char_set ) {
+ return NULL;
+ }
+
+ char_set_len = kal_wstrlen(char_set);
+ p = s;
+
+ while( 0 != *p ) {
+ for(i=0; i<char_set_len; i++) {
+ if( *p == char_set[i] ) {
+ break;
+ }
+ }
+ // if no char match in char_set
+ if( i == char_set_len ) {
+ return (WCHAR *)p;
+ }
+ p++;
+ }
+
+ return NULL;
+}
+
+WCHAR *ft_wstrichr(const WCHAR *s, int c)
+{
+ WCHAR tmp;
+
+ // to upper case
+ if( 0x61<=c && 0x7a>=c ) {
+ // a(0x61)~z(0x7a) --> A(0x41)~Z(0x5a)
+ c -= 0x20;
+ }
+
+ do
+ {
+ tmp = *s;
+
+ // to upper case
+ if( 0x61<=tmp && 0x7a>=tmp ) {
+ // a(0x61)~z(0x7a) --> A(0x41)~Z(0x5a)
+ tmp -= 0x20;
+ }
+
+ if (tmp == c)
+ return (WCHAR*)s;
+
+ } while (*s++);
+
+ return (0);
+}
+
+/*-----------------------------------*/
+/* Return : 0 s1 = s2 */
+/* <0 s1 is less than s2 */
+/* >0 s1 is greater than s2 */
+/*-----------------------------------*/
+int ft_wstrnicmp(const WCHAR *s1, const WCHAR *s2, int n)
+{
+ WCHAR c1, c2;
+
+ for(; 0!=*s1 && 0!=*s2 && n>0; s1++, s2++, n--) {
+
+ c1 = *s1;
+ c2 = *s2;
+
+ // to upper case
+ if( 0x61<=c1 && 0x7a>=c1 ) {
+ // a(0x61)~z(0x7a) --> A(0x41)~Z(0x5a)
+ c1 -= 0x20;
+ }
+
+ // to upper case
+ if( 0x61<=c2 && 0x7a>=c2 ) {
+ // a(0x61)~z(0x7a) --> A(0x41)~Z(0x5a)
+ c2 -= 0x20;
+ }
+
+ if( c1 != c2 ) {
+ // not match
+ break;
+ }
+ }
+
+ return (0>=n ? 0 : (*s1 - *s2));
+}
+
+const WCHAR * ft_wstristr(const WCHAR *s, const WCHAR *ptn) {
+
+ if( NULL == s || NULL == ptn ) {
+ return NULL;
+ }
+
+ while( NULL != (s=ft_wstrichr(s, ptn[0])) ) {
+ if(!ft_wstrnicmp(s, ptn, kal_wstrlen(ptn))) {
+ return s;
+ }
+ s++;
+ }
+
+ return NULL;
+}
+
+kal_bool ft_IsDirectoryExist(const WCHAR *dir) {
+
+ kal_int32 ret;
+
+ if( NULL == dir ) {
+ return KAL_FALSE;
+ }
+
+#if defined(__LOW_COST_SUPPORT_ULC__)
+ if( 0 > (ret = FS_Open(dir, FS_OPEN_DIR|FS_READ_ONLY))){
+ return KAL_FALSE;
+ }else{
+ if( FS_NO_ERROR != FS_Close(ret)){
+ ASSERT(0);
+ }
+ }
+#else
+ if( 0 >= (ret=FS_GetAttributes(dir)) ) {
+ return KAL_FALSE;
+ }
+
+ if(!(FS_ATTR_DIR&((kal_uint32)ret))) {
+ return KAL_FALSE;
+ }
+#endif
+
+ return KAL_TRUE;
+}
+
+kal_int32 ft_CreateFullDirectory(const WCHAR *pathname) {
+
+ kal_int32 ret;
+ WCHAR *buf, *p, ch;
+
+ if( NULL == pathname ) {
+ return 1;
+ }
+
+ if( NULL == (buf=(WCHAR *)get_ctrl_buffer(sizeof(WCHAR)*(kal_wstrlen(pathname)+1))) ) {
+ return 2;
+ }
+ kal_wstrcpy(buf, pathname);
+ p = buf;
+
+ if( KAL_TRUE != ft_IsDirectoryExist(p) ) {
+
+ // skip drive letter
+ if(!kal_wstrncmp(p+1, L":\\", 2)) {
+ p += 3; // skip "C:\"
+ }
+
+ // skip '\' and '.' to find the first directory name
+ while( NULL != (p=ft_wstrnpbrk(p, L"\\.")) ) {
+
+ // find the first '\' after directory name
+ if( NULL == (p=kal_wstrchr(p, L'\\')) ) {
+ // no more '\' all sub directories are created.
+ break;
+ }
+
+ // temporarily replace with 0
+ ch = *p;
+ *p = 0;
+
+ // create directory
+ if(!ft_IsDirectoryExist(buf)) {
+ if( FS_NO_ERROR != (ret=FS_CreateDir(buf)) ) {
+ free_ctrl_buffer(buf);
+ return ret;
+ }
+ }
+
+ // restore char
+ *p = ch;
+ }
+ }
+
+ free_ctrl_buffer(buf);
+
+ return 0;
+}
+
+kal_uint8 ft_fat_fullpath_concatenate(WCHAR *fullpath, kal_uint32 fullpath_len_of_bytes, const WCHAR *subname) {
+
+ kal_uint32 total_length;
+ kal_bool end_with_backslash;
+
+ // get base_path length first
+ total_length = kal_wstrlen(fullpath);
+
+ // check if end with backslash
+ if( L'\\' == fullpath[total_length-1] ) {
+ end_with_backslash = KAL_TRUE;
+ }
+ else {
+ end_with_backslash = KAL_FALSE;
+ total_length += 1; // add '\' length
+ }
+
+ // calculate total length
+ total_length += kal_wstrlen(subname) + 1; // including 0 terminator char
+
+ if( (fullpath_len_of_bytes/sizeof(WCHAR)) < total_length ) {
+ return 1;
+ }
+
+ if(!end_with_backslash) {
+ kal_wstrcat(fullpath, L"\\");
+ }
+ kal_wstrcat(fullpath, subname);
+
+ return 0;
+}
+
+kal_uint8 ft_fat_fullpath_extract(WCHAR *fullpath, WCHAR **pp_subname) {
+
+ WCHAR *p;
+
+ if( NULL == (p=kal_wstrrchr(fullpath, L'\\')) ) {
+ return 1;
+ }
+
+ *p = 0;
+
+ if( NULL != pp_subname ) {
+ *pp_subname = p+1;
+ }
+
+ return 0;
+}
+/* for build warning
+ static void ft_fat_find_close_handle(ft_fat_dir_info *dir_info, void *arg) {
+ FS_FindClose(dir_info->fs_handle);
+ }
+ */
+void ft_fat_free_buffer(ft_stack_handle *p_stack,WCHAR *fullpath, WCHAR *found)
+{
+ if(NULL != p_stack)
+ ft_stack_destroy(p_stack);//, (FT_STACK_RELEASE_CALLBACK)ft_fat_find_close_handle, NULL);
+ p_stack = NULL;
+
+ // free fullpath
+ if( NULL != fullpath ) {
+ free_ctrl_buffer(fullpath);
+ fullpath = NULL;
+ }
+
+ // free found
+ if( NULL != found ) {
+ free_ctrl_buffer(found);
+ found = NULL;
+ }
+}
+
+kal_uint8 ft_fat_find_file_only(ft_stack_handle *p_stack,
+ const WCHAR *find_pattern,
+ WCHAR *fullpath,
+ WCHAR *found,
+ FT_FAT_FIND_CALLBACK cb, void *usr_arg)
+{
+ FS_HANDLE fs_handle;
+ FS_DOSDirEntry fileinfo;
+ kal_uint8 ret = FT_FAT_FIND_NOT_FOUND;
+
+
+ // concatenate fullpath with file search pattern
+ if(ft_fat_fullpath_concatenate(fullpath, FT_FAT_MAX_FULLPATH, find_pattern)) {
+ ret = 10;
+ ft_fat_free_buffer(p_stack,fullpath,found);
+ return ret;
+ }
+
+ // find first file
+ fs_handle = FS_FindFirst(fullpath, 0, FS_ATTR_DIR, &fileinfo, found, FT_FAT_MAX_FILENAME);
+
+ // remove find_pattern from fullpath
+ if(ft_fat_fullpath_extract(fullpath, NULL)) {
+ ret = 11;
+ ft_fat_free_buffer(p_stack,fullpath,found);
+ return ret;
+ }
+
+ // keep finding file
+ if( 0 <= fs_handle ) {
+
+ do {
+ // file found!
+ ret = 0;
+
+ // concatenate fullpath with found filename
+ if(ft_fat_fullpath_concatenate(fullpath, FT_FAT_MAX_FULLPATH, found)) {
+ ret = 12;
+ ft_fat_free_buffer(p_stack,fullpath,found);
+ return ret;
+ }
+
+ // callback
+ if( 0 != cb(fullpath, &fileinfo, usr_arg) ) {
+ ret = 13;
+ ft_fat_free_buffer(p_stack,fullpath,found);
+ return ret;
+ }
+
+ // extract path
+ if(ft_fat_fullpath_extract(fullpath, NULL)) {
+ ret = 14;
+ ft_fat_free_buffer(p_stack,fullpath,found);
+ return ret;
+ }
+ }while( FS_NO_ERROR == FS_FindNext(fs_handle, &fileinfo, found, FT_FAT_MAX_FILENAME) );
+
+ // close find handle
+ FS_FindClose(fs_handle);
+ }
+
+ return ret;
+
+}
+kal_uint8 ft_fat_find_first_dir(ft_stack_handle *p_stack,
+ ft_fat_dir_info *p_dir_info,
+ WCHAR *fullpath,
+ WCHAR *found,
+ FS_DOSDirEntry *p_fileinfo,
+ kal_bool *p_IsDirSearchGoOn)
+{
+ kal_uint8 ret = FT_FAT_FIND_NOT_FOUND; // default value
+
+ (*p_IsDirSearchGoOn) = KAL_FALSE;
+
+ // concatenate fullpath with dir search pattern "*"
+ if(ft_fat_fullpath_concatenate(fullpath, FT_FAT_MAX_FULLPATH, L"*")) {
+ ret = 5;
+ ft_fat_free_buffer(p_stack,fullpath,found);
+ return ret;
+ }
+ // find first dir
+ p_dir_info->fs_handle = FS_FindFirst(fullpath, FS_ATTR_DIR, FS_ATTR_HIDDEN, p_fileinfo, found, FT_FAT_MAX_FILENAME);//update by wayne
+
+ // p_dir_info->fs_handle = FS_FindFirst(fullpath, FS_ATTR_DIR, 0, p_fileinfo, found, FT_FAT_MAX_FILENAME);
+
+
+ //cur_width=0;
+
+
+ // remove dir search pattern "*" from fullpath
+ if(ft_fat_fullpath_extract(fullpath, NULL)) {
+ ret = 6;
+ ft_fat_free_buffer(p_stack,fullpath,found);
+ return ret;
+ }
+
+ return ret;
+}
+
+kal_uint8 ft_fat_find(const WCHAR *base_path, const WCHAR *find_pattern, FT_FAT_FIND_MODE mode, FT_FAT_FIND_CALLBACK cb, void *usr_arg) {
+
+ ft_stack_handle stack;
+ ft_fat_dir_info dir_info;
+ // FS_HANDLE fs_handle; // for build warning
+ FS_DOSDirEntry fileinfo;
+
+ kal_uint16 cur_width;
+ kal_uint16 get_width;
+ kal_uint16 i;
+
+ kal_uint8 ret = FT_FAT_FIND_NOT_FOUND;
+ kal_bool IsDirSearchGoOn;
+ kal_bool IsSearchSubDirGoOn;
+ WCHAR *fullpath = NULL;
+ WCHAR *found = NULL;
+
+ kal_uint8 test_ret = 0;
+
+
+ if( NULL==base_path || 0==base_path[0] || NULL==find_pattern || 0==find_pattern[0] || NULL==cb ) {
+ return 1;
+ }
+
+ // create fullpath buffer
+ if( NULL == (fullpath=(WCHAR *)get_ctrl_buffer(FT_FAT_MAX_FULLPATH)) ) {
+ ret = 2;
+ goto free_buffer;
+ }
+
+ // create found buffer
+ if( NULL == (found=(WCHAR *)get_ctrl_buffer(FT_FAT_MAX_FILENAME)) ) {
+ ret = 3;
+ goto free_buffer;
+ }
+
+ // create stack for depth first dir search
+ //if(ft_stack_create(&stack, sizeof(ft_fat_dir_info), FT_FAT_MAX_DIR_DEPTH)) { //FT_FAT_MAX_DIR_DEPTH
+ memset(&stack, 0, sizeof(ft_stack_handle));
+ if(ft_stack_create(&stack,sizeof(kal_uint16), FT_FAT_MAX_DIR_DEPTH)) { //FT_FAT_MAX_DIR_DEPTH
+ ret = 4;
+ goto free_buffer;
+ }
+
+ // copy base_path to fullpath
+ kal_wstrcpy(fullpath, base_path);
+
+ // check find mode
+ if( FT_FAT_FIND_FILE == mode ) {
+ //goto file_search;
+ ret = ft_fat_find_file_only(&stack,find_pattern,fullpath,found,cb,usr_arg);
+ }
+ else // FT_FAT_FIND_FILE_RECURSIVE or FT_FAT_FIND_DIR_RECURSIVE
+ {
+ // search the first directory in the base_path == lable: dir_search
+ ret = ft_fat_find_first_dir(&stack, &dir_info, fullpath, found, &fileinfo, &IsDirSearchGoOn);
+ cur_width=0;
+ if(ret != FT_FAT_FIND_NOT_FOUND) goto free_buffer;
+
+ IsSearchSubDirGoOn = KAL_FALSE;
+ for(; ;)
+ {
+
+ if( 0 <= dir_info.fs_handle )
+ {
+ do{
+ cur_width++;
+
+ // if dir search go on, FindNext() again first
+ if(IsDirSearchGoOn) {
+ IsDirSearchGoOn = KAL_FALSE;
+ continue;
+ }
+ // if found is "." or ".." , skip it
+ if( !kal_wstrcmp(found, L".") || !kal_wstrcmp(found, L"..") ) {
+ continue;
+ }
+ if( FT_FAT_FIND_DIR_RECURSIVE == mode ) {
+ // dir found!
+ ret = 0;
+ }
+ //close the file handler before we push it!
+ FS_FindClose(dir_info.fs_handle);
+
+ // push current dir
+ cur_width--;
+ //test_ret = ft_stack_push(&stack, &dir_info, sizeof(dir_info), cur_width);
+ test_ret = ft_stack_push(&stack, cur_width);
+ if(test_ret>0)
+ {
+ if(test_ret == 1) ret = 60;
+ else if(test_ret ==2) ret = 61;
+ else if(test_ret ==3) ret = 62;
+
+ goto free_buffer;
+ }
+
+ // concatenate with the found sub dir
+ if(ft_fat_fullpath_concatenate(fullpath, FT_FAT_MAX_FULLPATH, found)) {
+ ret = 8;
+ goto free_buffer;
+ }
+
+ // callback
+ if( 0 != cb(fullpath, &fileinfo, usr_arg) ) {
+ ret = 9;
+ goto free_buffer;
+ }
+
+ // find from sub dir
+ //goto dir_search;
+ if(ret != 0)
+ ret = ft_fat_find_first_dir(&stack, &dir_info, fullpath, found, &fileinfo, &IsDirSearchGoOn);
+ else
+ ft_fat_find_first_dir(&stack, &dir_info, fullpath, found, &fileinfo, &IsDirSearchGoOn);
+
+ cur_width=0;
+ if(ret != 0 && ret != FT_FAT_FIND_NOT_FOUND) goto free_buffer;
+
+ IsSearchSubDirGoOn = KAL_TRUE;
+ break; // break the while loop
+ //goto dir_search_go_on;
+
+ }while( FS_NO_ERROR == FS_FindNext(dir_info.fs_handle, &fileinfo, found, FT_FAT_MAX_FILENAME) );
+
+ if(IsSearchSubDirGoOn == KAL_TRUE)
+ {
+ IsSearchSubDirGoOn = KAL_FALSE;
+ continue; // start from the for loop again
+
+ }
+ // close find handle
+ FS_FindClose(dir_info.fs_handle);
+
+
+
+ }// end of if( 0 <= dir_info.fs_handle )
+
+
+ // file_search: find file
+ if(FT_FAT_FIND_FILE_RECURSIVE == mode)
+ {
+ if(ret!= 0)
+ ret = ft_fat_find_file_only(&stack,find_pattern,fullpath,found,cb,usr_arg);
+ else
+ ft_fat_find_file_only(&stack,find_pattern,fullpath,found,cb,usr_arg);
+
+ if(ret != 0 && ret != FT_FAT_FIND_NOT_FOUND) goto free_buffer; // error
+ }
+
+
+ // pop to parent dir
+ if(!ft_stack_pop(&stack, &get_width)) {
+ // extract fullpath to parent dir
+ if(ft_fat_fullpath_extract(fullpath, NULL)) {
+ ret = 15;
+ goto free_buffer;
+ }
+
+
+ // open the directory after we pop it =========================
+ // concatenate fullpath with dir search pattern "*"
+ if(ft_fat_fullpath_concatenate(fullpath, FT_FAT_MAX_FULLPATH, L"*")) {
+ ret = 70;
+ goto free_buffer;
+ }
+
+ //dir_info.fs_handle = FS_FindFirst(fullpath, FS_ATTR_DIR, 0, &fileinfo, found, FT_FAT_MAX_FILENAME);
+ dir_info.fs_handle = FS_FindFirst(fullpath, FS_ATTR_DIR, FS_ATTR_HIDDEN , &fileinfo, found, FT_FAT_MAX_FILENAME);
+ for(i=0;i<get_width;i++)
+ {
+ if(FS_FindNext(dir_info.fs_handle, &fileinfo, found, FT_FAT_MAX_FILENAME) !=FS_NO_ERROR)
+ {
+ ret = 73;
+ goto free_buffer;
+ }
+ }
+
+ cur_width = get_width;
+
+ // remove dir search pattern "*" from fullpath
+ if(ft_fat_fullpath_extract(fullpath, NULL)) {
+ ret = 71;
+ goto free_buffer;
+ }
+ //===========================================================
+
+ // dir search go on
+ IsDirSearchGoOn = KAL_TRUE;
+ //goto dir_search_go_on;
+ }// end of pop up the parent dir
+ else
+ {
+ break; // exit the for(; ;) loop
+ }
+ } // end of for(; ;)
+
+
+ } // end of else
+free_buffer:
+
+ ft_fat_free_buffer(&stack,fullpath,found);
+ return ret;
+}
+
+static kal_bool ft_fat_check_if_path_restricted(const WCHAR *path)
+{
+ return nvram_check_hidden_file(path, (ft_gl_path_check_flag) ? KAL_FALSE : KAL_TRUE );
+}
+
+typedef struct {
+ FT_FAT_OPERATION *p_fat_ret;
+ peer_buff_struct **pp_peer_buff_ret;
+ FT_FAT_FIND_MODE find_mode;
+}ft_fat_find_cb_arg;
+
+static kal_int8 ft_fat_update_peer_buf(const WCHAR *fullpath, const FS_DOSDirEntry *dos_info, ft_fat_find_cb_arg *arg) {
+
+ kal_uint32 filesize;
+ kal_uint16 pdu_length;
+ kal_char *pdu_ptr;
+
+ // check find mode
+ if( FT_FAT_FIND_DIR_RECURSIVE == arg->find_mode ) {
+ // find dir mode, skip all non-dir found items
+ if(!(FS_ATTR_DIR&(dos_info->Attributes))) {
+ return 0;
+ }
+ }
+ else {
+ // find file mode, skip all non-file found items
+ if((FS_ATTR_DIR&(dos_info->Attributes))) {
+ return 0;
+ }
+ }
+
+ // check path restriction
+ if(ft_fat_check_if_path_restricted(fullpath)) {
+ return 0;
+ }
+
+allocate_peer_buf:
+ // if peer buffer is not allocated, allocate it now.
+ if( NULL == *(arg->pp_peer_buff_ret) ) {
+ if( NULL == (*(arg->pp_peer_buff_ret)=construct_peer_buff(FT_FAT_MAX_FRAME_SIZE, 0, 0, TD_CTRL)) ) {
+ return 1;
+ }
+ (*(arg->pp_peer_buff_ret))->pdu_len = 0;
+ }
+
+ // data format: filesize(4bytes) + filepath(string) + '\0'
+
+ // if data exceed limit, flush out.
+ if( FT_FAT_MAX_FRAME_SIZE < ((*(arg->pp_peer_buff_ret))->pdu_len+4+((kal_wstrlen(fullpath)+1)*2)) ) {
+ // set last_frame = 0
+ arg->p_fat_ret->last_frame = 0;
+ arg->p_fat_ret->status = FT_CNF_OK;
+ // send confirm
+ FT_FAT_SendCnf(arg->p_fat_ret, *(arg->pp_peer_buff_ret));
+
+ // sleep to wait for tst flush out data
+ kal_sleep_task(50);
+
+ // allocate peer buffer again
+ *(arg->pp_peer_buff_ret) = NULL;
+ goto allocate_peer_buf;
+ }
+
+ pdu_ptr = get_peer_buff_pdu( *(arg->pp_peer_buff_ret), &pdu_length );
+
+ // store filesize
+ filesize = dos_info->FileSize;
+ kal_mem_cpy(pdu_ptr+pdu_length, &filesize, sizeof(filesize));
+ // copy filepath
+ kal_mem_cpy(pdu_ptr+pdu_length+sizeof(filesize), (void *)fullpath, (kal_wstrlen(fullpath)+1)*2);
+ // update pdu_len
+ (*(arg->pp_peer_buff_ret))->pdu_len += ( sizeof(filesize) + (kal_wstrlen(fullpath)+1)*2 );
+
+ return 0;
+}
+
+#define MAX_OPENED_HANDLE 32
+static FS_HANDLE g_FAT_HandleArrary[MAX_OPENED_HANDLE];
+
+kal_int8 FT_FAT_Handle_Clear(void) {
+ kal_uint16 i;
+ for(i=0; i<MAX_OPENED_HANDLE; i++) {
+ g_FAT_HandleArrary[i] = -1;
+ }
+ return 0;
+}
+
+kal_int8 FT_FAT_Handle_Add(FS_HANDLE handle) {
+ kal_uint16 i;
+ for(i=0; i<MAX_OPENED_HANDLE; i++) {
+ if( -1 == g_FAT_HandleArrary[i] ) {
+ g_FAT_HandleArrary[i] = handle;
+ return 0;
+ }
+ }
+ return 1;
+}
+
+
+kal_int8 FT_FAT_Handle_Del(FS_HANDLE handle) {
+ kal_uint16 i;
+ for(i=0; i<MAX_OPENED_HANDLE; i++) {
+ if( handle == g_FAT_HandleArrary[i] ) {
+ g_FAT_HandleArrary[i] = -1;
+ return 0;
+ }
+ }
+ return 1;
+}
+
+kal_bool FT_FAT_Handle_IsAvailable(void) {
+ kal_uint16 i;
+ for(i=0; i<MAX_OPENED_HANDLE; i++) {
+ if( -1 == g_FAT_HandleArrary[i] ) {
+ return KAL_TRUE;
+ }
+ }
+ return KAL_FALSE;
+}
+
+#if !defined(__LOW_COST_SUPPORT_ULC__)
+kal_bool FT_FAT_IsFileAlreadyOpened(const WCHAR *filename, FS_HANDLE *handle) {
+ kal_uint16 i;
+ FS_FileInfo file_info;
+ for(i=0; i<MAX_OPENED_HANDLE; i++) {
+ if( -1 != g_FAT_HandleArrary[i] ) {
+ // get file handel info
+ if( 0 <= FS_GetFileInfo(g_FAT_HandleArrary[i], &file_info) ) {
+
+ // compare full filename
+ if(!ft_wstrnicmp(filename, (WCHAR *)file_info.FullName, kal_wstrlen(filename))) {
+ // filename is the same, this file is already opened!
+ if( NULL != handle ) {
+ *handle = g_FAT_HandleArrary[i];
+ }
+ return KAL_TRUE;
+ }
+
+ }
+ }
+ }
+ return KAL_FALSE;
+}
+
+kal_int8 FT_FAT_CloseFileIfAlreadyOpened(const WCHAR *filename) {
+ FS_HANDLE handle;
+ // check if handle is already opened
+ if( KAL_TRUE == FT_FAT_IsFileAlreadyOpened(filename, &handle) ) {
+ if( FS_NO_ERROR != FS_Close(handle) ) {
+ return 1;
+ }
+ // delete this handle from opened handle arrary
+ if( 0 != FT_FAT_Handle_Del(handle) ) {
+ return 2;
+ }
+ }
+ return 0;
+}
+#endif
+
+void FT_FAT_Operation(FT_FAT_OPERATION *ft_fat_op, peer_buff_struct *peer_buff_in) {
+
+ kal_uint32 mode;
+ kal_uint16 pdu_length;
+ kal_char *pdu_ptr;
+ peer_buff_struct *peer_buff_ret;
+ kal_uint32 finish_bytes;
+ FT_FAT_OPERATION ft_fat_ret;
+ ft_fat_find_cb_arg ft_fat_update_peer_buf_arg;
+ kal_uint32 filesize;
+ WCHAR *w_filepath_1;
+ WCHAR *w_filepath_2;
+ FT_FAT_DiskInfo_T DiskInfo;
+ FS_DiskInfo fs_diskinfo;
+ //kal_uint8 folder_total_amount;
+ //kal_uint8 folder_idx;
+
+ // initialize
+ pdu_length = 0;
+ pdu_ptr = NULL;
+ peer_buff_ret = NULL;
+ kal_mem_set(&ft_fat_ret, '\0', sizeof(FT_FAT_OPERATION));
+
+ if( NULL != peer_buff_in ) {
+ pdu_ptr = get_peer_buff_pdu( peer_buff_in, &pdu_length );
+ }
+
+ ft_fat_ret.fat_op = ft_fat_op->fat_op;
+ ft_fat_ret.status = FT_CNF_FAIL;
+ switch((int)ft_fat_op->fat_op) {
+ case FT_FAT_OP_OPEN|FT_FAT_OP_READ:
+ case FT_FAT_OP_OPEN|FT_FAT_OP_WRITE:
+ if( NULL != peer_buff_in && 0 < pdu_length ) {
+
+ // check if filepath too long
+ if( FT_FAT_MAX_FULLPATH < pdu_length ) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_TOO_LONG;
+ break;
+ }
+
+ // cast to WCHAR
+ w_filepath_1 = (WCHAR *)pdu_ptr;
+
+ // check path restriction
+ if(ft_fat_check_if_path_restricted(w_filepath_1)) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_RESTRICTION;
+ break;
+ }
+
+ // create dir
+ if( 0 != (ft_fat_ret.status=ft_CreateFullDirectory(w_filepath_1)) ) {
+ break;
+ }
+
+ if( (FT_FAT_OP_OPEN+FT_FAT_OP_WRITE) == ft_fat_ret.fat_op ) {
+ mode = FS_CREATE_ALWAYS;
+ }
+ else {
+ mode = FS_READ_ONLY;
+ }
+
+#if !defined(__LOW_COST_SUPPORT_ULC__)
+ // close file if it is already opened
+ FT_FAT_CloseFileIfAlreadyOpened(w_filepath_1);
+#endif
+
+ // check if file handle available
+ if( KAL_TRUE != FT_FAT_Handle_IsAvailable() ) {
+ ft_fat_ret.status = FS_TOO_MANY_FILES;
+ break;
+ }
+
+ if( 0 <= (ft_fat_ret.status=FS_Open(w_filepath_1, mode)) ) {
+ // assign file handle
+ ft_fat_ret.fs_handle = ft_fat_ret.status;
+ // ok
+ ft_fat_ret.status = FT_CNF_OK;
+ // add this handle into opened handle arrary
+ FT_FAT_Handle_Add(ft_fat_ret.fs_handle);
+ // send confirm
+ break;
+ }
+ }
+ break;
+ case FT_FAT_OP_READ:
+ ft_fat_ret.fs_handle = ft_fat_op->fs_handle;
+ ft_fat_ret.offset = ft_fat_op->offset;
+ ft_fat_ret.last_frame = 0;
+ if( 0 <= (ft_fat_ret.status=FS_Seek(ft_fat_ret.fs_handle, ft_fat_ret.offset, FS_FILE_BEGIN))) {
+ finish_bytes = 0;
+ if( NULL != (peer_buff_ret=construct_peer_buff(FT_FAT_MAX_FRAME_SIZE, 0, 0, TD_CTRL)) ) {
+
+ pdu_ptr = get_peer_buff_pdu( peer_buff_ret, &pdu_length );
+
+ if( FS_NO_ERROR == (ft_fat_ret.status=FS_GetFileSize(ft_fat_ret.fs_handle, &filesize)) ) {
+
+ if( FS_NO_ERROR == (ft_fat_ret.status=FS_Read(ft_fat_ret.fs_handle, pdu_ptr, FT_FAT_MAX_FRAME_SIZE, &finish_bytes)) ) {
+ if( (finish_bytes+ft_fat_ret.offset) >= filesize ) {
+ ft_fat_ret.last_frame = 1;
+ }
+ ft_fat_ret.status = FT_CNF_OK;
+ peer_buff_ret->pdu_len = finish_bytes;
+ // send confirm
+ break;
+ }
+
+ }
+
+ // error, free buffer
+ free_peer_buff(peer_buff_ret);
+ peer_buff_ret = NULL;
+ }
+ }
+ break;
+ case FT_FAT_OP_WRITE:
+ ft_fat_ret.fs_handle = ft_fat_op->fs_handle;
+ ft_fat_ret.offset = ft_fat_op->offset;
+ if( NULL != peer_buff_in && 0 < pdu_length ) {
+ if( 0 <= (ft_fat_ret.status=FS_Seek(ft_fat_ret.fs_handle, ft_fat_ret.offset, FS_FILE_BEGIN))) {
+ finish_bytes = 0;
+ if( FS_NO_ERROR==(ft_fat_ret.status=FS_Write(ft_fat_ret.fs_handle, pdu_ptr, pdu_length, &finish_bytes)) && pdu_length==finish_bytes ) {
+ ft_fat_ret.status = FT_CNF_OK;
+ // send confirm
+ break;
+ }
+ }
+ }
+ break;
+ case FT_FAT_OP_CLOSE:
+ ft_fat_ret.fs_handle = ft_fat_op->fs_handle;
+ if( FS_NO_ERROR == (ft_fat_ret.status=FS_Close(ft_fat_ret.fs_handle)) ) {
+ // ok
+ ft_fat_ret.status = FT_CNF_OK;
+ // delete this handle from opened handle arrary
+ FT_FAT_Handle_Del(ft_fat_ret.fs_handle);
+ // send confirm
+ break;
+ }
+ break;
+ case FT_FAT_OP_FILESIZE:
+ ft_fat_ret.fs_handle = ft_fat_op->fs_handle;
+ if( FS_NO_ERROR == (ft_fat_ret.status=FS_GetFileSize(ft_fat_ret.fs_handle, (kal_uint32 *)&(ft_fat_ret.offset))) ) {
+ // ok
+ ft_fat_ret.status = FT_CNF_OK;
+ // send confirm
+ break;
+ }
+ break;
+ case FT_FAT_OP_DELETE:
+ if( NULL != peer_buff_in && 0 < pdu_length ) {
+
+ // check if filepath too long
+ if( FT_FAT_MAX_FULLPATH < pdu_length ) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_TOO_LONG;
+ break;
+ }
+
+ // cast to WCHAR
+ w_filepath_1 = (WCHAR *)pdu_ptr;
+
+ // check path restriction
+ if(ft_fat_check_if_path_restricted(w_filepath_1)) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_RESTRICTION;
+ break;
+ }
+
+#if !defined(__LOW_COST_SUPPORT_ULC__)
+ // close file if it is already opened
+ FT_FAT_CloseFileIfAlreadyOpened(w_filepath_1);
+#endif
+ if( FS_NO_ERROR == (ft_fat_ret.status=FS_Delete(w_filepath_1)) ) {
+ // ok
+ ft_fat_ret.status = FT_CNF_OK;
+ // send confirm
+ break;
+ }
+ }
+ break;
+ case FT_FAT_OP_MOVE:
+#if defined(__LOW_COST_SUPPORT_ULC__)
+ ft_fat_ret.status = FT_FAT_ERR_ACTION_NOT_SUPPORT;
+#else // non __LOW_COST_SUPPORT_LC__
+ if( NULL != peer_buff_in && 0 < pdu_length ) {
+
+ w_filepath_1 = (WCHAR *)pdu_ptr;
+ w_filepath_2 = w_filepath_1+kal_wstrlen(w_filepath_1)+1;
+
+ // check if src path too long
+ if( FT_FAT_MAX_FULLPATH < (kal_wstrlen(w_filepath_1)+1)*2 ) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_TOO_LONG;
+ break;
+ }
+
+ // check if dest path too long
+ if( FT_FAT_MAX_FULLPATH < (kal_wstrlen(w_filepath_2)+1)*2 ) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_TOO_LONG;
+ break;
+ }
+
+ // check path restriction
+ if(ft_fat_check_if_path_restricted(w_filepath_1)) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_RESTRICTION;
+ break;
+ }
+
+ // check path restriction
+ if(ft_fat_check_if_path_restricted(w_filepath_2)) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_RESTRICTION;
+ break;
+ }
+
+ // close file if it is already opened
+ FT_FAT_CloseFileIfAlreadyOpened(w_filepath_1);
+ FT_FAT_CloseFileIfAlreadyOpened(w_filepath_2);
+
+ if( FS_NO_ERROR == (ft_fat_ret.status=FS_Rename(w_filepath_1, w_filepath_2)) ) {
+ // ok
+ ft_fat_ret.status = FT_CNF_OK;
+ // send confirm
+ break;
+ }
+ }
+#endif // non __LOW_COST_SUPPORT_LC__
+ break;
+ case FT_FAT_OP_FIND_FILE:
+ case FT_FAT_OP_FIND_FILE_RECURSIVE:
+ case FT_FAT_OP_FIND_DIR_RECURSIVE:
+ if( NULL != peer_buff_in && 0 < pdu_length ) {
+
+ w_filepath_1 = (WCHAR *)pdu_ptr;
+ w_filepath_2 = w_filepath_1+kal_wstrlen(w_filepath_1)+1;
+
+ // check if base_dir too long
+ if( FT_FAT_MAX_FULLPATH < (kal_wstrlen(w_filepath_1)+1)*2 ) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_TOO_LONG;
+ break;
+ }
+
+ // check if find_pattern path too long
+ if( FT_FAT_MAX_FULLPATH < (kal_wstrlen(w_filepath_2)+1)*2 ) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_TOO_LONG;
+ break;
+ }
+
+ // check path restriction in file search case
+ if( (FT_FAT_OP_FIND_DIR_RECURSIVE != ft_fat_op->fat_op) &&
+ ft_fat_check_if_path_restricted(w_filepath_1) ) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_RESTRICTION;
+ break;
+ }
+
+ // find
+ peer_buff_ret = NULL;
+ ft_fat_update_peer_buf_arg.p_fat_ret = &ft_fat_ret;
+ ft_fat_update_peer_buf_arg.pp_peer_buff_ret = &peer_buff_ret;
+ switch(ft_fat_op->fat_op) {
+ case FT_FAT_OP_FIND_FILE:
+ ft_fat_update_peer_buf_arg.find_mode = FT_FAT_FIND_FILE;
+ break;
+ case FT_FAT_OP_FIND_DIR_RECURSIVE:
+ ft_fat_update_peer_buf_arg.find_mode = FT_FAT_FIND_DIR_RECURSIVE;
+ break;
+ case FT_FAT_OP_FIND_FILE_RECURSIVE:
+ default:
+ ft_fat_update_peer_buf_arg.find_mode = FT_FAT_FIND_FILE_RECURSIVE;
+ break;
+ }
+ if( 0 == (ft_fat_ret.status=ft_fat_find(
+ w_filepath_1,
+ w_filepath_2,
+ ft_fat_update_peer_buf_arg.find_mode,
+ (FT_FAT_FIND_CALLBACK)ft_fat_update_peer_buf,
+ &ft_fat_update_peer_buf_arg)) )
+ {
+ // found
+ ft_fat_ret.last_frame = 1;
+ ft_fat_ret.status = FT_CNF_OK;
+ }
+ }
+ break;
+ case FT_FAT_OP_GET_DISK_INFO:
+ if( NULL != peer_buff_in && 0 < pdu_length ) {
+
+ // cast to WCHAR
+ w_filepath_1 = (WCHAR *)pdu_ptr;
+
+ /* // check path restriction
+ if(ft_fat_check_if_path_restricted(w_filepath_1)) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_RESTRICTION;
+ break;
+ }*/
+
+ if( NULL != (peer_buff_ret=construct_peer_buff(sizeof(FT_FAT_DiskInfo_T), 0, 0, TD_CTRL)) ) {
+
+ pdu_ptr = get_peer_buff_pdu( peer_buff_ret, &pdu_length );
+
+ kal_mem_set(&fs_diskinfo, 0, sizeof(fs_diskinfo));
+ if( 0 <= (ft_fat_ret.status=FS_GetDiskInfo(w_filepath_1, &fs_diskinfo, FS_DI_BASIC_INFO|FS_DI_FREE_SPACE)) ) {
+ // ok
+ ft_fat_ret.status = FT_CNF_OK;
+ // fill FT_FAT_DiskInfo_T
+ DiskInfo.Type = fs_diskinfo.FATType;
+ DiskInfo.SectorsPerCluster = fs_diskinfo.SectorsPerCluster;
+ DiskInfo.TotalClusters = fs_diskinfo.TotalClusters;
+ DiskInfo.FreeClusters = fs_diskinfo.FreeClusters;
+ kal_mem_cpy(pdu_ptr, &DiskInfo, sizeof(FT_FAT_DiskInfo_T));
+ // send confirm
+ break;
+ }
+
+ // error, free buffer
+ free_peer_buff(peer_buff_ret);
+ peer_buff_ret = NULL;
+ }
+ }
+ break;
+ case FT_FAT_OP_RMDIR:
+#if defined(__LOW_COST_SUPPORT_ULC__)
+ ft_fat_ret.status = FT_FAT_ERR_ACTION_NOT_SUPPORT;
+#else // non __LOW_COST_SUPPORT_ULC__
+ if( NULL != peer_buff_in && 0 < pdu_length ) {
+
+ // check if filepath too long
+ if( FT_FAT_MAX_FULLPATH < pdu_length ) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_TOO_LONG;
+ break;
+ }
+
+ // cast to WCHAR
+ w_filepath_1 = (WCHAR *)pdu_ptr;
+
+ // check path restriction
+ if(ft_fat_check_if_path_restricted(w_filepath_1)) {
+ ft_fat_ret.status = FT_FAT_ERR_PATH_RESTRICTION;
+ break;
+ }
+
+ // check if directory
+ if(!ft_IsDirectoryExist(w_filepath_1)) {
+ ft_fat_ret.status = FT_FAT_ERR_DIR_NOT_EXIST;
+ break;
+ }
+
+ // call FS_XDelete
+ if( 0 <= (ft_fat_ret.status=FS_XDelete(w_filepath_1, FS_FILE_TYPE|FS_DIR_TYPE|FS_RECURSIVE_TYPE, NULL, 0)) ) {
+ ft_fat_ret.status = FT_CNF_OK;
+ }
+ }
+#endif // end non __LOW_COST_SUPPORT_ULC__
+ break;
+ case FT_FAT_OP_GET_DRIVE_TYPE:
+ {
+ // Since FS_GetDevType is not supported
+ ft_fat_ret.status = FT_FAT_ERR_ACTION_NOT_SUPPORT;
+ break;
+ }
+ default:
+ break;
+ }
+
+ // send confirm
+ ft_gl_path_check_flag = KAL_TRUE; // re-enable the path restriction!
+ FT_FAT_SendCnf(&ft_fat_ret, peer_buff_ret);
+}
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_l1rf.c b/mcu/middleware/meta/ft/src/ft_fnc_l1rf.c
new file mode 100644
index 0000000..cce84e4
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_l1rf.c
@@ -0,0 +1,252 @@
+/*****************************************************************************
+* 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).
+*
+*****************************************************************************/
+/*******************************************************************************
+* Modification Notice:
+* --------------------------
+* This software is modified by MediaTek Inc. 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) 2001
+*
+*******************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * ft_fnc_l1rf.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Factory testing function for GSM/GPRS/EDGE
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if !defined(L1_NOT_PRESENT) && !defined(__L1_TASK_DISABLE__) && !defined(DUMMYL1)
+/*************************************************************************
+* Include Statements for KAL
+ *************************************************************************/
+#include "kal_public_defs.h"
+#include "task_config.h"
+#include "svc_sap.h"
+#include "md_sap.h"
+#include "ft_msgid.h"
+/*************************************************************************
+ * FT header
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_private.h"
+#include "ft_fnc_l1rf.h"
+/**
+ * @param metaMessage the input message from META tool for RF test command processing
+ */
+void FT_Rf_Operation(ilm_struct *ptrMsg)
+{
+ ilm_struct rfMessage;
+ FT_CONSTRUCT_CC_MSG(ptrMsg, &rfMessage);
+ FT_SEND_MSG(MOD_FT, MOD_L1, FT_GL1TST_SAP, MSG_ID_FT_TO_GL1TST, &rfMessage);
+}
+/**
+ * Confirm message handler for MOD_L1
+ */
+void FT_Rf_ConfirmHandler(ilm_struct* rfMessage)
+{
+ ft_rf_test_cnf_T *ptrMsg;
+ ptrMsg = (ft_rf_test_cnf_T *)rfMessage->local_para_ptr;
+ if(ptrMsg->type == RF_TEST_CMD_CHECK_IF_FUNC_EXIST)
+ {
+ FT_UTILITY_COMMAND_CNF cnf;
+ kal_mem_set(&cnf, '\0', sizeof(cnf));
+ cnf.status = (ptrMsg->param.CheckIfFuncExist.result==1)?FT_CNF_OK:FT_CNF_FAIL;
+ cnf.result.CheckIfFuncExist.query_ft_msg_id = ptrMsg->header.ft_msg_id;
+ cnf.result.CheckIfFuncExist.query_op_code = ptrMsg->param.CheckIfFuncExist.query_op_code;
+ FT_UTIL_SendCnf(&cnf, NULL);
+ return;
+ }
+ FT_SEND_MSG_TO_PC(rfMessage);
+}
+void FT_RfCheckFunctionSupported(kal_uint32 query_op_code)
+{
+ ilm_struct ilm_ptr;
+ ft_rf_test_req_T *ptrMsg;
+ FT_ALLOC_OTHER_CC_MSG( &ilm_ptr, sizeof(ft_rf_test_req_T) );
+ // local parameter
+ ptrMsg = (ft_rf_test_req_T *)ilm_ptr.local_para_ptr;
+ ptrMsg->header.ft_msg_id = FT_RF_TEST_REQ_ID;
+ ptrMsg->type = RF_TEST_CMD_CHECK_IF_FUNC_EXIST;
+ ptrMsg->param.query_op_code = (RfTestCmdType)query_op_code;
+ FT_SEND_MSG(MOD_FT, MOD_L1, FT_GL1TST_SAP, MSG_ID_FT_TO_GL1TST, &ilm_ptr);
+}
+#endif //#if !defined(L1_NOT_PRESENT) && !defined(__L1_TASK_DISABLE__) && !defined(DUMMYL1)
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_l4.c b/mcu/middleware/meta/ft/src/ft_fnc_l4.c
new file mode 100644
index 0000000..bff3c45
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_l4.c
@@ -0,0 +1,105 @@
+#if !defined(__L4_TASK_DISABLE__) && !defined(L4_NOT_PRESENT) || defined(DUMMY_PROTOCOL)
+/*************************************************************************
+* Include Statements for KAL
+ *************************************************************************/
+#include "kal_public_defs.h"
+#include "md_sap.h"
+#include "tst_msgid.h"
+#include "ft_msgid.h"
+#include "ps_public_l4_msgid.h"
+/*************************************************************************
+ * FT header
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_private.h"
+#include "ft_fnc_l4.h"
+#include "ft_msg_l4.h"
+/**
+ * @param metaMessage and MOD_L4C the input message for L4 AT test command processing
+ */
+void FT_L4_Operation(ilm_struct* ptrMsg)
+{
+ ilm_struct l4Message;
+
+ if(MOD_L4C == ptrMsg->src_mod_id)
+ {
+ switch (ptrMsg->msg_id)
+ {
+ case MSG_ID_FT_ENTER_FACTORY_MODE_CNF:
+ {
+ ft_enter_factory_mode_cnf_struct *l4CnfMsg;
+ FT_L4_ATCMD_CNF *ptrCnfMsg;
+ l4CnfMsg = (ft_enter_factory_mode_cnf_struct*)ptrMsg->local_para_ptr;
+ FT_ALLOC_MSG(&l4Message, sizeof(FT_L4_ATCMD_CNF));
+ ptrCnfMsg = (FT_L4_ATCMD_CNF *)l4Message.local_para_ptr;
+ ptrCnfMsg->header.ft_msg_id = FT_L4_ATCMD_CNF_ID;
+ ptrCnfMsg->type = 1;
+ if(l4CnfMsg->result == FT_MODE_SWITCH_SUCCESS)
+ {
+ ptrCnfMsg->status = FT_CNF_OK;
+ }
+ else if(l4CnfMsg->result == FT_MODE_SWITCH_RETRY)
+ {
+ ptrCnfMsg->status = FT_CNF_RETRY;
+ }
+ else
+ {
+ ptrCnfMsg->status = FT_CNF_FAIL;
+ }
+ FT_SEND_MSG_TO_PC(&l4Message);
+ break;
+ }
+ case MSG_ID_FT_ENTER_NORMAL_MODE_CNF:
+ {
+ ft_enter_normal_mode_cnf_struct *l4CnfMsg;
+ FT_L4_ATCMD_CNF *ptrCnfMsg;
+ l4CnfMsg = (ft_enter_normal_mode_cnf_struct*)ptrMsg->local_para_ptr;
+ FT_ALLOC_MSG(&l4Message, sizeof(FT_L4_ATCMD_CNF));
+ ptrCnfMsg = (FT_L4_ATCMD_CNF *)l4Message.local_para_ptr;
+ ptrCnfMsg->header.ft_msg_id = FT_L4_ATCMD_CNF_ID;
+ ptrCnfMsg->type = 0;
+ if(l4CnfMsg->result == FT_MODE_SWITCH_SUCCESS)
+ {
+ ptrCnfMsg->status = FT_CNF_OK;
+ }
+ else if(l4CnfMsg->result == FT_MODE_SWITCH_RETRY)
+ {
+ ptrCnfMsg->status = FT_CNF_RETRY;
+ }
+ else
+ {
+ ptrCnfMsg->status = FT_CNF_FAIL;
+ }
+ FT_SEND_MSG_TO_PC(&l4Message);
+ break;
+ }
+ /* FT not in switch mode broadcast list
+ case MSG_ID_L4C_ENTER_FACTORY_MODE_REQ:
+ {
+ l4Message.local_para_ptr = NULL;
+ l4Message.peer_buff_ptr = NULL;
+ FT_SEND_MSG(MOD_FT, MOD_L4C, L4C_META_SAP, MSG_ID_L4C_ENTER_FACTORY_MODE_CNF, &l4Message);
+ break;
+ }*/
+ }
+ }
+ else
+ {
+ FT_L4_ATCMD_REQ *ptrLocalMsg;
+ ptrLocalMsg = (FT_L4_ATCMD_REQ *)ptrMsg->local_para_ptr;
+ if(FT_L4_ATCMD_REQ_ID == ptrLocalMsg->header.ft_msg_id)
+ {
+ l4Message.local_para_ptr = NULL;
+ l4Message.peer_buff_ptr = NULL;
+ if(ptrLocalMsg->type == 1)
+ {
+ FT_SEND_MSG(MOD_FT, MOD_L4C, L4C_META_SAP, MSG_ID_FT_ENTER_FACTORY_MODE_REQ, &l4Message);
+ }
+ else if(ptrLocalMsg->type == 0)
+ {
+ FT_SEND_MSG(MOD_FT, MOD_L4C, L4C_META_SAP, MSG_ID_FT_ENTER_NORMAL_MODE_REQ, &l4Message);
+ }
+ }
+ }
+}
+#endif // #if !defined(__L4_TASK_DISABLE__) && !defined(L4_NOT_PRESENT) || defined(DUMMY_PROTOCOL)
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_lterf.c b/mcu/middleware/meta/ft/src/ft_fnc_lterf.c
new file mode 100644
index 0000000..bb54a6a
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_lterf.c
@@ -0,0 +1,194 @@
+/*****************************************************************************
+* 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).
+*
+*****************************************************************************/
+/*******************************************************************************
+* Modification Notice:
+* --------------------------
+* This software is modified by MediaTek Inc. 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) 2001
+*
+*******************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * ft_fnc_lterf.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Factory testing function for LTE
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(__LTE_RAT__)
+/*************************************************************************
+* Include Statements for KAL
+ *************************************************************************/
+#include "kal_public_defs.h"
+#include "svc_sap.h"
+#include "tst_msgid.h"
+#include "ft_msgid.h"
+/*************************************************************************
+ * FT header
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_private.h"
+#include "ft_fnc_lterf.h"
+/**
+ * @param metaMessage the input message from META tool for ERF test command processing
+ */
+void FT_Erf_Operation(ilm_struct* ptrMsg)
+{
+ ilm_struct erfMessage;
+ FT_CONSTRUCT_CC_MSG(ptrMsg, &erfMessage);
+ FT_SEND_MSG(MOD_FT, MOD_EL1, DHL_EL1TST_SAP, MSG_ID_DHL_TO_EL1TST, &erfMessage);
+}
+/**
+ * @param metaMessage the input message from META tool for ERF test command processing
+ */
+void FT_PhyTool_Operation(ilm_struct* ptrMsg)
+{
+ ilm_struct erfMessage;
+ FT_CONSTRUCT_CC_MSG(ptrMsg, &erfMessage);
+ FT_SEND_MSG(MOD_FT, MOD_EL1, DHL_ETSTM_SAP, MSG_ID_DHL_TO_ETSTM, &erfMessage);
+}
+/**
+ * Confirm message handler for MOD_ETSTM
+ */
+void FT_Erf_ConfirmHandler(ilm_struct* erfMessage)
+{
+ FT_ERF_TEST_CNF *ptrMsg;
+ ptrMsg = (FT_ERF_TEST_CNF *)erfMessage->local_para_ptr;
+ if(ptrMsg->type == ERF_TEST_CMD_CHECK_IF_FUNC_EXIST)
+ {
+ FT_UTILITY_COMMAND_CNF cnf;
+ kal_mem_set(&cnf, '\0', sizeof(cnf));
+ cnf.status = (ptrMsg->param.CheckIfFuncExist.result==1)?FT_CNF_OK:FT_CNF_FAIL;
+ cnf.result.CheckIfFuncExist.query_ft_msg_id = ptrMsg->header.ft_msg_id;
+ cnf.result.CheckIfFuncExist.query_op_code = ptrMsg->param.CheckIfFuncExist.query_op_code;
+ FT_UTIL_SendCnf(&cnf, NULL);
+ return;
+ }
+ FT_SEND_MSG_TO_PC(erfMessage);
+}
+void FT_ErfCheckFunctionSupported(kal_uint32 query_op_code)
+{
+ ilm_struct ilm_ptr;
+ FT_ERF_TEST_REQ *ptrMsg;
+ FT_ALLOC_OTHER_CC_MSG( &ilm_ptr, sizeof(FT_ERF_TEST_REQ) );
+ // local parameter
+ ptrMsg = (FT_ERF_TEST_REQ *)ilm_ptr.local_para_ptr;
+ ptrMsg->header.ft_msg_id = FT_ERF_TEST_REQ_ID;
+ ptrMsg->type = ERF_TEST_CMD_CHECK_IF_FUNC_EXIST;
+ ptrMsg->param.CheckIfFuncExist.cmd_tpye = (ERfTestCmdType)query_op_code;
+ FT_SEND_MSG(MOD_FT, MOD_EL1, DHL_EL1TST_SAP, MSG_ID_DHL_TO_EL1TST, &ilm_ptr);
+}
+#endif // #if defined(__LTE_RAT__)
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_misc.c b/mcu/middleware/meta/ft/src/ft_fnc_misc.c
new file mode 100644
index 0000000..f948081
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_misc.c
@@ -0,0 +1,1058 @@
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * ft_fnc_misc.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Misc Function
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * 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!!
+ *============================================================================
+ ****************************************************************************/
+
+/*************************************************************************
+ * Include Statements for KAL
+ *************************************************************************/
+#include "kal_public_defs.h" //MSBB change #include "stack_common.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_msgs.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_config.h"
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+#include "kal_trace.h"
+#include "string.h"
+#include "sst_interface.h"
+#include "svc_sap.h"
+#include "md_sap.h"
+#include "mw_sap.h"
+#include "ft_msgid.h"
+#include "nvram_msgid.h"
+#include "sim_public_msgid.h"
+/**************************************************************************
+ * HAL header
+ *************************************************************************/
+#include "dcl.h"
+/**************************************************************************
+ * FT header
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_private.h"
+#include "ft_fnc_misc.h"
+#include "ft_mem.h"
+#include "ft_fnc_nvram.h"
+#include "ft_trace_def.h"
+/**************************************************************************
+ * NVRAM header
+ *************************************************************************/
+#include "nvram_enums.h"
+#include "nvram_data_items.h"
+#include "ft_nvram_def.h"
+#include "l4_nvram_def.h"
+#include "mml1_nvram_def.h"
+#include "nvram_struct.h"
+#include "nvram_interface.h"
+#include "nvram_editor_data_item.h"
+#include "ft_nvram_editor.h"
+/* NVRAM private header for data item iterator */
+//#include "nvram_util.h" -> "nvram_interface.h"
+/**************************************************************************
+ * SIM header
+ *************************************************************************/
+#include "ps2sim_struct.h"
+/**************************************************************************
+ * Custom header
+ *************************************************************************/
+#include "meta_customize.h"
+kal_uint8 ft_gl_path_check_flag = KAL_TRUE;
+kal_uint8 *p_ft_misc_buf = NULL; // a pointer point to : nvram_cal_data_check_struct
+kal_bool b_ft_misc_buf_from_med = KAL_TRUE; // KAL_TRUE: from MED task, KAL_FALSE: from control buffer
+kal_uint16 ft_gl_misc_token = 0;
+kal_uint8 ft_gl_sim_cmd_type = 0; // store sim cmd type
+
+//=============== local buffer process =========================
+kal_uint8 FT_MISC_SendCnf(FT_MISC_CNF *ft_misc_ret, peer_buff_struct *peer_buff) {
+
+ ilm_struct ilm_ptr;
+ FT_MISC_CNF *ptrMsg;
+
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(FT_MISC_CNF));
+
+ /* if ptrMsg != NULL*/
+ ptrMsg = (FT_MISC_CNF *)ilm_ptr.local_para_ptr;
+
+ // assign primitive id
+ ptrMsg->header.ft_msg_id = FT_MISC_CMD_CNF_ID;
+
+ // assign return structure
+ ptrMsg->type = ft_misc_ret->type;
+
+ // copy the result directly without checking its cmd type
+ kal_mem_cpy(&(ptrMsg->result), &(ft_misc_ret->result), sizeof(FT_MISC_CNF_U));
+
+ ptrMsg->status = ft_misc_ret->status;
+
+ // assign peer buffer
+ if( NULL != peer_buff ) {
+ ilm_ptr.peer_buff_ptr = peer_buff;
+ }
+
+ /* FT_SEND_MSG(src_mod, dest_mod, sap_id, msg_id, ilm_ptr) */
+ FT_SEND_MSG_TO_PC_BY_TOKEN(&ilm_ptr, ft_gl_misc_token);
+ return 0;
+}
+#define FT_MISC_MAX_PEER_SIZE 2048
+#define FT_MISC_MAX_FRAME_SIZE FT_MISC_MAX_PEER_SIZE/64*56
+#define FT_OTHER_INFO_FLAG 0
+#define FT_IMEI_INFO_FLAG 1
+#define FT_SML_INFO_FLAG 2
+kal_uint8 ft_misc_op_collect_cal_info(FT_MISC_CNF *misc_cnf)
+{
+ kal_char *pcStrPrefix;
+ kal_char *pcStrVerNo;
+ kal_uint8 flag;
+ peer_buff_struct *peer_buff_ret = NULL;
+ kal_char *pdu_ptr = NULL;
+ kal_uint16 pdu_length = 0;
+ kal_uint16 cur_pos = 0;
+ nvram_ltable_entry_struct *entry = NULL;
+ // find the first enrty when the input pointer is NULL pointer
+ while(nvram_util_next_data_item(&entry) == KAL_TRUE)
+ {
+ if(NVRAM_IO_ERRNO_OK != nvram_check_backup(entry->LID, &pcStrPrefix, &pcStrVerNo))
+ {
+ continue;
+ }
+ flag = FT_OTHER_INFO_FLAG;
+ if(entry->LID == NVRAM_EF_IMEI_IMEISV_LID)
+ {
+ flag = FT_IMEI_INFO_FLAG;
+ }
+ else if(entry->LID==NVRAM_EF_SML_LID)
+ {
+ flag = FT_SML_INFO_FLAG;
+ }
+allocate_peer_buf:
+ if(NULL == peer_buff_ret) // allocate peer buffer
+ {
+ peer_buff_ret=construct_peer_buff(FT_MISC_MAX_FRAME_SIZE, 0, 0, TD_CTRL);
+ if(NULL == peer_buff_ret)
+ {
+ return 1;
+ }
+ /* Set the pdu_len to 0 to keep track of the current position and updated at each iteration */
+ peer_buff_ret->pdu_len = 0 ;
+ }
+ if( FT_MISC_MAX_FRAME_SIZE < (peer_buff_ret->pdu_len+3+strlen(pcStrPrefix)+strlen(pcStrVerNo)+1) )
+ {
+ misc_cnf->result.m_u1LastFrame = 0; // set last_frame = 0
+ misc_cnf->status = FT_CNF_OK;
+ // send confirm
+ FT_MISC_SendCnf(misc_cnf, peer_buff_ret);
+ // sleep to wait for tst flush out data
+ kal_sleep_task(50);
+ // allocate peer buffer again
+ peer_buff_ret = NULL;
+ cur_pos = 0;
+ goto allocate_peer_buf;
+ }
+ pdu_ptr = get_peer_buff_pdu( peer_buff_ret, &pdu_length );
+ // copy to peer buffer
+ cur_pos = 0;
+ // copy lid_value (Assertion check to guarantee that the protocol stays unchange)
+ {
+ ASSERT(sizeof(kal_uint16) == sizeof(nvram_lid_enum));
+ kal_mem_cpy(pdu_ptr+pdu_length, &(entry->LID), sizeof(kal_uint16));
+ cur_pos += sizeof(kal_uint16);
+ }
+ // copy file flag
+ {
+ kal_mem_cpy(pdu_ptr+pdu_length+cur_pos, &flag, sizeof(kal_uint8));
+ cur_pos += sizeof(kal_uint8);
+ }
+ // copy file prefix (Assertion check to guarantee that the protocol stays unchange)
+ {
+ ASSERT(strlen(pcStrPrefix) == 4);
+ kal_mem_cpy(pdu_ptr+pdu_length+cur_pos, pcStrPrefix, strlen(pcStrPrefix));
+ cur_pos +=(strlen(pcStrPrefix));
+ }
+ // copy lid Ver No (Assertion check to guarantee that the protocol stays unchange)
+ {
+ ASSERT(strlen(pcStrVerNo) == 3);
+ kal_mem_cpy(pdu_ptr+pdu_length+cur_pos, pcStrVerNo, strlen(pcStrVerNo)+1);
+ cur_pos += (strlen(pcStrVerNo)+1);
+ }
+ // update pdu_len
+ peer_buff_ret->pdu_len += cur_pos;
+ }
+ misc_cnf->result.m_u1LastFrame = 1;
+ misc_cnf->status = FT_CNF_OK;
+ FT_MISC_SendCnf(misc_cnf, peer_buff_ret);
+ return 0;
+}
+/**
+ * Get Number of ADC channels
+ * \return the number of ADC channels
+ */
+kal_uint8 FT_GetAdcMaxChannel(void)
+{
+ // HAL modification
+ DCL_HANDLE adc_handle;
+ ADC_CTRL_GET_MAX_PHYSICAL_CH_T prGetMaxPhyCh;
+ kal_uint8 adc_max_channel;
+ adc_handle = DclSADC_Open(DCL_ADC, FLAGS_NONE);
+ if(DclHADC_Control(adc_handle, ADC_CMD_GET_MAX_PHYSICAL_CH, (DCL_CTRL_DATA_T *)&prGetMaxPhyCh) != STATUS_OK)
+ {
+ // error handling (prevent from access out-of bound)
+ adc_max_channel = 1;
+ return adc_max_channel;
+ }
+ adc_max_channel = prGetMaxPhyCh.u4Adc_max_ch;
+ if(DclSADC_Close(adc_handle) != STATUS_OK)
+ {
+ // error handling (prevent from access out-of bound)
+ adc_max_channel = 1;
+ }
+ return adc_max_channel;
+}
+
+void FT_MISC_Operation(ilm_struct *ptrMsg)
+{
+ kal_wchar wpath[128];
+ FT_MISC_REQ *p_req = (FT_MISC_REQ *)ptrMsg->local_para_ptr;
+ FT_MISC_CNF misc_cnf;
+ memset(&misc_cnf, 0x0, sizeof(misc_cnf));
+ peer_buff_struct *peer_buff_ret = NULL; // default value
+ kal_char *pdu_ptr = NULL;
+ kal_uint16 pdu_length = 0;
+ misc_cnf.type = p_req->type;
+ misc_cnf.status = FT_CNF_FAIL; // default value
+ ft_gl_misc_token = p_req->header.token;
+ MD_TRC_FT_MISC_OP_FUNC(p_req->type);
+
+ switch(p_req->type)
+ {
+ case FT_MISC_OP_GET_IMEI_LOC:
+ {
+ misc_cnf.result.m_u1IMEILoc = nvram_get_imei_type();
+ misc_cnf.status = FT_CNF_OK;
+ break;
+ }
+ case FT_MISC_OP_GET_IMEI_VALUE:
+ {
+ // check the record index (because tools before 0912 causes assertion)
+ kal_uint16 rec_num = nvram_get_imei_record_num();
+ if(p_req->cmd.m_u1RecordIndex < 1 || p_req->cmd.m_u1RecordIndex > rec_num)
+ {
+ // set the record index to 1 (the behavior will be confrom to that of target load before 0909)
+ p_req->cmd.m_u1RecordIndex = 1;
+ }
+ if(KAL_TRUE == nvram_get_imei_value(NVRAM_EF_IMEI_IMEISV_SIZE,
+ misc_cnf.result.m_rIMEIData.buf, p_req->cmd.m_u1RecordIndex))
+ {
+ misc_cnf.result.m_rIMEIData.buf_len = NVRAM_EF_IMEI_IMEISV_SIZE;
+ misc_cnf.status = FT_CNF_OK;
+ }
+ else
+ misc_cnf.status = FT_CNF_FAIL;
+ break;
+
+ }
+#if defined(__MTK_INTERNAL__)
+ case FT_MISC_OP_SET_IMEI_VALUE:
+ {
+ FT_MISC_CNF misc_cnf;
+ misc_cnf.type = FT_MISC_OP_SET_IMEI_VALUE;
+ misc_cnf.result.m_u2RecordIndex = p_req->cmd.m_rIMEIData.record_index;
+ misc_cnf.status = FT_CNF_FAIL;
+
+ kal_uint8 *buffer = (kal_uint8*)get_ctrl_buffer(NVRAM_EF_IMEI_IMEISV_SIZE);
+ memcpy(buffer, p_req->cmd.m_rIMEIData.imei, 8);
+ buffer[8] = p_req->cmd.m_rIMEIData.svn;
+ if( NVRAM_ERRNO_SUCCESS == nvram_external_secure_write_data (NVRAM_EF_IMEI_IMEISV_LID, p_req->cmd.m_rIMEIData.record_index, buffer, NVRAM_EF_IMEI_IMEISV_SIZE, NULL) )
+ {
+ misc_cnf.status = FT_CNF_OK;
+ }
+ free_ctrl_buffer(buffer);
+ FT_MISC_SendCnf(&misc_cnf, NULL);
+ return;
+ }
+#endif //#if defined(__MTK_INTERNAL__)
+ case FT_MISC_OP_GET_IMEI_REC_NUM:
+ {
+ misc_cnf.result.m_u2IMEIRecords = nvram_get_imei_record_num();
+ misc_cnf.status = FT_CNF_OK;
+ break;
+ }
+ case FT_MISC_OP_VERIFY_TEMP_SML_FILE:
+ {
+ //kal_char *pdu_ptr;
+ //kal_uint16 pdu_length;
+ kal_wchar *w_filepath;
+ // get the file path from peer_buffer
+ if(ptrMsg->peer_buff_ptr != NULL)
+ {
+ pdu_ptr = get_peer_buff_pdu( ptrMsg->peer_buff_ptr, &pdu_length );
+
+ // cast to kal_wchar
+ w_filepath = (kal_wchar *)pdu_ptr;
+
+ misc_cnf.status = FT_CNF_OK;
+
+ // ask nvram task to check the SML file
+ if(NVRAM_IO_ERRNO_OK == nvram_validate_file(NVRAM_EF_SML_LID, w_filepath))
+ misc_cnf.result.m_u1VerifyResult = FT_SML_VALID;
+ else
+ misc_cnf.result.m_u1VerifyResult = FT_SML_INVALID;
+
+ }
+ else // peer buffer is null
+ {
+ misc_cnf.status = FT_CNF_FAIL;
+ misc_cnf.result.m_u1VerifyResult = FT_SML_NO_FILENAME;
+ }
+
+ break;
+ }
+ case FT_MISC_OP_GET_CAL_INFO:
+ {
+ ft_misc_op_collect_cal_info(&misc_cnf);
+ return;
+ }
+ case FT_MISC_OP_QUERY_NVRAM_FOLDER:
+ {
+ kal_uint16 length;
+ kal_char* buf;
+ kal_uint8 folder_total_amount = nvram_get_folder_total_amount();
+ kal_int16 total_length = 0;
+ kal_int8 i;
+ misc_cnf.status = FT_CNF_OK;
+
+ // allocate peer buffer
+ if(NULL == peer_buff_ret)
+ {//FT_MISC_MAX_FRAME_SIZE
+ peer_buff_ret = construct_peer_buff(FT_MISC_MAX_FRAME_SIZE, 0, 0, TD_CTRL);
+ if(NULL == peer_buff_ret) return;
+
+ peer_buff_ret->pdu_len = 0 ;
+ }
+ pdu_ptr = get_peer_buff_pdu( peer_buff_ret, &pdu_length );
+ for(i = 0;i<folder_total_amount;i++)
+ {
+ buf = nvram_get_work_path(i);
+ kal_wsprintf(wpath, "%s", buf);
+ if(nvram_check_hidden_file(wpath, KAL_TRUE))
+ {
+ continue;
+ }
+ length = (strlen(buf)+1);
+ kal_mem_cpy(pdu_ptr+pdu_length+total_length, (buf), length );
+ *(pdu_ptr+pdu_length+total_length+length-1) = '?';
+ total_length += length;
+ }
+ // update pdu_len
+ peer_buff_ret->pdu_len += (total_length);
+
+
+ break;
+ }
+ case FT_MISC_OP_VERIFY_NVRAM_ATTR_SETTING_COMPLETE:
+ {
+ kal_uint16 stop_index = custom_meta_check_must_backup_lid_array(p_req->cmd.m_bcheckImeiFlag);
+ if(stop_index == custom_meta_get_check_lid_num()) // check successfully!
+ {
+ misc_cnf.status = FT_CNF_OK;
+ misc_cnf.result.m_rNvramVerifyResult.m_stop_enum_value = custom_meta_get_enum_by_index(stop_index-1); // pass the imei_enum
+ misc_cnf.result.m_rNvramVerifyResult.m_total_lid_num = custom_meta_get_check_lid_num();
+ misc_cnf.result.m_rNvramVerifyResult.m_stop_index = stop_index;
+ }
+ else
+ {
+ misc_cnf.status = FT_CNF_FAIL;
+ misc_cnf.result.m_rNvramVerifyResult.m_stop_enum_value = custom_meta_get_enum_by_index(stop_index);
+ misc_cnf.result.m_rNvramVerifyResult.m_total_lid_num = custom_meta_get_check_lid_num();
+ misc_cnf.result.m_rNvramVerifyResult.m_stop_index = stop_index;
+ }
+ break;
+ }
+ case FT_MISC_OP_ENABLE_PATH_LIMITION:
+ case FT_MISC_OP_DISABLE_PATH_LIMITION:
+ {
+ ft_gl_path_check_flag = (p_req->type == FT_MISC_OP_ENABLE_PATH_LIMITION)?KAL_TRUE:KAL_FALSE;
+ misc_cnf.status = FT_CNF_OK;
+ break;
+ }
+ case FT_MISC_OP_GET_NVRAM_FOLDER_AMOUNT:
+ {
+ kal_uint8 i;
+ misc_cnf.result.m_u1NVRAMFolderAmount = nvram_get_folder_total_amount();
+ for(i = 0;i<nvram_get_folder_total_amount();i++)
+ {
+ kal_wsprintf(wpath, "%s", nvram_get_work_path(i));
+ if(nvram_check_hidden_file(wpath, KAL_TRUE))
+ {
+ misc_cnf.result.m_u1NVRAMFolderAmount--;
+ }
+ }
+ misc_cnf.status = FT_CNF_OK;
+
+ }
+ break;
+#ifndef SIM_NOT_PRESENT
+ case FT_MISC_OP_CHECK_SIM1_INSERTED:
+ {
+ // Send reset request to MOD_SIM
+ ilm_struct ilm_ptr;
+ sim_reset_req_struct* ptr_loc_para;
+ FT_ALLOC_OTHER_MSG(&ilm_ptr, sizeof(sim_reset_req_struct));
+ ptr_loc_para = (sim_reset_req_struct*) (ilm_ptr.local_para_ptr);
+ ptr_loc_para->src_id = 0xff;
+ // set sim cmd type to global variable
+ ft_gl_sim_cmd_type = FT_MISC_OP_CHECK_SIM1_INSERTED;
+ FT_SEND_MSG(MOD_FT, MOD_SIM, PS_SIM_SAP, MSG_ID_SIM_RESET_REQ, &ilm_ptr);
+ // wait for SIM task CNF message
+ return;
+ }
+#ifdef __GEMINI__
+ case FT_MISC_OP_CHECK_SIM2_INSERTED:
+ {
+ // Send reset request to MOD_SIM_2
+ ilm_struct ilm_ptr;
+ sim_reset_req_struct* ptr_loc_para;
+ FT_ALLOC_OTHER_MSG(&ilm_ptr, sizeof(sim_reset_req_struct));
+ ptr_loc_para = (sim_reset_req_struct*) (ilm_ptr.local_para_ptr);
+ ptr_loc_para->src_id = 0xff;
+ // set sim cmd type to global variable
+ ft_gl_sim_cmd_type =FT_MISC_OP_CHECK_SIM2_INSERTED;
+ FT_SEND_MSG(MOD_FT, MOD_SIM_2, PS_SIM_SAP, MSG_ID_SIM_RESET_REQ, &ilm_ptr);
+ // wait for SIM task CNF message
+ return;
+ }
+#endif // __GEMINI__
+#ifdef GEMINI_PLUS
+ case FT_MISC_OP_CHECK_GEMINI_PLUS_SIM_INSERTED:
+ {
+ // Send reset request to MOD_SIM_N
+ ilm_struct ilm_ptr;
+ sim_reset_req_struct* ptr_loc_para;
+ // if index out of range, break and then send error status CNF
+ if(p_req->cmd.m_u1SimIndex >= GEMINI_PLUS)
+ {
+ break;
+ }
+ FT_ALLOC_OTHER_MSG(&ilm_ptr, sizeof(sim_reset_req_struct));
+ ptr_loc_para = (sim_reset_req_struct*) (ilm_ptr.local_para_ptr);
+ ptr_loc_para->src_id = 0xff;
+ // set sim cmd type to global variable
+ ft_gl_sim_cmd_type = FT_MISC_OP_CHECK_GEMINI_PLUS_SIM_INSERTED;
+ FT_SEND_MSG(MOD_FT, (module_type)(MOD_SIM + p_req->cmd.m_u1SimIndex), PS_SIM_SAP, MSG_ID_SIM_RESET_REQ, &ilm_ptr);
+ // wait for SIM task CNF message
+ return;
+ }
+#endif // GEMINI_PLUS
+#endif // SIM_NOT_PRESENT
+ case FT_MISC_OP_SET_MUIC_CHARGER_MODE:
+ {
+#ifdef __DRV_EXT_CHARGER_DETECTION__
+ MU_BQ25040_Charger_Mode(p_req->cmd.m_u1ChargerMode);
+ misc_cnf.status = FT_CNF_OK;
+#else
+ misc_cnf.status = FT_CNF_FAIL;
+
+#endif
+ break;
+ }
+ case FT_MISC_OP_GET_ADC_FROM_EFUSE:
+ {
+ kal_bool b_ret_code;
+ kal_uint8 i;
+ kal_uint8 adc_max_channel;
+ DCL_HANDLE adc_handle;
+ ADC_CTRL_READ_CALIBRATION_DATA_T prReadCalibrationData;
+ adc_handle = DclSADC_Open(DCL_ADC, FLAGS_NONE);
+ adc_max_channel = FT_GetAdcMaxChannel();
+ b_ret_code = (STATUS_OK == DclSADC_Control(adc_handle, ADC_CMD_READ_CALIBRATION_DATA, (DCL_CTRL_DATA_T*)&prReadCalibrationData)) ?
+ KAL_TRUE : KAL_FALSE;
+ misc_cnf.status = FT_CNF_OK;
+ misc_cnf.result.m_rGetAdcFromEfuse.bADCStoredInEfuse = b_ret_code;
+ misc_cnf.result.m_rGetAdcFromEfuse.u2ADCChnNum = b_ret_code ? adc_max_channel : 0;
+
+ // if channel number > 0, construct peer buffer
+ if(misc_cnf.result.m_rGetAdcFromEfuse.u2ADCChnNum > 0) // i.e. FT_GetAdcMaxChannel()
+ {
+ if( NULL != (peer_buff_ret=construct_peer_buff(adc_max_channel*8, 0, 0, TD_CTRL)) )
+ {
+ pdu_ptr = get_peer_buff_pdu( peer_buff_ret, &pdu_length );
+ peer_buff_ret->pdu_len = adc_max_channel *8;
+
+ for(i =0; i< adc_max_channel; i++) // append slope first
+ {
+ kal_mem_cpy(pdu_ptr+(i*4), &(prReadCalibrationData.i4ADCSlope[i]), sizeof(kal_int32));
+ }
+ for(i =0; i<adc_max_channel; i++) // append offset second
+ {
+ kal_mem_cpy(pdu_ptr+((adc_max_channel+i)*4), &(prReadCalibrationData.i4ADCOffset[i]), sizeof(kal_int32));
+ }
+ }
+ }
+ break;
+ }
+ case FT_MISC_OP_GET_CALFLAG_ENUM:
+ {
+ misc_cnf.result.m_u2CalFlagEnum = custom_ft_get_calflag_enum();
+ misc_cnf.status = FT_CNF_OK;
+ }
+ break;
+ case FT_MISC_OP_GET_ADC_MAX_CHANNEL:
+ {
+ // HAL modification
+ misc_cnf.status = FT_CNF_OK;
+ misc_cnf.result.m_u1ADCMaxChannel = FT_GetAdcMaxChannel();
+ break;
+ }
+ case FT_MISC_OP_GET_TADC_INDEX:
+ {
+ // HAL modification
+ //misc_cnf.result.m_u1TADCChannelIndex = custom_adc_get_channel(rftmp_adc_channel);
+ DCL_HANDLE adc_handle;
+ ADC_CTRL_GET_PHYSICAL_CHANNEL_T adc_ch;
+ misc_cnf.status = FT_CNF_OK;
+ adc_handle = DclSADC_Open(DCL_ADC, FLAGS_NONE);
+ adc_ch.u2AdcName = DCL_RFTMP_ADC_CHANNEL;
+ if(DclSADC_Control( adc_handle, ADC_CMD_GET_CHANNEL, (DCL_CTRL_DATA_T *)& adc_ch) != STATUS_OK)
+ {
+ misc_cnf.status = FT_CNF_FAIL;
+ }
+ misc_cnf.result.m_u1TADCChannelIndex = adc_ch.u1AdcPhyCh;
+ if(DclSADC_Close(adc_handle) != STATUS_OK)
+ {
+ misc_cnf.status = FT_CNF_FAIL;
+ }
+ break;
+ }
+ case FT_MISC_OP_GET_RF_CAL_ENV_ENUM:
+ misc_cnf.result.m_u2Enum = custom_ft_get_rf_cal_env_enum();
+ misc_cnf.status = FT_CNF_OK;
+ break;
+ case FT_MISC_OP_GET_RF_CAL_LOSS_SETTING_ENUM:
+ misc_cnf.result.m_u2Enum = custom_ft_get_rf_loss_setting_enum();
+ misc_cnf.status = FT_CNF_OK;
+ break;
+ case FT_MISC_OP_GET_RF_TEST_POWER_RESULT_ENUM:
+ misc_cnf.result.m_u2Enum = custom_ft_get_rf_test_power_result_enum();
+ misc_cnf.status = FT_CNF_OK;
+ break;
+ case FT_MISC_OP_GET_RID:
+ {
+ if(KAL_TRUE == SST_Get_ChipRID((kal_char*)misc_cnf.result.m_rRIDData.buf, (p_req->cmd.m_RIDLength*8)))
+ {
+ misc_cnf.result.m_rRIDData.buf_len = p_req->cmd.m_RIDLength; // return RID length in bytes
+ }
+ else
+ {
+ misc_cnf.result.m_rRIDData.buf_len = 0; // return length = 0 for error check
+ }
+ misc_cnf.status = FT_CNF_OK;
+ break;
+ }
+ case FT_MISC_OP_GET_BARCODE_VALUE:
+ {
+ if(p_req->cmd.m_u1RecordIndex < 1 || p_req->cmd.m_u1RecordIndex > NVRAM_EF_BARCODE_NUM_TOTAL)
+ {
+ p_req->cmd.m_u1RecordIndex = 1;
+ }
+ if( NULL != (peer_buff_ret=construct_peer_buff(NVRAM_EF_BARCODE_NUM_SIZE, 0, 0, TD_CTRL)))
+ {
+ peer_buff_ret->pdu_len = NVRAM_EF_BARCODE_NUM_SIZE;
+ pdu_ptr = get_peer_buff_pdu( peer_buff_ret, &pdu_length );
+ if(KAL_TRUE == nvram_external_read_data(NVRAM_EF_BARCODE_NUM_LID, p_req->cmd.m_u1RecordIndex, (kal_uint8*)pdu_ptr, NVRAM_EF_BARCODE_NUM_SIZE))
+ {
+ misc_cnf.status = FT_CNF_OK;
+ }
+ }
+ break;
+ }
+ case FT_MISC_OP_CHECK_SIM_HW_TEST:
+ {
+#if !defined(SIM_NOT_PRESENT)
+ extern int usim_iftest_for_smt(kal_uint32 SIM_index);
+ kal_int32 status;
+ MD_TRC_FT_MISC_OP_CHECK_SIM_HW_TEST_ENTER_DRV();
+ status = usim_iftest_for_smt(p_req->cmd.m_u1SimIndex);
+ MD_TRC_FT_MISC_OP_CHECK_SIM_HW_TEST_LEAVE_DRV(status);
+ kal_mem_cpy(&(misc_cnf.result.m_i4SimHwStatus), &status, sizeof(kal_int32));
+ misc_cnf.status = FT_CNF_OK;
+#else // #if !defined(SIM_NOT_PRESENT)
+ kal_uint32* pStatus = (kal_uint32*) &(misc_cnf.result.m_i4SimHwStatus);
+ *pStatus = 0;
+ misc_cnf.status = FT_CNF_FAIL;
+#endif // #if defined(SIM_NOT_PRESENT)
+ break;
+ }
+ default:
+ return;
+ }
+ // send confirm to PC side
+ FT_MISC_SendCnf(&misc_cnf, peer_buff_ret);
+}
+
+/**
+ * Check if the function supported
+ * \param query_op_code the OP code to be checked if supported
+ * \retval FT_CNF_FAIL not supported
+ * \retval FT_CNF_OK supported
+ */
+kal_uint32 FT_MiscCheckFunctionSupported(kal_uint32 query_op_code)
+{
+ kal_uint32 cnf_code;
+ if(FT_MISC_OP_END> query_op_code)
+ {
+ if(FT_MISC_OP_SET_IMEI_VALUE == query_op_code)
+ {
+#if defined(__MTK_INTERNAL__)
+ cnf_code = FT_CNF_OK;
+#else
+ cnf_code = FT_CNF_FAIL;
+#endif //#if defined(__MTK_INTERNAL__)
+ }
+ else if(FT_MISC_OP_SET_WIFI_MAC_ADDR == query_op_code)
+ {
+ cnf_code = FT_CNF_FAIL;
+ }
+ else if(FT_MISC_OP_SET_MUIC_CHARGER_MODE == query_op_code)
+ {
+#ifdef __DRV_EXT_CHARGER_DETECTION__
+ cnf_code = FT_CNF_OK;
+#else
+ cnf_code = FT_CNF_FAIL;
+
+#endif
+ }
+ else if(
+ (FT_MISC_OP_GET_RF_CAL_ENV_ENUM == query_op_code) ||
+ (FT_MISC_OP_GET_RF_CAL_LOSS_SETTING_ENUM == query_op_code) ||
+ (FT_MISC_OP_GET_RF_TEST_POWER_RESULT_ENUM == query_op_code)
+ )
+ {
+#ifdef __TC01__
+ cnf_code = FT_CNF_OK;
+#else
+ cnf_code = FT_CNF_FAIL;
+#endif
+ }
+ else if(FT_MISC_OP_GET_MMI_CACHE_ENUM_INDEX == query_op_code)
+ {
+ cnf_code = FT_CNF_FAIL;
+ }
+ else if(FT_MISC_OP_CHECK_SIM_HW_TEST == query_op_code)
+ {
+#if !defined(SIM_NOT_PRESENT)
+ cnf_code = FT_CNF_OK;
+#else // #if !defined(SIM_NOT_PRESENT)
+ cnf_code = FT_CNF_FAIL;
+#endif // #if defined(SIM_NOT_PRESENT)
+ }
+ else if (
+ (FT_MISC_OP_CALDATA_INTEGRITY_START_REC == query_op_code) ||
+ (FT_MISC_OP_CALDATA_INTEGRITY_STOP_REC == query_op_code) ||
+ (FT_MISC_OP_CALDATA_INTEGRITY_ADD_ONE == query_op_code) ||
+ (FT_MISC_OP_CALDATA_INTEGRITY_DEL_ONE == query_op_code) ||
+ (FT_MISC_OP_CALDATA_INTEGRITY_DEL_ALL == query_op_code) ||
+ (FT_MISC_OP_CALDATA_INTEGRITY_CHECK_ONE == query_op_code) ||
+ (FT_MISC_OP_CALDATA_INTEGRITY_CHECK_ALL == query_op_code) ||
+ (FT_MISC_OP_CALDATA_INTEGRITY_START_REC_EX == query_op_code) ||
+ (FT_MISC_OP_CALDATA_INTEGRITY_STOP_REC_EX == query_op_code) ||
+ (FT_MISC_OP_CALDATA_INTEGRITY_ADD_ONE_EX == query_op_code) ||
+ (FT_MISC_OP_CALDATA_INTEGRITY_DEL_ONE_EX == query_op_code) ||
+ (FT_MISC_OP_CALDATA_INTEGRITY_DEL_ALL_EX == query_op_code)
+ )
+ {
+ cnf_code = FT_CNF_FAIL;
+ }
+ else
+ {
+ cnf_code = FT_CNF_OK;
+ }
+ }
+ else
+ {
+ cnf_code = FT_CNF_FAIL;
+ }
+ return cnf_code;
+}
+
+/**
+ * Handles the Add on record for other SW modules in target
+ * \param ptrMsg the ILM request message from other module
+ */
+void FT_Misc_CalDataInTargetAddOneRequestHandler(ilm_struct *ptrMsg)
+{
+ ilm_struct ilm_ptr;
+ kal_uint8 uRet = 0;
+ ft_cal_data_add_one_cnf_struct* cnf = NULL;
+
+ FT_ALLOC_OTHER_MSG( &ilm_ptr, sizeof(ft_cal_data_add_one_cnf_struct) );
+ // local parameter
+ cnf = (ft_cal_data_add_one_cnf_struct*)ilm_ptr.local_para_ptr;
+ cnf->status = uRet;
+ FT_SEND_MSG(MOD_FT, ptrMsg->src_mod_id, ptrMsg->sap_id, MSG_ID_FT_CAL_DATA_ADD_ONE_CNF, &ilm_ptr);
+}
+
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_misc_ex.c b/mcu/middleware/meta/ft/src/ft_fnc_misc_ex.c
new file mode 100644
index 0000000..20d7bb8
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_misc_ex.c
@@ -0,0 +1,615 @@
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * ft_fnc_misc_ex.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Misc Function
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*************************************************************************
+ * Include Statements for KAL
+ *************************************************************************/
+#include "kal_public_defs.h" //MSBB change #include "stack_common.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_msgs.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_config.h"
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+#include "svc_sap.h"
+#include "ft_msgid.h"
+#include "nvram_msgid.h"
+/**************************************************************************
+ * FT header
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_private.h"
+#include "ft_fnc_misc_ex.h"
+/**************************************************************************
+ * Custom header
+ *************************************************************************/
+#include "meta_customize.h"
+#if defined(__TC01_ERS_SUPPORT__)
+// FIXME: remove the compile option wrapping after GOLF QM
+#include "ers_type.h"
+#include "ers_api.h"
+#endif // #if defined(__TC01_ERS_SUPPORT__)
+
+#if defined(__FS_RAMDISK__)
+// added for ram disk dump
+#include "ramdisk_gprot.h"
+#endif //#if defined(__FS_RAMDISK__)
+
+// INT_SetCmdToSys
+#include "init.h"
+
+kal_uint16 ft_gl_misc_ex_token = 0;
+kal_uint8 *ft_gl_misc_ex_buf = NULL;
+kal_uint8 FT_MISC_EX_SendCnf(FT_MISC_EX_CNF *ft_misc_ret, peer_buff_struct *peer_buff)
+{
+
+ ilm_struct ilm_ptr;
+ FT_MISC_EX_CNF *ptrMsg;
+
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(FT_MISC_EX_CNF));
+
+ /* if ptrMsg != NULL*/
+ ptrMsg = (FT_MISC_EX_CNF *)ilm_ptr.local_para_ptr;
+
+ // assign primitive id
+ ptrMsg->header.ft_msg_id = FT_MISC_EX_CMD_CNF_ID;
+
+ // assign return structure
+ ptrMsg->type = ft_misc_ret->type;
+
+ // copy the result directly without checking its cmd type
+ kal_mem_cpy(&(ptrMsg->result), &(ft_misc_ret->result), sizeof(FT_MISC_EX_CNF_U));
+
+ ptrMsg->status = ft_misc_ret->status;
+
+ // assign peer buffer
+ if( NULL != peer_buff )
+ {
+ ilm_ptr.peer_buff_ptr = peer_buff;
+ }
+
+ FT_SEND_MSG_TO_PC_BY_TOKEN(&ilm_ptr, ft_gl_misc_ex_token);
+ return 0;
+}
+
+#if defined(__TC01_ERS_SUPPORT__)
+void FT_ReadERS_Data(ilm_struct *ptrMsg)
+{
+ kal_uint16 pdu_length_in;
+ kal_char *pdu_ptr_in;
+ FT_MISC_EX_CNF misc_ex_cnf;
+ kal_int32 ers_data_size;
+ kal_uint8 *p_ers_data ;
+ kal_int32 ers_data_idx;
+ kal_uint32 u4CurOffset = 0;
+
+
+
+
+ misc_ex_cnf.type = FT_MISC_EX_OP_GET_ERS_DATA;
+ misc_ex_cnf.status = FT_CNF_FAIL; // default value
+ ers_data_size = ERS_query_size(); //wise_query_ERS_size();
+
+ if( NULL != ptrMsg->peer_buff_ptr )
+ {
+ pdu_ptr_in = get_peer_buff_pdu( ptrMsg->peer_buff_ptr, &pdu_length_in );
+ }
+ kal_mem_cpy(&ers_data_idx, pdu_ptr_in, 4);
+ p_ers_data = (kal_uint8*)ERS_query_content_by_idx(ers_data_idx);//wise_query_ERS_content((WCHAR *)pdu_ptr_in);
+
+ // organize the buffer, and send it sequentially to PC side
+ if(p_ers_data != NULL)
+ {
+ // allocate the peer buffer to send to PC-side
+ while(u4CurOffset < ers_data_size)
+ {
+
+ peer_buff_struct *peer_buff = NULL;
+ kal_char *pdu_ptr = NULL;
+ kal_uint16 pdu_length = 0;
+ kal_uint16 u2_cur_len = FT_MISC_EX_DATA_FRAME_SIZE; // default: 1800 bytes to send
+
+ misc_ex_cnf.result.m_rErsDataFrm.m_u4TotalSize = ers_data_size;
+ misc_ex_cnf.result.m_rErsDataFrm.m_u4CurOffset = u4CurOffset;
+ if(u4CurOffset+FT_MISC_EX_DATA_FRAME_SIZE >= ers_data_size)
+ {
+ misc_ex_cnf.result.m_rErsDataFrm.m_bLastFrm = KAL_TRUE;
+ u2_cur_len = ers_data_size - u4CurOffset;
+ }
+ else
+ misc_ex_cnf.result.m_rErsDataFrm.m_bLastFrm = KAL_FALSE;
+
+ // allocate a peer buffer
+ if( NULL != (peer_buff=construct_peer_buff(u2_cur_len, 0, 0, TD_CTRL)) )
+ {
+ pdu_ptr = get_peer_buff_pdu( peer_buff, &pdu_length );
+ kal_mem_cpy(pdu_ptr, p_ers_data+u4CurOffset , u2_cur_len);
+ peer_buff->pdu_len = u2_cur_len;
+ }
+ misc_ex_cnf.status = FT_CNF_OK;
+ FT_MISC_EX_SendCnf(&misc_ex_cnf, peer_buff);
+ kal_sleep_task(50);
+
+ peer_buff = NULL;// the mem will be released by FT task when copy to TST buffer
+ u4CurOffset += u2_cur_len;
+
+
+ }
+
+ }
+ else
+ {
+ misc_ex_cnf.status = 0xFF;
+ FT_MISC_EX_SendCnf(&misc_ex_cnf, NULL);
+ }
+
+}
+#endif // #if defined(__TC01_ERS_SUPPORT__)
+
+void FT_MiscEx_NvramConfirmHandler(ilm_struct* ptrMsgCnf)
+{
+ FT_MISC_EX_CNF misc_ex_cnf;
+ memset(&misc_ex_cnf,0x0,sizeof(misc_ex_cnf));
+ peer_buff_struct *peer_buff_ret = NULL; // default value
+ misc_ex_cnf.status = FT_CNF_FAIL; // default value
+ switch (ptrMsgCnf->msg_id)
+ {
+ case MSG_ID_NVRAM_SDS_CNF:
+ case MSG_ID_NVRAM_BIN_REGION_CNF:
+ {
+#if !defined(__MODEM_CCCI_EXIST__) || !defined(__MODEM_CARD__)
+ if(!Custom_META_SdsSupported())
+ {
+ misc_ex_cnf.type = FT_MISC_EX_OP_BACKUP_TO_SDS;
+ misc_ex_cnf.status = FT_CNF_FAIL;
+ misc_ex_cnf.result.m_u4SDSStatus = 0;
+ }
+ else
+#endif
+ {
+#if !defined(__MODEM_CCCI_EXIST__) || !defined(__MODEM_CARD__)
+ nvram_sds_cnf_struct* cnf = (nvram_sds_cnf_struct*)ptrMsgCnf->local_para_ptr;
+#else
+ nvram_bin_region_cnf_struct* cnf = (nvram_bin_region_cnf_struct*)ptrMsgCnf->local_para_ptr;
+#endif
+ misc_ex_cnf.type = (FT_MISC_EX_CMD_TYPE)cnf->access_id;
+ misc_ex_cnf.status = FT_CNF_OK;
+ misc_ex_cnf.result.m_u4SDSStatus = cnf->result;
+ }
+ break;
+ }
+ default:
+ return;
+ }
+ FT_MISC_EX_SendCnf(&misc_ex_cnf,peer_buff_ret);
+}
+
+#if defined(__FS_RAMDISK__)
+void FT_Read_RamDisk_Data(ilm_struct *ptrMsg)
+{
+ FT_MISC_EX_CNF misc_ex_cnf;
+ FT_MISC_EX_REQ* p_req = (FT_MISC_EX_REQ *)ptrMsg->local_para_ptr;
+ kal_uint32 u4CurOffset = p_req->cmd.m_u4RamDiskReqOffset;
+ kal_uint32 u4TotalSize = ramdisk_get_raw_length();
+ // allocate the peer buffer to send to PC-side
+ peer_buff_struct *peer_buff = NULL;
+ kal_char *pdu_ptr = NULL;
+ kal_uint16 pdu_length = 0;
+ kal_uint16 u2_cur_len = FT_MISC_EX_DATA_FRAME_SIZE; // default: 1800 bytes to send
+
+ misc_ex_cnf.type = FT_MISC_EX_OP_RAMDISK_READ;
+ misc_ex_cnf.status = FT_CNF_FAIL; // default value
+
+ misc_ex_cnf.result.m_rRamDiskFrm.m_u4TotalSize = u4TotalSize;
+ misc_ex_cnf.result.m_rRamDiskFrm.m_u4CurOffset = u4CurOffset;
+ if(u4CurOffset+FT_MISC_EX_DATA_FRAME_SIZE >= u4TotalSize)
+ {
+ misc_ex_cnf.result.m_rErsDataFrm.m_bLastFrm = KAL_TRUE;
+ u2_cur_len = u4TotalSize - u4CurOffset;
+ }
+ else
+ misc_ex_cnf.result.m_rErsDataFrm.m_bLastFrm = KAL_FALSE;
+
+ // allocate a peer buffer
+ if( NULL != (peer_buff=construct_peer_buff(u2_cur_len, 0, 0, TD_CTRL)) )
+ {
+ pdu_ptr = get_peer_buff_pdu( peer_buff, &pdu_length );
+ peer_buff->pdu_len = u2_cur_len;
+ // read from ram disk
+ if(ramdisk_get_raw_data(pdu_ptr, u4CurOffset, u2_cur_len) > 0 || u2_cur_len == 0)
+ {
+ misc_ex_cnf.status = FT_CNF_OK;
+ }
+ FT_MISC_EX_SendCnf(&misc_ex_cnf, peer_buff);
+ peer_buff = NULL;// the mem will be released by FT task when copy to TST buffer
+ }
+ else
+ {
+ // return fail;
+ FT_MISC_EX_SendCnf(&misc_ex_cnf, NULL);
+ }
+}
+#endif //#if defined(__FS_RAMDISK__)
+void FT_MISC_EX_Operation(ilm_struct *ptrMsg)
+{
+#if defined(__TC01_ERS_SUPPORT__)
+ kal_char* pdu_ptr;
+ kal_uint16 pdu_length;
+#endif // #if defined(__TC01_ERS_SUPPORT__)
+ ilm_struct ptr_ilm;
+ FT_MISC_EX_CNF misc_ex_cnf;
+ memset(&misc_ex_cnf,0x0,sizeof(misc_ex_cnf));
+ FT_MISC_EX_REQ* p_req = (FT_MISC_EX_REQ *)ptrMsg->local_para_ptr;
+ peer_buff_struct* peer_buff_ret = NULL; // default value
+
+ misc_ex_cnf.type = p_req->type;
+ misc_ex_cnf.status = FT_CNF_FAIL;
+ ft_gl_misc_ex_token = p_req->header.token;
+ switch(p_req->type)
+ {
+ case FT_MISC_EX_OP_GET_ERS_COUNT:
+ {
+#if defined(__TC01_ERS_SUPPORT__)
+ misc_ex_cnf.result.m_i4ErsDataCount = ERS_query_count(); //wise_query_ERS_count();
+#else // #if defined(__TC01_ERS_SUPPORT__)
+ misc_ex_cnf.result.m_i4ErsDataCount = 0;
+#endif // #if !defined(__TC01_ERS_SUPPORT__)
+ misc_ex_cnf.status = FT_CNF_OK;
+ break;
+ }
+ case FT_MISC_EX_OP_GET_ERS_DATA_INFO_BY_INDEX:
+ {
+#if defined(__TC01_ERS_SUPPORT__)
+ ers_info_struct ers_info;
+ ERS_query_info(p_req->cmd.m_i4ErsDataIndex, &ers_info);
+ misc_ex_cnf.result.m_rErsDataTime.sec = ers_info.ers_ctime.sec;
+ misc_ex_cnf.result.m_rErsDataTime.min = ers_info.ers_ctime.min;
+ misc_ex_cnf.result.m_rErsDataTime.hour = ers_info.ers_ctime.hour;
+ misc_ex_cnf.result.m_rErsDataTime.day = ers_info.ers_ctime.day;
+ misc_ex_cnf.result.m_rErsDataTime.mon = ers_info.ers_ctime.mon;
+ misc_ex_cnf.result.m_rErsDataTime.wday = ers_info.ers_ctime.wday;
+ misc_ex_cnf.result.m_rErsDataTime.year = ers_info.ers_ctime.year;
+
+ if( NULL != (peer_buff_ret=construct_peer_buff((2+1)*2, 0, 0, TD_CTRL)) ) // defined in mcu\external_mmi\wise\bal\sys\include\ws_dbg_type.h
+ {
+ pdu_ptr = get_peer_buff_pdu( peer_buff_ret, &pdu_length );
+ // copy filename
+ //kal_mem_cpy(pdu_ptr, (void *)ers_info.ers_filename, (kal_wstrlen(ers_info.ers_filename)+1)*2);
+ kal_mem_cpy(pdu_ptr, (void*)&(p_req->cmd.m_i4ErsDataIndex), sizeof(kal_int32));
+ kal_mem_set(pdu_ptr+4, 0x0, 2);
+ peer_buff_ret->pdu_len = 6; //(kal_wstrlen(ers_info.ers_filename)+1)*2;
+ }
+ misc_ex_cnf.status = FT_CNF_OK;
+#else // #if defined(__TC01_ERS_SUPPORT__)
+ misc_ex_cnf.status = FT_CNF_FAIL;
+#endif // #if !defined(__TC01_ERS_SUPPORT__)
+ break;
+ }
+ case FT_MISC_EX_OP_GET_ERS_SIZE:
+ {
+#if defined(__TC01_ERS_SUPPORT__)
+ misc_ex_cnf.result.m_u4ErsDataSize = ERS_query_size(); //wise_query_ERS_size();
+#else // #if defined(__TC01_ERS_SUPPORT__)
+ misc_ex_cnf.result.m_u4ErsDataSize = 0;
+#endif // #if !defined(__TC01_ERS_SUPPORT__)
+ misc_ex_cnf.status = FT_CNF_OK;
+ break;
+ }
+ case FT_MISC_EX_OP_GET_ERS_DATA: // send message to NVRAM task to read ERS data
+ {
+#if defined(__TC01_ERS_SUPPORT__)
+ FT_ReadERS_Data(ptrMsg);
+ return;
+#else // #if defined(__TC01_ERS_SUPPORT__)
+ misc_ex_cnf.status = FT_CNF_FAIL;
+#endif // #if !defined(__TC01_ERS_SUPPORT__)
+ break;
+ }
+
+ case FT_MISC_EX_OP_BACKUP_TO_SDS:
+ {
+#if !defined(__MODEM_CCCI_EXIST__) || !defined(__MODEM_CARD__)
+ if(!Custom_META_SdsSupported())
+ {
+ misc_ex_cnf.status = FT_CNF_FAIL;
+ break;
+ }
+ else
+#endif
+ {
+ nvram_sds_req_struct* ptrMsg;
+ FT_ALLOC_OTHER_MSG(&ptr_ilm,sizeof(nvram_sds_req_struct));
+ ptrMsg = (nvram_sds_req_struct *)ptr_ilm.local_para_ptr;
+ ptrMsg->access_id = (kal_uint8)FT_MISC_EX_OP_BACKUP_TO_SDS;
+ // the access mode is defined in nvram_enums.h (nvram_sds_access_enum)
+ ptrMsg->access_mode = (nvram_sds_access_enum)p_req->cmd.mode;
+#if !defined(__MODEM_CCCI_EXIST__) || !defined(__MODEM_CARD__)
+ FT_SEND_MSG(MOD_FT, MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_SDS_REQ, &ptr_ilm);
+#else
+ FT_SEND_MSG(MOD_FT, MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_BIN_REGION_REQ, &ptr_ilm);
+#endif
+ return;
+ }
+ }
+ /* ram disk dump */
+#if defined(__FS_RAMDISK__)
+ case FT_MISC_EX_OP_RAMDISK_CHECK_EXIST: /**< \brief check ram disk is existing or not */
+ {
+ if(ramdisk_is_existed())
+ {
+ misc_ex_cnf.result.m_cRamDiskExist = 1;
+ }
+ else
+ {
+ misc_ex_cnf.result.m_cRamDiskExist = 0;
+ }
+ misc_ex_cnf.status = FT_CNF_OK;
+ break;
+ }
+ case FT_MISC_EX_OP_RAMDISK_GET_SIZE: /**< \brief get ram disk size */
+ {
+ misc_ex_cnf.result.m_u4RamDiskSize = ramdisk_get_raw_length();
+ if(misc_ex_cnf.result.m_u4RamDiskSize != 0)
+ {
+ misc_ex_cnf.status = FT_CNF_OK;
+ }
+ else
+ {
+ misc_ex_cnf.status = FT_CNF_FAIL;
+ }
+ break;
+ }
+ case FT_MISC_EX_OP_RAMDISK_READ: /**< \brief read from ram disk */
+ {
+ FT_Read_RamDisk_Data(ptrMsg);
+ return;
+ }
+#endif //#if defined(__FS_RAMDISK__)
+ case FT_MISC_EX_OP_SET_COMMAND_TO_SYSTEM: /**< \brief set/clr download flag */
+ {
+ misc_ex_cnf.status = FT_CNF_OK;
+ if(p_req->cmd.m_u4SetCmd2System == 0) // SET_DL_FLAG = 0 set BROM download flag
+ {
+ INT_SetCmdToSys(SYS_CMD_SET_BROM_DL);
+ }
+ else if(p_req->cmd.m_u4SetCmd2System == 1) // CLR_DL_FLAG = 1 clear download flag
+ {
+ INT_SetCmdToSys(SYS_CMD_CLR_DL_FLAG);
+ }
+ else if(p_req->cmd.m_u4SetCmd2System == 2) //SET_DL_FLAG_BL = 2 set Bootloader download flag
+ {
+ INT_SetCmdToSys(SYS_CMD_SET_BROM_DL);
+ }
+ else
+ {
+ misc_ex_cnf.status = FT_CNF_FAIL;
+ }
+ break;
+ }
+ default:
+ return;
+ }
+ FT_MISC_EX_SendCnf(&misc_ex_cnf, peer_buff_ret);
+}
+kal_uint32 FT_MiscExCheckFunctionSupported(kal_uint32 query_op_code)
+{
+ kal_uint32 cnf_code;
+ if(FT_MISC_EX_OP_END> query_op_code)
+ {
+ if( query_op_code == FT_MISC_EX_OP_GET_ERS_SIZE ||
+ query_op_code == FT_MISC_EX_OP_GET_ERS_DATA
+ )
+ {
+#ifdef WISDOM_MMI
+ cnf_code = FT_CNF_OK;
+#else
+ cnf_code = FT_CNF_FAIL;
+#endif
+
+ }
+ else if(query_op_code == FT_MISC_EX_OP_COPY_NVRAM_TO_BP_AREA ||
+ query_op_code == FT_MISC_EX_OP_VERIFY_BP_AREA
+ )
+ {
+ cnf_code = FT_CNF_FAIL;
+
+ }
+ else if(query_op_code == FT_MISC_EX_OP_BACKUP_TO_SDS)
+ {
+#if !defined(__MODEM_CCCI_EXIST__) || !defined(__MODEM_CARD__)
+ if(Custom_META_SdsSupported() != KAL_TRUE)
+ {
+ cnf_code = FT_CNF_FAIL;
+ }
+ else
+#endif
+ {
+ cnf_code = FT_CNF_OK;
+ }
+ }
+ else if(query_op_code == FT_MISC_EX_OP_RAMDISK_CHECK_EXIST ||
+ query_op_code == FT_MISC_EX_OP_RAMDISK_GET_SIZE ||
+ query_op_code == FT_MISC_EX_OP_RAMDISK_READ)
+ {
+#if defined(__FS_RAMDISK__)
+ cnf_code = FT_CNF_OK;
+#else
+ cnf_code = FT_CNF_FAIL;
+#endif
+ }
+ /*******************************
+ * obsoleted op codes
+ ******************************/
+ else if(query_op_code == FT_MISC_EX_OP_OBSOLETED1 ||
+ query_op_code == FT_MISC_EX_OP_OBSOLETED2)
+ {
+ cnf_code = FT_CNF_FAIL;
+ }
+ else if(query_op_code == FT_MISC_EX_OP_SET_COMMAND_TO_SYSTEM)
+ {
+ cnf_code = FT_CNF_OK;
+ }
+ else
+ {
+ cnf_code = FT_CNF_OK;
+ }
+
+ }
+ else
+ {
+ cnf_code = FT_CNF_FAIL;
+ }
+ return cnf_code;
+}
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_mmrf.c b/mcu/middleware/meta/ft/src/ft_fnc_mmrf.c
new file mode 100644
index 0000000..7e39932
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_mmrf.c
@@ -0,0 +1,224 @@
+/*****************************************************************************
+ * 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).
+*
+*****************************************************************************/
+/*******************************************************************************
+ * Modification Notice:
+ * --------------------------
+ * This software is modified by MediaTek Inc. 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) 2001
+ *
+ *******************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * ft_fnc_mmrf.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Factory testing function for MMRF
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+/*************************************************************************
+ * Include Statements for KAL
+ *************************************************************************/
+#include "kal_public_defs.h"
+#include "kal_trace.h"
+#include "svc_sap.h"
+#include "md_mw_sap.h"
+#include "mmrf_msgid.h"
+#include "mmrf_msg_interface.h"
+#include "ft_msgid.h"
+/*************************************************************************
+ * FT header
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_private.h"
+#ifndef L1_SIM
+#include "ft_fnc_nvram.h"
+#include "nvram_defs.h"
+#include "nvram_enums.h"
+#include "nvram_interface.h"
+#include "nvram_data_items.h"
+#include "ft_nvram_def.h"
+#include "nvram_struct.h"
+#endif // #ifndef L1_SIM
+#include "ft_fnc_mmrf.h"
+extern kal_eventgrpid MMRF_UPDATE_RUNTIME_EVENT;
+/**
+ * @param metaMessage the input message from META tool for MMRF test command processing
+ */
+void FT_Mmrf_Operation(ilm_struct* ptrMsg)
+{
+ ilm_struct mmrfMessage;
+ FT_CONSTRUCT_CC_MSG(ptrMsg, &mmrfMessage);
+ FT_SEND_MSG(MOD_FT, MOD_MMRF_XL1TST, FT_MMRF_SAP, MSG_ID_FT_TO_MMRF, &mmrfMessage);
+}
+/**
+ * Confirm message handler for MOD_ETSTM
+ */
+void FT_Mmrf_ConfirmHandler(ilm_struct* mmrfMessage)
+{
+ mmrftst_cnf_struct *ptrMsg;
+ ptrMsg = (mmrftst_cnf_struct *)mmrfMessage->local_para_ptr;
+ if(ptrMsg->type == MMRF_TEST_CMD_CHECK_IF_FUNC_EXIST)
+ {
+ FT_UTILITY_COMMAND_CNF cnf;
+ kal_mem_set(&cnf, '\0', sizeof(cnf));
+ cnf.status = (ptrMsg->result==1)?FT_CNF_OK:FT_CNF_FAIL;
+ cnf.result.CheckIfFuncExist.query_ft_msg_id = ptrMsg->header.ft_msg_id;
+ cnf.result.CheckIfFuncExist.query_op_code = ptrMsg->param.checkIfFuncExist.query_op_code;
+ FT_UTIL_SendCnf(&cnf, NULL);
+ return;
+ }
+ FT_SEND_MSG_TO_PC(mmrfMessage);
+}
+void FT_MmrfCheckFunctionSupported(kal_uint32 query_op_code)
+{
+ ilm_struct ilm_ptr;
+ mmrftst_req_struct *ptrMsg;
+ FT_ALLOC_OTHER_CC_MSG( &ilm_ptr, sizeof(mmrftst_req_struct) );
+ // local parameter
+ ptrMsg = (mmrftst_req_struct *)ilm_ptr.local_para_ptr;
+ ptrMsg->header.ft_msg_id = FT_MMRF_TEST_REQ_ID;
+ ptrMsg->type = MMRF_TEST_CMD_CHECK_IF_FUNC_EXIST;
+ ptrMsg->param.checkIfFuncExist.query_op_code = (MMRfTestCmdType)query_op_code;
+ FT_SEND_MSG(MOD_FT, MOD_MMRF_XL1TST, FT_MMRF_SAP, MSG_ID_FT_TO_MMRF, &ilm_ptr);
+}
+/**
+ * Update Runtime Confirm message handler for MOD_MMRF_XL1TST
+ */
+void FT_Mmrf_UpdateRuntimeHandler(peer_buff_struct* peer_buff, kal_uint16 lid, kal_uint16 rid)
+{
+ ilm_struct ilm_ptr;
+ kal_char* pduToMmrf;
+ kal_char* pduInput;
+ peer_buff_struct* peerToMmrf;
+ mmrf_update_runtime_req_struct* mmrf_update_runtime_req;
+
+ FT_ALLOC_OTHER_CC_MSG(&ilm_ptr, sizeof(mmrf_update_runtime_req_struct));
+ /* set local parameter */
+ mmrf_update_runtime_req = (mmrf_update_runtime_req_struct*)ilm_ptr.local_para_ptr;
+ mmrf_update_runtime_req->nvramLid = lid;
+ mmrf_update_runtime_req->record = rid;
+ /* copy peer buffer */
+ pduInput = get_peer_buff_pdu(peer_buff, NULL);
+ peerToMmrf = construct_cc_non_cached_peer_buff(peer_buff->pdu_len, 0, 0, TD_RESET);
+ pduToMmrf = get_peer_buff_pdu(peerToMmrf, NULL);
+ kal_mem_cpy(pduToMmrf, pduInput, peer_buff->pdu_len);
+ ilm_ptr.peer_buff_ptr = peerToMmrf;
+ FT_SEND_MSG(MOD_FT, MOD_MMRF_XL1TST, FT_MMRF_SAP, MSG_ID_MMRF_UPDATE_RUNTIME_REQ, &ilm_ptr);
+}
+/**
+ * Update Runtime Confirm message handler for MOD_MMRF_XL1TST
+ */
+void FT_Mmrf_UpdateRuntimeConfirmHandler(ilm_struct* _ilm)
+{
+ kal_set_eg_events(MMRF_UPDATE_RUNTIME_EVENT, 0x1, KAL_OR);
+}
+kal_bool FT_Mmrf_PollUpdateRuntimeReady()
+{
+ kal_uint32 ev;
+ kal_sleep_task(1);
+ if(kal_retrieve_eg_events(MMRF_UPDATE_RUNTIME_EVENT, 0x1, KAL_AND_CONSUME, &ev, 0) == KAL_NOT_PRESENT)
+ {
+ return KAL_FALSE;
+ }
+ return KAL_TRUE;
+}
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_nrf.c b/mcu/middleware/meta/ft/src/ft_fnc_nrf.c
new file mode 100644
index 0000000..cbdccf5
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_nrf.c
@@ -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) 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).
+*
+*****************************************************************************/
+/*******************************************************************************
+ * Modification Notice:
+ * --------------------------
+ * This software is modified by MediaTek Inc. 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) 2001
+ *
+ *******************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * ft_fnc_nr.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Factory testing function for NR
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ *************************************************************************/
+/*************************************************************************
+ * Include Statements for KAL
+ *************************************************************************/
+#include "kal_public_defs.h"
+#include "kal_trace.h"
+#include "ft_msgid.h"
+#include "svc_sap.h"
+#include "md_mw_sap.h"
+/*************************************************************************
+ * FT header
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_private.h"
+#include "ft_fnc_nrf.h"
+/**
+ * @param metaMessage the input message from META tool for NR test command processing
+ */
+void FT_Nrf_Operation(ilm_struct* ptrMsg)
+{
+ #if defined(__MD97__)
+ ilm_struct nrfMessage;
+ FT_CONSTRUCT_CC_MSG(ptrMsg, &nrfMessage);
+ FT_SEND_MSG(MOD_FT, MOD_NL1, NL1_FT_SAP, MSG_ID_FT_TO_NL1, &nrfMessage);
+ #endif //!defined(__MD97__)
+}
+/**
+ * Confirm message handler for MOD_NL
+ */
+void FT_Nrf_ConfirmHandler(ilm_struct* nrfMessage)
+{
+ FT_SEND_MSG_TO_PC(nrfMessage);
+}
\ No newline at end of file
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_nvram.c b/mcu/middleware/meta/ft/src/ft_fnc_nvram.c
new file mode 100644
index 0000000..312fd55
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_nvram.c
@@ -0,0 +1,428 @@
+/*****************************************************************************
+* 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).
+*
+*****************************************************************************/
+/*******************************************************************************
+* Modification Notice:
+* --------------------------
+* This software is modified by MediaTek Inc. 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) 2001
+*
+*******************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * ft_fnc_nvram.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * FT NVRAM operations
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#if defined(__MOD_NVRAM__) && !defined(NVRAM_NOT_PRESENT)
+/*************************************************************************
+ * FT header
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_private.h"
+#include "ft_fnc_nvram.h"
+#include "ft_fnc_misc.h"
+#include "svc_sap.h"
+#include "nvram_msgid.h"
+#include "ft_msgid.h"
+#include "ft_trace_def.h"
+#include "ft_fnc_mmrf.h"
+/**************************************************************************
+ * NVRAM header
+ *************************************************************************/
+#include "nvram_defs.h"
+#include "nvram_enums.h"
+#include "nvram_interface.h"
+#include "nvram_data_items.h"
+#include "ft_nvram_def.h"
+#include "l4_nvram_def.h"
+#include "nvram_struct.h"
+void FT_Nvram_SendWriteCommandToNvram(peer_buff_struct* peer_buff, kal_uint16 lid, kal_uint16 rid, kal_uint8 ftAccessId, kal_bool holdBufferForRelay)
+{
+ kal_uint8 *pdu_ptr;
+ kal_uint16 pdu_length;
+ ilm_struct ilm_ptr;
+ nvram_write_cnf_struct *cnf_result_ptr;
+
+ FT_ALLOC_OTHER_MSG(&ilm_ptr, sizeof( nvram_write_cnf_struct ));
+ cnf_result_ptr = (nvram_write_cnf_struct *)ilm_ptr.local_para_ptr;
+ pdu_ptr = get_peer_buff_pdu(peer_buff, &pdu_length);
+ cnf_result_ptr->file_idx = lid;
+ cnf_result_ptr->para = rid;
+ cnf_result_ptr->access_id = ftAccessId;
+
+ /* call secure API to access nvram item */
+ cnf_result_ptr->result = nvram_external_secure_write_data(lid, rid, pdu_ptr, pdu_length, NULL);
+ MD_TRC_FT_NVRAM_CALL_WRITE_NVRAM_API(cnf_result_ptr->result);
+
+ if( holdBufferForRelay != KAL_TRUE)
+ {
+ free_peer_buff(peer_buff);
+ }
+ /* Check polling for MMRF runtime update */
+ FT_SEND_MSG(MOD_FT, MOD_FT, PS_NVRAM_SAP, MSG_ID_NVRAM_WRITE_CNF, &ilm_ptr);
+}
+void FT_Nvram_SendReadCommandToNvram(kal_uint16 lid, kal_uint16 rid, kal_uint8 ftAccessId)
+{
+ nvram_read_cnf_struct cnf_result;
+ peer_buff_struct *peer_buff = NULL;
+ kal_uint8 *pdu_ptr;
+ kal_uint16 totalRID;
+ kal_uint16 pdu_length;
+
+ cnf_result.file_idx = lid;
+ cnf_result.para = rid;
+ cnf_result.length = 0;
+ cnf_result.access_id = ftAccessId;
+ cnf_result.result = nvram_get_info(lid, & totalRID, &pdu_length);
+ if( NVRAM_ERRNO_SUCCESS == cnf_result.result )
+ {
+ if( NULL != (peer_buff=construct_peer_buff(pdu_length, 0, 0, TD_CTRL)) )
+ {
+ pdu_ptr = get_peer_buff_pdu(peer_buff, &pdu_length);
+ cnf_result.length = pdu_length;
+ /* call secure API to access nvram item */
+ cnf_result.result = nvram_external_secure_read_data(lid, rid, pdu_ptr, pdu_length, NULL);
+ }
+ else
+ {
+ cnf_result.result = 0xFA;
+ }
+ }
+ MD_TRC_FT_NVRAM_CALL_READ_NVRAM_API(cnf_result.result);
+
+ if ( NVRAM_ERRNO_SUCCESS != cnf_result.result )
+ {
+ cnf_result.length = 0;
+ peer_buff = NULL;
+ free_peer_buff(peer_buff);
+ FT_Nvram_SendReadResponseToHost(&cnf_result, peer_buff, KAL_TRUE);
+ }
+ else
+ {
+ FT_Nvram_ReadNvramConfirmHandler(&cnf_result, peer_buff);
+ }
+}
+/*******************************************************************************
+ * FUNCTION
+ * FT_Nvram_WriteNvramHandler()
+ *
+ * DESCRIPTION
+ * Handle the write request of NVRAM
+ *
+ * CALLS
+ * None
+ *
+ * PARAMETERS
+ *
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ * None
+ *******************************************************************************/
+void FT_Nvram_WriteNvramHandler(ft_nvram_write_req_struct_T* req, peer_buff_struct* peer_buff, kal_uint8 accessId)
+{
+ /* Duplicate the message to MMRF for runtime update */
+ FT_Mmrf_UpdateRuntimeHandler(peer_buff, req->file_idx, req->para);
+ FT_Nvram_SendWriteCommandToNvram(peer_buff, req->file_idx, req->para, accessId, KAL_TRUE);
+}
+/*******************************************************************************
+ * FUNCTION
+ * FT_Nvram_ReadNvramHandler()
+ *
+ * DESCRIPTION
+ * Handle the read request of FT to NVRAM
+ *
+ * CALLS
+ * None
+ *
+ * PARAMETERS
+ *
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ * None
+ *******************************************************************************/
+void FT_Nvram_ReadNvramHandler(ft_nvram_read_req_struct_T* req, kal_uint8 accessId)
+{
+ FT_Nvram_SendReadCommandToNvram(req->file_idx, req->para, accessId);
+}
+void FT_Nvram_SendReadResponseToHost(nvram_read_cnf_struct* nvramReadCnf, peer_buff_struct* nvramReadCnfPeerBuf, kal_bool holdBufferForRelay)
+{
+ ilm_struct ilm_ptr;
+ ft_nvram_read_cnf_struct_T *ft_cnf;
+
+ MD_TRC_FT_NVRAM_SEND_READ_RESPONSE_TO_HOST(holdBufferForRelay);
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(ft_nvram_read_cnf_struct_T));
+ ft_cnf = (ft_nvram_read_cnf_struct_T *)ilm_ptr.local_para_ptr;
+ ft_cnf->header.ft_msg_id = FT_NVRAM_READ_CNF_ID;
+ ft_cnf->file_idx = nvramReadCnf->file_idx;
+ ft_cnf->para = nvramReadCnf->para;
+ /* Check the FILE index to SIM lock */
+ if( nvram_test_lock() && (NVRAM_EF_SML_LID == nvramReadCnf->file_idx) )
+ {
+ ft_cnf->status = 0xFF;
+ ilm_ptr.peer_buff_ptr = NULL;
+ free_peer_buff(nvramReadCnfPeerBuf);
+ }
+ else
+ {
+ ft_cnf->status = nvramReadCnf->result;
+ ilm_ptr.peer_buff_ptr = nvramReadCnfPeerBuf;
+ }
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+/*******************************************************************************
+ * FUNCTION
+ * FT_Nvram_ReadNvramConfirmHandler
+ *
+ * DESCRIPTION
+ * Handle the confirmation of reading
+ *
+ * CALLS
+ *
+ *
+ * PARAMETERS
+ * local_para_struct * local_para_ptr, //( force to nvram_read_cnf_struct* cnf )
+ * peer_buff_struct * peer_buff_ptr
+ *
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ * None
+ *******************************************************************************/
+void FT_Nvram_ReadNvramConfirmHandler(nvram_read_cnf_struct* nvramReadCnf, peer_buff_struct* nvramReadCnfPeerBuf)
+{
+ ft_gl_token = ft_gl_nvram_token;
+ FT_Nvram_SendReadResponseToHost(nvramReadCnf, nvramReadCnfPeerBuf, KAL_TRUE);
+}
+void FT_Nvram_SendWriteResponseToHost(nvram_write_cnf_struct* nvramWriteCnf)
+{
+ ilm_struct ilm_ptr;
+ ft_nvram_write_cnf_struct_T *ptrMsg ;
+
+ MD_TRC_FT_NVRAM_SEND_WRITE_RESPONSE_TO_HOST();
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(ft_nvram_write_cnf_struct_T));
+ ptrMsg = (ft_nvram_write_cnf_struct_T *)ilm_ptr.local_para_ptr;
+ ptrMsg->header.ft_msg_id = FT_NVRAM_WRITE_CNF_ID;
+ ptrMsg->file_idx = nvramWriteCnf->file_idx;
+ ptrMsg->para = nvramWriteCnf->para;
+ ptrMsg->status = nvramWriteCnf->result;
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+}
+/*******************************************************************************
+ * FUNCTION
+ * FT_Nvram_WriteNvramConfirmHandler
+ *
+ * DESCRIPTION
+ * Handle the confirmation of writting
+ *
+ * CALLS
+ *
+ *
+ * PARAMETERS
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ * None
+ *******************************************************************************/
+void FT_Nvram_WriteNvramConfirmHandler(nvram_write_cnf_struct* nvramWriteCnf)
+{
+ FT_Nvram_SendWriteResponseToHost(nvramWriteCnf);
+}
+kal_bool FT_Nvram_IsModNvramRespnose(ilm_struct* ilm_ptr)
+{
+ if(ilm_ptr->msg_id == MSG_ID_NVRAM_WRITE_CNF ||
+ ilm_ptr->msg_id == MSG_ID_NVRAM_CREATE_IMAGE_CNF ||
+ ilm_ptr->msg_id == MSG_ID_NVRAM_VERIFY_IMAGE_CNF ||
+ ilm_ptr->msg_id == MSG_ID_NVRAM_RESET_CNF ||
+ ilm_ptr->msg_id == MSG_ID_NVRAM_WRITE_IMEI_CNF ||
+ ilm_ptr->msg_id == MSG_ID_NVRAM_SET_LOCK_CNF ||
+ ilm_ptr->msg_id == MSG_ID_NVRAM_SDS_CNF ||
+ ilm_ptr->msg_id == MSG_ID_NVRAM_BIN_REGION_CNF)
+ {
+ return KAL_TRUE;
+ }
+ else
+ {
+ return KAL_FALSE;
+ }
+}
+#endif // #if defined(__MOD_NVRAM__) && !defined(NVRAM_NOT_PRESENT)
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_nvram_sec.c b/mcu/middleware/meta/ft/src/ft_fnc_nvram_sec.c
new file mode 100644
index 0000000..d2e73cc
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_nvram_sec.c
@@ -0,0 +1,322 @@
+/*****************************************************************************
+* 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).
+*
+*****************************************************************************/
+/*******************************************************************************
+* Modification Notice:
+* --------------------------
+* This software is modified by MediaTek Inc. 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) 2001
+*
+*******************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * ft_fnc_nvram.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * FT NVRAM security mechanism
+ *
+ * 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!
+ *
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+/*************************************************************************
+ * FT header
+ *************************************************************************/
+#if defined(__NVRAM_SECRET_DATA__)
+#include "ft_msg.h"
+#include "ft_private.h"
+#include "ft_fnc_nvram.h"
+#include "ft_fnc_misc.h"
+#include "svc_sap.h"
+#include "nvram_msgid.h"
+#include "ft_msgid.h"
+#include "ft_fnc_mmrf.h"
+/**************************************************************************
+ * NVRAM header
+ *************************************************************************/
+#include "nvram_defs.h"
+#include "nvram_enums.h"
+#include "nvram_interface.h"
+#include "nvram_data_items.h"
+#include "ft_nvram_def.h"
+#include "nvram_struct.h"
+#include "rc4.h"
+/*******************************************************************************
+ * FUNCTION
+ * FT_NvramSec_WriteNvramHandler()
+ *
+ * DESCRIPTION
+ * Handle the write request of NVRAM
+ *
+ * CALLS
+ * None
+ *
+ * PARAMETERS
+ *
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ * None
+ *******************************************************************************/
+kal_uint16 g_u2_ft_nvram_pdu_length = 0;
+kal_uint8 *p_g_u1_ft_nvram_pdu_ptr = NULL;
+peer_buff_struct *p_g_pbs_ft_nvram = NULL;
+void FT_NvramSec_WriteNvramHandler(ft_nvram_write_req_struct_T* req, peer_buff_struct* peer_buff, kal_uint8 accessId)
+{
+ //ilm_struct ilm_ptr;
+ //nvram_write_req_struct *nvram_ptr_loc_para;
+ kal_uint16 pdu_length;
+ kal_uint8 *pdu_ptr = get_peer_buff_pdu( peer_buff, &pdu_length );
+ kal_bool bPassCheck = KAL_FALSE;
+ kal_int32 err_code = 0xFE;
+ kal_uint8 key[256]; // at most 256 bytes
+ kal_int32 real_key_len;
+ real_key_len = custom_nvram_get_database_key(key, sizeof(key));
+ if(req->msg_num == 2 && real_key_len >0) // we must wait until we collect all
+ {
+ if(req->msg_idx == 0) // allocate a peer buffer to store it.
+ {
+ if(p_g_pbs_ft_nvram != NULL) // free previous buffer
+ {
+ free_peer_buff(p_g_pbs_ft_nvram);
+ p_g_pbs_ft_nvram = NULL;
+ }
+ // allocate a new peer buffer
+ if( NULL != (p_g_pbs_ft_nvram=construct_peer_buff(pdu_length, 0, 0, TD_CTRL)) )
+ {
+ p_g_u1_ft_nvram_pdu_ptr = get_peer_buff_pdu( p_g_pbs_ft_nvram, &g_u2_ft_nvram_pdu_length );
+ kal_mem_cpy(p_g_u1_ft_nvram_pdu_ptr, pdu_ptr , pdu_length);
+ p_g_pbs_ft_nvram->pdu_len = pdu_length;
+ }
+ return; // wait for next message
+ }
+ else // the second message with encrpted data
+ {
+ kal_int32 i;
+ RC4_CNXT cnxt;
+ kal_uint8 *output_data = (kal_uint8*) get_ctrl_buffer(g_u2_ft_nvram_pdu_length); // since at most 2k bytes
+ if(p_g_u1_ft_nvram_pdu_ptr!=NULL)
+ {
+ // get the key
+ //real_key_len = custom_nvram_get_database_key(key, sizeof(key));
+ if(real_key_len >0) // get the key
+ {
+ // deciphered the input data
+ che_rc4_set_key((RC4_CNXT *)&cnxt, (kal_uint32)real_key_len, (kal_uint8 *)key);
+ che_rc4((RC4_CNXT *)&cnxt, p_g_u1_ft_nvram_pdu_ptr , g_u2_ft_nvram_pdu_length, key, real_key_len, CHE_MODE_NULL, output_data);
+ for(i=0; i<g_u2_ft_nvram_pdu_length; i++)
+ {
+ if(output_data[i] != pdu_ptr[i])
+ {
+ err_code = 0xFD;
+ break;
+ }
+ }
+ if(i == g_u2_ft_nvram_pdu_length)
+ {
+ bPassCheck = true;
+ }
+ }
+ }
+ else
+ {
+ err_code = 0xFC;
+ }
+ free_ctrl_buffer(output_data);
+ }
+ }
+ else
+ {
+ if(real_key_len == 0) // sec not ON
+ bPassCheck = true;
+ }
+ if(!bPassCheck)
+ {
+ // invoke:
+ nvram_write_cnf_struct cnf_result;
+ cnf_result.file_idx = req->file_idx;
+ cnf_result.para = req->para;
+ cnf_result.result = err_code;
+ // allocate a peer buffer to stored the output data for debug
+ FT_WriteTo_NVRAM_CNF(&cnf_result);
+ return;
+ }
+ if(real_key_len >0 &&
+ req->msg_num == 2 &&
+ p_g_pbs_ft_nvram != NULL) // re-assign the pdu_ptr, and free the buffer
+ {
+ kal_mem_cpy(pdu_ptr, p_g_u1_ft_nvram_pdu_ptr,pdu_length);
+ free_peer_buff(p_g_pbs_ft_nvram);
+ p_g_pbs_ft_nvram = NULL;
+ }
+ /* Duplicate the message to MMRF for runtime update */
+ FT_Mmrf_UpdateRuntimeHandler(peer_buff, req->file_idx, req->para);
+ FT_Nvram_SendWriteCommandToNvram(peer_buff, req->file_idx, req->para, accessId, KAL_TRUE);
+}
+/*******************************************************************************
+ * FUNCTION
+ * FT_NvramSec_ReadNvramHandler()
+ *
+ * DESCRIPTION
+ * Handle the read request of FT to NVRAM
+ *
+ * CALLS
+ * None
+ *
+ * PARAMETERS
+ *
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ * None
+ *******************************************************************************/
+void FT_NvramSec_ReadNvramHandler(ft_nvram_read_req_struct_T* req, kal_uint8 accessId)
+{
+ //ilm_struct ilm_ptr;
+ //nvram_read_req_struct *ptrMsg;
+ kal_uint8 key[256]; // at most 256 bytes
+ kal_int32 real_key_len;
+ kal_uint8 input_data[4];
+ kal_uint8 output_data[4];
+ kal_uint8 i;
+ RC4_CNXT cnxt;
+ kal_uint32 err_code = 0xFE;
+ kal_bool bPassCheck = KAL_FALSE;
+ real_key_len = custom_nvram_get_database_key(key, sizeof(key));
+ kal_mem_set(output_data, 0x0, sizeof(output_data));
+ // make sure if the authenticaion pass
+ if(req->ciphered_data_valid && real_key_len > 0 ) // the load need to be checked, and user send ciphered data
+ {
+ kal_mem_cpy(input_data, &(req->file_idx), 2);
+ kal_mem_cpy(input_data+2, &(req->para), 2);
+ // deciphered the input data
+ che_rc4_set_key((RC4_CNXT *)&cnxt, (kal_uint32)real_key_len, (kal_uint8 *)key);
+ che_rc4((RC4_CNXT *)&cnxt, input_data , 4, key, real_key_len, CHE_MODE_NULL, output_data);
+ for(i=0; i<4; i++)
+ {
+ if(output_data[i] != req->ciphered_data[i])
+ {
+ err_code = 0xFD;
+ break;
+ }
+ }
+ if(i == 4)
+ bPassCheck = KAL_TRUE;
+ }
+ else // ciphered data invalid
+ {
+ if(real_key_len == 0) // no need to checked
+ bPassCheck = KAL_TRUE;
+ else // need check, but user doesn't send data
+ err_code = 0xFB;
+ }
+ if(!bPassCheck)
+ {
+ // invoke:
+ kal_uint16 pdu_length_new = 0;
+ kal_uint8 *pdu_ptr_new;
+ peer_buff_struct *peer_buff_new;
+ nvram_read_cnf_struct cnf_result;
+ cnf_result.file_idx = req->file_idx;
+ cnf_result.para = req->para;
+ cnf_result.result = err_code;
+ cnf_result.access_id = 0;
+ // allocate a peer buffer to stored the output data for debug
+
+ if( NULL != (peer_buff_new=construct_peer_buff(4, 0, 0, TD_CTRL)) )
+ {
+ pdu_ptr_new = get_peer_buff_pdu( peer_buff_new, &pdu_length_new );
+ kal_mem_cpy(pdu_ptr_new, output_data , 4);
+ peer_buff_new->pdu_len = 4;
+ }
+ FT_ReadFrom_NVRAM_CNF(&cnf_result, peer_buff_new);
+ return;
+ }
+ FT_Nvram_SendReadCommandToNvram(req->file_idx, req->para, accessId);
+}
+#endif // #if defined(__NVRAM_SECRET_DATA__)
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_util.c b/mcu/middleware/meta/ft/src/ft_fnc_util.c
new file mode 100644
index 0000000..1ecceed
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_util.c
@@ -0,0 +1,1131 @@
+/*****************************************************************************
+* 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).
+*
+*****************************************************************************/
+/*******************************************************************************
+* Modification Notice:
+* --------------------------
+* This software is modified by MediaTek Inc. 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) 2001
+*
+*******************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * ft_fnc_util.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Factory testing function library (Category: Utility Commands)
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+/*************************************************************************
+* Include Statements for KAL
+ *************************************************************************/
+#include "ctrl_buff_pool.h"
+#include "svc_sap.h"
+#include "ft_msgid.h"
+/**************************************************************************
+ * HAL header
+ *************************************************************************/
+#ifndef L1_SIM
+#include "dcl.h"
+#include "device.h"
+#include "drv_features.h"
+#include "fs_gprot.h"
+#endif //#ifndef L1_SIM
+#include "tst_def.h"
+/**************************************************************************
+ * FT header
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_private.h"
+#ifndef L1_SIM
+#include "ft_fnc_fat.h"
+#include "ft_fnc_misc.h"
+#include "ft_fnc_misc_ex.h"
+#endif //#ifndef L1_SIM
+#include "ft_fnc_l1rf.h"
+#include "ft_fnc_wcdma.h"
+#include "ft_fnc_lterf.h"
+#include "ft_fnc_tdscdma.h"
+#include "ft_fnc_mmrf.h"
+kal_uint32 FT_UtilCheckFunctionSupported(kal_uint32 query_op_code);
+/**************************************************************************
+ * Custom header
+ *************************************************************************/
+#ifndef L1_SIM
+#include "meta_customize.h"
+#include "custom_equipment.h"
+#endif // #ifndef L1_SIM
+
+kal_uint32 FT_REQUIRED_META_DLL_MAIN_VER = 6;
+kal_uint32 FT_REQUIRED_META_DLL_MINOR_VER = 944;
+kal_uint32 FT_REQUIRED_META_DLL_BUILD_NUM = 0;
+kal_uint32 FT_REQUIRED_VERSION_UNKNOWN = 0xFFFFFFFF;
+kal_uint32 FT_REQUIRED_CTRL_BUFF_MAXSIZE = 35536;
+/*******************************************************************************
+ *
+ * FAT functionality
+ *
+ *******************************************************************************/
+#ifndef L1_SIM /* xl1sim not support FAT */
+/**
+ * Get Path for requested size
+ */
+kal_int16 FT_GetAvailableDrive(kal_int32 size)
+{
+#if !defined(__LOW_COST_SUPPORT_ULC__)
+ kal_int16 drv_letter = -1;
+ kal_int16 i = 0;
+ kal_uint32 dev[4] = {FS_DRIVE_I_SYSTEM, FS_DRIVE_V_NORMAL, FS_DRIVE_V_REMOVABLE, FS_DRIVE_V_EXTERNAL};
+ kal_wchar *pathname = NULL;
+ pathname = (kal_wchar*)get_ctrl_buffer(FT_FAT_MAX_FULLPATH);
+ if(pathname)
+ {
+ for(i=0;i<4;i++)
+ {
+ drv_letter = FS_GetDrive(dev[i], 1, FS_NO_ALT_DRIVE);
+ if(drv_letter > 0)
+ {
+ kal_wsprintf(pathname, "%c:\\", drv_letter);
+ if(size < FT_GetDiskFreeSpace(pathname))
+ {
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ ASSERT(0);
+ }
+ free_ctrl_buffer(pathname);
+ return drv_letter;
+#else // #if !defined(__LOW_COST_SUPPORT_ULC__)
+ return -1;
+#endif // #if defined(__LOW_COST_SUPPORT_ULC__)
+}
+#endif //#ifndef L1_SIM
+/*************************************************************************
+ * FUNCTION
+ * ft_get_ctrlbuf_max_size
+ *
+ * DESCRIPTION
+ *
+ * PARAMETERS
+ *
+ * RETURNS
+ * 0: Could not target the maximal size
+ * else: maximal size supported.
+ *
+ * GLOBALS AFFECTED
+ *
+ *************************************************************************/
+kal_uint32 ft_get_ctrlbuf_max_size( void )
+{
+#ifndef L1_SIM
+ kal_int16 i=RPS_CREATED_CTRL_BUFF_POOLS-1;
+
+ /* Total entries defined at adaptation\include\ctrl_buff_pool.h
+ RPS_CREATED_CTRL_BUFF_POOLS = 14
+ For each buffer associated with non-zero entries count, it should have been created,
+ and pool_id always non-zero. */
+ while ( (ctrl_buff_pool_info_g[i].pool_id==0) && (i >= 0) )
+ i--;
+
+ /* Somehow, if table corrupted, must return 0 */
+ if ( i<0 )
+ return 0;
+
+ return (ctrl_buff_pool_info_g[i].size);
+#else // #ifndef L1_SIM
+ return FT_REQUIRED_CTRL_BUFF_MAXSIZE;
+#endif // #ifdef L1_SIM
+}
+
+/*******************************************************************************
+ *
+ * FT task check if function exist
+ *
+ *******************************************************************************/
+kal_uint8 FT_UTIL_SendCnf(const FT_UTILITY_COMMAND_CNF *cnf, peer_buff_struct *p_peer_buff) {
+
+ ilm_struct ilm_ptr;
+ FT_UTILITY_COMMAND_CNF *ptrMsg;
+
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(FT_UTILITY_COMMAND_CNF));
+
+ // if ptrMsg != NULL
+ ptrMsg = (FT_UTILITY_COMMAND_CNF *)ilm_ptr.local_para_ptr;
+
+ // assign primitive id
+ ptrMsg->header.ft_msg_id = FT_UTILITY_COMMAND_CNF_ID;
+
+ // assign return structure
+ ptrMsg->type = cnf->type;
+ ptrMsg->result = cnf->result;
+ ptrMsg->status = cnf->status;
+
+ // assign peer buffer
+ if( NULL != p_peer_buff ) {
+ ilm_ptr.peer_buff_ptr = p_peer_buff;
+ }
+
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+ return 0;
+}
+#ifndef L1_SIM /* xl1sim no device cmd */
+void ft_util_check_if_ulc_support(FT_UTILITY_COMMAND_CNF *cnf)
+{
+#if defined(__LOW_COST_SUPPORT_ULC__)
+ cnf->status = FT_CNF_OK;
+#else
+ cnf->status = FT_CNF_FAIL;
+#endif
+}
+void ft_util_watch_dog_start(FT_UTILITY_COMMAND_REQ *req, FT_UTILITY_COMMAND_CNF *cnf,peer_buff_struct *peer_buff_ret)
+{
+ DCL_HANDLE dcl_wdt_handle;
+ WDT_CTRL_SET_VALUE_T interval;
+ WDT_CTRL_ENABLE_T enable;
+ dcl_wdt_handle = DclWDT_Open(DCL_WDT, FLAGS_NONE);
+ if(DCL_HANDLE_INVALID != dcl_wdt_handle) /*DCL_HANDLE_INVALID (-1) define@dcl.h*/
+ {
+ // set interval
+ interval.u2Value = req->cmd.WatchDog.interval;
+ DclWDT_Control(dcl_wdt_handle, WDT_CMD_SET_VALUE, (DCL_CTRL_DATA_T*)&interval);
+ // send confirm first
+ cnf->status = FT_CNF_OK;
+ FT_UTIL_SendCnf(cnf,peer_buff_ret);
+ kal_sleep_task(50);
+ // disable all interrupt mask
+ SaveAndSetIRQMask();
+ // restart timer
+ DclWDT_Control(dcl_wdt_handle, WDT_CMD_RESTART, 0);
+ // enable watch dog count down
+ enable.fgEnable = DCL_TRUE;
+ DclWDT_Control(dcl_wdt_handle, WDT_CMD_ENABLE, (DCL_CTRL_DATA_T*)&enable);
+ DclWDT_Close(dcl_wdt_handle);
+ Custom_META_USBVirtualComDisconnect();
+ while(1);
+ }else
+ {
+ cnf->status = FT_CNF_FAIL;
+ }
+}
+#endif //#ifndef L1_SIM
+kal_int8 ft_util_check_if_func_exist(const FT_UTILITY_COMMAND_REQ *req, FT_UTILITY_COMMAND_CNF *cnf)
+{
+ kal_uint32 query_ft_msg_id = req->cmd.CheckIfFuncExist.query_ft_msg_id;
+ kal_uint32 query_op_code = req->cmd.CheckIfFuncExist.query_op_code;
+ cnf->status = FT_CNF_FAIL;
+ switch(query_ft_msg_id) {
+#ifndef L1_SIM
+ case FT_REG_READ_ID:
+ case FT_REG_WRITE_ID:
+ case FT_IS_ALIVE_REQ_ID:
+ case FT_POWER_OFF_REQ_ID:
+ case FT_NVRAM_GET_DISK_INFO_REQ_ID:
+ case FT_NVRAM_RESET_REQ_ID:
+ case FT_NVRAM_LOCK_REQ_ID:
+ case FT_NVRAM_READ_REQ_ID:
+ case FT_NVRAM_WRITE_REQ_ID:
+ case FT_VER_INFO_REQ_ID:
+ case FT_ADC_GETMEADATA_ID:
+ {
+ cnf->status = FT_CNF_OK;
+ break;
+ }
+#if !defined(L1_NOT_PRESENT) && !defined(__L1_TASK_DISABLE__) && !defined(DUMMYL1)
+ case FT_RF_TEST_REQ_ID:
+ {
+ FT_RfCheckFunctionSupported(query_op_code);
+ return 1; // does not reply message immediately
+ }
+#endif // #if !defined(L1_NOT_PRESENT) && !defined(__L1_TASK_DISABLE__) && !defined(DUMMYL1)
+#if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+#if !defined(__UL1_TASK_DISABLE__)
+ case FT_URF_TEST_REQ_ID:
+ {
+ FT_UL1RfCheckFunctionSuppported(query_op_code);
+ return 1; // does not reply message immediately
+ }
+#endif // #if !defined(__UL1_TASK_DISABLE__)
+#endif // #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+
+ case FT_FAT_OPERATION_ID:
+ if( FT_FAT_OP_OPEN<=query_op_code && FT_FAT_OP_END>query_op_code ) {
+ cnf->status = FT_CNF_OK;
+ }
+ break;
+ case FT_UTILITY_COMMAND_REQ_ID:
+ {
+ cnf->status = FT_UtilCheckFunctionSupported(query_op_code);
+ break;
+ }
+ case FT_MISC_CMD_REQ_ID:
+ {
+ cnf->status = FT_MiscCheckFunctionSupported(query_op_code);
+ break;
+ }
+ case FT_MISC_EX_CMD_REQ_ID:
+ {
+ cnf->status = FT_MiscExCheckFunctionSupported(query_op_code);
+ break;
+ }
+#if defined(__LTE_RAT__)
+#if !defined(__EL1_TASK_DISABLE__)
+ case FT_ERF_TEST_REQ_ID:
+ {
+ FT_ErfCheckFunctionSupported(query_op_code);
+ return 1; // does not reply message immediately
+ }
+#endif // #if !defined(__EL1_TASK_DISABLE__)
+#endif // #if defined(__LTE_RAT__)
+ case FT_MMRF_TEST_REQ_ID:
+ {
+ FT_MmrfCheckFunctionSupported(query_op_code);
+ return 1; // does not reply message immediately
+ }
+#else //#ifndef L1_SIM
+ case FT_IS_ALIVE_REQ_ID:
+ case FT_VER_INFO_REQ_ID:
+ {
+ cnf->status = FT_CNF_OK;
+ break;
+ }
+#if !defined(L1_NOT_PRESENT) && !defined(__L1_TASK_DISABLE__) && !defined(DUMMYL1)
+ case FT_RF_TEST_REQ_ID:
+ {
+ FT_RfCheckFunctionSupported(query_op_code);
+ return 1; // does not reply message immediately
+ }
+#endif // #if !defined(L1_NOT_PRESENT) && !defined(__L1_TASK_DISABLE__) && !defined(DUMMYL1)
+#if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+#if !defined(__UL1_TASK_DISABLE__)
+ case FT_URF_TEST_REQ_ID:
+ {
+ FT_UL1RfCheckFunctionSuppported(query_op_code);
+ return 1; // does not reply message immediately
+ }
+#endif // #if !defined(__UL1_TASK_DISABLE__)
+#endif // #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+
+ case FT_UTILITY_COMMAND_REQ_ID:
+ {
+ cnf->status = FT_UtilCheckFunctionSupported(query_op_code);
+ break;
+ }
+#if defined(__LTE_RAT__)
+ case FT_ERF_TEST_REQ_ID:
+ {
+ FT_ErfCheckFunctionSupported(query_op_code);
+ return 1; // does not reply message immediately
+ }
+#endif // #if defined(__LTE_RAT__)
+ case FT_MMRF_TEST_REQ_ID:
+ {
+ FT_MmrfCheckFunctionSupported(query_op_code);
+ return 1; // does not reply message immediately
+ }
+#endif //#ifndef L1_SIM
+ case FT_GET_SLA_STATUS_REQ_ID:
+ case FT_GET_SLA_PARA_REQ_ID:
+ case FT_VERIFY_SLA_RND_REQ_ID:
+ case FT_CHECK_SLA_VER_REQ_ID:
+ {
+ cnf->status = FT_CNF_OK;
+ break;
+ }
+ default:
+ cnf->status = FT_CNF_FAIL;
+ break;
+ }
+
+ // assign return structure
+ cnf->result.CheckIfFuncExist.query_ft_msg_id = query_ft_msg_id;
+ cnf->result.CheckIfFuncExist.query_op_code = query_op_code;
+ return 0;
+}
+
+#ifndef L1_SIM /* xl1sim not support */
+void ft_util_check_if_isp_support(FT_UTILITY_COMMAND_CNF *cnf) {
+ /*
+#if defined(ISP_SUPPORT) //&& !defined(YUV_SENSOR_SUPPORT)
+cnf->status = FT_CNF_OK;
+#else
+cnf->status = FT_CNF_FAIL;
+#endif
+*/
+ if(custom_ft_util_check_if_isp_support())
+ cnf->status = FT_CNF_OK;
+ else
+ cnf->status = FT_CNF_FAIL;
+}
+#endif //#ifndef L1_SIM
+void ft_util_check_if_smart_phone_modem_supported(FT_UTILITY_COMMAND_CNF *cnf)
+{
+#if defined(__SMART_PHONE_MODEM__)
+ cnf->status = FT_CNF_OK;
+#else
+ cnf->status = FT_CNF_FAIL;
+#endif
+}
+#ifndef L1_SIM /* xl1sim no power/deivce control */
+void ft_util_query_rtc(FT_UTILITY_COMMAND_CNF *cnf)
+{
+ // HAL modification
+ //RTC_GetTime(&cnf->result.rtc);
+ DCL_HANDLE rtc_handle;
+ RTC_CTRL_GET_TIME_T rtc_cmd_data3; // New Declaration
+ cnf->status = FT_CNF_OK;
+ rtc_handle = DclRTC_Open(DCL_RTC, FLAGS_NONE);
+ if(DclRTC_Control(rtc_handle, RTC_CMD_GET_TIME, (DCL_CTRL_DATA_T *)&rtc_cmd_data3) != STATUS_OK)
+ {
+ cnf->status = FT_CNF_FAIL;
+ }
+ cnf->result.rtc.rtc_year = rtc_cmd_data3.u1Year;
+ cnf->result.rtc.rtc_wday = rtc_cmd_data3.u1WDay;
+ cnf->result.rtc.rtc_mon = rtc_cmd_data3.u1Mon;
+ cnf->result.rtc.rtc_day = rtc_cmd_data3.u1Day;
+ cnf->result.rtc.rtc_hour = rtc_cmd_data3.u1Hour;
+ cnf->result.rtc.rtc_min = rtc_cmd_data3.u1Min;
+ cnf->result.rtc.rtc_sec = rtc_cmd_data3.u1Sec;
+ DclRTC_Close(rtc_handle);
+}
+void ft_util_query_itc_pcl(FT_UTILITY_COMMAND_CNF *cnf)
+{
+ // Phase out on UMOLY
+ cnf->result.rf_pcl = 0xFFFFFFFF;
+ cnf->status = FT_CNF_OK;
+}
+void ft_util_query_pmic_id(FT_UTILITY_COMMAND_CNF *cnf)
+{
+ cnf->result.pmic_id = FT_MT6326;
+ cnf->status = FT_CNF_OK;
+}
+
+void ft_util_set_led_light_level(FT_UTILITY_COMMAND_REQ *req, FT_UTILITY_COMMAND_CNF *cnf)
+{
+#if(!defined(__L1_STANDALONE__))
+ kal_uint8 level=0;
+ level=req->cmd.LEDLevel.led_light_level;
+ if(custom_cfg_gpio_set_level(GPIO_DEV_LED_KEY,level))
+ cnf->status = FT_CNF_OK;
+ else
+ cnf->status = FT_CNF_FAIL;
+#endif
+}
+void ft_util_set_vibrator_onoff(FT_UTILITY_COMMAND_REQ *req, FT_UTILITY_COMMAND_CNF *cnf)
+{
+#if(!defined(__L1_STANDALONE__))
+ kal_uint8 onoff=0;
+ onoff=req->cmd.VibrOnOff.onoff;
+ if(custom_cfg_gpio_set_level(GPIO_DEV_VIBRATOR,onoff))
+ cnf->status = FT_CNF_OK;
+ else
+ cnf->status = FT_CNF_FAIL;
+#endif
+}
+void ft_util_set_lcd_light_level(FT_UTILITY_COMMAND_REQ *req, FT_UTILITY_COMMAND_CNF *cnf)
+{
+#if(!defined(__L1_STANDALONE__))
+ kal_uint8 level=0;
+ kal_uint8 led_type;
+ level=req->cmd.LCDLevel.lcd_light_level;
+ led_type = req->cmd.LCDLevel.lcd_type;
+ if(level>5) level = 5;
+ if(led_type==0)
+ {
+ if(custom_cfg_gpio_set_level(GPIO_DEV_LED_MAINLCD,level))
+ cnf->status = FT_CNF_OK;
+ else
+ cnf->status = FT_CNF_FAIL;
+ }
+ else if(led_type==1)
+ {
+ if(custom_cfg_gpio_set_level(GPIO_DEV_LED_SUBLCD,level))
+ cnf->status = FT_CNF_OK;
+ else
+ cnf->status = FT_CNF_FAIL;
+
+ }
+#endif
+}
+#endif //#ifndef L1_SIM
+void ft_util_check_vers(FT_UTILITY_COMMAND_REQ *req, FT_UTILITY_COMMAND_CNF *cnf, peer_buff_struct **pp_peer_buff_ret)
+{
+ META_UTIL_CHECK_TARGET_VER_CNF_T *p_dt = NULL;
+ kal_uint16 pdu_length = 0;
+
+ // allocate peer buffer
+ if(NULL == (*pp_peer_buff_ret = construct_peer_buff(sizeof(META_UTIL_CHECK_TARGET_VER_CNF_T), 0, 0, TD_CTRL)))
+ {
+ cnf->status = FT_CNF_FAIL;
+ return;
+ }
+
+ p_dt = (META_UTIL_CHECK_TARGET_VER_CNF_T *)get_peer_buff_pdu(*pp_peer_buff_ret, &pdu_length);
+ kal_mem_set(p_dt, 0, sizeof(META_UTIL_CHECK_TARGET_VER_CNF_T));
+ p_dt->m_bCheckPass = KAL_TRUE;
+
+ if(req->cmd.m_rCheckMetaVerReq.m_eVerType == META_VERSION_META_DLL_UTIL_VER ||
+ req->cmd.m_rCheckMetaVerReq.m_eVerType == META_VERSION_USER_DEFINE)
+ {
+ // checkin
+ // main version first, if >, pass the check!, if < fail,
+ // if main version is the same, check minor version
+ // if minor version the same, check build number
+
+ if(req->cmd.m_rCheckMetaVerReq.m_u4MainVersion < FT_REQUIRED_META_DLL_MAIN_VER)
+ {
+ p_dt->m_bCheckPass = KAL_FALSE;
+ }
+ else if(req->cmd.m_rCheckMetaVerReq.m_u4MainVersion == FT_REQUIRED_META_DLL_MAIN_VER)
+ {
+ if(req->cmd.m_rCheckMetaVerReq.m_u4MinorVersion < FT_REQUIRED_META_DLL_MINOR_VER)
+ {
+ p_dt->m_bCheckPass = KAL_FALSE;
+ }
+ else if(req->cmd.m_rCheckMetaVerReq.m_u4MinorVersion == FT_REQUIRED_META_DLL_MINOR_VER)
+ {
+ if(req->cmd.m_rCheckMetaVerReq.m_u4BuildNum < FT_REQUIRED_META_DLL_BUILD_NUM)
+ p_dt->m_bCheckPass = KAL_FALSE;
+ }
+ }
+ // assign the target version information
+ p_dt->m_u4TargetMainVersion = FT_REQUIRED_META_DLL_MAIN_VER;
+ p_dt->m_u4TargetMinorVersion = FT_REQUIRED_META_DLL_MINOR_VER;
+ p_dt->m_u4TargetBuildNum = FT_REQUIRED_META_DLL_BUILD_NUM;
+ }
+ else // other type version check // so far, none, just assign version info to 0xFFFFFFFF
+ {
+ // in this case: version check pass
+ p_dt->m_u4TargetMainVersion = FT_REQUIRED_VERSION_UNKNOWN;
+ p_dt->m_u4TargetMinorVersion = FT_REQUIRED_VERSION_UNKNOWN;
+ p_dt->m_u4TargetBuildNum = FT_REQUIRED_VERSION_UNKNOWN;
+ }
+ cnf->status = FT_CNF_OK;
+}
+void ft_util_set_check_paras(FT_UTILITY_COMMAND_REQ *req, FT_UTILITY_COMMAND_CNF *cnf)
+{
+ cnf->status = FT_CNF_OK;
+}
+#ifndef L1_SIM /* xl1sim no power control */
+void ft_util_reboot_to_normal_mode(FT_UTILITY_COMMAND_REQ *req, FT_UTILITY_COMMAND_CNF *cnf)
+{
+ DCL_HANDLE handle;
+ handle=DclPW_Open(DCL_PW, FLAGS_NONE);
+ /* RCT_PDN2 bit1: make sure the the next boot is IDLE (normal mode) */
+ DclPW_Control(handle,PW_CMD_SET_SWITCH_TO_IDLE,NULL);
+ DclPW_Close(handle);
+ // enable watchdog timer
+ ft_util_watch_dog_start(req, cnf, NULL);
+}
+void ft_util_get_vpa_voltage_list(const FT_UTILITY_COMMAND_REQ *req, FT_UTILITY_COMMAND_CNF *cnf, peer_buff_struct **peer_buff_ret)
+{
+ DCL_HANDLE handle;
+ PMU_CTRL_VPA_GET_VOLTAGE_LIST voltageList;
+ handle=DclPMU_Open(DCL_PMU, FLAGS_NONE);
+ if(DclPMU_Control(handle, VPA_GET_VOLTAGE_LIST, (DCL_CTRL_DATA_T *)&voltageList) != STATUS_OK)
+ {
+ cnf->status = FT_CNF_FAIL;
+ }
+ else
+ {
+ cnf->status = FT_CNF_OK;
+ }
+ DclPMU_Close(handle);
+ if(cnf->status == FT_CNF_OK)
+ {
+ if( NULL != (*peer_buff_ret=construct_peer_buff(sizeof(FtUtilCmdCnfVpaVoltageList), 0, 0, TD_CTRL)) )
+ {
+ kal_uint32 i;
+ FtUtilCmdCnfVpaVoltageList * pdu_ptr = get_peer_buff_pdu( *peer_buff_ret, &((*peer_buff_ret)->pdu_len) );
+ if(pdu_ptr != NULL)
+ {
+ kal_mem_set(pdu_ptr, 0, sizeof(FtUtilCmdCnfVpaVoltageList));
+ for(i=0;i<voltageList.number;i++)
+ {
+ /******************************************************
+ * if the voltage is valid, pass the information to PC
+ *****************************************************/
+ if(voltageList.pVoltageList[i] != PMU_VOLT_INVALID)
+ {
+ pdu_ptr->voltageList[pdu_ptr->validNumber] = voltageList.pVoltageList[i];
+ pdu_ptr->registerValue[pdu_ptr->validNumber] = i;
+ pdu_ptr->validNumber++;
+ }
+ }
+ }
+ else
+ {
+ ASSERT(pdu_ptr);
+ }
+ }
+ else
+ {
+ ASSERT(0);
+ }
+ }
+}
+#endif //#ifndef L1_SIM
+#ifndef L1_SIM
+void FT_UtilityCommand(ilm_struct *ptrMsg) {
+
+ FT_UTILITY_COMMAND_REQ *p_req=(FT_UTILITY_COMMAND_REQ *)ptrMsg->local_para_ptr;
+ FT_UTILITY_COMMAND_CNF cnf;
+ peer_buff_struct *peer_buff_ret = NULL;
+
+ kal_mem_set(&cnf, '\0', sizeof(cnf));
+ cnf.type = p_req->type;
+ cnf.status = FT_CNF_FAIL;
+ peer_buff_ret = NULL;
+
+ switch(p_req->type) {
+ case FT_UTILCMD_CHECK_IF_FUNC_EXIST:
+ if(ft_util_check_if_func_exist(p_req, &cnf))
+ {
+ return;
+ }
+ break;
+ case FT_UTILCMD_CHECK_IF_ISP_SUPPORT:
+ ft_util_check_if_isp_support(&cnf);
+ break;
+ case FT_UTILCMD_ENABLE_WATCHDOG_TIMER:
+ ft_util_watch_dog_start(p_req, &cnf,peer_buff_ret);
+ break;
+ case FT_UTILCMD_CHECK_IF_ACOUSTIC16_SUPPORT:
+ cnf.status = FT_CNF_OK;
+ break;
+ case FT_UTILCMD_CHECK_IF_LOW_COST_SINGLE_BANK_FLASH:
+#ifdef _LOW_COST_SINGLE_BANK_FLASH_
+ cnf.status = FT_CNF_OK;
+#endif
+ break;
+ case FT_UTILCMD_QUERY_PMIC_ID:
+ ft_util_query_pmic_id(&cnf);
+ break;
+ case FT_UTILCMD_LED_LIGHT_LEVEL:
+ ft_util_set_led_light_level(p_req,&cnf);
+ break;
+ case FT_UTILCMD_VIBRATOR_ONOFF:
+ ft_util_set_vibrator_onoff(p_req,&cnf);
+ break;
+ case FT_UTILCMD_QUERY_LOCAL_TIME:
+ ft_util_query_rtc(&cnf);
+ break;
+ case FT_UTILCMD_CHECK_IF_DRC_SUPPORT:
+#if defined(DRC_ENABLED)
+ cnf.status = FT_CNF_OK;
+#endif
+ break;
+ case FT_UTILCMD_MAIN_SUB_LCD_LIGHT_LEVEL:
+ ft_util_set_lcd_light_level(p_req, &cnf);
+ break;
+ case FT_UTILCMD_CHECK_IF_ULC_FAT_SUPPORT:
+ ft_util_check_if_ulc_support(&cnf);
+ break;
+ case FT_UTILCMD_CHECK_IF_SMART_PHONE_MODEM_SUPPORT:
+ ft_util_check_if_smart_phone_modem_supported(&cnf);
+ break;
+ case FT_UTILCMD_CHECK_TARGET_META_REQUIRED_VERS:
+ ft_util_check_vers(p_req,&cnf,&peer_buff_ret);
+ break;
+ case FT_UTILCMD_SET_TARGET_CHECK_PARAS:
+ ft_util_set_check_paras(p_req,&cnf);
+ break;
+ case FT_UTILCMD_CHECK_IF_TARGET_NV_SEC_ON:
+ cnf.result.m_bNVSecOn = KAL_FALSE;
+ cnf.status = FT_CNF_OK;
+ break;
+ case FT_UTILCMD_REBOOT_TO_NORMAL_MODE:
+ ft_util_reboot_to_normal_mode(p_req, &cnf);
+ break;
+ case FT_UTILCMD_QUERY_TARGET_OPTION_INFO:
+ {
+ cnf.result.m_u4TargetOptionInfo = 0; // reset to 0
+#ifdef LIPTON_BB
+ cnf.result.m_u4TargetOptionInfo |= META_LIPTON_OPTION_ON; // 0x00000001
+#endif // #ifdef LIPTON_BB
+#ifdef __TC01__
+ cnf.result.m_u4TargetOptionInfo |= META_TC01_OPTION_ON; // 0x00000002
+#endif // #ifdef __TC01__
+#if defined(__UMTS_TDD128_MODE__) && defined(__AST_TL1_TDD__)
+ if(KAL_TRUE == TL1_IS_3G_TDD_EXIST())
+ {
+ cnf.result.m_u4TargetOptionInfo |= META_AST_TD_OPTION_ON; // 0x00000004
+ }
+#endif // #if defined(__UMTS_TDD128_MODE__) && defined(__AST_TL1_TDD__)
+ cnf.status = FT_CNF_OK;
+ break;
+ }
+ case FT_UTILCMD_QUERY_VPA_VOLTAGE_LIST:
+ {
+ ft_util_get_vpa_voltage_list(p_req, &cnf, &peer_buff_ret);
+ break;
+ }
+ case FT_UTILCMD_QUERY_DRIVE_AVAILABLE_FOR_FILE_SIZE:
+ {
+ cnf.status = FT_CNF_OK;
+ cnf.result.driveLetter = FT_GetAvailableDrive(p_req->cmd.requestedFileSize);
+ break;
+ }
+ case FT_UTILCMD_QUERY_MAX_CTRL_BUFFER_SIZE:
+ {
+ cnf.status = FT_CNF_OK;
+ /*
+ * prevent from customization error
+ */
+ if(ft_get_ctrlbuf_max_size() <= Custom_META_ControlBufferSize())
+ {
+ cnf.result.maxControlBufferSize = ft_get_ctrlbuf_max_size();
+ }
+ else
+ {
+ /*
+ * Keep the original performance
+ */
+ if(Custom_META_ControlBufferSize() < 2048)
+ {
+ cnf.result.maxControlBufferSize = 2048;
+ }
+ else
+ {
+ cnf.result.maxControlBufferSize = Custom_META_ControlBufferSize();
+ }
+ }
+ break;
+ }
+ case FT_UTILCMD_QUERY_ADC_MODULE_SUPPORT:
+ {
+ cnf.status = FT_CNF_OK;
+#if defined(DRV_ADC_NOT_EXIST)||defined(DRV_ADC_OFF)
+ cnf.result.module_support = KAL_FALSE;
+#else
+ cnf.result.module_support = KAL_TRUE;
+#endif // #if defined(DRV_ADC_NOT_EXIST)||defined(DRV_ADC_OFF)
+ break;
+ }
+ case FT_UTILCMD_QUERY_RTC_MODULE_SUPPORT:
+ {
+ cnf.status = FT_CNF_OK;
+#if defined(DRV_RTC_OFF)||defined(DRV_RTC_NOT_EXIST)
+ cnf.result.module_support = KAL_FALSE;
+#else
+ cnf.result.module_support = KAL_TRUE;
+#endif // #if defined(DRV_RTC_NOT_EXIST)||defined(DRV_RTC_OFF)
+ break;
+ }
+ case FT_UTILCMD_QUERY_META_MODE_TRACE:
+ {
+#if defined(__TST_META_MODE_TRACE_ENABLE__)
+ cnf.result.trace_mode = 0;
+ cnf.status = FT_CNF_OK;
+#else
+ cnf.status = FT_CNF_FAIL;
+#endif // #if defined(__TST_META_MODE_TRACE_ENABLE__)
+ break;
+ }
+ case FT_UTILCMD_ENABLE_META_MODE_TRACE:
+ {
+ cnf.status = FT_CNF_FAIL;
+ break;
+ }
+ case FT_UTILCMD_QUERY_MODEM_MODE:
+ {
+ kal_uint8 boot_mode = kal_query_boot_mode();
+ cnf.result.modem_mode = boot_mode;
+ cnf.status = FT_CNF_OK;
+ }
+ default:
+ break;
+ }
+ FT_UTIL_SendCnf(&cnf, peer_buff_ret);
+}
+#else //#ifndef L1_SIM
+void FT_UtilityCommand(ilm_struct *ptrMsg) {
+
+ FT_UTILITY_COMMAND_REQ *p_req=(FT_UTILITY_COMMAND_REQ *)ptrMsg->local_para_ptr;
+ FT_UTILITY_COMMAND_CNF cnf;
+ peer_buff_struct *peer_buff_ret = NULL;
+
+ kal_mem_set(&cnf, '\0', sizeof(cnf));
+ cnf.type = p_req->type;
+ cnf.status = FT_CNF_FAIL;
+ peer_buff_ret = NULL;
+
+ switch(p_req->type) {
+ case FT_UTILCMD_CHECK_IF_FUNC_EXIST:
+ if(ft_util_check_if_func_exist(p_req, &cnf))
+ {
+ return;
+ }
+ break;
+ case FT_UTILCMD_CHECK_IF_SMART_PHONE_MODEM_SUPPORT:
+ ft_util_check_if_smart_phone_modem_supported(&cnf);
+ break;
+ case FT_UTILCMD_CHECK_TARGET_META_REQUIRED_VERS:
+ ft_util_check_vers(p_req,&cnf,&peer_buff_ret);
+ break;
+ case FT_UTILCMD_SET_TARGET_CHECK_PARAS:
+ ft_util_set_check_paras(p_req,&cnf);
+ break;
+ case FT_UTILCMD_QUERY_MAX_CTRL_BUFFER_SIZE:
+ {
+ cnf.status = FT_CNF_OK;
+ cnf.result.maxControlBufferSize = ft_get_ctrlbuf_max_size();
+ break;
+ }
+ default:
+ break;
+ }
+ FT_UTIL_SendCnf(&cnf, peer_buff_ret);
+}
+#endif //#ifndef L1_SIM
+kal_uint32 FT_UtilCheckFunctionSupported(kal_uint32 query_op_code)
+{
+ kal_uint32 cnf_code;
+ if( FT_UTILCMD_END > query_op_code )
+ {
+ switch(query_op_code)
+ {
+ // obsolete
+ case FT_UTILCMD_BT_POWER_ON:
+ cnf_code = FT_CNF_FAIL;
+ break;
+ case FT_UTILCMD_QUERY_BT_WIFI_SINGLE_ANTENNA_CAP:
+ case FT_UTILCMD_SET_ANTENNA_PATH_TO_BT:
+ case FT_UTILCMD_SET_ANTENNA_PATH_TO_WIFI:
+ cnf_code = FT_CNF_FAIL;
+ break;
+ case FT_UTILCMD_QUERY_LIMITED_STATE:
+ {
+ cnf_code = FT_CNF_FAIL;
+ break;
+ }
+#if !defined(__TST_META_MODE_TRACE_ENABLE__)
+ case FT_UTILCMD_QUERY_META_MODE_TRACE:
+ case FT_UTILCMD_ENABLE_META_MODE_TRACE:
+ {
+ cnf_code = FT_CNF_FAIL;
+ break;
+ }
+#endif // #if !defined(__TST_META_MODE_TRACE_ENABLE__)
+ case FT_UTILCMD_RF_ITC_PCL:
+ {
+ cnf_code = FT_CNF_FAIL;
+ break;
+ }
+ default:
+ cnf_code = FT_CNF_OK;
+ break;
+ }
+ }
+ else
+ {
+ cnf_code = FT_CNF_FAIL;
+ }
+ return cnf_code;
+}
diff --git a/mcu/middleware/meta/ft/src/ft_fnc_wcdma.c b/mcu/middleware/meta/ft/src/ft_fnc_wcdma.c
new file mode 100644
index 0000000..2f5cc6c
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_fnc_wcdma.c
@@ -0,0 +1,351 @@
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * ft_fnc_wcdma.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * WCDMA Function
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+#if !defined(__UL1_TASK_DISABLE__)
+
+/*************************************************************************
+* Include Statements for KAL
+ *************************************************************************/
+
+#include "kal_public_defs.h" //MSBB change #include "stack_common.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_msgs.h"
+#include "md_sap.h"
+#include "svc_sap.h"
+#include "ft_msgid.h"
+
+#include "ul1tst_public.h"
+
+
+/*************************************************************************
+* Include Statements for MAUI
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_private.h"
+#include "ft_public.h"
+#include "ft_fnc_wcdma.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_config.h"
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+void FT_FtURfTestReq( ilm_struct *ptrMsg )
+{
+ ilm_struct urfMessage;
+ FT_CONSTRUCT_CC_MSG(ptrMsg, &urfMessage);
+ FT_SEND_MSG(MOD_FT, MOD_UL1, FT_UL1TST_SAP, MSG_ID_FT_TO_UL1TST, &urfMessage);
+}
+void FT_UL1TST_SEND_CNF_BACK(ilm_struct *ptrMsg_ul1tst)
+{
+ ft_urf_test_cnf_T *ptrMsg;
+ ptrMsg = (ft_urf_test_cnf_T *)ptrMsg_ul1tst->local_para_ptr;
+ if(ptrMsg->type == URF_TEST_CMD_CHECK_IF_FUNC_EXIST )
+ {
+ FT_UTILITY_COMMAND_CNF cnf;
+ kal_mem_set(&cnf, '\0', sizeof(cnf));
+ cnf.status = (ptrMsg->param.CheckIfFuncExist.result==1)?FT_CNF_OK:FT_CNF_FAIL;
+ cnf.result.CheckIfFuncExist.query_ft_msg_id = ptrMsg->header.ft_msg_id;
+ cnf.result.CheckIfFuncExist.query_op_code = ptrMsg->param.CheckIfFuncExist.query_op_code;
+ FT_UTIL_SendCnf(&cnf, NULL);
+ return;
+ }
+ FT_SEND_MSG_TO_PC(ptrMsg_ul1tst);
+}
+void FT_UL1RfCheckFunctionSuppported(kal_uint32 query_op_code)
+{
+ ilm_struct ilm_ptr;
+ ft_urf_test_req_T *ptrMsg;
+ FT_ALLOC_OTHER_CC_MSG( &ilm_ptr, sizeof(ft_urf_test_req_T) );
+ // local parameter
+ ptrMsg = (ft_urf_test_req_T *)ilm_ptr.local_para_ptr;
+ ptrMsg->header.ft_msg_id = FT_URF_TEST_REQ_ID;
+ ptrMsg->type = URF_TEST_CMD_CHECK_IF_FUNC_EXIST;
+ ptrMsg->param.query_op_code = (URfTestCmdType)query_op_code;
+ FT_SEND_MSG(MOD_FT, MOD_UL1, FT_UL1TST_SAP, MSG_ID_FT_TO_UL1TST, &ilm_ptr);
+}
+#endif // #ifndef (__UL1_TASK_DISABLE__)
+#endif // #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
diff --git a/mcu/middleware/meta/ft/src/ft_main.c b/mcu/middleware/meta/ft/src/ft_main.c
new file mode 100644
index 0000000..1b505a5
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_main.c
@@ -0,0 +1,1887 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * ft_main.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*************************************************************************
+ * Include Statements for KAL
+ *************************************************************************/
+#include "kal_public_defs.h" //MSBB change #include "stack_common.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_msgs.h"
+#ifndef L1_SIM
+#include "task_config.h"
+#endif // #ifndef L1_SIM
+#include "syscomp_config.h"
+#include "md_mw_sap.h"
+#include "mmrf_msgid.h"
+#include "mmrf_msg_interface.h"
+#include "svc_sap.h"
+#include "ft_msgid.h"
+//#include "wndrv_msgid.h"
+#include "l1hisr_msgid.h"
+#include "sim_public_msgid.h"
+#ifdef L1_SIM
+#include "simul_public.h"
+#endif
+/*************************************************************************
+ * System Service header
+ *************************************************************************/
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+#include "kal_public_defs.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_config.h"
+//MSBB remove #include "fctycomp_config.h"
+#include "stdio.h"
+#ifndef L1_SIM
+#include "init.h"
+#endif // #ifndef L1_SIM
+/*************************************************************************
+ * NVRAM header
+ *************************************************************************/
+#ifndef L1_SIM
+#include "nvram_data_items.h"
+#include "ft_nvram_def.h"
+#include "nvram_struct.h"
+#include "nvram_enums.h"
+#include "nvram_msgid.h"
+#endif // #ifndef L1_SIM
+/*************************************************************************
+ * Custom header
+ *************************************************************************/
+#ifndef L1_SIM
+#include "custom_nvram_config.h"
+#include "custom_equipment.h"
+#endif // #ifndef L1_SIM
+/*************************************************************************
+ * HAL header
+ *************************************************************************/
+#ifndef L1_SIM
+#if !defined(__L1_STANDALONE__)
+#include "device.h" // for GPIO_DEV_LED_MAINLCD and LED_LIGHT_LEVEL5
+#endif
+#endif // #ifndef L1_SIM
+/*************************************************************************
+ * FT header
+ *************************************************************************/
+#include "ft_msg.h"
+#include "ft_mem.h"
+#include "ft_private.h"
+#ifndef L1_SIM
+#include "ft_customize.h"
+#endif // #ifndef L1_SIM
+#include "ft_fnc_l1rf.h"
+#ifndef L1_SIM
+#include "ft_fnc_misc.h"
+#include "ft_fnc_misc_ex.h"
+#include "ft_fnc_custom.h"
+#include "ft_fnc_aux.h"
+#endif // #ifndef L1_SIM
+#include "ft_fnc_wcdma.h"
+#include "ft_fnc_tdscdma.h"
+#ifndef L1_SIM
+#include "ft_fnc_fat.h"
+#include "ft_fnc_nvram.h"
+#endif // #ifndef L1_SIM
+#include "ft_fnc_lterf.h"
+#include "ft_fnc_mmrf.h"
+#include "ft_fnc_nrf.h"
+#include "ft_fnc_l4.h"
+#ifndef L1_SIM
+#include "ft_fnc_c2krf.h"
+fp_nvram_read_handler_t FT_ReadFrom_NVRAM = FT_Nvram_ReadNvramHandler;
+fp_nvram_write_handler_t FT_WriteTo_NVRAM = FT_Nvram_WriteNvramHandler;
+fp_nvram_read_confirm_handler_t FT_ReadFrom_NVRAM_CNF = FT_Nvram_ReadNvramConfirmHandler;
+fp_nvram_write_confirm_handler_t FT_WriteTo_NVRAM_CNF = FT_Nvram_WriteNvramConfirmHandler;
+#endif // #ifndef L1_SIM
+/*************************************************************************
+ * SIM header
+ *************************************************************************/
+#ifndef L1_SIM
+#include "ps2sim_struct.h"
+#endif // #ifndef L1_SIM
+/*************************************************************************
+ * SLA header
+ *************************************************************************/
+#include "meta_sec_support.h"
+/*************************************************************************
+ * Function declaration
+ *************************************************************************/
+void FT_Task(task_entry_struct * task_entry_ptr);
+kal_bool FT_Init(void);
+extern void L1T_DispatchReports(void);
+kal_uint16 ft_gl_token=0;
+kal_uint16 ft_gl_rf_token;
+kal_uint16 ft_gl_l4aud_token;
+kal_uint16 ft_gl_l4aud_ind_token;
+kal_uint16 ft_gl_nvram_token;
+kal_uint16 ft_gl_customer_token;
+kal_uint16 ft_gl_l4aud_current_volume = 3;
+peer_buff_struct *ft_gl_l4aud_peer_buf = NULL;
+extern kal_uint8 ft_gl_sim_cmd_type; // sim cmd type from ft_fnc_misc.c
+
+kal_char g_FT_debug_buf[128];
+kal_uint16 FT_GetGolbalToken(void)
+{
+ return ft_gl_token;
+}
+/*************************************************************************
+ * FUNCTION
+ * ft_create
+ *
+ * DESCRIPTION
+ *
+ * PARAMETERS
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ *
+ *************************************************************************/
+kal_bool ft_create(comptask_handler_struct **handle)
+{
+ static const comptask_handler_struct ft_handler_info =
+ {
+ FT_Task, /* task entry function */
+ FT_Init, /* task initialization function */
+ NULL /* task configuration function */
+ };
+
+ *handle = (comptask_handler_struct *)&ft_handler_info;
+ return KAL_TRUE;
+}
+
+#ifdef L1_SIM
+extern kal_status gs_read_message(module_type, void *, kal_uint16, kal_bool);
+#endif
+
+
+/* ------------------------------------------------------------------------- */
+
+
+/*******************************************************************************
+ * FUNCTION
+ * FT_InitCalibrationData
+ *
+ * DESCRIPTION
+ * The calibration data fetch in power-on stage
+ *
+ * CALLS
+ *
+ * PARAMETERS
+ * None
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ * None
+ *******************************************************************************/
+void FT_InitCalibrationData(task_entry_struct *task_entry_ptr)
+{
+#ifndef L1_SIM
+ nvram_startup_req_struct *ptrMsg;
+ ptrMsg = (nvram_startup_req_struct*)construct_local_para(sizeof(nvram_startup_req_struct), TD_CTRL);
+ if(NULL == ptrMsg)
+ {
+ ASSERT(0);
+ }
+ ptrMsg->poweron_mode=NVRAM_POWERON_NORMAL;
+ msg_send5(MOD_FT, MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_STARTUP_REQ, (local_para_struct*)ptrMsg);
+#endif // #ifndef L1_SIM
+}
+
+/*******************************************************************************
+*
+* Local Functions
+*
+*******************************************************************************/
+#ifdef L1_CATCHER
+void Trc_Init(void);
+#endif
+static void FT_Initialization(task_entry_struct *task_entry_ptr)
+{
+ // active module ID in task_active_module_g
+ kal_set_active_module_id(MOD_FT);
+#ifndef L1_SIM
+ FtInitMemoryPool();
+ // custom init
+ FT_CustomInit();
+#if !defined(__L1_STANDALONE__)
+ // enable main LCD backlight
+ custom_cfg_gpio_set_level(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
+#endif // #if !defined(__L1_STANDALONE__)
+#endif // #ifndef L1_SIM
+#ifdef L1_CATCHER
+ // L1 logging initialization
+ Trc_Init();
+#endif // #ifdef L1_CATCHER
+ FT_InitCalibrationData(task_entry_ptr);
+ FT_InitFtData();
+#if ( defined(__HSDPA_SUPPORT__) || defined(__HSUPA_SUPPORT__) ) && defined(__MODEM_CARD__)
+ /// clear USB download RTC bit for HSPA data card project
+ INT_SetCmdToSys(SYS_CMD_CLR_DL_FLAG);
+#endif // #if ( defined(__HSDPA_SUPPORT__) || defined(__HSUPA_SUPPORT__) ) && defined(__MODEM_CARD__)
+}
+
+extern kal_bool Custom_META_IsSecureOperation(ilm_struct* ptrMsg);
+
+#ifndef L1_SIM
+void FT_DispatchMessage(ilm_struct* ptrMsg)
+{
+ FT_H *ft_header;
+ ft_header=(FT_H *)(ptrMsg->local_para_ptr);
+ /* process messages with specific message ID */
+ switch(ptrMsg->msg_id)
+ {
+ case MSG_ID_FT_CAL_DATA_ADD_ONE_REQ:
+ {
+ FT_Misc_CalDataInTargetAddOneRequestHandler(ptrMsg);
+ return;
+ }
+ case MSG_ID_MMRF_UPDATE_RUNTIME_CNF:
+ {
+ FT_Mmrf_UpdateRuntimeConfirmHandler(ptrMsg);
+ return;
+ }
+ default:
+ break;
+ }
+ /* process message with specific source module ID */
+#if !defined(__DHL_MODULE__)
+ if(ptrMsg->src_mod_id == MOD_TST_READER)
+#else
+ if(ptrMsg->src_mod_id == MOD_DHL)
+#endif // #if !defined(__DHL_MODULE__)
+ {
+ ft_gl_token=ft_header->token;
+#ifdef __META_SLA_ENHANCEMENT__
+ if (FT_MetaSLA_Is_Enabled() && !MetaSLA_Is_Verified())
+ {
+ if(KAL_TRUE == Custom_META_IsSecureOperation(ptrMsg))
+ {
+ dhl_print(TRACE_INFO, DHL_USER_FLAG_NONE, MOD_FT,"[SLA] msg id:%d is dropped since SLA is not verified", ft_header->ft_msg_id);
+ return;
+ }
+ }
+#endif // #ifdef __META_SLA_ENHANCEMENT__
+
+ switch (ft_header->ft_msg_id)
+ {
+ /********************************************
+ * L1 RF test functionality
+ ********************************************/
+#if !defined(L1_NOT_PRESENT) && !defined(__L1_TASK_DISABLE__) && !defined(DUMMYL1)
+ case FT_RF_TEST_REQ_ID:
+ {
+ FT_Rf_Operation(ptrMsg);
+ break;
+ }
+#endif // #if !defined(__LTE_SM__)&&defined(__MTK_GL1_GSM__)
+ /********************************************
+ * BB test functionality
+ ********************************************/
+ case FT_REG_READ_ID:
+ {
+ FT_FtRegisterRead((ft_RegisterRead_req_T*)ptrMsg->local_para_ptr,FT_BaseBandReg);
+ break;
+ }
+ case FT_REG_WRITE_ID:
+ {
+ FT_FtRegisterWrite((ft_RegisterWrite_req_T*)ptrMsg->local_para_ptr,FT_BaseBandReg);
+ break;
+ }
+ case FT_PMIC_REG_READ_ID:
+ {
+ FT_FtPMICRegisterRead((ft_PMICRegisterRead_req_T*)ptrMsg->local_para_ptr,FT_PMICReg);
+ break;
+ }
+ case FT_PMIC_REG_WRITE_ID:
+ {
+ FT_FtPMICRegisterWrite((ft_PMICRegisterWrite_req_T*)ptrMsg->local_para_ptr,FT_PMICReg);
+ break;
+ }
+ case FT_ADC_GETMEADATA_ID:
+ {
+ FT_FtADC_GetMeaData((ft_FtADC_GetMeaData_req_T*)ptrMsg->local_para_ptr);
+ break;
+ }
+ /********************************************
+ * UL1 RF test functionality
+ ********************************************/
+#if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+#if !defined(__UL1_TASK_DISABLE__)
+ case FT_URF_TEST_REQ_ID:
+ {
+ FT_FtURfTestReq( ptrMsg );
+ break;
+ }
+#endif // #if !defined(__UL1_TASK_DISABLE__)
+#endif // #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+ /********************************************
+ *
+ * NVRAM functionality
+ *
+ ********************************************/
+ case FT_NVRAM_GET_DISK_INFO_REQ_ID:
+ {
+ ilm_struct ilm_ptr;
+ FT_NVRAM_GET_DISK_INFO_CNF *ptr_loc_para;
+ // store nvram token id, because any of NVRAM command won't return immediately.
+ ft_gl_nvram_token = ft_header->token;
+ FT_ALLOC_OTHER_MSG(&ilm_ptr,sizeof(FT_NVRAM_GET_DISK_INFO_CNF));
+ ptr_loc_para=(FT_NVRAM_GET_DISK_INFO_CNF *)(ilm_ptr.local_para_ptr);
+ /* if ptr_ilm != NULL*/
+ ptr_loc_para->header.ft_msg_id=FT_NVRAM_GET_DISK_INFO_CNF_ID;
+#if defined(__MOD_NVRAM__)
+ if(nvram_get_disk_file_info(&(ptr_loc_para->diskfilesize), &(ptr_loc_para->freespace), &(ptr_loc_para->overhead))) {
+ ptr_loc_para->status = 0;
+ }
+ else {
+ ptr_loc_para->diskfilesize = 0;
+ ptr_loc_para->freespace = 0;
+ ptr_loc_para->overhead = 0;
+ ptr_loc_para->status = 1;
+ }
+#endif // #if defined(__MOD_NVRAM__)
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+ break;
+ }
+ case FT_NVRAM_RESET_REQ_ID:
+ {
+ ilm_struct ptr_ilm;
+ nvram_reset_req_struct *ptr_loc_para;
+ // store nvram token id, because any of NVRAM command won't return immediately.
+ ft_gl_nvram_token = ft_header->token;
+ FT_ALLOC_OTHER_MSG(&ptr_ilm,sizeof( nvram_reset_req_struct));
+ /* if ptr_ilm != NULL*/
+ ptr_loc_para=(nvram_reset_req_struct *)(ptr_ilm.local_para_ptr);
+
+ if( ((ft_nvram_reset_req_struct_T*)ptrMsg->local_para_ptr)->reset_category == 0) // reset all
+ {
+
+ ptr_loc_para->reset_category= NVRAM_RESET_ALL;
+ }
+ else if( ((ft_nvram_reset_req_struct_T*)ptrMsg->local_para_ptr)->reset_category == 3) // reset certain
+ {
+
+ ptr_loc_para->reset_category= NVRAM_RESET_CERTAIN;
+ }
+ else if( ((ft_nvram_reset_req_struct_T*)ptrMsg->local_para_ptr)->reset_category == 4) // reset factory
+ {
+ ptr_loc_para->reset_category= NVRAM_RESET_FACTORY;
+ }
+ else
+ {
+ destroy_ilm(&ptr_ilm);
+ break; // directly break!, Let PC side timeout!
+ }
+ ptr_loc_para->app_id = NVRAM_APP_RESERVED;
+ ptr_loc_para->LID=((ft_nvram_reset_req_struct_T*)ptrMsg->local_para_ptr)->file_idx;
+ FT_SEND_MSG(MOD_FT, MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_RESET_REQ, &ptr_ilm);
+ break;
+ }
+ case FT_NVRAM_READ_REQ_ID:
+ {
+ ft_gl_nvram_token = ft_header->token;
+ FT_ReadFrom_NVRAM((ft_nvram_read_req_struct_T*)ptrMsg->local_para_ptr, 0);
+ break;
+ }
+ case FT_NVRAM_WRITE_REQ_ID:
+ {
+ ft_gl_nvram_token = ft_header->token;
+ FT_WriteTo_NVRAM((ft_nvram_write_req_struct_T*)ptrMsg->local_para_ptr, ptrMsg->peer_buff_ptr, 0);
+ break;
+ }
+ case FT_NVRAM_LOCK_REQ_ID:
+ {
+ ilm_struct ptr_ilm;
+ nvram_set_lock_req_struct *ptr_loc_para;
+ ft_nvram_lock_req_struct_T *ptr_msg = (ft_nvram_lock_req_struct_T *)(ptrMsg->local_para_ptr);
+ // store nvram token id, because NVRAM command won't return immediately.
+ ft_gl_nvram_token = ft_header->token;
+ FT_ALLOC_OTHER_MSG(&ptr_ilm, sizeof(nvram_set_lock_req_struct));
+ /* if ptr_ilm != NULL*/
+ ptr_loc_para=(nvram_set_lock_req_struct *)(ptr_ilm.local_para_ptr);
+ // if OTP lock or NVRAM lock
+ if( NVRAM_LOCK_OTP == ptr_msg->lock_en ) {
+ ptr_loc_para->lock_en = NVRAM_LOCK_OTP;
+ }
+ else {
+ ptr_loc_para->lock_en = NVRAM_LOCK_ENABLE;
+ }
+ FT_SEND_MSG(MOD_FT, MOD_NVRAM, PS_NVRAM_SAP, MSG_ID_NVRAM_SET_LOCK_REQ, &ptr_ilm);
+ break;
+ }
+ /********************************************
+ *
+ * FAT functionality
+ *
+ ********************************************/
+ case FT_FAT_OPERATION_ID:
+ {
+ FT_FAT_Operation((FT_FAT_OPERATION *)ptrMsg->local_para_ptr, ptrMsg->peer_buff_ptr);
+ break;
+ }
+ /********************************************
+ *
+ * Version Info functionality
+ *
+ ********************************************/
+ case FT_VER_INFO_REQ_ID:
+ {
+ FT_GetVersionInfo();
+ break;
+ }
+ /********************************************
+ *
+ * FT task test alive
+ *
+ ********************************************/
+ case FT_IS_ALIVE_REQ_ID:
+ {
+ FT_TestAlive();
+ break;
+ }
+ /********************************************
+ *
+ * FT task Power Off
+ *
+ ********************************************/
+ case FT_POWER_OFF_REQ_ID:
+ {
+ FT_PowerOff();
+ break;
+ }
+ /********************************************
+ *
+ * FT task utility command
+ *
+ ********************************************/
+ case FT_UTILITY_COMMAND_REQ_ID:
+ {
+ FT_UtilityCommand(ptrMsg);
+ break;
+ }
+ /********************************************
+ *
+ * Misc utility command
+ *
+ ********************************************/
+ case FT_MISC_CMD_REQ_ID:
+ {
+ FT_MISC_Operation(ptrMsg);
+ break;
+ }
+ /********************************************
+ *
+ * Misc EX utility command
+ *
+ ********************************************/
+ case FT_MISC_EX_CMD_REQ_ID:
+ {
+ FT_MISC_EX_Operation(ptrMsg);
+ break;
+ }
+ case FT_CUSTOM_REQ_ID:
+ {
+ // send message to FTC task
+ ft_gl_customer_token = ft_header->token;
+ FT_Custom_Operation(ptrMsg);
+ break;
+ }
+#if defined(__UMTS_TDD128_MODE__) && defined(__AST_TL1_TDD__)
+ case FT_AUX_REQ_ID:
+ {
+ if(KAL_TRUE == TL1_IS_3G_TDD_EXIST()) //20130206
+ {
+ // send message to FTA task
+ ft_gl_customer_token = ft_header->token;
+ FT_Aux_Operation(ptrMsg);
+ }
+ else
+ {
+ sprintf(g_FT_debug_buf, "[FT_DispatchMessage][FT_AUX_REQ_ID] HW TDD does not exist.");
+ tst_sys_trace(g_FT_debug_buf);
+ }
+ break;
+ }
+#endif // #if defined(__UMTS_TDD128_MODE__) && defined(__AST_TL1_TDD__)
+#if defined(__LTE_RAT__) || defined(L1_SIM)
+ case FT_ERF_TEST_REQ_ID:
+ {
+ FT_Erf_Operation(ptrMsg);
+ break;
+ }
+ case FT_PHY_TOOL_REQ_ID:
+ {
+ FT_PhyTool_Operation(ptrMsg);
+ break;
+ }
+#endif // #if defined(__LTE_RAT__)
+
+#if defined(__C2K_RAT__)
+ case FT_CRF_TEST_REQ_ID:
+ {
+ FT_Crf_Operation(ptrMsg);
+ break;
+ }
+#endif // #if defined(__C2K_RAT__)
+
+ case FT_MMRF_TEST_REQ_ID:
+ {
+ FT_Mmrf_Operation(ptrMsg);
+ break;
+ }
+
+ case FT_NRF_TEST_REQ_ID:
+ {
+ FT_Nrf_Operation(ptrMsg);
+ break;
+ }
+#if !defined(__L4_TASK_DISABLE__) && !defined(L4_NOT_PRESENT) || defined(DUMMY_PROTOCOL)
+ case FT_L4_ATCMD_REQ_ID:
+ {
+ FT_L4_Operation(ptrMsg);
+ break;
+ }
+#endif // #if !defined(__L4_TASK_DISABLE__) && !defined(L4_NOT_PRESENT)
+
+ case FT_GET_SLA_STATUS_REQ_ID:
+ {
+ FT_GetSlaStatus();
+ break;
+ }
+
+ case FT_CHECK_SLA_VER_REQ_ID:
+ {
+ FT_CheckSlaVer((FT_CHECK_SLA_VER_REQ *)ptrMsg->local_para_ptr);
+ break;
+ }
+
+ case FT_GET_SLA_PARA_REQ_ID:
+ {
+ FT_GetSlaPara();
+ break;
+ }
+
+ case FT_VERIFY_SLA_RND_REQ_ID:
+ {
+ FT_VerifySla((FT_VERIFY_SLA_RND_REQ *)ptrMsg->local_para_ptr);
+ break;
+ }
+
+ default:
+ {
+ dhl_print(TRACE_INFO, DHL_USER_FLAG_NONE, MOD_FT,"[SLA] unknown msg id:%d", ft_header->ft_msg_id);
+ FT_SendDeniedMsgIdCnf(ft_header->ft_msg_id, FT_CNF_NOT_SUPPORTED);
+ break;
+ }
+ }
+ }
+ else if( (ptrMsg->src_mod_id == MOD_FTC) )
+ {
+ ft_gl_token = ft_gl_customer_token;
+ FT_Handle_FTC_CNF(ptrMsg);
+ ptrMsg->peer_buff_ptr=NULL; /* make sure the TST will release the mem*/
+ }
+
+#if defined(__UMTS_TDD128_MODE__) && defined(__AST_TL1_TDD__)
+ else if( (ptrMsg->src_mod_id == MOD_FTA) )
+ {
+ ft_gl_token = ft_gl_customer_token;
+ FT_Handle_FTA_CNF(ptrMsg);
+ ptrMsg->peer_buff_ptr=NULL; /* make sure the TST will release the mem*/
+ }
+#endif // #if defined(__UMTS_TDD128_MODE__) && defined(__AST_TL1_TDD__)
+#if defined(__MOD_NVRAM__)
+ else if( KAL_TRUE == FT_Nvram_IsModNvramRespnose(ptrMsg) )
+ {
+ switch (ptrMsg->msg_id)
+ {
+ case MSG_ID_NVRAM_WRITE_CNF:
+ {
+ nvram_write_cnf_struct* msg_ptr = NULL;
+ ft_gl_token = ft_gl_nvram_token;
+ msg_ptr=(nvram_write_cnf_struct*)ptrMsg->local_para_ptr;
+ /* Check MMRF runtime update */
+ if( KAL_FALSE == FT_Mmrf_PollUpdateRuntimeReady() )
+ {
+ hold_local_para(ptrMsg->local_para_ptr);
+ FT_SEND_MSG(MOD_FT, MOD_FT, PS_NVRAM_SAP, MSG_ID_NVRAM_WRITE_CNF, ptrMsg);
+ break;
+ }
+ FT_WriteTo_NVRAM_CNF(msg_ptr);
+ break;
+ }
+ case MSG_ID_NVRAM_RESET_CNF:
+ {
+ nvram_reset_cnf_struct* msg_ptr;
+ ilm_struct ilm_ptr;
+ ft_nvram_reset_cnf_struct_T* pMsg;
+ ft_gl_token = ft_gl_nvram_token;
+ msg_ptr=(nvram_reset_cnf_struct*)ptrMsg->local_para_ptr;
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(ft_nvram_reset_cnf_struct_T));
+ pMsg=(ft_nvram_reset_cnf_struct_T*)ilm_ptr.local_para_ptr;
+ pMsg->header.ft_msg_id=FT_NVRAM_RESET_CNF_ID;
+ pMsg->status = msg_ptr->result;
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+ break;
+ }
+ case MSG_ID_NVRAM_SET_LOCK_CNF:
+ {
+ nvram_set_lock_cnf_struct* msg_ptr;
+ ilm_struct ilm_ptr;
+ ft_nvram_lock_cnf_struct_T* pMsg;
+ ft_gl_token = ft_gl_nvram_token;
+ msg_ptr=(nvram_set_lock_cnf_struct*)ptrMsg->local_para_ptr;
+ FT_ALLOC_MSG(&ilm_ptr, sizeof(ft_nvram_lock_cnf_struct_T));
+ pMsg=(ft_nvram_lock_cnf_struct_T*)ilm_ptr.local_para_ptr;
+ pMsg->header.ft_msg_id=FT_NVRAM_LOCK_CNF_ID;
+ pMsg->status = msg_ptr->result;
+ FT_SEND_MSG_TO_PC(&ilm_ptr);
+ break;
+ }
+#if defined(__MTK_INTERNAL__)
+ case MSG_ID_NVRAM_WRITE_IMEI_CNF:
+ {
+ nvram_write_imei_cnf_struct* msg_ptr;
+ FT_MISC_CNF misc_cnf;
+ msg_ptr=(nvram_write_imei_cnf_struct*)ptrMsg->local_para_ptr;
+ misc_cnf.type = FT_MISC_OP_SET_IMEI_VALUE;
+ if(msg_ptr->result == NVRAM_ERRNO_SUCCESS)
+ {
+ misc_cnf.result.m_u2RecordIndex = msg_ptr->record_index;
+ misc_cnf.status = FT_CNF_OK;
+ }
+ else
+ {
+ misc_cnf.result.m_u2RecordIndex = msg_ptr->result;
+ misc_cnf.status = FT_CNF_FAIL;
+ }
+ FT_MISC_SendCnf(&misc_cnf, NULL);
+ break;
+ }
+#endif //#if defined(__MTK_INTERNAL__)
+ case MSG_ID_NVRAM_SDS_CNF:
+ case MSG_ID_NVRAM_BIN_REGION_CNF:
+ {
+ FT_MiscEx_NvramConfirmHandler(ptrMsg);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+#endif // end of #if defined(__MOD_NVRAM__)
+#if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+#if !defined(__UL1_TASK_DISABLE__)
+ else if( (ptrMsg->src_mod_id == MOD_UL1) )
+ {
+ FT_UL1TST_SEND_CNF_BACK(ptrMsg);
+ }
+#endif // #if !defined(__UL1_TASK_DISABLE__)
+#endif // #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+#if !defined(L1_NOT_PRESENT) && !defined(__L1_TASK_DISABLE__) && !defined(DUMMYL1)
+ else if( (ptrMsg->src_mod_id == MOD_L1) )
+ {
+ FT_Rf_ConfirmHandler(ptrMsg);
+ }
+#endif // #if !defined(L1_NOT_PRESENT) && !defined(__L1_TASK_DISABLE__) && !defined(DUMMYL1)
+#ifndef SIM_NOT_PRESENT
+ else if( (ptrMsg->src_mod_id == MOD_SIM) && (ft_gl_sim_cmd_type != FT_MISC_OP_CHECK_GEMINI_PLUS_SIM_INSERTED))
+ {
+ switch (ptrMsg->msg_id)
+ {
+ case MSG_ID_SIM_RESET_CNF:
+ {
+ FT_MISC_CNF misc_cnf;
+ sim_reset_cnf_struct *msg_ptr;
+ msg_ptr=(sim_reset_cnf_struct*)ptrMsg->local_para_ptr;
+ misc_cnf.type = FT_MISC_OP_CHECK_SIM1_INSERTED;
+ misc_cnf.result.m_u1SIMInserted = (kal_bool)msg_ptr->is_sim_inserted; // get SIM inserted status here. 1:insert , 0: not insert
+ misc_cnf.status = FT_CNF_OK;
+ FT_MISC_SendCnf(&misc_cnf, NULL);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+#ifdef __GEMINI__
+ else if((ptrMsg->src_mod_id == MOD_SIM_2) && (ft_gl_sim_cmd_type != FT_MISC_OP_CHECK_GEMINI_PLUS_SIM_INSERTED))
+ {
+ switch (ptrMsg->msg_id)
+ {
+ case MSG_ID_SIM_RESET_CNF:
+ {
+ FT_MISC_CNF misc_cnf;
+ sim_reset_cnf_struct *msg_ptr;
+ msg_ptr=(sim_reset_cnf_struct*)ptrMsg->local_para_ptr;
+ misc_cnf.type = FT_MISC_OP_CHECK_SIM2_INSERTED;
+ misc_cnf.result.m_u1SIMInserted = (kal_bool)msg_ptr->is_sim_inserted; // get SIM inserted status here. 1:insert , 0: not insert
+ misc_cnf.status = FT_CNF_OK;
+ FT_MISC_SendCnf(&misc_cnf, NULL);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+#endif // __GEMINI__
+#ifdef GEMINI_PLUS
+ else if((ptrMsg->src_mod_id >= MOD_SIM) && (ptrMsg->src_mod_id < MOD_SIM + GEMINI_PLUS) &&
+ (ft_gl_sim_cmd_type == FT_MISC_OP_CHECK_GEMINI_PLUS_SIM_INSERTED))
+ {
+ switch (ptrMsg->msg_id)
+ {
+ case MSG_ID_SIM_RESET_CNF:
+ {
+ FT_MISC_CNF misc_cnf;
+ sim_reset_cnf_struct *msg_ptr;
+ msg_ptr=(sim_reset_cnf_struct*)ptrMsg->local_para_ptr;
+ misc_cnf.type = FT_MISC_OP_CHECK_GEMINI_PLUS_SIM_INSERTED;
+ misc_cnf.result.m_u1SIMInserted = (kal_bool)msg_ptr->is_sim_inserted; // get SIM inserted status here. 1:insert , 0: not insert
+ misc_cnf.status = FT_CNF_OK;
+ FT_MISC_SendCnf(&misc_cnf, NULL);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+#endif // GEMINI_PLUS
+#endif // SIM_NOT_PRESENT
+#if defined(__LTE_RAT__)
+ else if( MOD_EL1== ptrMsg->src_mod_id )
+ {
+ FT_Erf_ConfirmHandler(ptrMsg);
+ }
+#endif // #if defined(__LTE_RAT__)
+
+#if defined(__C2K_RAT__)
+ else if( MOD_CL1TST == ptrMsg->src_mod_id )
+ {
+ FT_Crf_ConfirmHandler(ptrMsg);
+ }
+#endif // #if defined(__C2K_RAT__)
+
+ else if( MOD_MMRF_XL1TST == ptrMsg->src_mod_id )
+ {
+ FT_Mmrf_ConfirmHandler(ptrMsg);
+ }
+
+#if defined(__MD97__)
+ else if( MOD_NL1 == ptrMsg->src_mod_id )
+ {
+ FT_Nrf_ConfirmHandler(ptrMsg);
+ }
+#endif // #if !defined(__MD97__)
+
+#if !defined(__L4_TASK_DISABLE__) && !defined(L4_NOT_PRESENT) || defined(DUMMY_PROTOCOL)
+ else if( MOD_L4C == ptrMsg->src_mod_id )
+ {
+ FT_L4_Operation(ptrMsg);
+ }
+#endif // #if !defined(__L4_TASK_DISABLE__) && !defined(L4_NOT_PRESENT)
+
+}
+#else
+void FT_DispatchMessage(ilm_struct* ptrMsg)
+{
+ FT_H *ft_header;
+ ft_header=(FT_H *)(ptrMsg->local_para_ptr);
+ /* process messages with specific message ID */
+ switch(ptrMsg->msg_id)
+ {
+ case MSG_ID_MMRF_UPDATE_RUNTIME_CNF:
+ {
+ FT_Mmrf_UpdateRuntimeConfirmHandler(ptrMsg);
+ return;
+ }
+ default:
+ break;
+ }
+ /* process message with specific source module ID */
+#if !defined(__DHL_MODULE__)
+ if(ptrMsg->src_mod_id == MOD_TST_READER)
+#else
+ if(ptrMsg->src_mod_id == MOD_DHL)
+#endif // #if !defined(__DHL_MODULE__)
+ {
+ ft_gl_token=ft_header->token;
+ switch (ft_header->ft_msg_id)
+ {
+ /********************************************
+ * L1 RF test functionality
+ ********************************************/
+#if !defined(L1_NOT_PRESENT) && !defined(__L1_TASK_DISABLE__) && !defined(DUMMYL1)
+ case FT_RF_TEST_REQ_ID:
+ {
+ FT_Rf_Operation(ptrMsg);
+ break;
+ }
+#endif // #if !defined(__LTE_SM__)&&defined(__MTK_GL1_GSM__)
+ /********************************************
+ * UL1 RF test functionality
+ ********************************************/
+#if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+#if !defined(__UL1_TASK_DISABLE__)
+ case FT_URF_TEST_REQ_ID:
+ {
+ FT_FtURfTestReq( ptrMsg );
+ break;
+ }
+#endif // #if !defined(__UL1_TASK_DISABLE__)
+#endif // #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+ /********************************************
+ *
+ * Version Info functionality
+ *
+ ********************************************/
+ case FT_VER_INFO_REQ_ID:
+ {
+ FT_GetVersionInfo();
+ break;
+ }
+ /********************************************
+ *
+ * FT task test alive
+ *
+ ********************************************/
+ case FT_IS_ALIVE_REQ_ID:
+ {
+ FT_TestAlive();
+ break;
+ }
+ /********************************************
+ *
+ * FT task utility command
+ *
+ ********************************************/
+ case FT_UTILITY_COMMAND_REQ_ID:
+ {
+ FT_UtilityCommand(ptrMsg);
+ break;
+ }
+#if defined(__LTE_RAT__) || defined(L1_SIM)
+ case FT_ERF_TEST_REQ_ID:
+ {
+ FT_Erf_Operation(ptrMsg);
+ break;
+ }
+#endif // #if defined(__LTE_RAT__)
+ case FT_MMRF_TEST_REQ_ID:
+ {
+ FT_Mmrf_Operation(ptrMsg);
+ break;
+ }
+
+ case FT_NRF_TEST_REQ_ID:
+ {
+ FT_Nrf_Operation(ptrMsg);
+ break;
+ }
+
+#if !defined(__L4_TASK_DISABLE__) && !defined(L4_NOT_PRESENT) || defined(DUMMY_PROTOCOL)
+ case FT_L4_ATCMD_REQ_ID:
+ {
+ FT_L4_Operation(ptrMsg);
+ }
+#endif // #if !defined(__L4_TASK_DISABLE__) && !defined(L4_NOT_PRESENT)
+ default:
+ break;
+ }
+ }
+#if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+#if !defined(__UL1_TASK_DISABLE__)
+ else if( (ptrMsg->src_mod_id == MOD_UL1) )
+ {
+ FT_UL1TST_SEND_CNF_BACK(ptrMsg);
+ }
+#endif // #if !defined(__UL1_TASK_DISABLE__)
+#endif // #if defined(__UMTS_RAT__) && defined(__MTK_UL1_FDD__)
+#if !defined(L1_NOT_PRESENT) && !defined(__L1_TASK_DISABLE__) && !defined(DUMMYL1)
+ else if( (ptrMsg->src_mod_id == MOD_L1) )
+ {
+ FT_Rf_ConfirmHandler(ptrMsg);
+ }
+#endif // #if !defined(L1_NOT_PRESENT) && !defined(__L1_TASK_DISABLE__) && !defined(DUMMYL1)
+#if defined(__LTE_RAT__)
+ else if( MOD_EL1== ptrMsg->src_mod_id )
+ {
+ FT_Erf_ConfirmHandler(ptrMsg);
+ }
+#endif // #if defined(__LTE_RAT__)
+
+ else if( MOD_MMRF_XL1TST == ptrMsg->src_mod_id )
+ {
+ FT_Mmrf_ConfirmHandler(ptrMsg);
+ }
+#if defined(__MD97__)
+ else if( MOD_NL1 == ptrMsg->src_mod_id )
+ {
+ FT_Nrf_ConfirmHandler(ptrMsg);
+ }
+#endif // #if !defined(__MD97__)
+#if !defined(__L4_TASK_DISABLE__) && !defined(L4_NOT_PRESENT) || defined(DUMMY_PROTOCOL)
+ else if( MOD_L4C == ptrMsg->src_mod_id )
+ {
+ FT_L4_Operation(ptrMsg);
+ }
+#endif // #if !defined(__L4_TASK_DISABLE__) && !defined(L4_NOT_PRESENT)
+}
+#endif // #ifndef L1_SIM
+/*******************************************************************************
+ * FUNCTION
+ * FT_Task
+ *
+ * DESCRIPTION
+ * Entry point for the factory testing task. The function performs initialisation,
+ * then sits in an infinite loop reading messages or reports and dispatching
+ * them.
+ *
+ * CALLS
+ *
+ * PARAMETERS
+ * None
+ *
+ * RETURNS
+ * None
+ *
+ * GLOBALS AFFECTED
+ * None
+ *******************************************************************************/
+
+#define META_Version_Check_Fail 0
+#define META_Version_Check_Required 0
+
+void FT_Task(task_entry_struct * task_entry_ptr)
+{
+ ilm_struct current_ilm;
+ FT_Initialization(task_entry_ptr);
+ while ( 1 )
+ {
+#ifndef L1_SIM
+ msg_receive_extq(¤t_ilm );
+#else
+ gs_read_message(MOD_FT, ¤t_ilm, sizeof(current_ilm), KAL_TRUE);
+#endif //#ifndef L1_SIM
+ FT_DispatchMessage(¤t_ilm );
+ destroy_ilm(¤t_ilm);
+ }
+}
+kal_eventgrpid MMRF_UPDATE_RUNTIME_EVENT;
+kal_bool FT_Init(void)
+{
+ MMRF_UPDATE_RUNTIME_EVENT = kal_create_event_group("MMRF_UPD");
+ return KAL_TRUE;
+}
diff --git a/mcu/middleware/meta/ft/src/ft_mem.c b/mcu/middleware/meta/ft/src/ft_mem.c
new file mode 100644
index 0000000..4c46a86
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_mem.c
@@ -0,0 +1,138 @@
+/*****************************************************************************
+* 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).
+*
+*****************************************************************************/
+/*******************************************************************************
+* Modification Notice:
+* --------------------------
+* This software is modified by MediaTek Inc. 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) 2001
+*
+*******************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * ft_mem.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Factory testing memory management functions
+ *
+ * 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!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+/*************************************************************************
+ * Include Statements for KAL
+ *************************************************************************/
+#include "kal_general_types.h"
+#include "kal_public_defs.h"
+#include "kal_public_api.h"
+/*************************************************************************
+ * Include Statements FT
+ *************************************************************************/
+#include "ft_mem.h"
+#include "meta_customize.h"
+/*************************************************************************
+ * FT memory global variable
+ *************************************************************************/
+KAL_ADM_ID ft_ext_mem_pool_id = 0;
+void FtInitMemoryPool(void)
+{
+ ft_ext_mem_pool_id = kal_adm_create(
+ Custom_META_GetCustomMemoryPool(),
+ Custom_META_GetCustomMemoryPoolSize(),
+ (kal_uint32*)Custom_META_GetCustomMemoryPoolArrangement(),
+ KAL_FALSE
+ );
+}
+void* FtAllocExtMemory(kal_uint32 size)
+{
+ if(ft_ext_mem_pool_id > 0)
+ {
+ return kal_adm_alloc(ft_ext_mem_pool_id, size);
+ }
+ else
+ {
+ return NULL;
+ }
+}
+void FtFreeExtMemory(void* ptr)
+{
+ if(ft_ext_mem_pool_id > 0)
+ {
+ kal_adm_free(ft_ext_mem_pool_id, ptr);
+ }
+}
+kal_uint32 FtGetLeftExtMemory(void)
+{
+ if(ft_ext_mem_pool_id > 0)
+ {
+ return kal_adm_get_max_alloc_size(ft_ext_mem_pool_id);
+ }
+ else
+ {
+ return 0;
+ }
+}
diff --git a/mcu/middleware/meta/ft/src/ft_report.c b/mcu/middleware/meta/ft/src/ft_report.c
new file mode 100644
index 0000000..71b4720
--- /dev/null
+++ b/mcu/middleware/meta/ft/src/ft_report.c
@@ -0,0 +1,149 @@
+/*****************************************************************************
+* 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).
+*
+*****************************************************************************/
+/*******************************************************************************
+* Modification Notice:
+* --------------------------
+* This software is modified by MediaTek Inc. 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) 2001
+*
+*******************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * ft_report.c
+ *
+ * Project:
+ * --------
+ * MTK6208
+ *
+ * Description:
+ * ------------
+ * Functions to handle L1 report
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+#include "ft_msg.h"
+#include "ft_private.h"
+#include "ft_report.h"
+