[Feature]Upload Modem source code
Change-Id: Id4294f30faced84d3e6fd6d5e61e1111bf287a37
diff --git a/mcu/service/sys_svc/brom_ext/inc/brom_ext.h b/mcu/service/sys_svc/brom_ext/inc/brom_ext.h
new file mode 100644
index 0000000..d8994ff
--- /dev/null
+++ b/mcu/service/sys_svc/brom_ext/inc/brom_ext.h
@@ -0,0 +1,79 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * brom_ext.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file contain the brom ext header
+ *
+ * Author:
+ * -------
+ *
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef __BROM_EXT_H__
+#define __BROM_EXT_H__
+
+#include "kal_general_types.h"
+
+//==============================================================================
+// Extern function
+//==============================================================================
+extern void __attribute__ ((nomips16,used,section("BR_EXT_HEAD"))) brom_ext_main(kal_bool pll_en) ;
+
+#endif /* __BROM_EXT_H__ */
+
diff --git a/mcu/service/sys_svc/brom_ext/src/brom_ext.c b/mcu/service/sys_svc/brom_ext/src/brom_ext.c
new file mode 100644
index 0000000..e16e0c9
--- /dev/null
+++ b/mcu/service/sys_svc/brom_ext/src/brom_ext.c
@@ -0,0 +1,117 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * maui_GFH_body.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file contain the brom ext body
+ *
+ * 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 "brom_ext.h"
+#include "pll.h"
+
+//==============================================================================
+//
+//==============================================================================
+
+/*void __attribute__ ((nomips16,used,section("BR_EXT"))) brom_ext_subfunc()
+{
+
+ volatile int i;
+ volatile int cnt;
+
+ cnt = 0x0F;
+ for(i=0; i<512; i++)
+ {
+ cnt=~cnt;
+ }
+
+}*/
+
+
+void __attribute__ ((nomips16,used,section("BR_EXT_HEAD"))) brom_ext_main(kal_bool pll_en)
+{
+
+#if defined(__MTK_TARGET__)
+ if(pll_en)
+ {
+#if !defined(MT6885) && !defined(MT6873) && !defined(MT6853)
+ PLL_MD_Pll_Init();
+#endif
+ }
+ else
+ {
+#if !defined(MT6885) && !defined(MT6873) && !defined(MT6853)
+ PLL_Set_CLK_To_26M();
+#endif
+ }
+
+#endif /* __MTK_TARGET__ */
+
+}
diff --git a/mcu/service/sys_svc/dsp_loader/src/dsp_loader.c b/mcu/service/sys_svc/dsp_loader/src/dsp_loader.c
new file mode 100644
index 0000000..6755918
--- /dev/null
+++ b/mcu/service/sys_svc/dsp_loader/src/dsp_loader.c
@@ -0,0 +1,12 @@
+#include "dsp_loader.h"
+
+// 1. force to be RW
+// 2. do not modify the variable name
+__attribute__((section(".rodata"))) const kal_uint32 *g_dsp_bin_ptr = (kal_uint32*)0xDEADDEAD;
+
+kal_uint32 DSP_Load()
+{
+ // Load the DSP via CCCI FS call
+
+ return (kal_uint32) g_dsp_bin_ptr;
+}
\ No newline at end of file
diff --git a/mcu/service/sys_svc/dspfm_lte/inc/dspfm.h b/mcu/service/sys_svc/dspfm_lte/inc/dspfm.h
new file mode 100644
index 0000000..3c63a04
--- /dev/null
+++ b/mcu/service/sys_svc/dspfm_lte/inc/dspfm.h
@@ -0,0 +1,91 @@
+/*****************************************************************************
+* 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) 2013
+*
+* 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:
+ * ---------
+ * dspfm.h
+ *
+ * Project:
+ * --------
+ * Moly
+ *
+ * Description:
+ * ------------
+ * LTE DSP file management
+ *
+ * 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!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef _DSPFM_H
+#define _DSPFM_H
+
+extern kal_bool dspfm_get_fw_ver(kal_char **str);
+
+extern kal_bool dspfm_get_fw_btime(kal_char **str);
+
+/*!
+ * @brief Init DSP file manager
+ * @param none
+ * @return none
+ */
+extern void dspfm_init(void);
+
+#endif /*_DSPFM_H*/
diff --git a/mcu/service/sys_svc/dspfm_lte/inc/dspfm_trace.h b/mcu/service/sys_svc/dspfm_lte/inc/dspfm_trace.h
new file mode 100644
index 0000000..1b7a28a
--- /dev/null
+++ b/mcu/service/sys_svc/dspfm_lte/inc/dspfm_trace.h
@@ -0,0 +1,15 @@
+#ifndef _DSPFM_TRACE_H
+#define _DSPFM_TRACE_H
+#ifndef GEN_FOR_PC
+ #include "stack_config.h"
+#endif /* GEN_FOR_PC */
+#include "dhl_trace.h"
+#include "dhl_def.h"
+#if !defined(GEN_FOR_PC)
+#if defined(__DHL_MODULE__) || defined(__CUSTOM_RELEASE__)
+#endif /* TST Trace Defintion */
+#endif
+#if !defined(GEN_FOR_PC)
+#include"dspfm_trace_mod_dspfm_utmd.h"
+#endif
+#endif
diff --git a/mcu/service/sys_svc/dspfm_lte/inc/dspfm_trace_mod_dspfm_utmd.json b/mcu/service/sys_svc/dspfm_lte/inc/dspfm_trace_mod_dspfm_utmd.json
new file mode 100644
index 0000000..50f5859
--- /dev/null
+++ b/mcu/service/sys_svc/dspfm_lte/inc/dspfm_trace_mod_dspfm_utmd.json
@@ -0,0 +1,301 @@
+{
+ "endGen": "Legacy",
+ "startGen": "Legacy",
+ "legacyParameters": {},
+ "module": "MOD_DSPFM",
+ "traceClassDefs": [
+ {
+ "TRACE_INFO": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_INFO"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_WARNING": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_WARNING"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_ERROR": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_ERROR"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_FUNC": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_FUNC"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_STATE": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_STATE"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_GROUP_1": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_GROUP1"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_GROUP_2": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_GROUP2"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_GROUP_3": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_GROUP3"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_GROUP_4": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_GROUP4"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_GROUP_5": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_GROUP5"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_GROUP_6": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_GROUP6"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_GROUP_7": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_GROUP7"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_GROUP_8": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_GROUP8"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_GROUP_9": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_GROUP9"
+ ],
+ "traceType": "Public"
+ }
+ },
+ {
+ "TRACE_GROUP_10": {
+ "debugLevel": "Ultra-Low",
+ "tag": [
+ "Baseline",
+ "TRACE_GROUP10"
+ ],
+ "traceType": "Public"
+ }
+ }
+ ],
+ "traceDefs": [
+ {
+ "DSPFM_REGION_NOT_FOUND": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] Cannot find DSP region in flash layout",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_FILE_NOT_OPEN": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] DSP file not opened ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_PTR_NOT_ALIGN": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] DSP ptr not aligned ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_OFFSET_NOT_ALIGN": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] DSP offset not aligned ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_INVALID_GFH_FILE_INFO": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] Invalid GFH file info",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_FILE_SIZE_TOO_LARGE": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] DSP file size exceeds bound page",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_WRONG_GFH_FILE_TYPE": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] GFH file type is not LTE_DSP_ROM ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_LENGTH_TOO_LARGE": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] Read length exceeds file size ",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_READ_FLASH_FAILED": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] Read error at block %d, page %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_FLASH_BAD_BLOCK": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] Bad block at block %d",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_FILE_READ_FAILED": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] DSP file read failed",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_FILE_SEEK_FAILED": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] DSP file seek failed",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_VERSION_CHECK_FAIL": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] DSP version check failed",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_MAUI_GFH_NO_PLT_ID": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] MAUI platform id not found",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_MAUI_GFH_NO_PROJ_ID": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] MAUI project id not found",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_DSP_GFH_NO_FOUND": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] DSP GFH file info not found",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_DSP_GFH_NO_PLT_ID": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] DSP platform id not found",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_DSP_GFH_NO_PROJ_ID": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] DSP project id not found",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_DSP_PLT_ID_NOT_MATCH": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] DSP platform id is not matched",
+ "traceClass": "TRACE_INFO"
+ }
+ },
+ {
+ "DSPFM_DSP_PROJ_ID_NOT_MATCH": {
+ "_comment": "Trace reference not found",
+ "format": "[DSPFM] DSP project id is not matched",
+ "traceClass": "TRACE_INFO"
+ }
+ }
+ ],
+ "traceFamily": "PS"
+}
\ No newline at end of file
diff --git a/mcu/service/sys_svc/dspfm_lte/src/dspfm.c b/mcu/service/sys_svc/dspfm_lte/src/dspfm.c
new file mode 100644
index 0000000..903016e
--- /dev/null
+++ b/mcu/service/sys_svc/dspfm_lte/src/dspfm.c
@@ -0,0 +1,1088 @@
+/*****************************************************************************
+* 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) 2013
+*
+* 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:
+ * ---------
+ * dspfm.c
+ *
+ * Project:
+ * --------
+ * Moly
+ *
+ * Description:
+ * ------------
+ * LTE DSP file management
+ *
+ * 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!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#ifdef __CCCIFS_SUPPORT__
+/* under construction !*/
+#endif
+#ifndef __MAUI_BASIC__
+/* under construction !*/
+#endif
+/* under construction !*/
+#if defined(MTK_SLEEP_ENABLE) && defined(__X_BOOTING__)
+/* under construction !*/
+#endif
+/* under construction !*/
+#ifdef SDIO_TEMP_SLEEP_LOCK
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+#if defined(ATEST_ENABLE) && defined(ATEST_DRV_DSPFM)
+/* under construction !*/
+#else
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#ifndef __MAUI_BASIC__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#ifdef __CCCIFS_SUPPORT__
+/* under construction !*/
+#else
+/* under construction !*/
+#endif /*__CCCIFS_SUPPORT__*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(__MODEM_ONLY__)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#elif defined(__CCCIFS_SUPPORT__)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#ifdef SDIO_TEMP_SLEEP_LOCK
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+#else /* !__CCCIFS_SUPPORT__ && !__MODEM_ONLY__*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+#endif
diff --git a/mcu/service/sys_svc/excep_hdlr/inc/excep_hdlr.h b/mcu/service/sys_svc/excep_hdlr/inc/excep_hdlr.h
new file mode 100644
index 0000000..e247629
--- /dev/null
+++ b/mcu/service/sys_svc/excep_hdlr/inc/excep_hdlr.h
@@ -0,0 +1,134 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * excep_hdlr.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file provides typedefs and definiton for PS index trace.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef _EXCEP_HDLR_H_
+#define _EXCEP_HDLR_H_
+
+#include "ex_item.h"
+
+typedef enum sys_excep_act
+{
+ SYS_EXCEP_ACT_RETURN = 1,
+ SYS_EXCEP_ACT_RETURN_NEXT,
+} sys_excep_act;
+
+typedef struct sys_excep_param
+{
+ int excep_reason;
+ unsigned int excep_addr;
+ EX_CPU_REG_T *excep_reg;
+} sys_excep_param;
+
+typedef int (*sys_excep_hdlr)(sys_excep_param *param);
+
+typedef struct sys_excep_hdlr_desc
+{
+ struct sys_excep_hdlr_desc *next_desc;
+ sys_excep_hdlr hdlr;
+
+} sys_excep_hdlr_desc;
+
+typedef struct excep_ctxt
+{
+ unsigned int sp;
+ unsigned int lr;
+ unsigned int pc;
+ unsigned int tmp;
+} excep_ctxt;
+
+/* Define the thread per cpu structure type. */
+typedef struct TC_CPU_CB_STRUCT_DUMMY
+{
+ void * volatile tc_running_thread;
+} TC_CPU_CB_DUMMY;
+
+typedef struct CIS_CPU_INFO_STRUCT_DUMMY
+{
+ kal_uint32 c1; /* CPU ID */
+ kal_uint32 c2; /* CPU state */
+ kal_uint32 c3; /* CPU hardware id */
+ kal_bool b1; /* CPU bound domain flag */
+ kal_bool b2; /* is set to true if core is idle */
+} CIS_CPU_INFO_DUMMY;
+
+
+/* Define the CPU control block */
+typedef struct CIS_CCB_STRUCT_DUMMY
+{
+ CIS_CPU_INFO_DUMMY cis_info_cb;
+ TC_CPU_CB_DUMMY cis_thread_cb;
+
+} CIS_CCB_DUMMY;
+
+typedef struct CS_NODE_STRUCT_DUMMY
+{
+ struct CS_NODE_STRUCT_DUMMY *cs_previous;
+ struct CS_NODE_STRUCT_DUMMY *cs_next;
+ kal_uint16 cs_priority;
+
+} CS_NODE_DUMMY;
+
+int retrieve_excep_ctxt(excep_ctxt *ctxt);
+void sys_excep_hdlr_desc_init(sys_excep_hdlr_desc *hdlr_desc, sys_excep_hdlr hdlr);
+int sys_excep_excep_hdlr_reg(sys_excep_hdlr_desc *hdlr_desc);
+
+#endif /* _EXCEP_HDLR_H_ */
\ No newline at end of file
diff --git a/mcu/service/sys_svc/excep_hdlr/src/excep_hdlr.c b/mcu/service/sys_svc/excep_hdlr/src/excep_hdlr.c
new file mode 100644
index 0000000..d3c95c6
--- /dev/null
+++ b/mcu/service/sys_svc/excep_hdlr/src/excep_hdlr.c
@@ -0,0 +1,696 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * excep_hdlr.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file provides typedefs and definiton for PS index trace.
+ *
+ * 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!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#include "kal_public_api.h" //MSBB change #include "kal_release.h"
+#include "ex_item.h"
+#if defined(__MTK_TARGET__)
+#include "cc_ex_item.h"
+#include "custom_scatstruct.h"
+#endif /* __MTK_TARGET__ */
+#include "excep_hdlr.h"
+
+#if defined(KAL_ON_MERTOS)
+#include "kal_os.h"
+#endif
+
+#include "mdmp_typedef.h"
+#include "mpu.h"
+#include "ccci_if.h"
+
+
+/*******************************************************************************
+ * Define global data
+ *******************************************************************************/
+kal_uint32 ex_dump_level = EX_FULL_DUMP;
+
+kal_uint32 ex_sensitive_flag =
+#if defined(__SENSITIVE_DATA_MOSAIC__)
+ EX_CLEAN_SENSITIVE;
+#else
+ EX_NO_CLEAN_SENSITIVE;
+#endif
+
+static kal_uint32 SysMemoryInfo[(DUMP_REGION_COUNT
+#if defined(__SCC_SIB_SUPPORT__)
+ + 1
+#if defined(__MD97__)
+ + 3
+#endif
+#endif /* __SCC_SIB_SUPPORT__ */
+#if defined (__HIF_CCCI_SUPPORT__) && defined(__CCCI_PRODUCT_TYPE_THIN_MODEM__)
+ + 1 /* Small AP 64MB Mem */
+#endif
+#if defined(__KAL_STACK_ISOLATION__)
+ + 1
+#endif
+ )* 2];
+
+#if defined(__HIF_CCCI_SUPPORT__)
+static kal_uint32 ShareMemoryInfo[MEM_SYS_SHM_REGION_MAX * 2];
+#endif
+
+/*******************************************************************************
+ * Define import function prototype
+ *******************************************************************************/
+extern kal_uint32 INT_Exception_SP;
+
+extern kal_uint32 INT_HW_CPU_COUNT;
+
+sys_excep_hdlr_desc *desc_head = NULL;
+extern EX_INTERAPTIV_T ex_interaptive_state;
+extern EX_INFO_T ex_info[SYS_MCU_NUM_VPE][2];
+extern kal_uint8 INT_Exception_Count[SYS_MCU_NUM_VPE];
+
+
+
+#if defined(__MTK_TARGET__)
+
+#if defined(__ARMCC_VERSION)
+
+#elif defined(__GNUC__)
+
+void retrieve_curr_ctxt(excep_ctxt *ctxt){
+
+}
+
+#endif /* __RVCT__ , __GNUC__ */
+#endif /* __MTK_TARGET__ */
+
+excep_ctxt g_ctxt;
+
+void sys_excep_hdlr_desc_init(sys_excep_hdlr_desc *hdlr_desc, sys_excep_hdlr hdlr)
+{
+ if(hdlr_desc==NULL || hdlr==NULL)
+ {
+ ASSERT(0);
+ }
+ memset(hdlr_desc, 0, sizeof(sys_excep_hdlr_desc));
+ hdlr_desc->hdlr = hdlr;
+}
+
+int sys_excep_excep_hdlr_reg(sys_excep_hdlr_desc *hdlr_desc)
+{
+ sys_excep_hdlr_desc *desc = desc_head;
+
+ if(hdlr_desc==NULL || hdlr_desc->next_desc!=NULL)
+ {
+ ASSERT(0);
+ }
+
+ if(desc==NULL)
+ {
+ desc_head = hdlr_desc;
+ }
+ else
+ {
+ for(; desc->next_desc!=0; desc=desc->next_desc);
+ desc->next_desc = hdlr_desc;
+ }
+
+ return 0;
+}
+
+int sys_excep_hook(int excep_reason, int excep_addr, EX_CPU_REG_T *excep_reg)
+{
+ sys_excep_hdlr_desc *desc;
+ sys_excep_param param = { 0 };
+
+ param.excep_reason = excep_reason;
+ param.excep_addr = excep_addr;
+ param.excep_reg = excep_reg;
+ retrieve_excep_ctxt(&g_ctxt);
+
+ for(desc=desc_head; desc; desc=desc->next_desc)
+ {
+ switch(desc->hdlr(¶m))
+ {
+ case SYS_EXCEP_ACT_RETURN:
+ return 1;
+ break;
+ case SYS_EXCEP_ACT_RETURN_NEXT:
+ return 2;
+ break;
+ default:
+ break;
+ }
+ }
+ return 0; // return to exception handler
+}
+
+int retrieve_excep_ctxt(excep_ctxt *ctxt)
+{
+ unsigned int *excep_stack;
+#if defined(__MTK_TARGET__)
+ unsigned int *excep_stack_dummy;
+#endif /* __MTK_TARGET__ */
+
+ if(ctxt==NULL) return -1;
+ memset(ctxt, 0, sizeof(excep_ctxt));
+
+ if(INT_Exception_Count[0]>0 && INT_HW_CPU_COUNT >0
+ )
+ {
+ if(ex_log_ptr)
+ excep_stack = (unsigned int*)ex_log_ptr->basic_info.stack_ptr;
+ else
+ excep_stack = NULL;
+
+#if defined(__MTK_TARGET__)
+ excep_stack_dummy = (unsigned int*)ex_fulllog_ptr->mcu.ex_log.basic_info.stack_ptr;
+#endif /* __MTK_TARGET__ */
+
+ /* exception type */
+ if(ex_log_ptr)
+ {
+ switch (ex_log_ptr->header.ex_type)
+ {
+ case ASSERT_FAIL_EXCEPTION:
+ ctxt->sp = (unsigned int)excep_stack; //only for dummy reference
+ ctxt->tmp = ex_interaptive_state.coreregs[0].MVPControl;
+ break;
+#if defined(__MTK_TARGET__)
+ case CC_INVALID_EXCEPTION:
+ ctxt->sp = (unsigned int)excep_stack_dummy; //only for dummy reference
+ break;
+ case STACKACCESS_EXCEPTION:
+ kal_mem_cpy(ex_log_ptr, &ex_dump_level, sizeof(ex_dump_level)); //only for dummy reference
+ break;
+#endif /* __MTK_TARGET__ */
+#if defined(KAL_ON_MERTOS)
+ case SYS_FATALERR_EXT_TASK_EXCEPTION:
+ if(excep_stack_dummy)
+ ctxt->tmp = (kal_uint32)&((kal_os_timer_type*)ctxt->tmp)->instance;
+ else
+ ctxt->tmp = (kal_uint32)&((kal_os_eventgrp_type*)ctxt->tmp)->instance;
+ break;
+#endif
+ default:
+ if(excep_stack_dummy)
+ ctxt->tmp = ex_info[0][0].SST_Exception_Timestamp;
+#if defined(KAL_ON_MERTOS)
+ else
+ ctxt->tmp = (kal_uint32)&((kal_os_sem_type*)ctxt->tmp)->instance;
+#endif
+ return -1;
+ }
+ }
+ }
+ else
+ {
+#if defined(__MTK_TARGET__)
+ retrieve_curr_ctxt(ctxt);
+#endif /* __MTK_TARGET__ */
+ }
+
+ ctxt->pc &= 0xFFFFFFFE;
+
+ return 0;
+}
+
+#if defined(__MTK_TARGET__)
+/*************************************************************************
+* FUNCTION
+* INT_GetSysMemoryInfo
+*
+* DESCRIPTION
+* This API is design for TST/TR/Catcher to do exception handling.
+*
+* PARAMETERS
+*
+* RETURNS
+*
+*************************************************************************/
+void INT_DummySST_Reference(void)
+{
+ excep_ctxt ctxt;
+ sys_excep_hook(1,1,NULL);
+ retrieve_excep_ctxt(&ctxt);
+}
+
+void INT_GetSysMemoryInfo( kal_uint32 **info, kal_uint16* count, kal_uint8* region_config)
+{
+ kal_uint32 var_index = 0, count_sys_num = 0;
+#if defined(__SCC_SIB_SUPPORT__)
+ kal_uint32 share_startaddr = 0, share_endaddr = 0 , share_len = 0;
+ extern void scc_dump_region_info(kal_uint32 *start_address, kal_uint32 *size);
+#endif
+#if defined(__KAL_STACK_ISOLATION__)
+ kal_uint32 stack_addr = 0, stack_len = 0;
+#endif /* __KAL_STACK_ISOLATION__ */
+
+ /* get regions to be dumped from scatter struct */
+ if(MDMP_IS_REGION_SELECTED(region_config, MEM_SYS_REGION_WITHOUT_UC_ROM)){
+ var_index += custom_query_dump_region_without_UC_ROM((EXTSRAM_REGION_INFO_T*) (SysMemoryInfo + var_index));
+ }
+
+ if(MDMP_IS_REGION_SELECTED(region_config, MEM_SYS_REGION_ROM)){
+ var_index += custom_query_dump_region_ROM((EXTSRAM_REGION_INFO_T*) (SysMemoryInfo + var_index));
+ }
+
+ if(MDMP_IS_REGION_SELECTED(region_config, MEM_SYS_REGION_PA)){
+ var_index += custom_query_dump_region_PA((EXTSRAM_REGION_INFO_T*) (SysMemoryInfo + var_index));
+ }
+
+ if(MDMP_IS_REGION_SELECTED(region_config, MEM_SYS_REGION_VA)){
+ var_index += custom_query_dump_region_VA((EXTSRAM_REGION_INFO_T*) (SysMemoryInfo + var_index));
+ }
+
+#if defined(__SCC_SIB_SUPPORT__)
+ share_startaddr = 0;
+ share_len = 0;
+ scc_dump_region_info(&share_startaddr, &share_len);
+ SysMemoryInfo[var_index++] = share_startaddr;
+ SysMemoryInfo[var_index++] = share_len;
+ (void)share_endaddr;
+#if defined(__MD97__)
+ extern void scc_dump_region_info1(kal_uint32 *start_address, kal_uint32 *size);
+ scc_dump_region_info1(&share_startaddr, &share_len);
+ SysMemoryInfo[var_index++] = share_startaddr;
+ SysMemoryInfo[var_index++] = share_len;
+ extern void scc_dump_region_info2(kal_uint32 *start_address, kal_uint32 *size);
+ scc_dump_region_info2(&share_startaddr, &share_len);
+ SysMemoryInfo[var_index++] = share_startaddr;
+ SysMemoryInfo[var_index++] = share_len;
+ extern void scc_dump_region_info3(kal_uint32 *start_address, kal_uint32 *size);
+ scc_dump_region_info3(&share_startaddr, &share_len);
+ SysMemoryInfo[var_index++] = share_startaddr;
+ SysMemoryInfo[var_index++] = share_len;
+#endif
+#endif
+
+#if defined(__KAL_STACK_ISOLATION__) && !defined(__FUE__) && !defined(__UBL__)
+ kal_query_stack_space(&stack_addr, &stack_len);
+ SysMemoryInfo[var_index++] = stack_addr;
+ SysMemoryInfo[var_index++] = stack_len;
+#endif /* __KAL_STACK_ISOLATION__ */
+
+#if defined (__HIF_CCCI_SUPPORT__) && defined(__CCCI_PRODUCT_TYPE_THIN_MODEM__)
+ if( ex_is_ap_triggered_cross_core_error() && !sap_shm.resultFail ){
+ SysMemoryInfo[var_index++] = sap_shm.mem_addr;
+ SysMemoryInfo[var_index++] = sap_shm.mem_size;
+ }else {
+ SysMemoryInfo[var_index++] = 0;
+ SysMemoryInfo[var_index++] = 0;
+ }
+#endif
+
+ /* calculate the number of regions to be dumped */
+ *info = (kal_uint32*)SysMemoryInfo;
+ *count = var_index / 2;
+ count_sys_num = sizeof(SysMemoryInfo) / sizeof(kal_uint32) / 2;
+ if (*count > count_sys_num) {
+
+#if 0 /* SMO: Remove Assert. But we cannot do error handling however... */
+/* under construction !*/
+/* under construction !*/
+#endif
+
+ }
+}
+
+/*************************************************************************
+* FUNCTION
+* INT_GetSlaveSysMemoryInfo
+*
+* DESCRIPTION
+* This API is design for TST/TR/Catcher to do exception handling.
+*
+* PARAMETERS
+*
+* RETURNS
+*
+*************************************************************************/
+
+void INT_GetSlaveSysMemoryInfo( kal_uint32 **info, kal_uint16* count )
+{
+}
+
+#if defined(__HIF_CCCI_SUPPORT__)
+kal_uint32 ShareMemoryFeatureFlag;
+#endif
+void INT_GetSysShmMemoryInfo( kal_uint32 **info, kal_uint16* count, kal_uint8* region_config)
+{
+#if defined(__HIF_CCCI_SUPPORT__)
+ kal_uint32 var_index = 0;
+ kal_uint32 share_startaddr = 0, share_endaddr = 0 , share_len = 0;
+ CCCI_RUNTIME_SHARE_MEMORY_FORMAT_T shm_info;
+ UDC_SHARE_MEMORY_FORMAT_T udc_shm_info;
+ CCCI_RUNTIME_FEATURE_SUPPORT_T feature_support;
+
+ if(MDMP_IS_REGION_SELECTED(region_config,MEM_SYS_SHM_REGION_UNCACHEABLE_MEM_ALL)){
+ system_query_noncacheable_shm_info(&share_startaddr, &share_endaddr , &share_len);
+ if((share_len != 0x0)&&(share_startaddr != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_UNCACHEABLE_MEM_ALL);
+ ShareMemoryInfo[var_index++] = share_startaddr;
+ ShareMemoryInfo[var_index++] = share_len;
+ (void)share_endaddr;
+ }
+ }
+
+ if(MDMP_IS_REGION_SELECTED(region_config,MEM_SYS_SHM_REGION_CACHEABLE_MEM_ALL)){
+ system_query_cacheable_shm_info(&share_startaddr, &share_endaddr , &share_len);
+ if((share_len != 0x0)&&(share_startaddr != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_CACHEABLE_MEM_ALL);
+ ShareMemoryInfo[var_index++] = share_startaddr;
+ ShareMemoryInfo[var_index++] = share_len;
+ (void)share_endaddr;
+ }
+ }
+
+ if(_MDMP_HAS_REGION_CONFIG_BIT(region_config,MEM_SYS_SHM_REGION_APMD_CCCI_64K)){
+ ccci_get_ex_shm_info((void **)&share_startaddr, &share_len);
+ if((share_len != 0x0)&&(share_startaddr != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_APMD_CCCI_64K);
+ ShareMemoryInfo[var_index++] = share_startaddr;
+ ShareMemoryInfo[var_index++] = share_len;
+ }
+ }
+
+ if(_MDMP_HAS_REGION_CONFIG_BIT(region_config,MEM_SYS_SHM_REGION_APMD_CCCI_SCP)){
+ ccci_get_ccism_scp_shm_info((void **)&share_startaddr, &share_len);
+ if((share_len != 0x0)&&(share_startaddr != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_APMD_CCCI_SCP);
+ ShareMemoryInfo[var_index++] = share_startaddr;
+ ShareMemoryInfo[var_index++] = share_len;
+ }
+ }
+
+ if(_MDMP_HAS_REGION_CONFIG_BIT(region_config,MEM_SYS_SHM_REGION_APMD_CCCI_CCB_CTRL)){
+ ccci_get_ccb_ctrl_shm_info((void **)&share_startaddr, &share_len);
+ if((share_len != 0x0)&&(share_startaddr != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_APMD_CCCI_CCB_CTRL);
+ ShareMemoryInfo[var_index++] = share_startaddr;
+ ShareMemoryInfo[var_index++] = share_len;
+ }
+ }
+#if 0 /*feature not ready*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ if(_MDMP_HAS_REGION_CONFIG_BIT(region_config,MEM_SYS_SHM_REGION_APMD_CCCI_AUDIO)){
+ feature_support = ccci_runtime_data_query(AP_CCCI_AUDIO_RAW_MEMORY, &shm_info, sizeof(CCCI_RUNTIME_SHARE_MEMORY_FORMAT_T));
+ if(feature_support.support_mask == CCCI_RUNTIME_FEATURE_MUST_SUPPORT){
+ if((shm_info.addr != 0x0)&&(shm_info.size != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_APMD_CCCI_AUDIO);
+ ShareMemoryInfo[var_index++] = shm_info.addr;
+ ShareMemoryInfo[var_index++] = shm_info.size;
+ }
+ }
+ }
+
+ /*mcu*/
+ if(_MDMP_HAS_REGION_CONFIG_BIT(region_config,MEM_SYS_SHM_REGION_APMD_CCCI_MCU)){
+ ccci_get_ccism_shm_info((void **)&share_startaddr, &share_len);
+ if((share_len != 0x0)&&(share_startaddr != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_APMD_CCCI_MCU);
+ ShareMemoryInfo[var_index++] = share_startaddr;
+ ShareMemoryInfo[var_index++] = share_len;
+ }
+ }
+
+ /*mcu exp*/
+ if(_MDMP_HAS_REGION_CONFIG_BIT(region_config,MEM_SYS_SHM_REGION_APMD_CCCI_MCU_EXP)){
+ ccci_get_ccism_expt_shm_info((void **)&share_startaddr, &share_len);
+ if((share_len != 0x0)&&(share_startaddr != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_APMD_CCCI_MCU_EXP);
+ ShareMemoryInfo[var_index++] = share_startaddr;
+ ShareMemoryInfo[var_index++] = share_len;
+ }
+ }
+
+ if(_MDMP_HAS_REGION_CONFIG_BIT(region_config,MEM_SYS_SHM_REGION_POS)){
+ feature_support = ccci_runtime_data_query(AP_CCCI_RUNTIME_AMMS_POS_SHARE_MEMORY, &shm_info, sizeof(CCCI_RUNTIME_SHARE_MEMORY_FORMAT_T));
+ if(feature_support.support_mask == CCCI_RUNTIME_FEATURE_MUST_SUPPORT){
+ if((shm_info.addr != 0x0)&&(shm_info.size != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_POS);
+ ShareMemoryInfo[var_index++] = shm_info.addr;
+ ShareMemoryInfo[var_index++] = shm_info.size;
+ }
+ }
+ }
+
+ if(_MDMP_HAS_REGION_CONFIG_BIT(region_config,MEM_SYS_SHM_REGION_UDC_UC)){
+ feature_support = ccci_runtime_data_query(AP_CCCI_RUNTIME_MD_UDC_SHARE_MEMORY, &udc_shm_info, sizeof(UDC_SHARE_MEMORY_FORMAT_T));
+ if(feature_support.support_mask == CCCI_RUNTIME_FEATURE_MUST_SUPPORT){
+ if((udc_shm_info.udc_buf.addr != 0x0)&&(udc_shm_info.udc_buf.size != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_UDC_UC);
+ ShareMemoryInfo[var_index++] = udc_shm_info.udc_buf.addr;
+ ShareMemoryInfo[var_index++] = udc_shm_info.udc_buf.size;
+ }
+ }
+ }
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ /* cacheable region */
+
+ if(_MDMP_HAS_REGION_CONFIG_BIT(region_config,MEM_SYS_SHM_REGION_CONSYS)){
+ feature_support = ccci_runtime_data_query(AP_CCCI_RUNTIME_MD_CONSYS_SHARE_MEMORY, &shm_info, sizeof(CCCI_RUNTIME_SHARE_MEMORY_FORMAT_T));
+ if(feature_support.support_mask == CCCI_RUNTIME_FEATURE_MUST_SUPPORT){
+ if((shm_info.addr != 0x0)&&(shm_info.size != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_CONSYS);
+ ShareMemoryInfo[var_index++] = shm_info.addr;
+ ShareMemoryInfo[var_index++] = shm_info.size;
+ }
+ }
+ }
+#if 0 /*feature not ready*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+#if defined(__DHL_CCB_LOGGING_SUPPORT__) || defined(__LWA_SUPPORT__)
+ if(_MDMP_HAS_REGION_CONFIG_BIT(region_config,MEM_SYS_SHM_REGION_CCB_DHL)){
+ ccci_get_ccb_data_shm_info((void **)&share_startaddr, &share_len);
+ if((share_len != 0x0)&&(share_startaddr != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_CCB_DHL);
+ ShareMemoryInfo[var_index++] = share_startaddr;
+ ShareMemoryInfo[var_index++] = share_len;
+ }
+ }
+
+ if(_MDMP_HAS_REGION_CONFIG_BIT(region_config,MEM_SYS_SHM_REGION_CCB_RAW_DHL)){
+ ccci_get_dhl_raw_shm_info((void **)&share_startaddr, &share_len);
+ if((share_len != 0x0)&&(share_startaddr != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_CCB_RAW_DHL);
+ ShareMemoryInfo[var_index++] = share_startaddr;
+ ShareMemoryInfo[var_index++] = share_len;
+ }
+ }
+#endif
+ if(_MDMP_HAS_REGION_CONFIG_BIT(region_config,MEM_SYS_SHM_REGION_UDC_C)){
+ feature_support = ccci_runtime_data_query(AP_CCCI_RUNTIME_MD_UDC_SHARE_MEMORY, &udc_shm_info, sizeof(UDC_SHARE_MEMORY_FORMAT_T));
+ if(feature_support.support_mask == CCCI_RUNTIME_FEATURE_MUST_SUPPORT){
+ if((udc_shm_info.udc_tbl.addr != 0x0)&&(udc_shm_info.udc_tbl.size != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_UDC_C);
+ ShareMemoryInfo[var_index++] = udc_shm_info.udc_tbl.addr;
+ ShareMemoryInfo[var_index++] = udc_shm_info.udc_tbl.size;
+ }
+ }
+ }
+
+ if(_MDMP_HAS_REGION_CONFIG_BIT(region_config,MEM_SYS_SHM_REGION_AUDIO)){
+ feature_support = ccci_runtime_data_query(AP_CCCI_RUNTIME_MD_USIP_SHARE_MEMORY, &shm_info, sizeof(CCCI_RUNTIME_SHARE_MEMORY_FORMAT_T));
+ if(feature_support.support_mask == CCCI_RUNTIME_FEATURE_MUST_SUPPORT){
+ if((shm_info.addr != 0x0)&&(shm_info.size != 0x0)){
+ ShareMemoryFeatureFlag |= (1<<MEM_SYS_SHM_REGION_CONSYS);
+ ShareMemoryInfo[var_index++] = shm_info.addr;
+ ShareMemoryInfo[var_index++] = shm_info.size;
+ }
+ }
+ }
+
+ /* calculate the number of regions to be dumped */
+ *info = (kal_uint32*)ShareMemoryInfo;
+ *count = var_index / 2;
+#else /*__HIF_CCCI_SUPPORT__*/
+
+ *info = NULL;
+ *count = 0;
+
+#endif
+}
+
+
+#endif //defined(__MTK_TARGET__)
+
diff --git a/mcu/service/sys_svc/ftl/src/FTL.c b/mcu/service/sys_svc/ftl/src/FTL.c
new file mode 100644
index 0000000..5ac4002
--- /dev/null
+++ b/mcu/service/sys_svc/ftl/src/FTL.c
@@ -0,0 +1,713 @@
+/*****************************************************************************
+* 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) 2006
+*
+* 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:
+ * ---------
+ * FTL.c
+ *
+ * Project:
+ * --------
+ * Bootloader
+ *
+ * Description:
+ * ------------
+ * Abstraction layer preparing for FTL
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+#include "kal_public_defs.h"
+#include "sw_types.h"
+#include "FTL.h"
+
+#if defined(__EMMC_BOOTING__)
+#include "kal_public_api.h" //MSBB change #include "kal_release.h"
+
+static kal_mutexid ftl_lock = NULL;
+kal_uint32 ftl_task_bitmap[(KAL_MAX_NUM_TASKS + 31) /32];
+#endif /* __EMMC_BOOTING__ */
+
+#ifndef __MTK_TARGET__
+
+FTL_FuncTbl ftlFuncTbl =
+{
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+
+kal_bool FTL_isPollingMode()
+{
+ return KAL_FALSE;
+}
+
+#elif defined(_NAND_FLASH_BOOTING_)
+
+#include "fota_error.h"
+#include "NAND_DAL.h"
+
+#define MAX_SPARE_SIZE (64)
+
+FTL_STATUS_CODE NFB_ERR_2_FTL_ERR(kal_uint32 error)
+{
+ switch(error)
+ {
+ case ERROR_NFB_SUCCESS:
+ case ERROR_NFB_ECC_CORRECTED:
+ return FTL_SUCCESS;
+
+ case ERROR_NFB_READ:
+ return FTL_ERROR_READ_FAILURE;
+
+ case ERROR_NFB_PROGRAM:
+ return FTL_ERROR_WRITE_FAILURE;
+
+ case ERROR_NFB_ERASE:
+ return FTL_ERROR_ERASE_FAILURE;
+
+ case ERROR_NFB_BAD_BLOCK:
+ return FTL_ERROR_BAD_BLOCK;
+
+ }
+ ASSERT(0);
+ return FTL_SUCCESS;
+}
+
+kal_uint32 FTL_GetBlockSize(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ return DAL_GetBlockSize();
+}
+
+kal_uint32 FTL_GetPageSize()
+{
+ return DAL_GetPageSize();
+}
+
+
+FTL_STATUS_CODE FTL_Init(void *pArgv)
+{
+ DAL_init();
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_DeInit(void *pArgv)
+{
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_ReadPage(kal_uint32 block, kal_uint32 page, kal_uint32 *pBuf, FTL_OptParam *opt_param)
+{
+ kal_int32 status;
+
+ ASSERT(opt_param == NULL || opt_param->bypass_dal == KAL_FALSE);
+
+ status = (opt_param == NULL || !opt_param->is_polling) ? NFB_ReadPhysicalPage(block, page, pBuf)
+ : demp_ReadPhysicalPage(block, page, pBuf);
+
+ if(status > 0)
+ {
+ return FTL_SUCCESS;
+ }
+ return NFB_ERR_2_FTL_ERR(status);
+}
+
+FTL_STATUS_CODE FTL_WritePage(kal_uint32 block, kal_uint32 page, kal_uint32 *pBuf, FTL_OptParam *opt_param)
+{
+ kal_int32 status = NFB_ProgramPhysicalPage(block, page, pBuf, KAL_TRUE);
+ if(status > 0)
+ {
+ return FTL_SUCCESS;
+ }
+ return NFB_ERR_2_FTL_ERR(status);
+}
+
+FTL_STATUS_CODE FTL_CheckGoodBlock(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ kal_uint32 status = NFB_CheckGoodBlock2(block, KAL_TRUE);
+ if(status == 0)
+ return FTL_SUCCESS;
+ return FTL_ERROR_BAD_BLOCK;
+}
+
+FTL_STATUS_CODE FTL_MarkBadBlock(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ kal_uint32 status = NFB_MarkBadBlock(block, KAL_TRUE);
+ return NFB_ERR_2_FTL_ERR(status);
+}
+
+FTL_STATUS_CODE FTL_EraseBlock(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ kal_uint32 status = NFB_ErasePhysicalBlock(block, KAL_TRUE);
+ return NFB_ERR_2_FTL_ERR(status);
+}
+
+
+FTL_FuncTbl ftlFuncTbl =
+{
+ FTL_Init,
+ FTL_DeInit,
+ FTL_ReadPage,
+ NULL,
+ FTL_WritePage,
+ FTL_CheckGoodBlock,
+ FTL_MarkBadBlock,
+ FTL_EraseBlock,
+ FTL_GetBlockSize,
+ FTL_GetPageSize,
+};
+
+kal_bool FTL_isPollingMode()
+{
+ return KAL_FALSE;
+}
+
+#elif defined(__EMMC_BOOTING__)
+
+#include "sd_adap.h"
+#define EMMC_ID MCDEV_SD0
+#define EMMC_SECTOR_SIZE 512
+
+kal_uint32 FTL_emmcGetBlockSize(kal_uint32 block, FTL_OptParam *opt_param);
+kal_uint32 FTL_emmcGetPageSize();
+
+static kal_bool initialized = KAL_FALSE;
+
+FTL_STATUS_CODE EMMC_ERR_2_FTL_ERR(DRV_STATUS_CODE error)
+{
+ switch(error)
+ {
+ case DRV_SUCCESS:
+ return FTL_SUCCESS;
+
+ case DRV_READ_FAILURE:
+ return FTL_ERROR_READ_FAILURE;
+
+ case DRV_WRITE_FAILURE:
+ return FTL_ERROR_WRITE_FAILURE;
+
+ case DRV_ERASE_FAILURE:
+ return FTL_ERROR_ERASE_FAILURE;
+
+ case DRV_ECC_CORRECTED:
+ return FTL_ERROR_ECC_CORRECTED;
+
+ default:
+ return FTL_ERROR_OTHER_ERROR;
+ }
+ ASSERT(0);
+ return FTL_SUCCESS;
+}
+
+
+FTL_STATUS_CODE FTL_emmcInit(void *pArgv)
+{
+ DRV_STATUS_CODE status = DRV_SUCCESS;
+
+ if(!initialized)
+ {
+ status = DRV_SD_Init();
+ if(status == DRV_SUCCESS)
+ {
+ status = DRV_SD_MountDevice(EMMC_ID, 0);
+
+ if(status == DRV_SUCCESS)
+ {
+ initialized = KAL_TRUE;
+ }
+ }
+ }
+
+ ftl_lock = kal_create_mutex("FTL Lock");
+
+ return EMMC_ERR_2_FTL_ERR(status);
+}
+
+FTL_STATUS_CODE FTL_emmcDeInit(void *pArgv)
+{
+ DRV_STATUS_CODE status = DRV_SUCCESS;
+
+ if(initialized)
+ {
+ status = DRV_SD_DeInit();
+ if(status == DRV_SUCCESS)
+ {
+ initialized = KAL_FALSE;
+ }
+ }
+ return EMMC_ERR_2_FTL_ERR(status);
+}
+
+FTL_STATUS_CODE FTL_emmcReadPage(kal_uint32 block, kal_uint32 page, kal_uint32 *pBuf, FTL_OptParam *opt_param)
+{
+ DRV_STATUS_CODE status;
+ kal_uint32 task_idx, sector;
+
+#if !defined(__FUE__) && !defined(__UBL__)
+ if (opt_param->is_polling)
+ {
+ kal_get_my_task_index(&task_idx);
+
+ get_FTL_lock();
+ /* set the corresponding polling bit */
+ ftl_task_bitmap[task_idx >> 5] |= (0x1 << (task_idx & 31));
+ free_FTL_lock();
+ }
+#endif /* !__FUE__ && !__UBL__ */
+
+ sector = (block * FTL_emmcGetBlockSize(0, NULL)) / EMMC_SECTOR_SIZE
+ + (page * FTL_emmcGetPageSize()) / EMMC_SECTOR_SIZE;
+
+ status = DRV_SD_ReadSectors(EMMC_ID, sector, FTL_emmcGetPageSize()/EMMC_SECTOR_SIZE, pBuf, 0);
+
+#if !defined(__FUE__) && !defined(__UBL__)
+ if (opt_param->is_polling)
+ {
+ get_FTL_lock();
+ /* clear the corresponding polling bit */
+ ftl_task_bitmap[task_idx >> 5] &= ~(0x1 << (task_idx & 31));
+ free_FTL_lock();
+ }
+#endif /* !__FUE__ && !__UBL__ */
+
+ return EMMC_ERR_2_FTL_ERR(status);
+}
+
+FTL_STATUS_CODE FTL_emmcWritePage(kal_uint32 block, kal_uint32 page, kal_uint32 *pBuf, FTL_OptParam *opt_param)
+{
+ DRV_STATUS_CODE status;
+
+ kal_uint32 sector = (block * FTL_emmcGetBlockSize(0, NULL))/EMMC_SECTOR_SIZE + (page * FTL_emmcGetPageSize())/EMMC_SECTOR_SIZE;
+
+ status = DRV_SD_WriteSectors(EMMC_ID, sector, FTL_emmcGetPageSize()/EMMC_SECTOR_SIZE, pBuf, 0);
+
+ return EMMC_ERR_2_FTL_ERR(status);
+}
+
+FTL_STATUS_CODE FTL_emmcCheckGoodBlock(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_emmcMarkBadBlock(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_emmcEraseBlock(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ DRV_STATUS_CODE status = DRV_SUCCESS;
+ kal_uint32 i;
+ kal_uint32 sector = (block * FTL_emmcGetBlockSize(0, NULL)) / EMMC_SECTOR_SIZE;
+ kal_uint32 sectorCount = FTL_emmcGetBlockSize(0, NULL)/EMMC_SECTOR_SIZE;
+ static kal_uint32 dummyBuf[FTL_EMMC_PAGE_SIZE>>2];
+
+ memset(dummyBuf, 0xff, sizeof(dummyBuf));
+ for(i=0; i<sectorCount && status==DRV_SUCCESS; i+=sizeof(dummyBuf)/EMMC_SECTOR_SIZE)
+ {
+ status = DRV_SD_WriteSectors(EMMC_ID, sector+i, sizeof(dummyBuf)/EMMC_SECTOR_SIZE, dummyBuf, 0);
+ }
+
+ if(status != DRV_SUCCESS)
+ {
+ return FTL_ERROR_ERASE_FAILURE;
+ }
+ else
+ {
+ return FTL_SUCCESS;
+ }
+}
+
+kal_uint32 FTL_emmcGetBlockSize(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ return FTL_EMMC_BLOCK_SIZE;
+}
+
+kal_uint32 FTL_emmcGetPageSize()
+{
+ return FTL_EMMC_PAGE_SIZE;
+}
+
+FTL_FuncTbl ftlFuncTbl =
+{
+ FTL_emmcInit,
+ FTL_emmcDeInit,
+ FTL_emmcReadPage,
+ NULL,
+ FTL_emmcWritePage,
+ FTL_emmcCheckGoodBlock,
+ FTL_emmcMarkBadBlock,
+ FTL_emmcEraseBlock,
+ FTL_emmcGetBlockSize,
+ FTL_emmcGetPageSize
+};
+
+kal_bool FTL_isPollingMode()
+{
+ kal_uint32 task_idx;
+ kal_bool is_polling;
+
+ kal_get_my_task_index(&task_idx);
+ is_polling = ((ftl_task_bitmap[task_idx >> 5] & (0x1 << (task_idx & 31))) != 0) ? KAL_TRUE : KAL_FALSE;
+
+ return is_polling;
+}
+
+#else
+
+#ifdef __NOR_FULL_DRIVER__ //BL_TODO
+
+#include <flash_disk.h>
+
+FTL_STATUS_CODE NOR_ERR_2_FTL_ERR(kal_uint32 error)
+{
+ switch(error)
+ {
+ case ERROR_NOR_SUCCESS:
+ return FTL_SUCCESS;
+
+ case ERROR_NOR_READ:
+ return FTL_ERROR_READ_FAILURE;
+
+ case ERROR_NOR_PROGRAM:
+ return FTL_ERROR_WRITE_FAILURE;
+
+ case ERROR_NOR_ERASE:
+ return FTL_ERROR_ERASE_FAILURE;
+
+ }
+ ASSERT(0);
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_Init(void *pArgv)
+{
+ kal_int32 status;
+ static kal_bool initialized = KAL_FALSE;
+
+ if(initialized)
+ {
+ return FTL_SUCCESS;
+ }
+
+ status = NOR_init();
+ initialized = KAL_TRUE;
+
+ return NOR_ERR_2_FTL_ERR(status);
+}
+
+FTL_STATUS_CODE FTL_DeInit(void *pArgv)
+{
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_ReadPage(kal_uint32 block, kal_uint32 page, kal_uint32 *pBuf, FTL_OptParam *opt_param)
+{
+ kal_int32 status;
+
+ status = NOR_ReadPhysicalPage(block, page, (kal_uint8*)pBuf);
+
+ return NOR_ERR_2_FTL_ERR(status);
+ }
+
+FTL_STATUS_CODE FTL_WritePage(kal_uint32 block, kal_uint32 page, kal_uint32 *pBuf, FTL_OptParam *opt_param)
+{
+ kal_int32 status;
+
+#if defined(__NOR_FULL_DRIVER__)
+
+ status = NOR_ProgramPhysicalPage(block, page, (kal_uint8*)pBuf);
+
+ return NOR_ERR_2_FTL_ERR(status);
+
+#else
+
+ return FTL_ERROR_WRITE_FAILURE;
+
+#endif
+
+ }
+
+FTL_STATUS_CODE FTL_CheckGoodBlock(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_MarkBadBlock(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_EraseBlock(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ kal_int32 status;
+
+#if defined(__NOR_FULL_DRIVER__)
+
+ status = NOR_ErasePhysicalBlock(block);
+
+ return NOR_ERR_2_FTL_ERR(status);
+
+#else
+
+ return FTL_ERROR_ERASE_FAILURE;
+
+#endif
+
+}
+
+kal_uint32 FTL_GetBlockSize(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ return NOR_BlockSize(block);
+}
+
+kal_uint32 FTL_GetPageSize()
+{
+ return 2048;
+}
+
+kal_uint32 FTL_AddrToBlockPage(kal_uint32 addr, kal_uint32 *pBlock, kal_uint32 *pPage, FTL_OptParam *opt_param)
+{
+ kal_int32 status;
+ kal_uint32 offset;
+
+ ASSERT(pBlock);
+
+ status = NOR_Addr2BlockIndexOffset(addr, pBlock, &offset);
+
+ if(status == ERROR_NOR_SUCCESS)
+ {
+ *pPage = offset / FTL_GetPageSize();
+ return FTL_SUCCESS;
+ }
+
+ return NOR_ERR_2_FTL_ERR(status);
+}
+
+kal_uint32 FTL_BlockPageToAddr(kal_uint32 Block, kal_uint32 Page, kal_uint32 *addr, FTL_OptParam *opt_param)
+{
+ kal_uint32 offset;
+
+ ASSERT(addr);
+
+ offset = Page * FTL_GetPageSize();
+
+ return NOR_BlockIndexOffset2Addr(Block, offset, addr);
+}
+
+
+FTL_FuncTbl ftlFuncTbl =
+{
+ FTL_Init,
+ FTL_DeInit,
+ FTL_ReadPage,
+ NULL,
+ FTL_WritePage,
+ FTL_CheckGoodBlock,
+ FTL_MarkBadBlock,
+ FTL_EraseBlock,
+ FTL_GetBlockSize,
+ FTL_GetPageSize,
+ FTL_AddrToBlockPage,
+ FTL_BlockPageToAddr
+};
+
+kal_bool FTL_isPollingMode()
+{
+ return KAL_FALSE;
+}
+
+#else
+
+
+FTL_STATUS_CODE FTL_Init(void *pArgv)
+{
+ ASSERT(0);
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_DeInit(void *pArgv)
+{
+ ASSERT(0);
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_ReadPage(kal_uint32 block, kal_uint32 page, kal_uint32 *pBuf, FTL_OptParam *opt_param)
+{
+ ASSERT(0);
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_WritePage(kal_uint32 block, kal_uint32 page, kal_uint32 *pBuf, FTL_OptParam *opt_param)
+{
+ ASSERT(0);
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_CheckGoodBlock(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ ASSERT(0);
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_MarkBadBlock(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ ASSERT(0);
+ return FTL_SUCCESS;
+}
+
+FTL_STATUS_CODE FTL_EraseBlock(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ ASSERT(0);
+ return FTL_SUCCESS;
+}
+
+kal_uint32 FTL_GetBlockSize(kal_uint32 block, FTL_OptParam *opt_param)
+{
+ ASSERT(0);
+ return 0;
+}
+
+kal_uint32 FTL_GetPageSize()
+{
+ ASSERT(0);
+ return 0;
+}
+
+kal_uint32 FTL_AddrToBlockPage(kal_uint32 addr, kal_uint32 *pBlock, kal_uint32 *pPage, FTL_OptParam *opt_param)
+{
+ ASSERT(0);
+ return FTL_SUCCESS;
+}
+
+kal_uint32 FTL_BlockPageToAddr(kal_uint32 Block, kal_uint32 Page, kal_uint32 *addr, FTL_OptParam *opt_param)
+{
+ ASSERT(0);
+ return FTL_SUCCESS;
+}
+
+FTL_FuncTbl ftlFuncTbl =
+{
+ FTL_Init,
+ FTL_DeInit,
+ FTL_ReadPage,
+ NULL,
+ FTL_WritePage,
+ FTL_CheckGoodBlock,
+ FTL_MarkBadBlock,
+ FTL_EraseBlock,
+ FTL_GetBlockSize,
+ FTL_GetPageSize,
+ FTL_AddrToBlockPage,
+ FTL_BlockPageToAddr
+};
+
+kal_bool FTL_isPollingMode()
+{
+ return KAL_FALSE;
+}
+
+#endif /* BL_TODO */
+
+#endif
+
diff --git a/mcu/service/sys_svc/gfh/public/GFH_defs.h b/mcu/service/sys_svc/gfh/public/GFH_defs.h
new file mode 100644
index 0000000..daa4ad8
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/GFH_defs.h
@@ -0,0 +1,114 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2009
+*
+* 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:
+ * ---------
+ * GFH_defs.h
+ *
+ * Project:
+ * --------
+ * BOOTROM
+ *
+ * Description:
+ * ------------
+ * Define values and structures for GFH body definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __GFH_DEFS_H__
+#define __GFH_DEFS_H__
+
+#include "br_GFH.h"
+#include "sw_types.h"
+
+//==============================================================================
+// SIGNATURE version and size, depending on the platform
+// CAUSION: DO NOT change these values at well
+//==============================================================================
+
+#define SIG_HASH_VER (1) //Signature Configure V1, RSA2048 + SHA256
+#define SIG_CERT_VER (2)
+#define SIG_NONE_LEN (0)
+#define SIG_PHASH_LEN (32)
+#define SIG_SINGLE_LEN (256)
+#define SIG_SINGLE_AND_PHASH_LEN (292)
+#define SIG_CERT_CHAIN_LEN (1644)
+
+//==============================================================================
+// GFH structures
+// CAUSION: DO NOT change these definition at well
+//==============================================================================
+
+typedef struct {
+ GFH_Header m_gfh_hdr;
+ U8 _reserved[524];
+} GFH_BL_SEC_KEY_v1;
+
+typedef struct {
+ GFH_Header m_gfh_hdr;
+ U8 _reserved[524];
+} GFH_MAUI_SEC_KEY_v1;
+
+typedef GFH_MAUI_SEC_KEY_v1 GFH_MAUI_CODE_KEY_v1;
+typedef GFH_MAUI_SEC_KEY_v1 GFH_MAUI_SECURE_RO_KEY_v1;
+typedef GFH_MAUI_SEC_KEY_v1 GFH_MAUI_RESOURCE_KEY_v1;
+
+typedef struct {
+ GFH_Header m_gfh_hdr;
+ U8 _reserved[40];
+} GFH_BROM_SEC_CFG_v1;
+
+typedef struct {
+ GFH_Header m_gfh_hdr;
+ U8 _reserved[8];
+} GFH_BROM_CFG_v1;
+
+typedef struct {
+ GFH_Header m_gfh_hdr;
+ U8 _reserved[73];
+} GFH_BROM_CFG_v2;
+
+typedef struct {
+ GFH_Header m_gfh_hdr;
+ U8 _reserved[92];
+} GFH_BROM_CFG_v3;
+
+#endif /* __GFH_DEFS_H__ */
+
diff --git a/mcu/service/sys_svc/gfh/public/Gen93/maui_GFH_body.c b/mcu/service/sys_svc/gfh/public/Gen93/maui_GFH_body.c
new file mode 100644
index 0000000..0461f07
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/Gen93/maui_GFH_body.c
@@ -0,0 +1,515 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * maui_GFH_body.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file contain the GFH body and content for all MAUI parts
+ *
+ * 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!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+
+#include "br_GFH.h"
+#include "br_GFH_file_info.h"
+#include "br_GFH_maui_info.h"
+#include "br_GFH_flash_info.h"
+#include "br_GFH_cbr_info.h"
+#include "br_GFH_maui_sec.h"
+#include "br_GFH_secure_ro_info.h"
+#include "br_GFH_binary_location.h"
+#include "SST_init.h"
+#include "brom_ext.h"
+
+
+#include "GFH_defs.h"
+#include "Gen93/maui_GFH_body.h"
+#include "feature_def.h"
+
+#include "custom_img_config.h"
+
+#include "kal_general_types.h"
+
+#ifdef _NAND_FLASH_BOOTING_
+#include "NAND_DAL_Version.h"
+#endif
+
+#ifdef __BOOT_CERT_V2__
+#include "boot_cert_pattern.h"
+#endif
+
+//==============================================================================
+// Linker symbols
+//==============================================================================
+
+extern kal_uint32 Image$$AUROM$$Base;
+
+extern kal_uint32 INT_VECTOR_CODE$$Base;
+extern kal_uint32 INT_VECTOR_CODE$$Limit;
+
+
+extern kal_uint32 Image$$ROM_GFH$$Length;
+extern kal_uint32 Load$$ROM_GFH$$Base;
+
+extern kal_uint32 BR_EXT$$Length;
+extern kal_uint32 BR_EXT$$Base;
+
+extern kal_uint32 Image$$SECURE_RO_S_GFH$$Length;
+extern kal_uint32 Load$$SECURE_RO_S_GFH$$Base;
+
+extern kal_uint32 Image$$SECURE_RO_ME_GFH$$Length;
+extern kal_uint32 Load$$SECURE_RO_ME_GFH$$Base;
+
+//==============================================================================
+// Section definition
+//==============================================================================
+
+#undef __section
+
+#ifdef __MTK_TARGET__
+#define __section(S) __attribute__ ((used,section(#S)))
+#else
+#define __section(S)
+#endif
+
+#define __maui_iv_region_section__ __section(MAUI_IV_REGION)
+#define __maui_gfh__ __section(MAUI_GFH)
+#define __maui_signature_section__ __section(MAUI_SIGNATURE_SECTION)
+#define __brom_ext_section__ __section(BROM_EXT)
+#define __brom_ext_signature_section__ __section(BROM_EXT_SIGNATURE_SECTION)
+#define __secure_ro_s_gfh__ __section(SECURE_RO_S_GFH)
+#define __secure_ro_s_signature_section__ __section(SECURE_RO_S_SIGNATURE_SECTION)
+#define __secure_ro_me_gfh__ __section(SECURE_RO_ME_GFH)
+#define __secure_ro_me_signature_section__ __section(SECURE_RO_ME_SIGNATURE_SECTION)
+
+/* SECURE RO S is not ready yet, we use a macro to disable it first */
+#define __SECURE_RO_S_DISABLE__
+
+//==============================================================================
+// MAUI parameters
+//==============================================================================
+
+//Define where the MAUI locates
+#if defined (_NAND_FLASH_BOOTING_)
+
+#define MAUI_DEVICE_TYPE F_NAND_FDM50
+#define BINARY_ATTRIBUTE 0
+
+#elif defined (__EMMC_BOOTING__)
+
+#define MAUI_DEVICE_TYPE F_EMMC_DATA_REGION
+#define BINARY_ATTRIBUTE 0
+
+#elif defined(__X_BOOTING__)
+
+#define MAUI_DEVICE_TYPE F_XBOOT
+#define BINARY_ATTRIBUTE 0
+
+#else
+
+#define MAUI_DEVICE_TYPE F_NOR
+
+#if defined(__XIP_SHADOWING__)
+#define BINARY_ATTRIBUTE 0
+#else
+#endif
+#if defined(__USE_PSS__)
+#define BINARY_ATTRIBUTE FILE_INFO_ATTR_XIP | FILE_INFO_ATTR_USE_RSA_PSS
+#else
+#define BINARY_ATTRIBUTE FILE_INFO_ATTR_XIP
+#endif
+
+#endif
+
+
+//Define the size of MAUI iv region
+#define MAUI_IV_REGION_LEN 0x400
+#define MAUI_IV_REGION_MARK "IV_REGION"
+
+//Define the signature type of MAUI binaries
+#define P_MAUI_SIGNATURE_TYPE SIG_SINGLE
+#define P_MAUI_SIGNATURE_LEN SIG_SINGLE_LEN
+
+//Constants
+#define DUMMY_END (0xffffffff)
+
+//Define the version of MAUI software
+#define MAUI_VERSION 1
+#define SECURE_RO_VERSION 1
+
+
+//==============================================================================
+// MAUI's initial vector region
+//==============================================================================
+__maui_iv_region_section__ const char g_maui_iv_region[MAUI_IV_REGION_LEN] = MAUI_IV_REGION_MARK;
+
+//==============================================================================
+// MAUI's GFH header body
+//==============================================================================
+
+
+__maui_gfh__ const MAUI_GFH g_maui_gfh =
+{
+ //GFH_FILE_INFO_v1
+ {
+ GFH_HEADER(GFH_FILE_INFO, 1),
+ GFH_FILE_INFO_ID,
+
+ MAUI_VERSION,
+#ifndef __FACTORY_BIN__
+ PRIMARY_MAUI,
+#else
+ PRIMARY_FACTORY_BIN,
+#endif
+ MAUI_DEVICE_TYPE,
+ P_MAUI_SIGNATURE_TYPE,
+
+ (kal_uint32)(&Load$$ROM_GFH$$Base) + MAUI_IV_REGION_LEN,
+ GFH_FILE_SIZE_BY_POST_BUILD,
+ MAX_LENGTH_ROM,
+ (kal_uint32)(&Image$$ROM_GFH$$Length) - MAUI_IV_REGION_LEN,
+ P_MAUI_SIGNATURE_LEN,
+ (kal_uint32)(&Image$$AUROM$$Base),
+ BINARY_ATTRIBUTE
+ },
+
+ //GFH_MAUI_INFO_v2
+ {
+ GFH_HEADER(GFH_MAUI_INFO, 2),
+
+ //platform_id & project_id
+ "N/A",
+ "N/A",
+
+ 1, //BL_MAUI_PAIRED_VER,
+ FEATURE_COMBINATION,
+ FEATURE_COMBINATINO_EX,
+ 0,
+ SW_MINOR_VER,
+#ifdef __SECURE_DATA_STORAGE__
+ SDS_START_ADDR,
+ SDS_TOTAL_SIZE,
+#else
+ 0,
+ 0,
+#endif
+ MIN_FLASHTOOL_VER_REQURIEMENT,
+#ifdef __BOOT_CERT_V2__
+ (kal_uint32)&g_SRD_INFO,
+ (kal_uint32)sizeof(g_SRD_INFO),
+#else
+ 0,0,
+#endif
+ {0}
+
+ },
+
+ //GFH_FLASH_INFO_v1
+ {
+ GFH_HEADER(GFH_FLASH_INFO, 1),
+#ifdef _NAND_FLASH_BOOTING_
+ { 0x30, (FDM_MAJOR_VER+0x30), (FDM_MINOR_VER1+0x30), (FDM_MINOR_VER2+0x30),
+ 0x30, (DAL_MAJOR_VER+0x30), (DAL_MINOR_VER1+0x30), (DAL_MINOR_VER2+0x30)
+ },
+#endif
+ },
+
+ //GFH_CBR_INFO_v2
+ {
+ GFH_HEADER(GFH_CBR_INFO, 2),
+ 0, //CBR_REGION_NORMAL_BLOCK_NUM,
+ 0, //CBR_REGION_SPARE_BLOCK_NUM,
+ 0,
+ 0
+ },
+
+#ifdef __MTK_SECURE_PLATFORM__
+ //GFH_MAUI_SEC_v1
+ {
+ GFH_HEADER(GFH_MAUI_SEC, 1),
+ },
+#endif /* __MTK_SECURE_PLATFORM__ */
+
+ //GFH_MAUI_CODE_KEY_v1, for Code binaries
+ {
+ GFH_HEADER(GFH_MAUI_CODE_KEY, 1),
+ },
+
+ //GFH_MAUI_SECURE_RO_KEY_v1, for Secure RO
+ /*{
+ GFH_HEADER(GFH_MAUI_SECURE_RO_KEY, 1),
+ },*/
+
+#ifdef __FOTA_DM__
+ //GFH_FOTA_INFO_v1
+ {
+ GFH_HEADER(GFH_FOTA_INFO, 1),
+ FOTA_PACKAGE_STORAGE_BASE,
+ FOTA_PACKAGE_STORAGE_SIZE,
+ FOTA_BACKUP_STORAGE_BASE,
+ FOTA_BACKUP_STORAGE_SIZE,
+ FOTA_EXTRA_RESERVED_BLOCKS,
+ },
+#endif
+
+#ifdef __XIP_SHADOWING__
+ //GFH_BINARY_LOCATION_v1
+ {
+ GFH_HEADER(GFH_BINARY_LOCATION, 1),
+#ifndef __FACTORY_BIN__
+ MAUI_ROM_START_ADDR
+#else
+ FACTORY_ROM_START_ADDR
+#endif
+ },
+#endif
+
+ //GFH_VEC_INFO_v1
+ {
+ GFH_HEADER(GFH_VEC_INFO, 1),
+ (kal_uint32)(&INT_VECTOR_CODE$$Base),
+ (kal_uint32)(&INT_VECTOR_CODE$$Limit)
+ },
+
+};
+
+//==============================================================================
+// MAUI's Signature
+//==============================================================================
+__maui_signature_section__ const unsigned long g_maui_sig[P_MAUI_SIGNATURE_LEN>>2] = {SIG_HASH_VER};
+
+//==============================================================================
+// Misc
+//==============================================================================
+kal_uint32 DummyReference()
+{
+ kal_uint32 size = 0;
+
+ size += ((kal_uint32)(&g_maui_iv_region)
+ + (kal_uint32)(&g_maui_gfh)+(kal_uint32)(&g_maui_sig)
+ );
+
+ return size;
+}
+
+
diff --git a/mcu/service/sys_svc/gfh/public/Gen93/maui_GFH_body.h b/mcu/service/sys_svc/gfh/public/Gen93/maui_GFH_body.h
new file mode 100644
index 0000000..ccc2a7a
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/Gen93/maui_GFH_body.h
@@ -0,0 +1,178 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * secure_maui_GFH_body.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file contain the GFH definition
+ *
+ * Author:
+ * -------
+ *
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef __MAUI_GFH_BODY_H__
+#define __MAUI_GFH_BODY_H__
+
+#include "br_GFH_file_info.h"
+#include "br_GFH_maui_info.h"
+#include "br_GFH_anti_clone.h"
+#include "br_GFH_maui_sec.h"
+#include "br_GFH_secure_ro_info.h"
+#include "br_GFH_flash_info.h"
+#include "br_GFH_fota_info.h"
+#include "br_GFH_cbr_record_info.h"
+#include "br_GFH_cbr_info.h"
+#include "br_GFH_binary_location.h"
+#include "br_GFH_vec_info.h"
+#include "br_GFH_brom_ext_info.h"
+#include "GFH_defs.h"
+
+//==============================================================================
+// Primary MAUI GFH structure
+//==============================================================================
+
+typedef struct
+{
+ GFH_FILE_INFO_v1 gfh_file_info;
+ GFH_MAUI_INFO_v2 gfh_maui_info;
+ GFH_FLASH_INFO_v1 gfh_flash_info;
+ GFH_CBR_INFO_v2 gfh_cbr_info;
+
+#ifdef __MTK_SECURE_PLATFORM__
+ GFH_MAUI_SEC_v1 gfh_maui_sec;
+#endif /* __MTK_SECURE_PLATFORM__ */
+ GFH_MAUI_CODE_KEY_v1 gfh_maui_sec_key_maui; //The key to verify SecondaryMAUI
+ //GFH_MAUI_SECURE_RO_KEY_v1 gfh_maui_sec_key_secro; //The key to verify SecureRO
+
+#ifdef __FOTA_DM__
+ GFH_FOTA_INFO_v1 gfh_fota_info;
+#endif /* __FOTA_DM__ */
+
+#ifdef __XIP_SHADOWING__
+ GFH_BINARY_LOCATION_v1 gfh_binary_location;
+#endif /* __XIP_SHADOWING__ */
+ GFH_VEC_INFO_v1 gfh_vec_info;
+} MAUI_GFH;
+
+//==============================================================================
+// Export symbols
+//==============================================================================
+
+extern const MAUI_GFH g_maui_gfh;
+
+#endif /* __MAUI_GFH_BODY_H__ */
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH.h b/mcu/service/sys_svc/gfh/public/br_GFH.h
new file mode 100644
index 0000000..0c716b0
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH.h
@@ -0,0 +1,161 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * GFH(General File Header) header definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_H__
+#define __BR_GFH_H__
+
+#include "br_sw_types.h"
+
+//==============================================================================
+// GFH type definition
+//==============================================================================
+
+typedef enum {
+
+ GFH_FILE_INFO = 0x0000
+ ,GFH_BL_INFO = 0x0001
+ ,GFH_ANTI_CLONE = 0x0002
+ ,GFH_BL_SEC_KEY = 0x0003
+ ,GFH_SCTRL_CERT = 0x0004
+ ,GFH_TOOL_AUTH = 0x0005
+ ,GFH_MTK_RESERVED1 = 0x0006
+ ,GFH_BROM_CFG = 0x0007
+ ,GFH_BROM_SEC_CFG = 0x0008
+ ,GFH_MTK_RESERVED2 = 0x0009
+ ,GFH_MTK_RESERVED3 = 0x000a
+ ,GFH_ROOT_CERT = 0x000b
+ ,GFH_EXP_CHK = 0x000c
+ ,GFH_EPP_PARAM = 0x000d
+ ,GFH_CHIP_VER = 0x000e
+ ,GFH_MTK_RESERVED4 = 0x000f
+ ,GFH_MD_SEC_CFG = 0x0010
+
+ ,GFH_EPP_INFO = 0x0100
+ ,GFH_EMI_LIST = 0x0101
+ ,GFH_CMEM_ID_INFO = 0x0102
+ ,GFH_CMEM_NOR_INFO = 0x0103
+ ,GFH_DSP_INFO = 0x0104
+
+ ,GFH_MAUI_INFO = 0x0200
+ ,GFH_MAUI_SEC = 0x0201
+ ,GFH_MAUI_CODE_KEY = 0x0202 //MAUI_SEC_KEY for code part
+ ,GFH_MAUI_SECURE_RO_KEY = 0x0203 //MAUI_SEC_KEY for secure ro part
+ ,GFH_MAUI_RESOURCE_KEY = 0x0204 //MAUI_SEC_KEY for resource part
+
+ ,GFH_SECURE_RO_INFO = 0x0205
+
+ ,GFH_DL_PACKAGE_INFO = 0x0206
+ ,GFH_FLASH_INFO = 0x0207
+ ,GFH_MACR_INFO = 0x0208
+ ,GFH_ARM_BL_INFO = 0x0209
+ ,GFH_EMMC_BOOTING_INFO = 0x020A
+ ,GFH_FOTA_INFO = 0x020B
+ ,GFH_CBR_RECORD_INFO = 0x020C
+ ,GFH_CONFIDENTIAL_BIN_INFO = 0x020D
+ ,GFH_CBR_INFO = 0x020E
+ ,GFH_MBA_INFO = 0x020F
+ ,GFH_BINARY_LOCATION = 0x0210
+ ,GFH_VEC_INFO = 0x0211
+ ,GFH_BROM_EXT_INFO = 0x0212
+
+ ,GFH_BOOT_CERT_CTRL_CONTENT = 0x0300
+
+ ,GFH_TYPE_NUM
+ ,GFH_TYPE_END = (U16)0xffff
+} GFH_TYPE;
+
+//==============================================================================
+// GFH header definition
+//==============================================================================
+
+#define GFH_HDR_MAGIC 0x004D4D4D // "MMM"
+#define GFH_HDR_MAGIC_END_MARK 0x45454545 // "EEEE"
+#define GFH_GET_MAGIC(magic_ver) ((magic_ver)&0x00FFFFFF)
+#define GFH_GET_VER(magic_ver) ((magic_ver)>>24)
+
+// WARNING!! in order to guarantee all GFH structure is 4B aligned and size is multiple of 4B
+// the following rules must be guaranteed!
+// 1. GFH_Header structure size must be multiple of 4B
+// 2. GFH_Header structure alignment must be 4B aligned
+// so that use m_magic_ver(U32) to guarantee that
+typedef struct GFH_Header {
+ U32 m_magic_ver;
+ U16 m_size;
+ #if defined(WIN32)
+ U16 m_type;
+ #else
+ GFH_TYPE m_type;
+ #endif
+} GFH_Header;
+
+typedef struct GFH_End {
+ U32 m_magic_end;
+} GFH_End;
+
+#define GFH_HEADER(type, ver) { (GFH_HDR_MAGIC|((ver)<<24)) , sizeof(type##_v##ver), type}
+
+//==============================================================================
+// Misc definition
+//==============================================================================
+
+#define SECURE_CUST_NAME_LEN 32 // 32B
+#define MAX_DA_BLOCKS 10
+
+//==============================================================================
+// FILE_INFO GFH definition
+//==============================================================================
+// Raymond : Fix recursive header inclusion problem br_GFH.h -> br_GFH_file_info.h -> br_GFH.h
+//#include "br_GFH_file_info.h"
+
+#endif
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_anti_clone.c b/mcu/service/sys_svc/gfh/public/br_GFH_anti_clone.c
new file mode 100644
index 0000000..e3ebf46
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_anti_clone.c
@@ -0,0 +1,118 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_anti_clone.c
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * ANTI_CLONE GFH structure implementation
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#include "br_GFH_anti_clone.h"
+#include "br_bootrom_error.h"
+
+//==============================================================================
+// GFH: ANTI_CLONE exported APIs
+//==============================================================================
+U32 GFH_ANTI_CLONE_IsValid(const GFH_FILE_INFO_v1 *p_gfh_file_info,
+ const GFH_ANTI_CLONE_v1 *p_gfh_anti_clone)
+{
+ U32 ac_offset;
+ U32 ac_len;
+ U32 ac_valid_len;
+
+ //-------------------------------------------------
+ // check FILE_INFO
+ //-------------------------------------------------
+ if( NULL == p_gfh_file_info )
+ {
+ return E_GFH_FILE_INFO_NOT_FOUND;
+ }
+
+ //-------------------------------------------------
+ // check ANTI_CLONE
+ //-------------------------------------------------
+ if( NULL == p_gfh_anti_clone )
+ {
+ return E_GFH_ANTI_CLONE_NOT_FOUND;
+ }
+
+ // get current BL AC_K_EN/AC_C_EN setting to check if Anti-clone is enabled
+ if( !(p_gfh_anti_clone->m_ac_b2k || p_gfh_anti_clone->m_ac_b2c) )
+ {
+ // Anti-clone is disabled
+ return B_OK;
+ }
+
+ //-------------------------------------------------
+ // check AC offset and len
+ //-------------------------------------------------
+ ac_offset = p_gfh_anti_clone->m_ac_offset;
+ ac_len = p_gfh_anti_clone->m_ac_len;
+
+ // check if file content length is valid
+ if( p_gfh_file_info->m_file_len <= p_gfh_file_info->m_content_offset + p_gfh_file_info->m_sig_len )
+ {
+ // file content length is invalid, there is no available anti-clone area
+ return E_AC_FILE_CONTENT_LEN_INVALID;
+ }
+
+ // calculate valid anti-clone area
+ ac_valid_len = (p_gfh_file_info->m_file_len - p_gfh_file_info->m_content_offset - p_gfh_file_info->m_sig_len);
+
+ // check if anti-clone area locates in valid region
+ if( (0 == ac_len)
+ || (ac_valid_len <= ac_offset)
+ || (ac_valid_len <= ac_len)
+ || ((ac_valid_len-ac_offset) <= ac_len)
+ ) {
+ // Anti-clone area must locate between content offset and signature addr
+ return E_AC_OFFSET_OR_LEN_INVALID;
+ }
+
+ return B_OK;
+}
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_anti_clone.h b/mcu/service/sys_svc/gfh/public/br_GFH_anti_clone.h
new file mode 100644
index 0000000..e6f0037
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_anti_clone.h
@@ -0,0 +1,85 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_anti_clone.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * ANTI_CLONE GFH structure declaration
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_ANTI_CLONE_H__
+#define __BR_GFH_ANTI_CLONE_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+#include "br_GFH_file_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//==============================================================================
+// ANTI_CLONE definition
+//==============================================================================
+
+typedef struct GFH_ANTI_CLONE_v1 {
+ GFH_Header m_gfh_hdr;
+ bool m_ac_b2k;
+ bool m_ac_b2c;
+ U32 m_ac_offset; // offset begins from FILE_INFO content offset
+ U32 m_ac_len;
+} GFH_ANTI_CLONE_v1;
+
+extern U32 GFH_ANTI_CLONE_IsValid(const GFH_FILE_INFO_v1 *p_gfh_file_info,
+ const GFH_ANTI_CLONE_v1 *p_gfh_anti_clone);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_arm_bl_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_arm_bl_info.h
new file mode 100644
index 0000000..df4d7a9
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_arm_bl_info.h
@@ -0,0 +1,74 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_arm_bl_info.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * ARM_BL_INFO(ARM BL specific information) GFH structure definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_ARM_BL_INFO_H__
+#define __BR_GFH_ARM_BL_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+//==============================================================================
+// ARM_BL_INFO definition
+//==============================================================================
+
+typedef struct GFH_ARM_BL_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+ U32 m_bl_maui_paired_ver;
+ U32 m_feature_combination;
+ U32 m_feature_combination_ex;
+ U8 m_nand_fdm_dal_ver[8];
+} GFH_ARM_BL_INFO_v1;
+
+#endif
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_binary_location.h b/mcu/service/sys_svc/gfh/public/br_GFH_binary_location.h
new file mode 100644
index 0000000..65f454d
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_binary_location.h
@@ -0,0 +1,72 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_binary_location.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * GFH_BINARY_LOCATION GFH structure definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_BINARY_LOCATION_H__
+#define __BR_GFH_BINARY_LOCATION_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+//==============================================================================
+// GFH_BINARY_LOCATION definition
+//==============================================================================
+
+typedef struct GFH_BINARY_LOCATION_v1 {
+ GFH_Header m_gfh_hdr;
+ U32 m_binary_location;
+ U32 m_reserve[5];
+} GFH_BINARY_LOCATION_v1;
+
+#endif
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_bl_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_bl_info.h
new file mode 100644
index 0000000..b6a0ef0
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_bl_info.h
@@ -0,0 +1,73 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_bl_info.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * BL_INFO(BL information) GFH structure declaration
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_BL_INFO_H__
+#define __BR_GFH_BL_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+//==============================================================================
+// BL_INFO definition
+//==============================================================================
+
+// BL attributes
+#define BL_ATTR_LOAD_BY_BOOTROM 0x00000001
+
+typedef struct GFH_BL_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+ U32 m_bl_attr;
+} GFH_BL_INFO_v1;
+
+#endif
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_brom_ext_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_brom_ext_info.h
new file mode 100644
index 0000000..578f0c0
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_brom_ext_info.h
@@ -0,0 +1,80 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_brom_ext_info.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * BROM_EXT_INFO GFH structure declaration
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+
+#ifndef __BR_GFH_BROM_EXT_INFO_H__
+#define __BR_GFH_BROM_EXT_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+ typedef struct GFH_BROM_EXT_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+ U32 m_brom_ext_start_addr;
+ U32 m_brom_ext_size;
+ U32 m_brom_ext_sig_len;
+ U8 m_brom_ext_sig_type;
+ U8 _reserved[7];
+ }GFH_BROM_EXT_INFO_v1;
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_cbr_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_cbr_info.h
new file mode 100644
index 0000000..f672827
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_cbr_info.h
@@ -0,0 +1,83 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_cbr_info.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * CBR_INFO GFH structure definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_CBR_INFO_H__
+#define __BR_GFH_CBR_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+//==============================================================================
+// GFH_CBR_INFO definition
+//==============================================================================
+
+typedef struct GFH_CBR_INFO_v2 {
+ GFH_Header m_gfh_hdr;
+ U32 m_cbr_normal_block_num;
+ U32 m_cbr_spare_block_num;
+ U32 m_cbr_rgion_size;
+ U32 m_cbr_spare_size;
+ U32 m_reserved[2];
+} GFH_CBR_INFO_v2;
+
+typedef struct GFH_CBR_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+ U32 m_cbr_normal_block_num;
+ U32 m_cbr_spare_block_num;
+ U32 m_reserved[4];
+} GFH_CBR_INFO_v1;
+
+#endif
+
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_cbr_record_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_cbr_record_info.h
new file mode 100644
index 0000000..7001f06
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_cbr_record_info.h
@@ -0,0 +1,73 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_cbr_record_info.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * CBR_RECORD_INFO GFH structure definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_CBR_RECORD_INFO_H__
+#define __BR_GFH_CBR_RECORD_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+//==============================================================================
+// GFH_CBR_RECORD_INFO definition
+//==============================================================================
+
+typedef struct GFH_CBR_RECORD_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+ U32 m_cbr_index;
+ U32 m_attribute;
+ U32 m_reserved[2];
+} GFH_CBR_RECORD_INFO_v1;
+
+#endif
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_cmem_id_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_cmem_id_info.h
new file mode 100644
index 0000000..6bde067
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_cmem_id_info.h
@@ -0,0 +1,81 @@
+/*****************************************************************************
+* 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) 2011
+*
+* 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:
+ * ---------
+ * br_GFH_cmem_id_info.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * GFH(General File Header) header definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_CMEM_ID_INFO_H__
+#define __BR_GFH_CMEM_ID_INFO_H__
+
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+#include "combo_flash_defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ GFH_Header m_gfh_hdr;
+ CMEMEntryIDList m_data;
+} GFH_CMEM_ID_INFO_v1;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SV5_ENABLED__ || __SV5X_ENABLED__ */
+
+#endif /* __BR_GFH_CMEM_ID_INFO_H__ */
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_cmem_nor_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_cmem_nor_info.h
new file mode 100644
index 0000000..bc75029
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_cmem_nor_info.h
@@ -0,0 +1,80 @@
+/*****************************************************************************
+* 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) 2011
+*
+* 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:
+ * ---------
+ * br_GFH_cmem_nor_info.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * GFH(General File Header) header definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_CMEM_NOR_INFO_H__
+#define __BR_GFH_CMEM_NOR_INFO_H__
+
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+#include "combo_flash_defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ GFH_Header m_gfh_hdr;
+ CMEMEntryNORList m_data;
+} GFH_CMEM_NOR_INFO_v1;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SV5_ENABLED__ || __SV5X_ENABLED__ */
+
+#endif /* __BR_GFH_CMEM_NOR_INFO_H__ */
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_confidential_bin_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_confidential_bin_info.h
new file mode 100644
index 0000000..9b5731d
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_confidential_bin_info.h
@@ -0,0 +1,88 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_confidential_bin_info.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * The information in confidential binary used in Secure USBDL
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_CONFIDENTIAL_BIN_INFO_H__
+#define __BR_GFH_CONFIDENTIAL_BIN_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//==============================================================================
+// GFH_CONFIDENTIAL_BIN_INFO definition
+//==============================================================================
+
+
+typedef struct GFH_CONFIDENTIAL_BIN_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+#if defined(WIN32)
+ U16 m_file_type;
+ U8 m_flash_dev;
+#else
+ GFH_FILE_TYPE m_file_type;
+ GFH_FLASH_DEV m_flash_dev;
+#endif
+
+} GFH_CONFIDENTIAL_BIN_INFO_v1;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_dl_package_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_dl_package_info.h
new file mode 100644
index 0000000..a4964be
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_dl_package_info.h
@@ -0,0 +1,147 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_dl_package_info.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * DL PACKAGE GFH structure definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_DL_PACKAGE_INFO_H__
+#define __BR_GFH_DL_PACKAGE_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GFH_DL_PACKAGE_ID "DL_PACKAGE_ID"
+
+typedef enum {
+ IM_NOR = 0,
+ IM_NAND = 1
+} IM_FORMAT;
+
+typedef enum {
+ IM_DOWNLOAD = 0,
+ IM_SKIP = 1,
+ IM_ERASE = 2,
+ IM_INVALID = -1
+} IM_OPERATION;
+
+typedef struct GFH_DL_PACKAGE_INFO_v1
+{
+ GFH_Header m_gfh_hdr;
+ U8 m_identifier[16]; //including '\0'
+ U8 m_platform_id[128];
+ U8 m_project_id[64];
+
+ U8 m_im_device;
+ U8 m_reserve1[3];
+
+ U32 m_sig_offset;
+ U32 m_sig_len;
+
+ U32 m_customer_info[32];
+
+ U32 m_reserve2[16];
+} GFH_DL_PACKAGE_INFO_v1;
+
+//V2 part
+
+#define GFH_DL_PKG_EXTRA_INFO_COUNT (16)
+
+typedef struct
+{
+#if defined(WIN32)
+ U16 m_bin_type;
+#else
+ GFH_FILE_TYPE m_bin_type;
+#endif
+ U8 m_reserve[2];
+
+ U32 m_bin_start_addr;
+ U32 m_bin_length;
+ U32 m_operation;
+ U32 m_reserve2[4];
+} GFH_DL_PACKAGE_EXTRA_INFO;
+
+typedef struct GFH_DL_PACKAGE_INFO_v2
+{
+ GFH_Header m_gfh_hdr;
+ U8 m_identifier[16]; //including '\0'
+ U8 m_platform_id[128];
+ U8 m_project_id[64];
+
+ U8 m_im_device;
+ U8 m_reserve1[3];
+
+ U32 m_sig_offset;
+ U32 m_sig_len;
+
+ U32 m_customer_info[32];
+
+ U32 m_reserve2[16];
+
+ // V2
+ GFH_DL_PACKAGE_EXTRA_INFO m_extra_info[GFH_DL_PKG_EXTRA_INFO_COUNT];
+
+} GFH_DL_PACKAGE_INFO_v2;
+
+
+extern U32 GFH_DL_PACKAGE_IsValid(const GFH_FILE_INFO_v1 *p_gfh_file_info,
+ const GFH_DL_PACKAGE_INFO_v1 *p_gfh_dl_package);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_dsp_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_dsp_info.h
new file mode 100644
index 0000000..87a70fc
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_dsp_info.h
@@ -0,0 +1,79 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_dsp_info.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * DSP_INFO GFH structure definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_DSP_INFO_H__
+#define __BR_GFH_DSP_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+//==============================================================================
+// GFH_DSP_INFO definition
+//==============================================================================
+
+typedef struct GFH_DSP_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+ U32 m_product_ver;
+ U32 m_image_type;
+
+ U8 m_platform_id[16];
+ U8 m_project_id[64];
+
+ U8 m_build_time[64];
+ U8 reserved[64];
+} GFH_DSP_INFO_v1;
+
+#endif
+
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_emi_list.h b/mcu/service/sys_svc/gfh/public/br_GFH_emi_list.h
new file mode 100644
index 0000000..8c1910b
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_emi_list.h
@@ -0,0 +1,102 @@
+/*****************************************************************************
+* 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) 2010
+*
+* 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:
+ * ---------
+ * br_GFH_emi_list.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * EMI List GFH structure declaration
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_EMI_LIST_H__
+#define __BR_GFH_EMI_LIST_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+#include "custom_EMI.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//==============================================================================
+// EPP_PARAM
+//==============================================================================
+
+#define EMI_LIST_ID "EMI_LIST"
+
+/*
+typedef struct EMI_List_v5 {
+ //char m_identifier[12]; // including '\0'
+ //U32 m_raw_data[(512-12)>>2];
+
+} EMI_List_v5;
+*/
+
+//==============================================================================
+// GFH_EPP_PARAM declaration
+//==============================================================================
+typedef struct GFH_EMI_LIST_v5 {
+ GFH_Header m_gfh_hdr;
+ //EMI_List_v5 m_emi_list;
+ //EPP_Param_v1 m_epp_param;
+
+ kal_uint32 m_ver;
+ kal_uint8 op_ver;
+ kal_uint8 reserved_1;
+ kal_uint8 reserved_2;
+ kal_uint8 mcps_num;
+ MTK_EMI_Info mem_info[__EMI_COMBO_ENTRY_COUNT];
+
+} GFH_EMI_LIST_v5;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BR_GFH_EMI_LIST_H__ */
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_emmc_booting_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_emmc_booting_info.h
new file mode 100644
index 0000000..fedde7c
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_emmc_booting_info.h
@@ -0,0 +1,78 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_emmc_booting_info.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * EMMC_BOOTING_INFO (EMMC Booting specific information) GFH structure definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_EMMC_BOOTING_INFO_H__
+#define __BR_GFH_EMMC_BOOTING_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+//==============================================================================
+// EMMC_BOOTING_INFO definition
+//==============================================================================
+
+ typedef struct GFH_EMMC_BOOTING_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+ U32 m_emmc_page_size_def;
+ U32 m_emmc_block_size_def;
+ U32 m_emmc_GP1_size_def; // unit: 512 Bytes
+ U32 m_emmc_GP2_size_def; // unit: 512 Bytes
+ U32 m_emmc_GP3_size_def; // unit: 512 Bytes
+ U32 m_emmc_GP4_size_def; // unit: 512 Bytes
+ U32 m_reserved[4];
+} GFH_EMMC_BOOTING_INFO_v1;
+
+#endif
+
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_epp_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_epp_info.h
new file mode 100644
index 0000000..099d2d0
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_epp_info.h
@@ -0,0 +1,71 @@
+/*****************************************************************************
+* 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) 2010
+*
+* 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:
+ * ---------
+ * br_GFH_epp_info.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * EPP information GFH structure declaration
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_EPP_INFO_H__
+#define __BR_GFH_EPP_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+//==============================================================================
+// EPP_INFO definition
+//==============================================================================
+
+typedef struct GFH_EPP_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+ U32 m_pc_epp_param_addr;
+ U32 m_pc_epp_option_addr;
+} GFH_EPP_INFO_v1;
+
+#endif
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_epp_param.c b/mcu/service/sys_svc/gfh/public/br_GFH_epp_param.c
new file mode 100644
index 0000000..a4d023b
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_epp_param.c
@@ -0,0 +1,70 @@
+/*****************************************************************************
+* 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) 2010
+*
+* 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:
+ * ---------
+ * br_GFH_epp_param.c
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * EPP Parameters GFH implementation
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#include <string.h>
+#include "br_GFH_epp_param.h"
+
+//==============================================================================
+// EPP_PARAM
+//==============================================================================
+
+bool EPP_Param_IsValid(const EPP_Param_v1 *p_epp_param)
+{
+ if( NULL!=p_epp_param && !strcmp(p_epp_param->m_identifier, EPP_PARAM_ID) )
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_epp_param.h b/mcu/service/sys_svc/gfh/public/br_GFH_epp_param.h
new file mode 100644
index 0000000..135e9c5
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_epp_param.h
@@ -0,0 +1,99 @@
+/*****************************************************************************
+* 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) 2010
+*
+* 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:
+ * ---------
+ * br_GFH_epp_param.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * EPP Parameters GFH structure declaration
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_EPP_PARAM_H__
+#define __BR_GFH_EPP_PARAM_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//==============================================================================
+// EPP_PARAM
+//==============================================================================
+
+#define EPP_PARAM_ID "EPP_PARAM"
+
+typedef struct EPP_Param_v1 {
+ char m_identifier[12]; // including '\0'
+ U32 m_raw_data[(512-12)>>2];
+} EPP_Param_v1;
+
+extern bool EPP_Param_IsValid(const EPP_Param_v1 *p_epp_param);
+
+//==============================================================================
+// EPP prototype
+//==============================================================================
+
+typedef U32 (*CB_ENV_PREPARE_PROG_V2)(U32 pc_epp_param_addr,
+ U32 pc_epp_param_len,
+ const void * p_hb_epp_param,
+ const void * p_common_func_tbl);
+
+//==============================================================================
+// GFH_EPP_PARAM declaration
+//==============================================================================
+typedef struct GFH_EPP_PARAM_v1 {
+ GFH_Header m_gfh_hdr;
+ EPP_Param_v1 m_epp_param;
+} GFH_EPP_PARAM_v1;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_error.h b/mcu/service/sys_svc/gfh/public/br_GFH_error.h
new file mode 100644
index 0000000..90c4f0e
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_error.h
@@ -0,0 +1,108 @@
+/*****************************************************************************
+* 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) 2008
+*
+* 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:
+ * ---------
+ * br_GFH_error.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * GFH error code
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_ERROR_H__
+#define __BR_GFH_ERROR_H__
+
+#define B_OK 0x0000
+#define E_ERROR 0x00FF
+
+//==============================================================================
+// Public GFH status code, from 0x8000 to 0x80FF
+// Note: DO NOT CHANGE IT!!
+//==============================================================================
+
+#define E_GFH_HANDLE_NOT_INIT 0x8000
+#define E_GFH_NOT_FOUND 0x8001
+#define E_GFH_INVALID_PARAM 0x8002
+#define E_GFH_CALLBACK_MAP_IS_FULL 0x8003
+#define E_GFH_INVALID_SIZE 0x8004
+#define E_GFH_FILE_INFO_NOT_FOUND 0x8005
+#define E_GFH_FILE_INFO_INVALID_CONTENT_OFFSET 0x8006
+#define E_GFH_FILE_INFO_INVALID_FILE_LEN 0x8007
+#define E_GFH_FILE_INFO_INVALID_SIG_LEN 0x8008
+#define E_GFH_FILE_INFO_FILE_LEN_EXCEED_MAX_SIZE 0x8009
+#define E_GFH_FILE_INFO_INVALID_JUMP_OFFSET 0x800A
+#define E_GFH_CALLBACK_NOT_EXIST 0x800B
+#define E_GFH_BUF_ADDR_NOT_32BITS_ALIGNED 0x800C
+
+#define E_GFH_FILE_INFO_INVALID_SIG_TYPE 0x800D
+#define E_GFH_CERT_NOT_FOUND 0x800E
+
+#define E_GFH_CERT_KEY_NOT_FOUND 0x8010
+#define E_GFH_CERT_KEY_INVALID_LEN 0x8011
+#define E_GFH_CERT_KEY_SMALLER_VER 0x8012
+#define E_GFH_CERT_KEY_INVALID_VER 0x8013
+#define E_GFH_CERT_KEY_INVALID_SW_VERION_ID 0x8014
+// 0x8015 ~ 0x801F is reserved to CERT_KEY
+
+#define E_GFH_CERT_CONTENT_NOT_FOUND 0x8020
+#define E_GFH_CERT_CONTENT_INVALID_LEN 0x8021
+#define E_GFH_CERT_CONTENT_SMALLER_VER 0x8022
+#define E_GFH_CERT_CONTENT_INVALID_VER 0x8023
+#define E_GFH_CERT_CONTENT_INVALID_SW_VERION_ID 0x8024
+#define E_GFH_CERT_CONTENT_MISMATCH_NV_COUNTER 0x8025
+// 0x8027 ~ 0x802F is reserved to CERT_CONTENT
+
+#define E_GFH_CERT_DBP_NOT_FOUND 0x8030
+#define E_GFH_CERT_DBP_INVALID_LEN 0x8031
+
+#define E_GFH_CERT_DBS_NOT_FOUND 0x8038
+#define E_GFH_CERT_DBS_INVALID_LEN 0x8039
+
+#define E_GFH_CERT_OFFSET_NOT_32BITS_ALIGNED 0x8050
+#define E_GFH_CERT_ADDR_NOT_32BITS_ALIGNED 0x8051
+
+#endif /* __GFH_ERROR_H__ */
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_file_info.c b/mcu/service/sys_svc/gfh/public/br_GFH_file_info.c
new file mode 100644
index 0000000..8db3af7
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_file_info.c
@@ -0,0 +1,237 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_file_info.c
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * FILE_INFO(the 1st GFH) GFH structure implementation
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#include "br_sw_types.h"
+#include "br_GFH.h"
+#include "br_GFH_file_info.h"
+#include "br_GFH_error.h"
+#include <string.h>
+
+//==============================================================================
+// GFH: FILE_INFO exported APIs
+//==============================================================================
+
+U32 GFH_FILE_INFO_BasicCheck(const GFH_FILE_INFO_v1 * p_gfh_file_info)
+{
+ // check if FILE_INFO exist
+ if( (GFH_HDR_MAGIC != GFH_GET_MAGIC(p_gfh_file_info->m_gfh_hdr.m_magic_ver))
+ || (GFH_FILE_INFO != p_gfh_file_info->m_gfh_hdr.m_type)
+ || strcmp(p_gfh_file_info->m_identifier, GFH_FILE_INFO_ID)
+ ) {
+ return E_GFH_FILE_INFO_NOT_FOUND;
+ }
+
+ // check if content offset is valid
+ if( (0 == p_gfh_file_info->m_content_offset)
+ || (GFH_MAX_CONTENT_OFFSET < p_gfh_file_info->m_content_offset)
+ ) {
+ return E_GFH_FILE_INFO_INVALID_CONTENT_OFFSET;
+ }
+
+ // check file length vs content offset
+ if( (0 == p_gfh_file_info->m_file_len )
+ || (GFH_MAX_FILE_LEN < p_gfh_file_info->m_file_len)
+ ) {
+ return E_GFH_FILE_INFO_INVALID_FILE_LEN;
+ }
+ else if( p_gfh_file_info->m_content_offset > p_gfh_file_info->m_file_len )
+ {
+ return E_GFH_FILE_INFO_INVALID_CONTENT_OFFSET;
+ }
+
+ return B_OK;
+}
+
+U32 GFH_FILE_INFO_IsValid(const GFH_FILE_INFO_v1 * p_gfh_file_info)
+{
+ GFH_SIG_TYPE sig_type;
+ U32 sig_len;
+ U32 status=B_OK;
+
+ //-------------------------------------------------------------------------------------
+ // WARNING!!! m_file_len, m_content_offset and sig_len must be validated here!
+ // Once FILE_INFO is found, these 3 fields will be assumed correct in other functions!
+ //-------------------------------------------------------------------------------------
+
+ // perform basic check
+ status = GFH_FILE_INFO_BasicCheck(p_gfh_file_info);
+ if( E_ERROR <= status )
+ {
+ return status;
+ }
+
+#ifndef __GFH_SKIP_MAX_SIZE_CHECK__
+ // check max file size
+ if( (GFH_FILE_MAX_SIZE_IGNORED != p_gfh_file_info->m_max_size)
+ && (p_gfh_file_info->m_max_size < p_gfh_file_info->m_file_len)
+ ) {
+ return E_GFH_FILE_INFO_FILE_LEN_EXCEED_MAX_SIZE;
+ }
+#endif
+
+ // check signature length
+ sig_type = p_gfh_file_info->m_sig_type;
+ sig_len = p_gfh_file_info->m_sig_len;
+ if( (SIG_NONE == sig_type) && (0 != sig_len) )
+ {
+ return E_GFH_FILE_INFO_INVALID_SIG_LEN;
+ }
+ else if( SIG_NONE != sig_type )
+ {
+ // check sig len
+ if( (0 == sig_len) ||
+ (p_gfh_file_info->m_file_len <= sig_len) ||
+ (p_gfh_file_info->m_content_offset > (p_gfh_file_info->m_file_len-sig_len))
+ ) {
+ return E_GFH_FILE_INFO_INVALID_SIG_LEN;
+ }
+ }
+
+ // check jump offset
+ if( 0 != p_gfh_file_info->m_jump_offset )
+ {
+ // jump offset is activated, validate it
+ if( (p_gfh_file_info->m_content_offset > p_gfh_file_info->m_jump_offset)
+ || ((p_gfh_file_info->m_file_len-sig_len) <= p_gfh_file_info->m_jump_offset)
+ ) {
+ return E_GFH_FILE_INFO_INVALID_JUMP_OFFSET;
+ }
+ }
+
+ return B_OK;
+}
+
+#if defined(__GFH_UTIL__)
+//==============================================================================
+// Exported utility APIs
+//==============================================================================
+const char * __WIN32_STDCALL GFH_GetFileTypeName(GFH_FILE_TYPE file_type)
+{
+ switch(file_type) {
+
+ BR_ENUM_TO_CASE_STRING(GFH_FILE_NONE)
+ BR_ENUM_TO_CASE_STRING(ARM_BL)
+ BR_ENUM_TO_CASE_STRING(ARM_EXT_BL)
+ BR_ENUM_TO_CASE_STRING(DUALMAC_DSP_BL)
+ BR_ENUM_TO_CASE_STRING(SCTRL_CERT)
+ BR_ENUM_TO_CASE_STRING(TOOL_AUTH)
+ BR_ENUM_TO_CASE_STRING(FILE_MTK_RESERVED1)
+ BR_ENUM_TO_CASE_STRING(EPP)
+ BR_ENUM_TO_CASE_STRING(FILE_MTK_RESERVED2)
+ BR_ENUM_TO_CASE_STRING(FILE_MTK_RESERVED3)
+ BR_ENUM_TO_CASE_STRING(ROOT_CERT)
+
+ BR_ENUM_TO_CASE_STRING(PRIMARY_MAUI)
+ BR_ENUM_TO_CASE_STRING(SECONDARY_MAUI)
+ BR_ENUM_TO_CASE_STRING(ON_DEMAND_PAGING)
+ BR_ENUM_TO_CASE_STRING(THIRD_ROM)
+ BR_ENUM_TO_CASE_STRING(DSP_ROM)
+ BR_ENUM_TO_CASE_STRING(CACHED_DSP_ROM)
+
+ BR_ENUM_TO_CASE_STRING(CUSTOM_PACK)
+ BR_ENUM_TO_CASE_STRING(LANGUAGE_PACK)
+ BR_ENUM_TO_CASE_STRING(JUMP_TABLE)
+
+ BR_ENUM_TO_CASE_STRING(FOTA_UE)
+
+ BR_ENUM_TO_CASE_STRING(SECURE_RO_S)
+ BR_ENUM_TO_CASE_STRING(SECURE_RO_ME)
+
+ BR_ENUM_TO_CASE_STRING(CARD_DOWNLOAD_PACKAGE)
+ BR_ENUM_TO_CASE_STRING(CONFIDENTIAL_BINARY)
+
+ BR_ENUM_TO_CASE_STRING(FILE_SYSTEM)
+
+ BR_ENUM_TO_CASE_STRING(BOOT_CERT_CTRL)
+
+ default:
+ return "UNKNOWN";
+ }
+}
+
+const char * __WIN32_STDCALL GFH_GetFlashDevName(GFH_FLASH_DEV flash_type)
+{
+ switch(flash_type) {
+
+ BR_ENUM_TO_CASE_STRING(FLASH_DEV_NONE)
+ BR_ENUM_TO_CASE_STRING(F_NOR)
+ BR_ENUM_TO_CASE_STRING(F_NAND_SEQUENTIAL)
+ BR_ENUM_TO_CASE_STRING(F_NAND_TTBL)
+ BR_ENUM_TO_CASE_STRING(F_NAND_FDM50)
+ BR_ENUM_TO_CASE_STRING(F_EMMC_BOOT_REGION)
+ BR_ENUM_TO_CASE_STRING(F_EMMC_DATA_REGION)
+ BR_ENUM_TO_CASE_STRING(F_SF)
+
+ default:
+ return "UNKNOWN";
+ }
+}
+
+const char * __WIN32_STDCALL GFH_GetSigTypeName(GFH_SIG_TYPE sig_type)
+{
+ switch(sig_type) {
+
+ BR_ENUM_TO_CASE_STRING(SIG_NONE)
+ BR_ENUM_TO_CASE_STRING(SIG_PHASH)
+ BR_ENUM_TO_CASE_STRING(SIG_SINGLE)
+ BR_ENUM_TO_CASE_STRING(SIG_SINGLE_AND_PHASH)
+ BR_ENUM_TO_CASE_STRING(SIG_MULTI)
+ BR_ENUM_TO_CASE_STRING(SIG_CERT_CHAIN)
+
+ default:
+ return "UNKNOWN";
+ }
+}
+
+#endif
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_file_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_file_info.h
new file mode 100644
index 0000000..25df820
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_file_info.h
@@ -0,0 +1,250 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_file_info.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * FILE_INFO(the 1st GFH) GFH structure declaration
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_FILE_INFO_H__
+#define __BR_GFH_FILE_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//==============================================================================
+// FILE_INFO definition (This is the 1st GFH header)
+//==============================================================================
+
+typedef enum {
+ GFH_FILE_NONE = 0x0000 //Recognized by BootROM
+ ,ARM_BL = 0x0001
+ ,ARM_EXT_BL = 0x0002
+ ,DUALMAC_DSP_BL = 0x0003
+ ,SCTRL_CERT = 0x0004
+ ,TOOL_AUTH = 0x0005
+ ,FILE_MTK_RESERVED1 = 0x0006
+ ,EPP = 0x0007
+ ,FILE_MTK_RESERVED2 = 0x0008
+ ,FILE_MTK_RESERVED3 = 0x0009
+ ,ROOT_CERT = 0x000a
+ ,AP_BL = 0x000b
+
+ ,V_MAUI_BINARY = 0x0100 //MAUI binary group
+ ,PRIMARY_MAUI = V_MAUI_BINARY
+ ,SECONDARY_MAUI = 0x0101
+ ,ON_DEMAND_PAGING = 0x0102
+ ,THIRD_ROM = 0x0103
+ ,DSP_ROM = 0x0104
+ ,CACHED_DSP_ROM = 0x0105
+ ,PRIMARY_FACTORY_BIN = 0x0106
+ ,SECONDARY_FACTORY_BIN = 0x0107
+ ,VIVA = 0x0108
+ ,LTE_DSP_ROM = 0x0109
+ ,DSP_BIN = 0x010a
+ ,V_MAUI_BINARY_END = 0x017f
+
+ ,V_RESOURCE_BINARY = 0x0180 //Resource binary group
+ ,CUSTOM_PACK = V_RESOURCE_BINARY
+ ,LANGUAGE_PACK = 0x0181
+ ,JUMP_TABLE = 0x0182
+ ,V_RESOURCE_BINARY_END = 0x01ff
+
+ ,V_MISC_BINARY = 0x0200 //Binary not belonging to MAUI
+ ,FOTA_UE = V_MISC_BINARY
+ ,ARM_EXT_BL_BACKUP = 0x0201
+ ,V_MISC_BINARY_END
+
+ ,V_SECURE_RO = 0x0300 //Secure structure group
+ ,SECURE_RO_S = V_SECURE_RO
+ ,SECURE_RO_ME = 0x0301
+ ,V_SECURE_RO_END
+
+ ,V_EXTERNAL_FILE = 0x0400
+ ,CARD_DOWNLOAD_PACKAGE = V_EXTERNAL_FILE
+ ,CONFIDENTIAL_BINARY = 0x0401
+ ,V_EXTERNAL_FILE_END
+
+ ,V_FILE_SYSTEM_BINARY = 0x0480 //File System
+ ,FILE_SYSTEM = V_FILE_SYSTEM_BINARY
+ ,V_FILE_SYSTEM_BINARY_END
+
+ ,V_SRD = 0x500 //Secure structure group
+ ,BOOT_CERT_CTRL = V_SRD
+ ,V_SRD_END
+
+ ,V_CUSTOMIZED_FILE = 0x7000
+ ,CUSTOMER_BIN1 = V_CUSTOMIZED_FILE
+ ,CUSTOMER_BIN2 = 0x7001
+ ,CUSTOMER_BIN3 = 0x7002
+ ,V_CUSTOMIZED_FILE_END = 0x70ff
+
+ ,GFH_FILE_TYPE_FOR_MT6290 = 0x8000
+#ifdef __IC_SLT_LOADER__
+ ,V_SLT_LOAD_FILE = GFH_FILE_TYPE_FOR_MT6290
+ ,V_SLT_LOAD_FILE_END = 0x800f
+#endif
+
+ ,GFH_FILE_END = (U16)0xffff
+} GFH_FILE_TYPE;
+
+typedef enum {
+ FLASH_DEV_NONE = 0
+ ,F_NOR = 1
+ ,F_NAND_SEQUENTIAL = 2
+ ,F_NAND_TTBL = 3
+ ,F_NAND_FDM50 = 4
+ ,F_EMMC_BOOT_REGION = 5
+ ,F_EMMC_DATA_REGION = 6
+ ,F_SF = 7
+ ,F_XBOOT = 8
+ ,FLASH_DEV_END = (U8)255
+} GFH_FLASH_DEV;
+
+typedef enum {
+ SIG_NONE = 0
+ ,SIG_PHASH = 1
+ ,SIG_SINGLE = 2
+ ,SIG_SINGLE_AND_PHASH = 3
+ ,SIG_MULTI = 4
+ ,SIG_CERT_CHAIN = 5
+ ,SIG_TYPE_NUM
+ ,SIG_TYPE_END = (U8)255
+} GFH_SIG_TYPE;
+
+#define GFH_FILE_INFO_ID "FILE_INFO"
+#define GFH_MAX_CONTENT_OFFSET 0x100000 // 1MB
+#define GFH_MAX_FILE_LEN 0x80000000 // 2GB (FAT16 max size)
+
+#define GFH_LOAD_ADDR_NA 0xFFFFFFFF
+#define GFH_FILE_SIZE_BY_POST_BUILD 0xFFFFFFFF
+#define GFH_FILE_SIZE_NA 0xFFFFFFFF
+
+#define GFH_FILE_MAX_SIZE_IGNORED 0xFFFFFFFF
+#define GFH_FILE_MAX_SIZE_BY_POST_BUILD 0x00000000
+
+#define FILE_INFO_ATTR_POST_BUILD_DONE 0x00000001
+#define FILE_INFO_ATTR_XIP 0x00000002
+#define FILE_INFO_ATTR_SLT 0x00000004
+#define FILE_INFO_ATTR_USE_RSA_PSS 0x00000010 //Gen93: select PSS padding
+#define FILE_INFO_ATTR_DUAL_IMAGE 0x01000000 // bit[31:24] for MT6290
+#if defined(__IC_SLT_LOADER__)
+#define FILE_INFO_ATTR_IS_HVT_LOAD 0x10000000 // bit[31:24] for MT6290
+#define FILE_INFO_ATTR_IS_MD_LOAD 0x20000000 // bit[31:24] for MT6290
+#define FILE_INFO_ATTR_TO_LOAD_AP 0x40000000 // bit[31:24] for MT6290
+#define FILE_INFO_ATTR_AP_LOAD_MASK 0x0F000000 // bit[27:24] for the mask of ap load index in the loadsequence
+#endif
+
+
+// for passing to CL_GFH_Handle, Gen 95 signature mask and attr
+#define GET_SIG_EXT(a) (a & FILE_INFO_SIG_EXT_MASK)
+#define FILE_INFO_SUPPORT_SIG_EXT(a) ((a & FILE_INFO_SIG_MASK_MAGIC) == FILE_INFO_SIG_EXT_MAGIC)
+#define FILE_INFO_GET_SIG_PADDING(a) ((a & FILE_INFO_SIG_MASK_PADDING) >> 24)
+#define FILE_INFO_GET_SIG_ASYM_ALG(a) ((a & FILE_INFO_SIG_MASK_ASYM_ALG) >> 20)
+#define FILE_INFO_GET_SIG_HASH_ALG(a) ((a & FILE_INFO_SIG_MASK_HASH_ALG) >> 16)
+#define FILE_INFO_SIG_EXT_MASK 0xFFFF0000
+#define FILE_INFO_SIG_MASK_MAGIC 0xF0000000
+#define FILE_INFO_SIG_EXT_MAGIC 0xC0000000
+#define FILE_INFO_SIG_MASK_PADDING 0x0F000000
+#define FILE_INFO_SIG_PAD_M1 0x01000000
+#define FILE_INFO_SIG_PAD_PSS 0x02000000
+#define FILE_INFO_SIG_MASK_ASYM_ALG 0x00F00000
+#define FILE_INFO_SIG_RSA_M1 0x00100000
+#define FILE_INFO_SIG_RSA_STD 0x00200000
+#define FILE_INFO_SIG_RSA_HW 0x00400000
+#define FILE_INFO_SIG_MASK_HASH_ALG 0x000F0000
+#define FILE_INFO_SIG_SHA_SW 0x00010000
+#define FILE_INFO_SIG_SHA_HW 0x00020000
+
+typedef struct GFH_FILE_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+ char m_identifier[12]; // including '\0'
+ U32 m_file_ver;
+#if defined(WIN32)
+ U16 m_file_type;
+ U8 m_flash_dev;
+ U8 m_sig_type;
+#else
+ GFH_FILE_TYPE m_file_type;
+ GFH_FLASH_DEV m_flash_dev;
+ GFH_SIG_TYPE m_sig_type;
+#endif
+ U32 m_load_addr;
+ U32 m_file_len;
+ U32 m_max_size;
+ U32 m_content_offset;
+ U32 m_sig_len;
+ U32 m_jump_offset;
+ U32 m_attr;
+} GFH_FILE_INFO_v1;
+
+//==============================================================================
+// Exported APIs
+//==============================================================================
+extern U32 GFH_FILE_INFO_BasicCheck(const GFH_FILE_INFO_v1 * p_gfh_file_info);
+extern U32 GFH_FILE_INFO_IsValid(const GFH_FILE_INFO_v1 * p_gfh_file_info);
+
+#if defined(__GFH_UTIL__)
+//==============================================================================
+// Exported utility APIs
+//==============================================================================
+extern const char * __WIN32_STDCALL GFH_GetFileTypeName(GFH_FILE_TYPE file_type);
+extern const char * __WIN32_STDCALL GFH_GetFlashDevName(GFH_FLASH_DEV flash_type);
+extern const char * __WIN32_STDCALL GFH_GetSigTypeName(GFH_SIG_TYPE sig_type);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_flash_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_flash_info.h
new file mode 100644
index 0000000..0a531db
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_flash_info.h
@@ -0,0 +1,87 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_flash_info.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * FLASH_INFO(FLASH information) GFH structure definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_FLASH_INFO_H__
+#define __BR_GFH_FLASH_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+//==============================================================================
+// FLASH_INFO definition
+//==============================================================================
+
+typedef struct {
+ U16 m_manu_id;
+ U16 m_dev_id;
+ U16 m_ext_dev_id1;
+ U16 m_ext_dev_id2;
+ U32 m_fat_begin_addr;
+ U32 m_fat_length;
+} GFH_FlashDevInfo_ST;
+
+typedef struct GFH_FLASH_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+
+ U8 m_nand_fdm_dal_ver[8];
+
+ U16 m_flash_dev_cnt;
+ GFH_FlashDevInfo_ST m_flash_info[6];
+
+ U32 m_reserved[2];
+
+} GFH_FLASH_INFO_v1;
+
+#endif
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_fota_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_fota_info.h
new file mode 100644
index 0000000..7284800
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_fota_info.h
@@ -0,0 +1,76 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_fota_info.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * FOTA_INFO (FOTA specific information) GFH structure definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_FOTA_INFO_H__
+#define __BR_GFH_FOTA_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+//==============================================================================
+// EMMC_BOOTING_INFO definition
+//==============================================================================
+
+typedef struct GFH_FOTA_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+ U32 m_fota_package_base;
+ U32 m_fota_package_size;
+ U32 m_fota_backup_base;
+ U32 m_fota_backup_size;
+ U32 m_fota_reserved_size;
+} GFH_FOTA_INFO_v1;
+
+#endif
+
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_maui_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_maui_info.h
new file mode 100644
index 0000000..fff8bd2
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_maui_info.h
@@ -0,0 +1,103 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_maui_info.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * MAUI_INFO(MAUI ROM information) GFH structure definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_MAUI_INFO_H__
+#define __BR_GFH_MAUI_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+//==============================================================================
+// MAUI_INFO definition
+//==============================================================================
+
+typedef struct GFH_MAUI_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+ U8 m_platform_id[128];
+ U8 m_project_id[64];
+
+ U32 m_bl_maui_paired_ver;
+ U32 m_feature_combination;
+ U32 m_feature_combination_ex;
+ U32 m_extsram_size;
+
+ U32 m_sw_minor_ver;
+ U32 m_sds_base_addr; /* For flash tool to check overlap region */
+ U32 m_sds_len; /* For flash tool to check overlap region */
+ U32 m_flashtool_ver_req;
+} GFH_MAUI_INFO_v1;
+
+
+typedef struct GFH_MAUI_INFO_v2 {
+ GFH_Header m_gfh_hdr;
+ U8 m_platform_id[128];
+ U8 m_project_id[64];
+
+ U32 m_bl_maui_paired_ver;
+ U32 m_feature_combination;
+ U32 m_feature_combination_ex;
+ U32 m_extsram_size;
+
+ U32 m_sw_minor_ver;
+ U32 m_sds_base_addr; /* For flash tool to check overlap region */
+ U32 m_sds_len; /* For flash tool to check overlap region */
+ U32 m_flashtool_ver_req;
+ U32 m_boot_cert_addr;
+ U32 m_boot_cert_len;
+ U8 m_platform_for_check[16];
+ U32 m_reserved[12];
+} GFH_MAUI_INFO_v2;
+
+#endif
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_maui_sec.h b/mcu/service/sys_svc/gfh/public/br_GFH_maui_sec.h
new file mode 100644
index 0000000..1642184
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_maui_sec.h
@@ -0,0 +1,73 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_maui_sec.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * GFH structure definition of MAUI security options
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __GFH_MAUI_SEC_H__
+#define __GFH_MAUI_SEC_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+//==============================================================================
+// MAUI_SEC definition
+//==============================================================================
+
+typedef struct GFH_MAUI_SEC_v1 {
+ GFH_Header m_gfh_hdr;
+ U32 m_da_check_version;
+ U32 m_da_check_version_cust;
+ U32 m_secure_ver;
+} GFH_MAUI_SEC_v1;
+
+#endif
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_parser.c b/mcu/service/sys_svc/gfh/public/br_GFH_parser.c
new file mode 100644
index 0000000..598139d
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_parser.c
@@ -0,0 +1,415 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_parser.c
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * GFH(General File Header) parser functions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#include "br_GFH_parser.h"
+#include "br_GFH_error.h"
+
+static U32 GFH_Internal_Parser(U32 buf_addr, const GFH_Parser_Handle * p_handle, GFH_TYPE type, void ** pp_gfh, U32 index);
+
+#if defined(__GFH_PARSER__)
+
+GFH_Parser_Handle g_GFH_PARSER_HANDLE;
+
+//==============================================================================
+// local functions
+//==============================================================================
+
+__BR_STATIC U32 GFH_Parser_IsHandleInitialized(const GFH_Parser_Handle * p_handle);
+
+#define GFH_PARSER_INSTALL_CB(p_cb, type, cb, p_arg)\
+ do {\
+ p_cb->m_enable = TRUE;\
+ p_cb->m_type = type;\
+ p_cb->m_cb_interpreter = cb;\
+ p_cb->m_cb_interpreter_arg = p_arg;\
+ } while(0)
+
+//==============================================================================
+// GFH handle is initialized?
+//==============================================================================
+U32 GFH_Parser_IsHandleInitialized(const GFH_Parser_Handle * p_handle)
+{
+ if( NULL==p_handle || GFH_PARSER_HANDLE_MAGIC!=p_handle->m_magic )
+ {
+ return E_GFH_HANDLE_NOT_INIT;
+ }
+
+ return B_OK;
+}
+
+//==============================================================================
+// GFH init internal status
+//==============================================================================
+U32 GFH_Parser_Init(GFH_Parser_Handle * p_handle, U32 cb_map_size, GFH_Callback * cb_map)
+{
+ // check if handle is NULL
+ if( NULL == p_handle )
+ {
+ return E_GFH_INVALID_PARAM;
+ }
+
+ if( (0==cb_map_size && NULL!=cb_map) ||
+ (0!=cb_map_size && NULL==cb_map) )
+ {
+ return E_GFH_INVALID_PARAM;
+ }
+
+ // initialized the handle
+ p_handle->m_magic = GFH_PARSER_HANDLE_MAGIC;
+ p_handle->m_cb_map_size = cb_map_size;
+ p_handle->m_p_cb_map = cb_map;
+ p_handle->m_p_cb_default_handler = NULL;
+ p_handle->m_p_cb_default_handler_arg = NULL;
+
+ // clear all callbacks
+ GFH_Parser_ClearAll(p_handle);
+
+ return B_OK;
+}
+
+//==============================================================================
+// GFH install callback by type
+//==============================================================================
+U32 GFH_Parser_Install(GFH_Parser_Handle * p_handle, GFH_TYPE type, CB_GFH_INTERPRETER cb, void * p_arg)
+{
+ U32 i;
+ GFH_Callback *p_cb;
+
+ if( B_OK != GFH_Parser_IsHandleInitialized(p_handle) )
+ {
+ return E_GFH_HANDLE_NOT_INIT;
+ }
+
+ // check input arguments
+ if( NULL == cb )
+ {
+ return E_GFH_INVALID_PARAM;
+ }
+
+ // to guarantee that we won't have multiple callback entries for
+ // the same GFH type, we have to check whether we could overwrite
+ // an existing entry first
+ for(i=0; i<p_handle->m_cb_map_size; i++)
+ {
+ p_cb = (p_handle->m_p_cb_map + i);
+ if( p_cb->m_type == type )
+ {
+ GFH_PARSER_INSTALL_CB(p_cb, type, cb, p_arg);
+ return B_OK;
+ }
+ }
+
+ // then we can insert an new entry if there's room for us to do so
+ for(i=0; i<p_handle->m_cb_map_size; i++)
+ {
+ p_cb = (p_handle->m_p_cb_map + i);
+ if( FALSE == p_cb->m_enable )
+ {
+ GFH_PARSER_INSTALL_CB(p_cb, type, cb, p_arg);
+ return B_OK;
+ }
+ }
+
+ return E_GFH_CALLBACK_MAP_IS_FULL;
+}
+
+//==============================================================================
+// GFH install default callback which will be used if no proper one is matched
+//==============================================================================
+U32 GFH_Parser_Install_Default_Handler(GFH_Parser_Handle * p_handle, CB_GFH_INTERPRETER cb, void * p_arg)
+{
+ if( B_OK != GFH_Parser_IsHandleInitialized(p_handle) )
+ {
+ return E_GFH_HANDLE_NOT_INIT;
+ }
+
+ // check input arguments
+ if( NULL == cb )
+ {
+ return E_GFH_INVALID_PARAM;
+ }
+
+ p_handle->m_p_cb_default_handler = cb;
+ p_handle->m_p_cb_default_handler_arg = p_arg;
+
+ return B_OK;
+}
+
+//==============================================================================
+// GFH un-install callback by type
+//==============================================================================
+U32 GFH_Parser_Uninstall(GFH_Parser_Handle * p_handle, GFH_TYPE type)
+{
+ U32 i;
+ GFH_Callback *p_cb;
+
+ if( B_OK != GFH_Parser_IsHandleInitialized(p_handle) )
+ {
+ return E_GFH_HANDLE_NOT_INIT;
+ }
+
+ for(i=0; i<p_handle->m_cb_map_size; i++)
+ {
+ p_cb = (p_handle->m_p_cb_map + i);
+ if( p_cb->m_type == type )
+ {
+ p_cb->m_enable = FALSE;
+ return B_OK;
+ }
+ }
+
+ return E_GFH_CALLBACK_NOT_EXIST;
+}
+
+//==============================================================================
+// GFH clear all callbacks
+//==============================================================================
+U32 GFH_Parser_ClearAll(GFH_Parser_Handle * p_handle)
+{
+ U32 i;
+
+ if( B_OK != GFH_Parser_IsHandleInitialized(p_handle) )
+ {
+ return E_GFH_HANDLE_NOT_INIT;
+ }
+
+ // remove all callbacks
+ for(i=0; i<p_handle->m_cb_map_size; i++)
+ {
+ // un-install callback
+ p_handle->m_p_cb_map[i].m_enable = FALSE;
+ }
+
+ return B_OK;
+}
+
+//==============================================================================
+// GFH parse
+//==============================================================================
+U32 GFH_Parser_Start(const GFH_Parser_Handle * p_handle, U32 buf_addr)
+{
+ if( B_OK != GFH_Parser_IsHandleInitialized(p_handle) )
+ {
+ return E_GFH_HANDLE_NOT_INIT;
+ }
+
+ // callback mode, index is ignored
+ return GFH_Internal_Parser(buf_addr, p_handle, (GFH_TYPE)0, NULL, 0);
+}
+
+#endif
+
+//==============================================================================
+// GFH search by type
+//==============================================================================
+U32 GFH_Find(U32 buf_addr, GFH_TYPE type, void ** pp_gfh)
+{
+ // only search for the 1st matched GFH
+ return GFH_Internal_Parser(buf_addr, NULL, type, pp_gfh, 0);
+}
+
+//==============================================================================
+// GFH search by type with multiple instances search
+//==============================================================================
+U32 GFH_FindEx(U32 buf_addr, GFH_TYPE type, void ** pp_gfh, U32 index)
+{
+ U32 status;
+
+ if( NULL == pp_gfh )
+ {
+ return E_GFH_INVALID_PARAM;
+ }
+
+ *pp_gfh = NULL;
+
+ status = GFH_Internal_Parser(buf_addr, NULL, type, pp_gfh, index);
+
+ return status;
+}
+
+//==============================================================================
+// GFH search by type
+//==============================================================================
+static U32 GFH_Internal_Parser(U32 buf_addr, const GFH_Parser_Handle * p_handle, GFH_TYPE type, void ** pp_gfh, U32 index)
+{
+#if defined(__GFH_PARSER__)
+ const GFH_Callback *p_cb;
+ U32 i;
+#endif
+ GFH_FILE_INFO_v1 *p_gfh_file_info;
+ GFH_Header *p_gfh_hdr;
+ GFH_End *p_gfh_end;
+ U32 status;
+ U32 offset;
+ U32 occur_index = 0;
+ U32 next_gfh_offset;
+ U32 file_content_offset;
+ bool bEnableCallbackMap = FALSE;
+ bool bAnyCallbackInvoked = FALSE;
+
+ // check if use callback map or just a single search?
+ if( NULL != p_handle )
+ {
+ bEnableCallbackMap = TRUE;
+ }
+
+ // check data addr
+ if( 0 != (buf_addr&(4-1)))
+ {
+ status = E_GFH_BUF_ADDR_NOT_32BITS_ALIGNED;
+ return status;
+ }
+
+ // perform FILE_INFO basic check
+ p_gfh_file_info = (GFH_FILE_INFO_v1 *)buf_addr;
+ status = GFH_FILE_INFO_BasicCheck(p_gfh_file_info);
+ if( E_ERROR <= status )
+ {
+ return status;
+ }
+ file_content_offset = p_gfh_file_info->m_content_offset;
+
+ // search target GFH
+ offset = 0;
+ while( offset < file_content_offset )
+ {
+ p_gfh_hdr = (GFH_Header *)(buf_addr+offset);
+ p_gfh_end = (GFH_End *)p_gfh_hdr;
+
+ // stop when end mark is found
+ if( GFH_HDR_MAGIC_END_MARK == p_gfh_end->m_magic_end )
+ {
+ break;
+ }
+
+ // check if GFH Header exist
+ if( GFH_HDR_MAGIC != GFH_GET_MAGIC(p_gfh_hdr->m_magic_ver) )
+ {
+ return E_GFH_NOT_FOUND;
+ }
+
+ // check if size is valid
+ next_gfh_offset = (offset+p_gfh_hdr->m_size);
+ if( (sizeof(GFH_Header) > p_gfh_hdr->m_size)
+ || (file_content_offset < next_gfh_offset)
+ ) {
+ return E_GFH_INVALID_SIZE;
+ }
+
+ // callback or search target type?
+#if defined(__GFH_PARSER__)
+ if(bEnableCallbackMap)
+ {
+ for(i=0; i<p_handle->m_cb_map_size; i++)
+ {
+ p_cb = (p_handle->m_p_cb_map + i);
+
+ if( p_cb->m_enable && (p_cb->m_type == p_gfh_hdr->m_type) )
+ {
+ status = p_cb->m_cb_interpreter(p_gfh_hdr, p_cb->m_cb_interpreter_arg);
+ // if callback return error, stop parsing
+ if( E_ERROR <= status )
+ {
+ return status;
+ }
+
+ bAnyCallbackInvoked = TRUE;
+ break;
+ }
+ }
+
+ //No callback found but the default handler exists
+ if(i==p_handle->m_cb_map_size && p_handle->m_p_cb_default_handler)
+ {
+ status = p_handle->m_p_cb_default_handler(p_gfh_hdr, p_handle->m_p_cb_default_handler_arg);
+ // if callback return error, stop parsing
+ if( E_ERROR <= status )
+ {
+ return status;
+ }
+ bAnyCallbackInvoked = TRUE;
+ }
+ }
+ else
+#endif
+ {
+ // check if type is matched
+ if( type == p_gfh_hdr->m_type )
+ {
+ // check occurrence index for multiple instances searching
+ if( occur_index == index )
+ {
+ // matched
+ *pp_gfh = p_gfh_hdr;
+ return B_OK;
+ }
+ else
+ {
+ // not matched, increase occurrence count and continue to search
+ occur_index++;
+ }
+ }
+ }
+
+ // update offset
+ offset = next_gfh_offset;
+ }
+
+ if( bEnableCallbackMap && bAnyCallbackInvoked )
+ {
+ return B_OK;
+ }
+
+ return E_GFH_NOT_FOUND;
+}
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_parser.h b/mcu/service/sys_svc/gfh/public/br_GFH_parser.h
new file mode 100644
index 0000000..0ed2e19
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_parser.h
@@ -0,0 +1,121 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_parser.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * GFH(General File Header) parser interface
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_PARSER_H__
+#define __BR_GFH_PARSER_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+#include "br_GFH_file_info.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//==============================================================================
+// GFH callback function definition
+//==============================================================================
+
+typedef U32 (*CB_GFH_INTERPRETER)(void * p_gfh, void * p_arg);
+
+//==============================================================================
+// GFH parser handle
+//==============================================================================
+
+typedef struct GFH_Callback {
+ bool m_enable;
+ #if defined(WIN32)
+ U16 m_type;
+ #else
+ GFH_TYPE m_type;
+ #endif
+ CB_GFH_INTERPRETER m_cb_interpreter;
+ void * m_cb_interpreter_arg;
+} GFH_Callback;
+
+#define GFH_PARSER_HANDLE_MAGIC 0x50484647 // represent for "GFHP"
+
+typedef struct GFH_Parser_Handle {
+ U32 m_magic;
+ U32 m_cb_map_size;
+ GFH_Callback *m_p_cb_map;
+ CB_GFH_INTERPRETER m_p_cb_default_handler;
+ void *m_p_cb_default_handler_arg;
+} GFH_Parser_Handle;
+
+//==============================================================================
+// Exported APIs
+//==============================================================================
+
+#if defined(__GFH_PARSER__)
+// default global GFH parser handle
+extern GFH_Parser_Handle g_GFH_PARSER_HANDLE;
+
+extern U32 GFH_Parser_Init(GFH_Parser_Handle * p_handle, U32 cb_map_size, GFH_Callback * cb_map);
+extern U32 GFH_Parser_Install(GFH_Parser_Handle * p_handle, GFH_TYPE type, CB_GFH_INTERPRETER cb, void * p_arg);
+extern U32 GFH_Parser_Uninstall(GFH_Parser_Handle * p_handle, GFH_TYPE type);
+extern U32 GFH_Parser_Install_Default_Handler(GFH_Parser_Handle * p_handle, CB_GFH_INTERPRETER cb, void * p_arg);
+extern U32 GFH_Parser_ClearAll(GFH_Parser_Handle * p_handle);
+extern U32 GFH_Parser_Start(const GFH_Parser_Handle * p_handle, U32 buf_addr);
+#endif
+
+extern U32 GFH_Find(U32 buf_addr, GFH_TYPE type, void ** pp_gfh);
+extern U32 GFH_FindEx(U32 buf_addr, GFH_TYPE type, void ** pp_gfh, U32 index);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_secure_ro_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_secure_ro_info.h
new file mode 100644
index 0000000..bf0510c
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_secure_ro_info.h
@@ -0,0 +1,75 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_secure_ro_info.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * SECURE_RO_INFO GFH structure definition
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_GFH_SECURE_RO_INFO_H__
+#define __BR_GFH_SECURE_RO_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+//==============================================================================
+// GFH_SECURE_RO_INFO definition
+//==============================================================================
+
+#define SECURE_RO_ENCRYPTED_BY_KEY 0x00000001
+
+typedef struct GFH_SECURE_RO_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+ bool m_B2C;
+ U32 m_attr;
+ U32 m_resvered[4];
+} GFH_SECURE_RO_INFO_v1;
+
+#endif
+
diff --git a/mcu/service/sys_svc/gfh/public/br_GFH_vec_info.h b/mcu/service/sys_svc/gfh/public/br_GFH_vec_info.h
new file mode 100644
index 0000000..02653db
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/br_GFH_vec_info.h
@@ -0,0 +1,78 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_GFH_vec_info.h
+ *
+ * Project:
+ * --------
+ * GFH
+ *
+ * Description:
+ * ------------
+ * VEC_INFO GFH structure declaration
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+
+#ifndef __BR_GFH_VEC_INFO_H__
+#define __BR_GFH_VEC_INFO_H__
+
+#include "br_sw_types.h"
+#include "br_GFH.h"
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+ typedef struct GFH_VEC_INFO_v1 {
+ GFH_Header m_gfh_hdr;
+ U32 m_vec_start_addr;
+ U32 m_vec_end_addr;
+ U8 _reserved[8];
+ }GFH_VEC_INFO_v1;
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/mcu/service/sys_svc/gfh/public/maui_GFH_body.c b/mcu/service/sys_svc/gfh/public/maui_GFH_body.c
new file mode 100644
index 0000000..0be04c9
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/maui_GFH_body.c
@@ -0,0 +1,557 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * maui_GFH_body.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file contain the GFH body and content for all MAUI parts
+ *
+ * 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!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+
+#include "br_GFH.h"
+#include "br_GFH_file_info.h"
+#include "br_GFH_maui_info.h"
+#include "br_GFH_flash_info.h"
+#include "br_GFH_cbr_info.h"
+#include "br_GFH_maui_sec.h"
+#include "br_GFH_secure_ro_info.h"
+#include "br_GFH_binary_location.h"
+#include "SST_init.h"
+#include "brom_ext.h"
+
+
+#include "GFH_defs.h"
+#include "maui_GFH_body.h"
+
+#include "feature_def.h"
+
+#include "custom_img_config.h"
+
+#include "kal_general_types.h"
+
+#ifdef _NAND_FLASH_BOOTING_
+#include "NAND_DAL_Version.h"
+#endif
+
+#ifdef __BOOT_CERT_V2__
+#include "boot_cert_pattern.h"
+#endif
+
+//==============================================================================
+// Linker symbols
+//==============================================================================
+
+extern kal_uint32 INT_VECTOR_CODE$$Base;
+extern kal_uint32 INT_VECTOR_CODE$$Limit;
+
+
+extern kal_uint32 Image$$ROM_GFH$$Length;
+extern kal_uint32 Load$$ROM_GFH$$Base;
+
+extern kal_uint32 BR_EXT$$Length;
+extern kal_uint32 BR_EXT$$Base;
+
+extern kal_uint32 Image$$SECURE_RO_S_GFH$$Length;
+extern kal_uint32 Load$$SECURE_RO_S_GFH$$Base;
+
+extern kal_uint32 Image$$SECURE_RO_ME_GFH$$Length;
+extern kal_uint32 Load$$SECURE_RO_ME_GFH$$Base;
+
+//==============================================================================
+// Section definition
+//==============================================================================
+
+#undef __section
+
+#ifdef __MTK_TARGET__
+#define __section(S) __attribute__ ((used,section(#S)))
+#else
+#define __section(S)
+#endif
+
+#define __maui_iv_region_section__ __section(MAUI_IV_REGION)
+#define __maui_gfh__ __section(MAUI_GFH)
+#define __maui_signature_section__ __section(MAUI_SIGNATURE_SECTION)
+#define __brom_ext_section__ __section(BROM_EXT)
+#define __brom_ext_signature_section__ __section(BROM_EXT_SIGNATURE_SECTION)
+#define __secure_ro_s_gfh__ __section(SECURE_RO_S_GFH)
+#define __secure_ro_s_signature_section__ __section(SECURE_RO_S_SIGNATURE_SECTION)
+#define __secure_ro_me_gfh__ __section(SECURE_RO_ME_GFH)
+#define __secure_ro_me_signature_section__ __section(SECURE_RO_ME_SIGNATURE_SECTION)
+
+/* SECURE RO S is not ready yet, we use a macro to disable it first */
+#define __SECURE_RO_S_DISABLE__
+
+//==============================================================================
+// MAUI parameters
+//==============================================================================
+
+//Define where the MAUI locates
+#if defined (_NAND_FLASH_BOOTING_)
+
+#define MAUI_DEVICE_TYPE F_NAND_FDM50
+#define BINARY_ATTRIBUTE 0
+
+#elif defined (__EMMC_BOOTING__)
+
+#define MAUI_DEVICE_TYPE F_EMMC_DATA_REGION
+#define BINARY_ATTRIBUTE 0
+
+#elif defined(__X_BOOTING__)
+
+#define MAUI_DEVICE_TYPE F_XBOOT
+#define BINARY_ATTRIBUTE 0
+
+#else
+
+#define MAUI_DEVICE_TYPE F_NOR
+
+#if defined(__XIP_SHADOWING__)
+#define BINARY_ATTRIBUTE 0
+#else
+#endif
+#if defined(__CERT_CHAIN_IMG__)
+#define BINARY_ATTRIBUTE FILE_INFO_ATTR_XIP | FILE_INFO_SIG_PAD_PSS | FILE_INFO_SIG_EXT_MAGIC | FILE_INFO_SIG_RSA_STD
+#else
+#define BINARY_ATTRIBUTE FILE_INFO_ATTR_XIP | FILE_INFO_SIG_EXT_MAGIC | FILE_INFO_SIG_RSA_M1
+#endif
+
+#endif
+
+
+//Define the size of MAUI iv region
+#define MAUI_IV_REGION_LEN 0x400
+#define MAUI_IV_REGION_MARK "IV_REGION"
+
+#if defined(__CERT_CHAIN_IMG__)
+#define P_MAUI_SIGNATURE_TYPE SIG_CERT_CHAIN
+#define P_MAUI_SIGNATURE_LEN SIG_CERT_CHAIN_LEN
+#else
+//Define the signature type of MAUI binaries
+#define P_MAUI_SIGNATURE_TYPE SIG_SINGLE
+#define P_MAUI_SIGNATURE_LEN SIG_SINGLE_LEN
+#endif
+
+#define P_BROM_EXT_SIGNATURE_TYPE SIG_SINGLE_AND_PHASH
+#define P_BROM_EXT_SIGNATURE_LEN SIG_SINGLE_AND_PHASH_LEN
+
+
+//Constants
+#define DUMMY_END (0xffffffff)
+
+//Define the version of MAUI software
+#define MAUI_VERSION 1
+#define SECURE_RO_VERSION 1
+
+
+//==============================================================================
+// MAUI's initial vector region
+//==============================================================================
+
+__maui_iv_region_section__ const char g_maui_iv_region[MAUI_IV_REGION_LEN] = MAUI_IV_REGION_MARK;
+
+
+//==============================================================================
+// MAUI's GFH header body
+//==============================================================================
+
+
+__maui_gfh__ const MAUI_GFH g_maui_gfh =
+{
+ //GFH_FILE_INFO_v1
+ {
+ GFH_HEADER(GFH_FILE_INFO, 1),
+ GFH_FILE_INFO_ID,
+
+ MAUI_VERSION,
+#ifndef __FACTORY_BIN__
+ PRIMARY_MAUI,
+#else
+ PRIMARY_FACTORY_BIN,
+#endif
+ MAUI_DEVICE_TYPE,
+ P_MAUI_SIGNATURE_TYPE,
+
+ (kal_uint32)(&Load$$ROM_GFH$$Base) + MAUI_IV_REGION_LEN,
+ GFH_FILE_SIZE_BY_POST_BUILD,
+ MAX_LENGTH_ROM,
+ (kal_uint32)(&Image$$ROM_GFH$$Length) - MAUI_IV_REGION_LEN,
+ P_MAUI_SIGNATURE_LEN,
+ (kal_uint32)(&INT_VECTOR_CODE$$Base),
+ BINARY_ATTRIBUTE
+ },
+
+ //GFH_MAUI_INFO_v2
+ {
+ GFH_HEADER(GFH_MAUI_INFO, 2),
+
+ //platform_id & project_id
+ "N/A",
+ "N/A",
+
+ 1, //BL_MAUI_PAIRED_VER,
+ FEATURE_COMBINATION,
+ FEATURE_COMBINATINO_EX,
+ 0,
+ SW_MINOR_VER,
+#ifdef __SECURE_DATA_STORAGE__
+ SDS_START_ADDR,
+ SDS_TOTAL_SIZE,
+#else
+ 0,
+ 0,
+#endif
+ MIN_FLASHTOOL_VER_REQURIEMENT,
+#ifdef __BOOT_CERT_V2__
+ (kal_uint32)&g_SRD_INFO,
+ (kal_uint32)sizeof(g_SRD_INFO),
+#else
+ 0,0,
+#endif
+ {0}
+
+ },
+
+ //GFH_FLASH_INFO_v1
+ {
+ GFH_HEADER(GFH_FLASH_INFO, 1),
+#ifdef _NAND_FLASH_BOOTING_
+ { 0x30, (FDM_MAJOR_VER+0x30), (FDM_MINOR_VER1+0x30), (FDM_MINOR_VER2+0x30),
+ 0x30, (DAL_MAJOR_VER+0x30), (DAL_MINOR_VER1+0x30), (DAL_MINOR_VER2+0x30)
+ },
+#endif
+ },
+
+ //GFH_CBR_INFO_v2
+ {
+ GFH_HEADER(GFH_CBR_INFO, 2),
+ 0, //CBR_REGION_NORMAL_BLOCK_NUM,
+ 0, //CBR_REGION_SPARE_BLOCK_NUM,
+ 0,
+ 0
+ },
+
+#ifdef __MTK_SECURE_PLATFORM__
+ //GFH_MAUI_SEC_v1
+ {
+ GFH_HEADER(GFH_MAUI_SEC, 1),
+ },
+#endif /* __MTK_SECURE_PLATFORM__ */
+
+ //GFH_MAUI_CODE_KEY_v1, for Code binaries
+ {
+ GFH_HEADER(GFH_MAUI_CODE_KEY, 1),
+ },
+
+ //GFH_MAUI_SECURE_RO_KEY_v1, for Secure RO
+ /*{
+ GFH_HEADER(GFH_MAUI_SECURE_RO_KEY, 1),
+ },*/
+
+#ifdef __FOTA_DM__
+ //GFH_FOTA_INFO_v1
+ {
+ GFH_HEADER(GFH_FOTA_INFO, 1),
+ FOTA_PACKAGE_STORAGE_BASE,
+ FOTA_PACKAGE_STORAGE_SIZE,
+ FOTA_BACKUP_STORAGE_BASE,
+ FOTA_BACKUP_STORAGE_SIZE,
+ FOTA_EXTRA_RESERVED_BLOCKS,
+ },
+#endif
+
+#ifdef __XIP_SHADOWING__
+ //GFH_BINARY_LOCATION_v1
+ {
+ GFH_HEADER(GFH_BINARY_LOCATION, 1),
+#ifndef __FACTORY_BIN__
+ MAUI_ROM_START_ADDR
+#else
+ FACTORY_ROM_START_ADDR
+#endif
+ },
+#endif
+
+ //GFH_VEC_INFO_v1
+ {
+ GFH_HEADER(GFH_VEC_INFO, 1),
+ (kal_uint32)(&INT_VECTOR_CODE$$Base),
+ (kal_uint32)(&INT_VECTOR_CODE$$Limit)
+ },
+
+ //GFH_BROM_EXT_INFO_v1
+ {
+ GFH_HEADER(GFH_BROM_EXT_INFO, 1),
+ (kal_uint32)(&BR_EXT$$Base),
+ (kal_uint32)(&BR_EXT$$Length),
+ P_BROM_EXT_SIGNATURE_LEN,
+ P_BROM_EXT_SIGNATURE_TYPE
+ },
+
+};
+
+//==============================================================================
+// BROM EXT's Signature
+//==============================================================================
+__brom_ext_signature_section__ const unsigned long g_brom_ext_sig[P_BROM_EXT_SIGNATURE_LEN>>2] = {SIG_HASH_VER};
+
+
+//==============================================================================
+// MAUI's Signature
+//==============================================================================
+#if defined(__CERT_CHAIN_IMG__)
+__maui_signature_section__ const unsigned long g_maui_sig[P_MAUI_SIGNATURE_LEN>>2] = {SIG_CERT_VER};
+#else
+__maui_signature_section__ const unsigned long g_maui_sig[P_MAUI_SIGNATURE_LEN>>2] = {SIG_HASH_VER};
+#endif
+//==============================================================================
+// Misc
+//==============================================================================
+kal_uint32 DummyReference()
+{
+ kal_uint32 size = 0;
+
+ size += ((kal_uint32)(&g_maui_iv_region)
+ + (kal_uint32)(&brom_ext_main)
+ + (kal_uint32)(&g_maui_gfh)+(kal_uint32)(&g_maui_sig)
+ +(kal_uint32)(&g_brom_ext_sig)
+ );
+
+ return size;
+}
+
+
diff --git a/mcu/service/sys_svc/gfh/public/maui_GFH_body.h b/mcu/service/sys_svc/gfh/public/maui_GFH_body.h
new file mode 100644
index 0000000..70a89b8
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/maui_GFH_body.h
@@ -0,0 +1,180 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * secure_maui_GFH_body.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file contain the GFH definition
+ *
+ * Author:
+ * -------
+ *
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef __MAUI_GFH_BODY_H__
+#define __MAUI_GFH_BODY_H__
+
+#include "br_GFH_file_info.h"
+#include "br_GFH_maui_info.h"
+#include "br_GFH_anti_clone.h"
+#include "br_GFH_maui_sec.h"
+#include "br_GFH_secure_ro_info.h"
+#include "br_GFH_flash_info.h"
+#include "br_GFH_fota_info.h"
+#include "br_GFH_cbr_record_info.h"
+#include "br_GFH_cbr_info.h"
+#include "br_GFH_binary_location.h"
+#include "br_GFH_vec_info.h"
+#include "br_GFH_brom_ext_info.h"
+#include "GFH_defs.h"
+
+//==============================================================================
+// Primary MAUI GFH structure
+//==============================================================================
+
+typedef struct
+{
+ GFH_FILE_INFO_v1 gfh_file_info;
+ GFH_MAUI_INFO_v2 gfh_maui_info;
+ GFH_FLASH_INFO_v1 gfh_flash_info;
+ GFH_CBR_INFO_v2 gfh_cbr_info;
+
+#ifdef __MTK_SECURE_PLATFORM__
+ GFH_MAUI_SEC_v1 gfh_maui_sec;
+#endif /* __MTK_SECURE_PLATFORM__ */
+ GFH_MAUI_CODE_KEY_v1 gfh_maui_sec_key_maui; //The key to verify SecondaryMAUI
+ //GFH_MAUI_SECURE_RO_KEY_v1 gfh_maui_sec_key_secro; //The key to verify SecureRO
+
+#ifdef __FOTA_DM__
+ GFH_FOTA_INFO_v1 gfh_fota_info;
+#endif /* __FOTA_DM__ */
+
+#ifdef __XIP_SHADOWING__
+ GFH_BINARY_LOCATION_v1 gfh_binary_location;
+#endif /* __XIP_SHADOWING__ */
+ GFH_VEC_INFO_v1 gfh_vec_info;
+ GFH_BROM_EXT_INFO_v1 gfh_brom_ext_info;
+
+} MAUI_GFH;
+
+//==============================================================================
+// Export symbols
+//==============================================================================
+
+extern const MAUI_GFH g_maui_gfh;
+
+#endif /* __MAUI_GFH_BODY_H__ */
+
diff --git a/mcu/service/sys_svc/gfh/public/secure_ro_GFH_body.c b/mcu/service/sys_svc/gfh/public/secure_ro_GFH_body.c
new file mode 100644
index 0000000..11027cb
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/secure_ro_GFH_body.c
@@ -0,0 +1,199 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * secure_ro_GFH_body.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file contain the GFH body and content for all SecureRO parts
+ *
+ * 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!!
+ *============================================================================
+ ****************************************************************************/
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#ifdef __MTK_SECURE_PLATFORM__
+/* under construction !*/
+/* under construction !*/
+#else
+/* under construction !*/
+/* under construction !*/
+#endif /* __MTK_SECURE_PLATFORM__ */
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#ifdef _NAND_FLASH_BOOTING_
+#endif /* _NAND_FLASH_BOOTING_ */
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
diff --git a/mcu/service/sys_svc/gfh/public/secure_ro_GFH_body.h b/mcu/service/sys_svc/gfh/public/secure_ro_GFH_body.h
new file mode 100644
index 0000000..e7b4e37
--- /dev/null
+++ b/mcu/service/sys_svc/gfh/public/secure_ro_GFH_body.h
@@ -0,0 +1,92 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 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:
+ * ---------
+ * secure_ro_GFH_body.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file contain the GFH definition
+ *
+ * Author:
+ * -------
+ *
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+#if 0
+#ifndef __SECURE_RO_GFH_BODY_H__
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif /* __SECURE_RO_GFH_BODY_H__ */
+#endif
diff --git a/mcu/service/sys_svc/profile/inc/br_time_stamp.h b/mcu/service/sys_svc/profile/inc/br_time_stamp.h
new file mode 100644
index 0000000..8bd6715
--- /dev/null
+++ b/mcu/service/sys_svc/profile/inc/br_time_stamp.h
@@ -0,0 +1,176 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_time_stamp.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Time stamp measurement utility functions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_TIME_STAMP_H__
+#define __BR_TIME_STAMP_H__
+
+#include "br_sw_types.h"
+#include "br_time_stamp_cb.h"
+
+#if defined(__BOOTROM__)
+ #include "br_time_stamp_id.h"
+#elif defined(__UBL__)
+ #include "bl_time_stamp_id.h"
+#elif defined(__FUE__)
+ #include "fue_time_stamp_id.h"
+#else
+ // MAUI
+ #include "maui_time_stamp_id.h"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//==============================================================================
+// TimeStamp Measurement APIs
+//==============================================================================
+#define TS_MAGIC1 0x454D4954 // "TIME"
+#define TS_MAGIC2 0x504D5453 // "STMP"
+
+typedef enum {
+ TS_TIME_TICK = 0
+ ,TS_TIME_US
+ ,TS_TIME_MS
+} TS_TIME_UNIT;
+
+typedef struct {
+ TSID m_id;
+ U16 m_duration;
+ U32 m_info1;
+ U32 m_info2;
+ U32 m_info3;
+ U32 m_begin_tick;
+ U32 m_end_tick;
+} TS_Unit;
+
+typedef struct {
+ TS_TIME_UNIT m_unit;
+ TS_Unit m_record[TSID_NUM];
+} TS_RecordTable;
+
+#if defined(__TIME_STAMP__)
+
+ // function prototype
+ extern void TS_Init(bool bResetRecords);
+ extern void TS_ConvertTimeUnit(void);
+ extern void TS_Record(TSID id, TS_TIME_ANCHOR anchor);
+ extern void TS_UpdateInfo(TSID id, U32 data1, U32 data2, U32 data3);
+ #if defined(__RTLSIM__)
+ extern void TS_Record_RTLSIM(const char *id_str, TSID id, TS_TIME_ANCHOR anchor);
+ extern void TS_UpdateInfo_RTLSIM(const char *id_str, TSID id, U32 data1, U32 data2, U32 data3);
+ #elif defined(__UBL__)
+ extern void TS_Record_BLWrapper(TSID id, TS_TIME_ANCHOR anchor);
+ extern void TS_UpdateInfo_BLWrapper(TSID id, U32 data1, U32 data2, U32 data3);
+ #endif
+
+ // macro re-define
+ #if defined(__RTLSIM__)
+ #define TS_RECORD_FUNC TS_Record_RTLSIM
+ #define TS_INFO_FUNC TS_UpdateInfo_RTLSIM
+ #define TS_BEGIN(id) TS_Record_RTLSIM(QUOTE(id##[BEGIN]), id, TS_BEGIN)
+ #define TS_END(id) TS_Record_RTLSIM(QUOTE(id##[END]), id, TS_END)
+ #define TS_INFO(id,d1,d2,d3) TS_UpdateInfo_RTLSIM(QUOTE(id##[INFO]), id, d1, d2, d3)
+ #elif defined(__UBL__)
+ #define TS_RECORD_FUNC TS_Record_BLWrapper
+ #define TS_INFO_FUNC TS_UpdateInfo_BLWrapper
+ #define TS_BEGIN(id) TS_Record_BLWrapper(id, TS_BEGIN)
+ #define TS_END(id) TS_Record_BLWrapper(id, TS_END)
+ #define TS_INFO(id,d1,d2,d3) TS_UpdateInfo_BLWrapper(id, d1, d2, d3)
+ #else
+ #define TS_RECORD_FUNC TS_Record
+ #define TS_INFO_FUNC TS_UpdateInfo
+ #define TS_BEGIN(id) TS_Record(id, TS_BEGIN)
+ #define TS_END(id) TS_Record(id, TS_END)
+ #define TS_INFO(id,d1,d2,d3) TS_UpdateInfo(id, d1, d2, d3)
+ #endif
+
+#else
+
+ #define TS_Init(b)
+ #define TS_ConvertTimeUnit()
+ #define TS_RECORD_FUNC NULL
+ #define TS_INFO_FUNC NULL
+ #define TS_BEGIN(id)
+ #define TS_END(id)
+ #define TS_INFO(id,d1,d2,d3)
+
+#endif
+
+//==============================================================================
+// TimeStamp Utility APIs
+//==============================================================================
+
+#if defined(__TIME_STAMP__)
+
+ #if defined(__TIME_STAMP_UTIL__)
+ extern void TS_GetContext(U32 *p_addr, U32 *p_size);
+ extern void TS_SetTimeUnit(TS_TIME_UNIT unit);
+ extern const TS_RecordTable * TS_GetRecordTable(void);
+ #endif
+
+#else
+
+ #define TS_GetContext(a,s)
+ #define TS_SetTimeUnit(u)
+ #define TS_GetRecordTable() NULL
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/mcu/service/sys_svc/profile/inc/br_time_stamp_cb.h b/mcu/service/sys_svc/profile/inc/br_time_stamp_cb.h
new file mode 100644
index 0000000..383a61d
--- /dev/null
+++ b/mcu/service/sys_svc/profile/inc/br_time_stamp_cb.h
@@ -0,0 +1,145 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * br_time_stamp_cb.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Prototype definition of time stamp measurement callback function
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __BR_TIME_STAMP_CB_H__
+#define __BR_TIME_STAMP_CB_H__
+
+#include "br_sw_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//==============================================================================
+// TimeStamp callback function prototype
+//==============================================================================
+
+typedef enum {
+ TS_BEGIN = 0
+ ,TS_END
+} TS_TIME_ANCHOR;
+
+typedef void (*CB_TS_RECORD)(U32 id, TS_TIME_ANCHOR anchor);
+typedef void (*CB_TS_INFO)(U32 id, U32 data1, U32 data2, U32 data3);
+typedef void (*CB_TS_ID_STR_RECORD)(const char *id_str, U32 id, TS_TIME_ANCHOR anchor);
+typedef void (*CB_TS_ID_STR_INFO)(const char *id_str, U32 id, U32 data1, U32 data2, U32 data3);
+
+//==============================================================================
+// TimeStamp macro definition
+//==============================================================================
+
+#if defined(__TIME_STAMP__)
+
+ #if defined(__RTLSIM__)
+
+ #define CALLBACK_TS_BEGIN(id,func)\
+ do{\
+ if( NULL != (func) ) {\
+ ((CB_TS_ID_STR_RECORD)(func))(QUOTE(id##[BEGIN]), id, TS_BEGIN);\
+ }\
+ }while(0)
+
+ #define CALLBACK_TS_END(id,func)\
+ do{\
+ if( NULL != (func) ) {\
+ ((CB_TS_ID_STR_RECORD)(func))(QUOTE(id##[END]), id, TS_END);\
+ }\
+ }while(0)
+
+ #define CALLBACK_TS_INFO(id,d1,d2,d3,func)\
+ do{\
+ if( NULL != (func) ) {\
+ ((CB_TS_ID_STR_INFO)(func))(QUOTE(id##[INFO]), id, d1, d2, d3);\
+ }\
+ }while(0)
+
+ #else
+
+ #define CALLBACK_TS_BEGIN(id,func)\
+ do{\
+ if( NULL != (func) ) {\
+ ((CB_TS_RECORD)(func))(id, TS_BEGIN);\
+ }\
+ }while(0)
+
+ #define CALLBACK_TS_END(id,func)\
+ do{\
+ if( NULL != (func) ) {\
+ ((CB_TS_RECORD)(func))(id, TS_END);\
+ }\
+ }while(0)
+
+ #define CALLBACK_TS_INFO(id,d1,d2,d3,func)\
+ do{\
+ if( NULL != (func) ) {\
+ ((CB_TS_INFO)(func))(id, d1, d2, d3);\
+ }\
+ }while(0)
+
+ #endif
+
+#else
+
+ #define CALLBACK_TS_BEGIN(id,func)
+ #define CALLBACK_TS_END(id,func)
+ #define CALLBACK_TS_INFO(id,d1,d2,d3,func)
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/mcu/service/sys_svc/profile/inc/maui_time_stamp_id.h b/mcu/service/sys_svc/profile/inc/maui_time_stamp_id.h
new file mode 100644
index 0000000..d05e863
--- /dev/null
+++ b/mcu/service/sys_svc/profile/inc/maui_time_stamp_id.h
@@ -0,0 +1,106 @@
+/*****************************************************************************
+* 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) 2010
+*
+* 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:
+ * ---------
+ * maui_time_stamp_id.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Time stamp measurement id (MAUI Only)
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __MAUI_TIME_STAMP_ID_H__
+#define __MAUI_TIME_STAMP_ID_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//==============================================================================
+// TimeStamp Measurement ID
+//==============================================================================
+
+typedef enum {
+
+ TSID_INIT_TOTAL
+ ,TSID_INIT_READY_TO_DISPLAY
+ ,TSID_INIT_ASM
+ ,TSID_INIT_APPINIT
+ ,TSID_INIT_CLIB1
+ ,TSID_INIT_CCCI
+ ,TSID_INIT_CCCIHS1
+ ,TSID_INIT_MDCIHS1
+ ,TSID_INIT_TSIDMODE
+ ,TSID_INIT_SYSTEMINIT
+ ,TSID_INIT_NVRAM
+ ,TSID_INIT_HWDINIT
+ ,TSID_INIT_OSTD
+ ,TSID_INIT_PREFOTA
+ ,TSID_INIT_THIRDROM
+ ,TSID_INIT_LOADSECMAUI
+ ,TSID_INIT_DEMP
+ ,TSID_INIT_DRV2_START
+ ,TSID_INIT_RESINIT
+ ,TSID_INIT_CHECKMSGID
+ ,TSID_INIT_CLIB2
+ ,TSID_INIT_MAINP
+ ,TSID_INIT_CCCIHS2
+ ,TSID_INIT_MDCIHS2
+ ,TSID_INIT_DMDSP2
+
+ ,TSID_NUM
+
+ ,TSID_END = (U8)255 // max 255 records
+ ,TSID_NONE = TSID_END
+
+} TSID;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/mcu/service/sys_svc/profile/inc/maui_time_stamp_util.h b/mcu/service/sys_svc/profile/inc/maui_time_stamp_util.h
new file mode 100644
index 0000000..67c2845
--- /dev/null
+++ b/mcu/service/sys_svc/profile/inc/maui_time_stamp_util.h
@@ -0,0 +1,73 @@
+/*****************************************************************************
+* 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) 2010
+*
+* 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:
+ * ---------
+ * maui_time_stamp_util.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Time stamp measurement utility (MAUI Only)
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __MAUI_TIME_STAMP_UTIL_H__
+#define __MAUI_TIME_STAMP_UTIL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(__TIME_STAMP__)
+ extern void TS_DumpTimeStamps(void);
+#else
+ #define TS_DumpTimeStamps()
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/mcu/service/sys_svc/profile/inc/time_stamp_timer.h b/mcu/service/sys_svc/profile/inc/time_stamp_timer.h
new file mode 100644
index 0000000..a60ef10
--- /dev/null
+++ b/mcu/service/sys_svc/profile/inc/time_stamp_timer.h
@@ -0,0 +1,73 @@
+/*****************************************************************************
+* 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) 2009
+*
+* 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:
+ * ---------
+ * time_stamp_timer.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * Provide timestamp service an abstration layer of different kinds of timer
+ * (INTERNAL USE ONLY)
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ ****************************************************************************/
+#ifndef __TIME_STAMP_TIMER_H__
+#define __TIME_STAMP_TIMER_H__
+
+#include "br_sw_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern U32 TS_GetTick(void);
+extern U32 TS_TickToUS(U32 tick);
+extern U32 TS_TickToMS(U32 tick);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/mcu/service/sys_svc/region/inc/init_memory_stack_int.h b/mcu/service/sys_svc/region/inc/init_memory_stack_int.h
new file mode 100644
index 0000000..f97db32
--- /dev/null
+++ b/mcu/service/sys_svc/region/inc/init_memory_stack_int.h
@@ -0,0 +1,137 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * init.h
+ *
+ * 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!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef __INIT_MEMORY_STACK_INT_H__
+#define __INIT_MEMORY_STACK_INT_H__
+
+#include "kal_public_defs.h"
+typedef enum
+{
+ STACK_FREED,
+ STACK_ALLOCATED
+} switch_stack_state;
+
+typedef struct
+{
+ void *stack_start;
+ void *stack_end;
+} switch_stack_info_struct;
+
+typedef struct
+{
+ switch_stack_state state;
+ void *stack_start;
+ void *stack_end;
+ void *old_sp;
+ kal_taskid task_id;
+} switch_stack_history_struct;
+
+#if defined(__LOW_COST_SUPPORT_ULC__)
+
+#define SWITCH_STACK_INFO_NUM 2
+
+#define SWITCH_STACK_HISTORY_NUM 4
+
+#else
+
+#define SWITCH_STACK_INFO_NUM 10
+
+#define SWITCH_STACK_HISTORY_NUM 10
+
+#endif /* __LOW_COST_SUPPORT_ULC__ */
+
+
+#endif /* __INIT_MEMORY_STACK_INT_H__ */
diff --git a/mcu/service/sys_svc/region/src/init_memory_stack.c b/mcu/service/sys_svc/region/src/init_memory_stack.c
new file mode 100644
index 0000000..25488f2
--- /dev/null
+++ b/mcu/service/sys_svc/region/src/init_memory_stack.c
@@ -0,0 +1,1652 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * init_memory_stack.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file defines the stack distribution, will be referenced in bootarm.s
+ *
+ * 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!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*******************************************************************************
+ * Include header files
+ *******************************************************************************/
+
+#include <stdarg.h>
+#include "init_memory_stack_int.h"
+#include "init_memory_stack.h"
+#include "init.h"
+#include "cache_sw_int.h"
+#include "cache_sw.h"
+#include "cpu.h"
+#include "mips_mmu.h"
+
+#if defined(__SMART_PHONE_MODEM__)
+#include "ccci.h"
+#endif /* __SMART_PHONE_MODEM__ */
+#include "intrCtrl.h"
+#include "custom_scatstruct.h"
+#include "kal_general_types.h"
+#include "kal_public_defs.h"
+#include "kal_public_api.h"
+
+
+#ifdef __MTK_TARGET__
+
+/*******************************************************************************
+ * Define import global data
+ *******************************************************************************/
+
+#if !(defined(_NAND_FLASH_BOOTING_) && !defined(__NFB_SINGLE_ROM__))
+extern kal_uint32 Image$$EXTSRAM_DSP_TX_ZI$$Base;
+extern kal_uint32 Image$$EXTSRAM_DSP_RX_ZI$$Base;
+extern kal_uint32 Image$$EXTSRAM_DSP_TX_ZI$$Length;
+extern kal_uint32 Image$$EXTSRAM_DSP_RX_ZI$$Length;
+extern kal_uint32 Image$$EXTSRAM_DSP_TX_ZI$$ZI$$Length;
+extern kal_uint32 Image$$EXTSRAM_DSP_RX_ZI$$ZI$$Length;
+#endif /* end of !(defined(_NAND_FLASH_BOOTING_) && !defined(__NFB_SINGLE_ROM__)) */
+
+extern kal_uint32 Image$$ROM$$Base;
+extern kal_uint32 Image$$EXTSRAM$$Base;
+extern kal_uint32 Image$$EXTSRAM$$ZI$$Limit;
+
+extern kal_uint32 SYS_Stack_Pool[];
+extern kal_uint32 SYS_Stack_End;
+extern kal_char _stack_pattern_ptr[];
+
+/*******************************************************************************
+ * Define global data
+ *******************************************************************************/
+
+switch_stack_info_struct switch_stack_info_g[SWITCH_STACK_INFO_NUM];
+kal_uint32 switch_stack_info_cnt_g = 0;
+
+switch_stack_history_struct switch_stack_history_g[SWITCH_STACK_HISTORY_NUM];
+kal_uint32 switch_stack_history_cur_g = 0;
+
+#if defined(__RTL_SIMULATION_FOR_60QBIT__)
+static EBM_LOG_T init_ibus_log1, init_ibus_log2, init_dbus_log1, init_dbus_log2;
+#endif /* __RTL_SIMULATION_FOR_60QBIT__ */
+
+
+/*******************************************************************************
+ * Define import function prototype
+ *******************************************************************************/
+
+extern kal_uint32 INT_SwitchStackAndBranch(void *new_stack, kal_func_ptr func, kal_uint32 argc, void *argv);
+extern kal_uint32 SaveAndSetIRQMask(void);
+extern void RestoreIRQMask(kal_uint32 irq);
+extern int INT_GetCurrentSP(void);
+extern void INT_GetStackInfo(kal_uint32 * const base, kal_uint32 * const end);
+
+
+
+
+
+
+void INT_QueryHWITCRange(kal_uint32 *base_addr, kal_uint32 *length)
+{
+ extern kal_uint32 L2CACHE_LOCK_ITC_ROCODE$$Base;
+ extern kal_uint32 L2CACHE_LOCK_ITC_ROCODE$$Length;
+
+ *base_addr = (kal_uint32) &L2CACHE_LOCK_ITC_ROCODE$$Base;
+ *length = (kal_uint32) &L2CACHE_LOCK_ITC_ROCODE$$Length;
+}
+
+
+
+
+#if !defined(__FUE__)
+
+/*************************************************************************
+* FUNCTION
+* INT_QueryBiggestPool
+*
+* DESCRIPTION
+* Query the biggest Pool, available for META mode only!
+*
+* PARAMETERS
+*
+* RETURNS
+*
+*************************************************************************/
+kal_bool INT_QueryBiggestPool(kal_uint32 *availableSize, void **ptr)
+{
+ *availableSize = 0;
+ *ptr = 0;
+
+ return KAL_TRUE;
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(_NAND_FLASH_BOOTING_) || defined(__NOR_FLASH_BOOTING__) || defined(__EMMC_BOOTING__)
+#if defined(__DYNAMIC_SWITCH_CACHEABILITY__) || defined(__ARM9_DCACHEABLE__)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else /* __DYNAMIC_SWITCH_CACHEABILITY__ || __ARM9_DCACHEABLE__ */
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif /* __DYNAMIC_SWITCH_CACHEABILITY__ || __ARM9_DCACHEABLE__ */
+#else
+#if defined(__DYNAMIC_SWITCH_CACHEABILITY__) || defined(__ARM9_DCACHEABLE__)
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else /* __DYNAMIC_SWITCH_CACHEABILITY__ || __ARM9_DCACHEABLE__ */
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif /* __DYNAMIC_SWITCH_CACHEABILITY__ || __ARM9_DCACHEABLE__ */
+#endif /* _NAND_FLASH_BOOTING_ || __NOR_FLASH_BOOTING__ || __EMMC_BOOTING__ */
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+}
+
+/*************************************************************************
+* FUNCTION
+* INT_GetSystemStackStartEndAddress
+*
+* DESCRIPTION
+* Retrieve start address and end address of the system stack
+*
+* PARAMETERS
+*
+* RETURNS
+*
+*************************************************************************/
+void INT_GetSystemStackStartEndAddress(kal_uint32 *start, kal_uint32 *end)
+{
+ INT_GetStackInfo(start, end);
+}
+
+/*************************************************************************
+* FUNCTION
+* INT_RetrieveRemappedFlashBaseAddr
+*
+* DESCRIPTION
+* Retrieve start address and end address of the system stack
+* (remapped bank in ALICE support)
+*
+* PARAMETERS
+*
+* RETURNS
+*
+*************************************************************************/
+kal_uint32 INT_RetrieveRemappedFlashBaseAddr(void)
+{
+ return (kal_uint32)(&Image$$ROM$$Base) & 0xf0000000;
+}
+
+/*************************************************************************
+* FUNCTION
+* INT_RetrieveFlashBaseAddr
+*
+* DESCRIPTION
+* This function returns flash base address to caller.
+* (raw bank in ALICE support)
+*
+* CALLS
+*
+* PARAMETERS
+*
+* RETURNS
+*
+*************************************************************************/
+kal_uint32 INT_RetrieveFlashBaseAddr(void)
+{
+ return INT_RetrieveRemappedFlashBaseAddr();
+}
+
+
+/*************************************************************************
+* FUNCTION
+* INT_RetrieveDSPTXRXBaseAddr
+*
+* DESCRIPTION
+* This function returns flash base address to caller.
+*
+* CALLS
+*
+* PARAMETERS
+*
+* RETURNS
+*
+*************************************************************************/
+kal_bool INT_RetrieveDSPTXRXBaseAddr(kal_uint32 *TX_Base, kal_uint32 *RX_Base,
+ kal_uint32 *CS,
+ kal_uint32 *TX_Size, kal_uint32 *RX_Size)
+{
+
+ kal_uint32 chipSelect;
+ kal_uint32 region_sz;
+
+#if defined(IC_BURNIN_TEST)
+
+ *TX_Base = 0;
+ *RX_Base = 0;
+ return KAL_TRUE;
+
+
+#else /* IC_BURNIN_TEST */
+
+ /* MT6280 goes here */
+ *TX_Base = (kal_uint32)&Image$$EXTSRAM_DSP_TX_ZI$$Base;
+ *RX_Base = (kal_uint32)&Image$$EXTSRAM_DSP_RX_ZI$$Base;
+
+ region_sz = 4 * 1024;
+ while (region_sz < ((kal_uint32)&Image$$EXTSRAM_DSP_TX_ZI$$Length
+ +(kal_uint32)&Image$$EXTSRAM_DSP_TX_ZI$$ZI$$Length))
+ {
+ region_sz = region_sz << 1;
+ }
+ *TX_Size = region_sz;
+
+ region_sz = 4 * 1024;
+ while (region_sz < ((kal_uint32)&Image$$EXTSRAM_DSP_RX_ZI$$Length
+ +(kal_uint32)&Image$$EXTSRAM_DSP_RX_ZI$$ZI$$Length))
+ {
+ region_sz = region_sz << 1;
+ }
+ *RX_Size = region_sz;
+
+ chipSelect = (*TX_Base&0xF8000000) >> 27;
+
+ *CS = chipSelect;
+
+ return KAL_TRUE;
+
+#endif /* IC_BURNIN_TEST */
+}
+
+#endif /* !__FUE__ */
+
+
+#if !defined(__FUE__)
+/*************************************************************************
+* FUNCTION
+* INT_SwitchStackToRun
+*
+* DESCRIPTION
+* Switch current stack pointer to new_stack and then run func(...).
+*
+* CALLS
+* INT_SwitchStackAndBranch
+*
+* PARAMETERS
+* stack_start the start address of the new stack (NOT a pointer of start address)
+* stack_size the size of the stack
+* func the pointer of function which want to run
+* argc the number of arguments of func
+* ... the arguments of func
+*
+* RETURNS
+* The reture value of func
+*
+*************************************************************************/
+kal_uint32 INT_SwitchStackToRun(void *stack_start, kal_uint32 stack_size, kal_func_ptr func, kal_uint32 argc, ...)
+{
+#if 1
+ /* we do not support INT_SwitchStackToRun() now */
+ ASSERT(0);
+ return 0;
+#else
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#ifdef __STACK_ALIGN_MPU__
+#if defined(__CR4__)
+/* under construction !*/
+#elif defined(__MTK_MMU_V2__)
+/* under construction !*/
+#else /* __MTK_MMU_V2__ */
+/* under construction !*/
+#endif /* else */
+#endif /* end of __STACK_ALIGN_MPU__ */
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#ifdef __STACK_ALIGN_MPU__
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#if defined(__RVCT__) || defined(__GNUC__) && !defined(__APCS_ADSABI)
+/* under construction !*/
+#else
+/* under construction !*/
+#endif
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+}
+#endif /* !__FUE__ */
+
+/*************************************************************************
+* FUNCTION
+* INT_QuerySystemRAMInfo
+*
+* DESCRIPTION
+* This function gets the start address and lenght of system RAM.
+*
+* CALLS
+*
+* PARAMETERS
+* addr - pointer to store start address of system RAM
+* len - pointer to sttore length of system RAM
+*
+* RETURNS
+* 0 for success; -1 for failure
+*
+*************************************************************************/
+kal_int32 INT_QuerySystemRAMInfo(kal_uint32 *addr, kal_uint32 *len)
+{
+
+ return 0;
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+}
+
+/*************************************************************************
+* FUNCTION
+* INT_QueryOnDemandROMInfo
+*
+* DESCRIPTION
+* This function gets the start address and lenght of NFB OnDemand ROM.
+*
+* CALLS
+*
+* PARAMETERS
+* addr - pointer to store start address of OnDemand ROM
+* len - pointer to sttore length of OnDemand ROM
+*
+* RETURNS
+* 0 for success; -1 for failure
+*
+*************************************************************************/
+kal_int32 INT_QueryOnDemandROMInfo(kal_uint32 *addr, kal_uint32 *len)
+{
+ return -1;
+}
+
+
+#if defined(__RTL_SIMULATION_FOR_60QBIT__)
+/*************************************************************************
+* FUNCTION
+* profile_INT_SwitchStackToRun_before
+*
+* DESCRIPTION
+* The function profile the critical path 1 of IRQ-lock code within the
+* function INT_SwitchStackToRun.
+* Notex: This function is only used for profiling the IRQ-lock code in
+* a new project's pre-silicon stage. It is not used on real target.
+*
+* PARAMETERS
+* none
+*
+* RETURNS
+* 0 for success; -1 for failure
+*
+*************************************************************************/
+kal_int32 profile_INT_SwitchStackToRun_before(void)
+{
+ void *stack_start;
+ kal_uint32 stack_size;
+ kal_uint32 irq;
+ kal_uint32 i, available = NO_AVAILABLE;
+ kal_taskid task_self_id;
+
+ /* set some data to trigger the longest path of the program */
+
+ stack_start = (void *)10;
+ stack_size = 5;
+ switch_stack_info_cnt_g = SWITCH_STACK_INFO_NUM - 1;
+ switch_stack_history_cur_g = SWITCH_STACK_HISTORY_NUM - 1;
+ task_self_id = kal_get_task_self_id();
+
+ for (i = 0; i < SWITCH_STACK_INFO_NUM; i++) {
+ switch_stack_info_g[i].stack_start = (void *)((kal_uint32)stack_start + 2 * stack_size);
+ switch_stack_info_g[i].stack_end = (void *)((kal_uint32)stack_start + stack_size);
+ }
+
+ /* extract the critical path of the IRQ-lock program in INT_SwitchStackToRun() */
+
+ EBM_INIT();
+
+ EBM_START();
+
+ irq = SaveAndSetIRQMask(); /* begin of critical section */
+
+ /* check the stack not overlap with previous stacks */
+ for (i = 0; i < switch_stack_info_cnt_g; i++)
+ {
+ if (switch_stack_info_g[i].stack_start)
+ {
+
+ if ((kal_uint32)stack_start < (kal_uint32)switch_stack_info_g[i].stack_end
+ && (kal_uint32)stack_start + stack_size > (kal_uint32)switch_stack_info_g[i].stack_start)
+ {
+ #define SWITCH_STACK_OVERLAP 0
+ EXT_ASSERT(SWITCH_STACK_OVERLAP,
+ (kal_uint32)stack_start,
+ (kal_uint32)switch_stack_info_g[i].stack_start,
+ (kal_uint32)switch_stack_info_g[i].stack_end);
+ }
+ }
+ else if (available == NO_AVAILABLE)
+ {
+ /* mark it an available slot */
+ available = i;
+ }
+ }
+
+ /* if no available slot, increase the count of slots */
+ if (available == NO_AVAILABLE)
+ {
+ if (switch_stack_info_cnt_g < SWITCH_STACK_INFO_NUM)
+ {
+ available = switch_stack_info_cnt_g;
+ switch_stack_info_cnt_g++;
+ }
+ else
+ {
+ #define SWITCH_STACK_NO_MORE_SLOT 0
+ EXT_ASSERT(SWITCH_STACK_NO_MORE_SLOT,
+ (kal_uint32)switch_stack_info_cnt_g, 0, 0);
+ }
+ }
+
+ /* fill the info of the stack */
+ switch_stack_info_g[available].stack_start = stack_start;
+ switch_stack_info_g[available].stack_end = (void *)( (kal_uint32) stack_start + stack_size);
+
+ switch_stack_history_g[switch_stack_history_cur_g].state = STACK_ALLOCATED;
+ switch_stack_history_g[switch_stack_history_cur_g].stack_start = stack_start;
+ switch_stack_history_g[switch_stack_history_cur_g].stack_end = (void *)( (kal_uint32) stack_start + stack_size);
+ switch_stack_history_g[switch_stack_history_cur_g].old_sp = (void *)INT_GetCurrentSP();
+ switch_stack_history_g[switch_stack_history_cur_g].task_id = task_self_id;
+
+ switch_stack_history_cur_g++;
+ if (switch_stack_history_cur_g == SWITCH_STACK_HISTORY_NUM)
+ switch_stack_history_cur_g = 0;
+
+ RestoreIRQMask(irq); /* end of critical section */
+
+ EBM_PAUSE();
+ EBM_GET_MCU_IBUS_LOG(&init_ibus_log1);
+ EBM_GET_MCU_DBUS_LOG(&init_dbus_log1);
+
+ EBM_STOP();
+
+ return 0;
+}
+
+/*************************************************************************
+* FUNCTION
+* profile_INT_SwitchStackToRun_after
+*
+* DESCRIPTION
+* The function profile the critical path 2 of IRQ-lock code within the
+* function INT_SwitchStackToRun.
+* Notex: This function is only used for profiling the IRQ-lock code in
+* a new project's pre-silicon stage. It is not used on real target.
+*
+* PARAMETERS
+* none
+*
+* RETURNS
+* 0 for success; -1 for failure
+*
+*************************************************************************/
+kal_int32 profile_INT_SwitchStackToRun_after(void)
+{
+ kal_uint32 irq;
+ kal_uint32 i, available;
+ void *stack_start;
+
+ /* set some data to trigger the longest path of the program */
+
+ available = 0;
+ switch_stack_info_cnt_g = SWITCH_STACK_INFO_NUM - 1;
+ switch_stack_history_cur_g = 0;
+ stack_start = (void *)10;
+
+ for (i = 0; i < SWITCH_STACK_INFO_NUM; i++) {
+ switch_stack_info_g[i].stack_start = (void *)0;
+ switch_stack_info_g[i].stack_end = (void *)0;
+ }
+
+ for (i = 1; i < SWITCH_STACK_HISTORY_NUM; i++) {
+ switch_stack_history_g[i].stack_start = (void *)0;
+ switch_stack_history_g[i].state = STACK_ALLOCATED;
+ }
+ switch_stack_history_g[0].stack_start = stack_start;
+ switch_stack_history_g[0].state = STACK_ALLOCATED;
+
+ /* extract the critical path of the IRQ-lock program in INT_SwitchStackToRun() */
+
+ EBM_INIT();
+
+ EBM_START();
+
+ irq = SaveAndSetIRQMask(); /* begin of critical section */
+
+ /* clear the stack info */
+ switch_stack_info_g[available].stack_start = 0;
+ while (switch_stack_info_cnt_g && !(switch_stack_info_g[switch_stack_info_cnt_g-1].stack_start))
+ switch_stack_info_cnt_g--;
+
+ i = switch_stack_history_cur_g;
+ do
+ {
+ if (i == 0)
+ i = SWITCH_STACK_HISTORY_NUM - 1;
+ else
+ i--;
+
+ if (switch_stack_history_g[i].stack_start == stack_start
+ && switch_stack_history_g[i].state == STACK_ALLOCATED)
+ {
+ switch_stack_history_g[i].state = STACK_FREED;
+ break;
+ }
+ } while (i != switch_stack_history_cur_g);
+
+ RestoreIRQMask(irq); /* end of critical section */
+
+ EBM_PAUSE();
+ EBM_GET_MCU_IBUS_LOG(&init_ibus_log2);
+ EBM_GET_MCU_DBUS_LOG(&init_dbus_log2);
+
+ EBM_STOP();
+
+ return 0;
+}
+#endif /* __RTL_SIMULATION_FOR_60QBIT__ */
+
+#endif /* __MTK_TARGET__ */
+
diff --git a/mcu/service/sys_svc/region/src/regioninit_c_gcc.c b/mcu/service/sys_svc/region/src/regioninit_c_gcc.c
new file mode 100644
index 0000000..34ce89a
--- /dev/null
+++ b/mcu/service/sys_svc/region/src/regioninit_c_gcc.c
@@ -0,0 +1,1143 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * regioninit_c_gcc.c
+ *
+ * Project:
+ * --------
+ *
+ *
+ * Description:
+ * ------------
+ * This Module defines the initialization of RW/ZI/RO data for each area.
+ *
+ * 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!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+
+/*******************************************************************************
+ * Include Statements
+ *******************************************************************************/
+#include <cache_internal_api.h> /* For L2 Cache Clean & Invalidate */
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+#include "custom_scatstruct.h" /* for getting address info of I/DSPRAM */
+#include "mips_mmu.h" /* for adjusting MMU while MCU RO init */
+#include "kal_internal_api.h"
+
+#if !defined(__TCM_ONLY_LOAD__)
+#include "cache_sw.h" /* for lock_l2cache */
+#endif
+
+
+/*******************************************************************************
+ * Defination
+ *******************************************************************************/
+
+#define BANK_MASK (0xF0000000)
+#define PHY_BANK (0x00000000)
+#if defined(__TCM_ONLY_LOAD__)
+#define RAMAP_TO_PHY_BANK(addr) (addr)
+#else
+#define RAMAP_TO_PHY_BANK(addr) (((kal_uint32)addr & ~(BANK_MASK)) | PHY_BANK)
+#endif
+
+/* remap load view address to bank 0 since we could only read data from bank A in legacy mode */
+
+/*
+ * (1) common part
+ */
+#define macro_C_RegionRWInit(areaname) \
+ do{ \
+ extern kal_uint32 Load$$##areaname##$$Base; \
+ extern kal_uint32 Image$$##areaname##$$Base; \
+ extern kal_uint32 Image$$##areaname##$$Length; \
+ void *LV_base = (void *) RAMAP_TO_PHY_BANK(&Load$$##areaname##$$Base); \
+ void *EV_base = (void *) &Image$$##areaname##$$Base; \
+ volatile kal_uint32 EV_length = (kal_uint32) &Image$$##areaname##$$Length; \
+ if (0!=EV_length) kal_mem_cpy_init(EV_base, LV_base, EV_length); \
+ }while(0);
+
+#define macro_C_RegionZIInit(areaname) \
+ do{ \
+ extern kal_uint32 Image$$##areaname##$$ZI$$Base; \
+ extern kal_uint32 Image$$##areaname##$$ZI$$Length; \
+ void * ZI_base = (void *) &Image$$##areaname##$$ZI$$Base; \
+ volatile kal_uint32 ZI_length = (kal_uint32) &Image$$##areaname##$$ZI$$Length; \
+ if (0!=ZI_length) kal_mem_set_init(ZI_base, 0, ZI_length); \
+ }while(0);
+
+#define macro_C_RegionInit(areaname) \
+ macro_C_RegionRWInit(areaname) \
+ macro_C_RegionZIInit(areaname)
+
+
+/*
+ * (2) Usage: before common region init since memcpy and memset are not ready, and dest is NC EMI
+ */
+#define macro_C_RegionRWInitByEMIMEMCPY_NC(areaname) \
+ do{ \
+ extern kal_uint32 Load$$##areaname##$$Base; \
+ extern kal_uint32 Image$$##areaname##$$Base; \
+ extern kal_uint32 Image$$##areaname##$$Length; \
+ void *LV_base = (void *) RAMAP_TO_PHY_BANK(&Load$$##areaname##$$Base); \
+ void *EV_base = (void *) RAMAP_TO_PHY_BANK(&Image$$##areaname##$$Base); \
+ volatile kal_uint32 EV_length = (kal_uint32) &Image$$##areaname##$$Length; \
+ if (0!=EV_length) _emi_memcpy(EV_base, LV_base, EV_length); \
+ }while(0);
+
+#define macro_C_RegionZIInitByEMIMEMSET_NC(areaname) \
+ do{ \
+ extern kal_uint32 Image$$##areaname##$$ZI$$Base; \
+ extern kal_uint32 Image$$##areaname##$$ZI$$Length; \
+ void *ZI_base = (void *) RAMAP_TO_PHY_BANK(&Image$$##areaname##$$ZI$$Base); \
+ volatile kal_uint32 ZI_length = (kal_uint32) &Image$$##areaname##$$ZI$$Length; \
+ if (0!=ZI_length) _emi_memset(ZI_base, 0, ZI_length); \
+ }while(0);
+
+
+#define macro_C_RegionInitByEMI_NC(areaname) \
+ macro_C_RegionRWInitByEMIMEMCPY_NC(areaname) \
+ macro_C_RegionZIInitByEMIMEMSET_NC(areaname)
+
+/*
+ * (3) Per-core section, memcpy and memset are not ready
+ */
+#define macro_C_RegionPerCoreRWInit(areaname) \
+ do{ \
+ extern kal_uint32 Load$$##areaname##$$Base; \
+ extern kal_uint32 areaname##$$Base; \
+ extern kal_uint32 areaname##$$Length; \
+ void *LV_base = (void *) RAMAP_TO_PHY_BANK(&Load$$##areaname##$$Base); \
+ void *EV_base = (void *) &areaname##$$Base; \
+ volatile kal_uint32 EV_length = (kal_uint32) &areaname##$$Length; \
+ if (0!=EV_length) _emi_memcpy(EV_base, LV_base, EV_length); \
+ }while(0);
+
+#define macro_C_RegionPerCoreZIInit(areaname) \
+ do{ \
+ extern kal_uint32 areaname##$$ZI$$Base; \
+ extern kal_uint32 areaname##$$ZI$$Length; \
+ void * ZI_base = (void *) &areaname##$$ZI$$Base; \
+ volatile kal_uint32 ZI_length = (kal_uint32) &areaname##$$ZI$$Length; \
+ if (0!=ZI_length) _emi_memset(ZI_base, 0, ZI_length); \
+ }while(0);
+
+
+/*
+ * WATCHOUT the sequence of below MACROs
+ */
+
+/* requirement: only RW is need for palladium, undef all ZI init */
+#if defined(__PALLADIUM__)
+/* (1) */
+#undef macro_C_RegionZIInit
+/* (2) */
+#undef macro_C_RegionZIInitByEMIMEMSET_NC
+/* (3) */
+#undef macro_C_RegionPerCoreZIInit
+
+
+/* (1) */
+#define macro_C_RegionZIInit(areaname)
+/* (2) */
+#define macro_C_RegionZIInitByEMIMEMSET_NC(areaname)
+/* (3) */
+#define macro_C_RegionPerCoreZIInit(areaname)
+#endif // __PALLADIUM__
+
+
+/* requirement: undef all */
+#if defined(__ESL_ENABLE__) || defined(__ESL_SPEEDUP__)
+/* (1) */
+#undef macro_C_RegionInit
+#undef macro_C_RegionRWInit
+#undef macro_C_RegionZIInit
+/* (2) */
+#undef macro_C_RegionInitByEMI_NC
+#undef macro_C_RegionRWInitByEMIMEMCPY_NC
+#undef macro_C_RegionZIInitByEMIMEMSET_NC
+/* (3) */
+#undef macro_C_RegionPerCoreRWInit
+#undef macro_C_RegionPerCoreZIInit
+
+/* (1) */
+#define macro_C_RegionInit(areaname)
+#define macro_C_RegionRWInit(areaname)
+#define macro_C_RegionZIInit(areaname)
+/* (2) */
+#define macro_C_RegionInitByEMI_NC(areaname)
+#define macro_C_RegionRWInitByEMIMEMCPY_NC(areaname)
+#define macro_C_RegionZIInitByEMIMEMSET_NC(areaname)
+/* (3) */
+#define macro_C_RegionPerCoreRWInit(areaname)
+#define macro_C_RegionPerCoreZIInit(areaname)
+#endif // end of defined(__ESL_ENABLE__) || defined(__ESL_SPEEDUP__)
+
+
+/* requirement: ? */
+#if defined(GEN93_COSIM)
+#undef macro_C_RegionZIInit
+
+#define macro_C_RegionZIInit(areaname)
+#endif // __PALLADIUM__
+
+
+/* requirement: for TCM only load, load view = execution view, undef all RW init */
+/*#if defined(__TCM_ONLY_LOAD__) */
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif // __TCM_ONLY_LOAD__
+
+
+#define LoadBase(ID, spram_index) Load$$##ID##SPRAM##spram_index##$$Base
+#define ImageBase(ID, spram_index) Image$$##ID##SPRAM##spram_index##$$Base
+#define ImageLimit(ID, spram_index) Image$$##ID##SPRAM##spram_index##$$Limit
+#define ImageLength(ID, spram_index) Image$$##ID##SPRAM##spram_index##$$Length
+#define ImageZIBase(ID, spram_index) Image$$##ID##SPRAM##spram_index##$$ZI$$Base
+#define ImageZILimit(ID, spram_index) Image$$##ID##SPRAM##spram_index##$$ZI$$Limit
+#define ImageZILength(ID, spram_index) Image$$##ID##SPRAM##spram_index##$$ZI$$Length
+
+
+#define SPRAM_LINKER_SYMBOL_DEFINE(spram_index) \
+ extern kal_uint32 LoadBase(I, spram_index); \
+ extern kal_uint32 ImageBase(I, spram_index); \
+ extern kal_uint32 ImageLimit(I, spram_index); \
+ extern kal_uint32 ImageLength(I, spram_index); \
+ extern kal_uint32 LoadBase(D, spram_index); \
+ extern kal_uint32 ImageBase(D, spram_index); \
+ extern kal_uint32 ImageLimit(D, spram_index); \
+ extern kal_uint32 ImageLength(D, spram_index); \
+ extern kal_uint32 ImageZIBase(D, spram_index); \
+ extern kal_uint32 ImageZILimit(D, spram_index); \
+ extern kal_uint32 ImageZILength(D, spram_index);
+
+#if (defined(__MD97__) || defined(__MD97P__)) && !defined(MT6297_IA)
+#define IS_VPE0(cpu_id) ((cpu_id % 3) == 0)
+#else
+#define IS_VPE0(cpu_id) ((cpu_id & 1) == 0)
+#endif
+/*******************************************************************************
+ * Declarations of Imported Functions
+ *******************************************************************************/
+SPRAM_LINKER_SYMBOL_DEFINE(0)
+SPRAM_LINKER_SYMBOL_DEFINE(1)
+SPRAM_LINKER_SYMBOL_DEFINE(2)
+SPRAM_LINKER_SYMBOL_DEFINE(3)
+
+DECLARE_MIPS32 extern void INT_InitGPRegister_C(kal_uint32 core);
+DECLARE_MIPS32 extern void INT_InitSPRAMRegions_C(kal_uint32 core);
+extern void INT_InitPerCoreRegion_C(kal_uint32 core);
+extern void INT_InitL2cacheLockRegion_C(void);
+
+extern kal_int32 custom_mk_ram_info();
+extern void system_set_ispram_protection(kal_uint32 mpu_index,kal_uint32 addr, kal_bool value);
+/*******************************************************************************
+ * variable
+ *******************************************************************************/
+
+
+/*******************************************************************************
+ * static Functions
+ *******************************************************************************/
+#if defined(__DYNAMIC_CACHE_LOCK_CENTRAL_CONTROL_SUPPORT__) || !(defined(__MD95__) || defined(__MD97__) || defined(__MD97P__))
+/* create this func since using memmove will redirect to memcpy and cause exception during init */
+void *_emi_memcpy(void *dest, const void *src, kal_uint32 n)
+{
+ kal_char *dp = dest;
+ const kal_char *sp = src;
+ while (n--)
+ *dp++ = *sp++;
+ return dest;
+}
+
+/* create this func since no backup solution for memset */
+void * _emi_memset(void *s, kal_int32 c, kal_uint32 n)
+{
+ kal_uint8 *p=s;
+ while(n--)
+ *p++ = (kal_uint8)c;
+ return s;
+}
+#endif
+/*******************************************************************************
+ * Functions
+ *******************************************************************************/
+/* to be called before enabling cache */
+void INTL2SRAMRegions_C()
+{
+
+}
+
+ /*******************************************************************************
+ * FUNCTION
+ * INT_InitRegions_C
+ * DESCRIPTION
+ * region init by C code
+ * PARAMETERS
+ * N/A
+ * RETURNS
+ * N/A
+ * NOTE
+ * make sure to init current context stack before calling this function
+ * e.g. system stack in CACHED_EXTSRAM
+ ******************************************************************************/
+void INT_InitRegions_C()
+{
+ kal_uint32 core = kal_get_current_core_id();
+ kal_uint32 vpe = kal_get_current_vpe_id();
+
+ /* Only initialize SPRAM and pre-core section @ each VPE 0 */
+ if (!IS_VPE0(vpe))
+ return;
+
+ /* GP register init */
+ INT_InitGPRegister_C(core);
+
+#if !defined(__TCM_ONLY_LOAD__)
+ /* SPRAM HW init and SPRAM region init */
+#ifndef __MD95__
+ INT_InitSPRAMRegions_C(core);
+#endif
+ /* per-core section init */
+ INT_InitPerCoreRegion_C(core);
+#endif
+
+
+ /* only core 0 execute common region init */
+ if (0 != core) {return;}
+
+ /* init L2$ which included memcpy & memset */
+ INT_InitL2cacheLockRegion_C();
+
+#if !defined (__GEN97_ESL_SPEEDUP__)
+ /* EMI */
+ /* macro_C_RegionInit(CACHED_EXTSRAM_L1DSPBIN_ZI); */ /* do not init this region, there is DSP bin file */
+ /* macro_C_RegionInit(CACHED_EXTSRAM); */
+ macro_C_RegionInit(CACHED_EXTSRAM_NVRAM_LTABLE);
+ macro_C_RegionInit(DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_CACHEABLE_RW);
+ macro_C_RegionRWInit(DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_RW);
+ /*macro_C_RegionInit(DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_ZI);*/
+ do {
+ extern kal_uint32 Image$$DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_RW$$ZI$$Base;
+ extern kal_uint32 Image$$DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_RW$$ZI$$Length;
+ extern kal_uint32 MCURW_HWRO_DNC_NOINIT$$Length;
+ void * ZI_base = (void *) ((kal_uint32)&Image$$DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_RW$$ZI$$Base + (kal_uint32)&MCURW_HWRO_DNC_NOINIT$$Length);
+ volatile kal_uint32 ZI_length = (kal_uint32) &Image$$DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_RW$$ZI$$Length - (kal_uint32) &MCURW_HWRO_DNC_NOINIT$$Length;
+ if(0!=ZI_length) kal_mem_set_init(ZI_base, 0, ZI_length);
+ }while(0);
+ macro_C_RegionInit(EXTSRAM);
+#if defined(__MD97__) || defined(__MD97P__) || defined(__MD95__)
+ macro_C_RegionInit(CACHED_EXTSRAM_WT);
+#endif
+#if 0 /* per-core section init, done by each vpe 0 of each core */
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ macro_C_RegionInit(DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_MCURW_HWRW);
+ macro_C_RegionInit(DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_CACHEABLE_MCURW_HWRW);
+ macro_C_RegionInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW); // ?!
+#if defined(__MD97__) || defined(__MD97P__)
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_00);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_01);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_02);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_03);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_04);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_05);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_06);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_07);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_08);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_09);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_10);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_11);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_12);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_13);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_14);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU2_MCURW_HWRW_ZI_15);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_00);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_01);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_02);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_03);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_04);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_05);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_06);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_07);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_08);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_09);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_10);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_11);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_12);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_13);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_14);
+ macro_C_RegionZIInit(CACHED_EXTSRAM_IOCU3_MCURW_HWRW_ZI_15);
+ macro_C_RegionInit(CACHED_EXTSRAM_IOCU3_READ_WRITE_ALLOC_MCURW_HWRW); // ?!
+ macro_C_RegionInit(CACHED_EXTSRAM_IOCU2_ULTRA_DATA);
+ macro_C_RegionInit(CACHED_EXTSRAM_ULTRA_DATA);
+ macro_C_RegionInit(CACHED_EXTSRAM_IOCU3_ULTRA_DATA);
+ macro_C_RegionRWInit(L2SRAM_L2C_CODE);
+ macro_C_RegionInit(L2SRAM_L2C_DATA);
+#else
+ macro_C_RegionInit(CACHED_EXTSRAM_IOCU3_READ_ALLOC_MCURW_HWRW); // ?!
+#endif
+ macro_C_RegionInit(EXTSRAM_MCURW_HWRW);
+ macro_C_RegionInit(CACHED_EXTSRAM_MCURW_HWRW);
+ macro_C_RegionInit(EXTSRAM_DSP_TX_ZI);
+ macro_C_RegionInit(EXTSRAM_DSP_RX_ZI);
+
+ macro_C_RegionRWInit(CACHED_EXTSRAM);
+
+#endif /* !defined (__GEN97_ESL_SPEEDUP__) */
+
+ /* MCU RO, HWRW: no need to init by MCU */
+
+#if !defined(__PALLADIUM__) && !defined(__ESL_ENABLE__) && !defined(GEN93_COSIM) && !defined(__ESL_SPEEDUP__)
+ /* only RW is need for palladium */
+ /* should be init before calling this function since current context stack is in it */
+ /* stack place in ZI */
+ do{
+ extern kal_uint32 STACK_INIT$$ZI$$Limit;
+ extern kal_uint32 Image$$CACHED_EXTSRAM$$ZI$$Limit;
+ void * ZI_base = (void *) (kal_uint32)&STACK_INIT$$ZI$$Limit;
+ kal_uint32 ZI_length = (kal_uint32)&Image$$CACHED_EXTSRAM$$ZI$$Limit - (kal_uint32)&STACK_INIT$$ZI$$Limit;
+ if (0!=ZI_length) kal_mem_set_init(ZI_base, 0, ZI_length);
+ }while(0);
+#endif
+#if (defined(MT6885) || defined(MT6873)) && !defined(MT6893)
+ /* Init CSIF sections */
+ do{
+ extern kal_uint32 Image$$MCURW_HWRW_DNC_SS_EXT_CSIF$$Base;
+ extern kal_uint32 Image$$MCURW_HWRW_DNC_NL1_EXT_CSIF$$Limit;
+ void * ZI_base = (void *) &Image$$MCURW_HWRW_DNC_SS_EXT_CSIF$$Base;
+ kal_uint32 ZI_length = (kal_uint32) &Image$$MCURW_HWRW_DNC_NL1_EXT_CSIF$$Limit - (kal_uint32)&Image$$MCURW_HWRW_DNC_SS_EXT_CSIF$$Base;
+ if (0!=ZI_length) kal_mem_set_init(ZI_base, 0, ZI_length);
+ }while(0);
+#endif
+ /* phase out */
+#if 0
+/* under construction !*/
+#endif
+
+ /* Initialize ECTSRAM info tables. */
+ /* Should be done on Core0 VPE0 AFTER region init is comleted. */
+ custom_mk_ram_info();
+}
+
+/* Only initialize gp register @ each VPE 0 */
+DECLARE_MIPS32
+void INT_InitGPRegister_C(kal_uint32 core)
+{
+ switch (core)
+ {
+ case 0:
+ __asm__ __volatile__
+ (
+ "la $gp, _gp_0"
+ );
+ break;
+ case 1:
+ __asm__ __volatile__
+ (
+ "la $gp, _gp_1"
+ );
+ break;
+ case 2:
+ case 3:
+ /* do nothing */
+ break;
+ default:
+ ASSERT(0);
+ }
+}
+
+
+/* in single VPE or SMP architecture, bypass region init and SPRAM enable in VPE1. */
+/* Only initialize SPRAM @ each VPE 0 */
+#ifndef __MD95__
+DECLARE_MIPS32
+void INT_InitSPRAMRegions_C(kal_uint32 core)
+{
+#if defined(__MD97__) || defined(__MD97P__)
+#if 0 /*USPRAM temporaly disabled for GEN97*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+#else
+ kal_uint32 ispram_base, dspram_base;
+ kal_uint32 src_addr, dst_addr, dst_end_addr, len, end;
+ kal_uint32 i, back_err_ctl;
+ kal_status ret;
+
+ ret = custom_get_ISPRAM_Base(core, &ispram_base);
+ EXT_ASSERT(ret==KAL_SUCCESS, ret, core, ispram_base);
+
+ ret = custom_get_DSPRAM_Base(core, &dspram_base);
+ EXT_ASSERT(ret==KAL_SUCCESS, ret, core, dspram_base);
+
+ /* init SPRAM */
+ /* $28: C0_TAGLO, $26: C0_ERRCTL, $28, 2: C0_DTAGLO */
+ __asm__ __volatile__
+ (
+ "li $t0, 0xffffffff\r\n"
+ "move $t1, %0\r\n"
+ "ins $t1, $t0, 7, 1\r\n"
+ "mtc0 $t1, $28\r\n"
+ "mfc0 $t1, $26\r\n"
+ "move $t2, $t1\r\n"
+ "ins $t2, $t0, 28, 1\r\n"
+ "mtc0 $t2, $26\r\n"
+ "ehb\r\n"
+ "cache 0x8, 0($zero)\r\n"
+ "move $t2, %1\r\n"
+ "ins $t2, $t0, 7, 1\r\n"
+ "mtc0 $t2, $28, 2\r\n"
+ "ehb\r\n"
+ "cache 0x9, 0($zero)\r\n"
+ "mtc0 $t1, $26\r\n"
+ "ehb\r\n"
+ :
+ : "r" (ispram_base), "r" (dspram_base)
+ : "$t0", "$t1", "$t2"
+ );
+
+ /* backup C0_ERRCTL and set WST = 0, ITC = 0, SPR = 1 in ErrCtl */
+ /* $k0: C0_ERRCTL */
+ /* C0_ERRCTL[26]: ITC, C0_ERRCTL[28]: SPR, C0_ERRCTL[29]: WST */
+ __asm__ __volatile__
+ (
+ "mfc0 $t0, $26\r\n"
+ "move %0, $t0\r\n"
+ "lui $t1, 0x2400\r\n"
+ "not $t1, $t1\r\n"
+ "and $t0, $t0, $t1\r\n"
+ "lui $t1, 0x1000\r\n"
+ "or $t0, $t0, $t1\r\n"
+ "mtc0 $t0, $26\r\n"
+ "ehb\r\n"
+ : "=r" (back_err_ctl)
+ :
+ : "$t0", "$t1"
+ );
+
+#if !defined(__ESL_ENABLE__)&&!defined(__ESL_SPEEDUP__)
+ /* Bypass SPRAM region initialization since ESL simulator will loading SPRAM
+ * section via VMA
+ */
+
+#if !defined(GEN93_COSIM)
+ // TODO: remove it and do the same thing in DSM_Init()
+ { /* init all SPRAM to DSM_UNINIT_STAMP(0xDEDEDEDE) for init dynamic section */
+ /* this is temp solution, to avoid MSBB rule, we just use 0xDEDEDEDE directly */
+ /* ISPRAM */
+ dst_addr = ispram_base;
+ src_addr = 0xDEDEDEDE;
+
+ ret = custom_get_ISPRAM_End(core, &end);
+ EXT_ASSERT(ret==KAL_SUCCESS, ret, core, end);
+ len = end - ispram_base;
+
+ for (i = 0; i < len; i += 8)
+ {
+ /* $28,1: C0_DATALO */
+ /* $29,1: C0_DATAHI */
+ __asm__ __volatile__
+ (
+ "lw $t0, 0(%0)\r\n"
+ "lw $t1, 0(%0)\r\n"
+ "mtc0 $t0, $28,1\r\n"
+ "mtc0 $t1, $29,1\r\n"
+ "ehb\r\n"
+ "cache 0xc, 0(%1)\r\n"
+ :
+ : "r" (&src_addr), "r" (dst_addr)
+ : "$t0", "$t1"
+ );
+ dst_addr += 8;
+ }
+
+ /* DSPRAM */
+ dst_addr = dspram_base;
+
+ ret = custom_get_DSPRAM_End(core, &end);
+ EXT_ASSERT(ret==KAL_SUCCESS, ret, core, end);
+ len = end - dspram_base;
+
+ for (i = 0; i < len; i += 8)
+ {
+ *(kal_uint32 *)(dst_addr + i + 0) = 0xDEDEDEDE;
+ *(kal_uint32 *)(dst_addr + i + 4) = 0xDEDEDEDE;
+ }
+ }
+#endif
+
+ /* ISPRAM, Make len 8 byte aligned */
+ ret = custom_get_ISPRAM_Load_Base(core, &src_addr);
+ EXT_ASSERT(ret==KAL_SUCCESS, ret, core, src_addr);
+ src_addr = RAMAP_TO_PHY_BANK(src_addr);
+
+ ret = custom_get_ISPRAM_CODE_Base(core, &dst_addr);
+ EXT_ASSERT(ret==KAL_SUCCESS, ret, core, dst_addr);
+
+ ret = custom_get_ISPRAM_CODE_End(core, &dst_end_addr);
+ EXT_ASSERT(ret==KAL_SUCCESS, ret, core, dst_end_addr);
+ len = (((dst_end_addr - dst_addr) + (8-1)) >> 3) << 3;
+
+ for (i = 0; i < len; i += 8)
+ {
+ /* $28,1: C0_DATALO */
+ /* $29,1: C0_DATAHI */
+ __asm__ __volatile__
+ (
+ "lw $t0, 0(%0)\r\n"
+ "lw $t1, 4(%0)\r\n"
+ "mtc0 $t0, $28,1\r\n"
+ "mtc0 $t1, $29,1\r\n"
+ "ehb\r\n"
+ "cache 0xc, 0(%1)\r\n"
+ :
+ : "r" (src_addr), "r" (dst_addr)
+ : "$t0", "$t1"
+ );
+
+ src_addr += 8;
+ dst_addr += 8;
+ }
+
+
+
+ /* DSPRAM, Make len 8 byte aligned */
+ /* RW */
+ ret = custom_get_DSPRAM_Load_Base(core, &src_addr);
+ EXT_ASSERT(ret==KAL_SUCCESS, ret, core, src_addr);
+ src_addr = RAMAP_TO_PHY_BANK(src_addr);
+
+ ret = custom_get_DSPRAM_DATA_Base(core, &dst_addr);
+ EXT_ASSERT(ret==KAL_SUCCESS, ret, core, dst_addr);
+
+ ret = custom_get_DSPRAM_DATA_End(core, &dst_end_addr);
+ EXT_ASSERT(ret==KAL_SUCCESS, ret, core, dst_end_addr);
+ len = (((dst_end_addr - dst_addr) + (8-1)) >> 3 ) << 3;
+
+ for (i = 0; i < len; i += 8)
+ {
+ *((kal_uint32 *)(dst_addr + i + 0)) = *((kal_uint32 *)(src_addr + i + 0));
+ *((kal_uint32 *)(dst_addr + i + 4)) = *((kal_uint32 *)(src_addr + i + 4));
+ }
+
+
+#if !defined(GEN93_COSIM)
+ /* ZI */
+ ret = custom_get_DSPRAM_DATA_ZI_Base(core, &dst_addr);
+ EXT_ASSERT(ret==KAL_SUCCESS, ret, core, dst_addr);
+
+ ret = custom_get_DSPRAM_DATA_ZI_End(core, &dst_end_addr);
+ EXT_ASSERT(ret==KAL_SUCCESS, ret, core, dst_end_addr);
+ len = (((dst_end_addr - dst_addr) + (8-1)) >> 3 ) << 3;
+
+ for (i = 0; i < len; i += 8)
+ {
+ *(kal_uint32 *)(dst_addr + i + 0) = 0;
+ *(kal_uint32 *)(dst_addr + i + 4) = 0;
+ }
+#endif
+
+
+#endif /* end if !defined(__ESL_ENABLE__)&& !defined(__ESL_SPEEDUP__) */
+
+ /* only restore ErrCtl @ each VPE 0 */
+ //if ((vpe & 1) == 0)
+ {
+ /* recover ErrCtl */
+ __asm__ __volatile__
+ (
+ "move $t0, %0\r\n"
+ "mtc0 $t0, $26\r\n"
+ "ehb\r\n"
+ :
+ : "r" (back_err_ctl)
+ : "$t0"
+ );
+ }
+
+#endif /*__MD97__ || __MD97P__*/
+}
+#endif /*__MD95__*/
+/* per-core section init */
+void INT_InitPerCoreRegion_C(kal_uint32 core)
+{
+ #define macro_C_RegionInitRerCore(ID) \
+ do{ \
+ macro_C_RegionPerCoreRWInit(CACHED_EXTSRAM_CORE##ID); \
+ macro_C_RegionPerCoreZIInit(CACHED_EXTSRAM_CORE##ID); \
+ macro_C_RegionPerCoreRWInit(DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_CACHEABLE_CORE##ID##_RW); \
+ macro_C_RegionPerCoreZIInit(DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_CACHEABLE_CORE##ID##_ZI); \
+ macro_C_RegionPerCoreRWInit(DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_CORE##ID##_RW); \
+ macro_C_RegionPerCoreZIInit(DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_CORE##ID##_ZI); \
+ macro_C_RegionPerCoreRWInit(EXTSRAM_CORE##ID); \
+ macro_C_RegionPerCoreZIInit(EXTSRAM_CORE##ID); \
+ } while(0);
+#if !(defined(__MD97__) || defined(__MD97P__))
+ if (0==core){ macro_C_RegionInitRerCore(0); }
+ if (1==core){ macro_C_RegionInitRerCore(1); }
+#endif
+ /* no core 2 & core 3 */
+}
+
+
+void INT_InitL2cacheLockRegion_C(void)
+{
+#if !defined(__TCM_ONLY_LOAD__)
+#if !(defined(__MD95__) || defined(__MD97__) || defined(__MD97P__))
+ macro_C_RegionInitByEMI_NC(CACHED_EXTSRAM_L2CACHE_LOCK_DATA);
+#endif
+#if defined(__DYNAMIC_CACHE_LOCK_CENTRAL_CONTROL_SUPPORT__)
+ // Move to ROM since it is code only section
+ //macro_C_RegionInitByEMI_NC(DYNAMIC_SECTION_L2CACHE_LOCK_0);
+ /*Move connection & idle mode sections to ROM on Gen97, since it is code only support now*/
+#if !(defined(__MD97__) || defined(__MD97P__))
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_L_IDLE);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_W_COMMON);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_W_PAGING);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_T_IDLE);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_C_RTT_IDLE);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_C_DO_IDLE);
+#if 0/*only for Gen97, if NR section in RAM*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_L_CONN0);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_L_CONN1);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_L_CONN2);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_W_CONN0);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_W_CONN1);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_W_CONN2);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_T_CONN0);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_T_CONN1);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_T_CONN2);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_C_RTT_TALKING);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_C_DO_DATALINK);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_MML1_IDLE);
+ macro_C_RegionRWInitByEMIMEMCPY_NC(DYNAMIC_SECTION_L2CACHE_LOCK_SS_IDLE);
+#endif
+#endif
+#if !(defined(__MD95__) || defined(__MD97__) || defined(__MD97P__))
+ {
+ extern kal_uint32 L2CACHE_LOCK$$Base;
+ extern kal_uint32 L2CACHE_LOCK$$Limit;
+
+ kal_uint32 base = (kal_uint32) &L2CACHE_LOCK$$Base;
+ kal_uint32 end = (kal_uint32) &L2CACHE_LOCK$$Limit;
+ lock_l2cache(base, end - base);
+ }
+#endif
+#endif
+
+}
diff --git a/mcu/service/sys_svc/region/src/regioninit_gcc.S b/mcu/service/sys_svc/region/src/regioninit_gcc.S
new file mode 100644
index 0000000..5e8a654
--- /dev/null
+++ b/mcu/service/sys_svc/region/src/regioninit_gcc.S
@@ -0,0 +1,1332 @@
+#/*****************************************************************************
+#* 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).
+#* testyg
+#*****************************************************************************/
+#
+#/*****************************************************************************
+# *
+# * Filename:
+# * ---------
+# * regioninit.s
+# *
+# * Project:
+# * --------
+# * Maui_Software
+# *
+# * Description:
+# * ------------
+# * This Module defines the initialization of RW/ZI/RO data for each area..
+# *
+# * Author:
+# * -------
+# * Rex Luo (mtk00389)
+# * Anthony Chin (mtk00276)
+# * Shalyn Chua (mtk00576)
+# *
+# *============================================================================
+# * HISTORY
+# * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+# *------------------------------------------------------------------------------
+# * $Log$
+# *
+# * 03 13 2018 tero.jarkko
+# * [MOLY00313013] [Gen97][SystemService][Auto-Gen]Fixed MT6297 build error
+# *
+# * .
+# *
+# * 03 01 2017 carl.kao
+# * [MOLY00216659] MIPS16 porting merge
+# * replace __MIPS16 to __mips16
+# *
+# * 12 07 2016 carl.kao
+# * [MOLY00216659] MIPS16 porting merge
+# * .
+# *
+# * 12 07 2016 carl.kao
+# * [MOLY00216659] MIPS16 porting merge
+# * .
+# *
+# * 05 04 2016 carl.kao
+# * [MOLY00177702] [LR12] [SYSTEM SERVICE] [SYS_SVC] Fix build warning in sys_svc lib
+# * .
+# *
+# * 11 17 2015 carl.kao
+# * [MOLY00148842] [LR12][SystemService][Auto-Gen] 92 lds, for Full region ready, Code in Right Location
+# * Apply SPRAM init
+# *
+# * 11 11 2015 carl.kao
+# * [MOLY00148842] [LR12][SystemService][Auto-Gen] 92 lds, for Full region ready, Code in Right Location
+# * New image layout for "Full region ready, Code in Right Location"
+# *
+# * 09 16 2015 carl.kao
+# * [MOLY00136979] [92][SYSTEM SERVICE][KAL][IPC] Fix KAL build fail
+# * [Elbrus] MIPS header files
+# *
+# * 08 25 2015 carl.kao
+# * [MOLY00136979] [92][SYSTEM SERVICE][KAL][IPC] Fix KAL build fail
+# * merge regioninit_SPRAM from 91+dev
+# *
+# * 08 07 2015 hc.yang
+# * [MOLY00136062] [System Service] Merge Nucleus/KAL changes from 91 Plus DEV to UMOLY Trunk
+# * check in common folder modification
+# *
+# * 07 24 2015 carl.kao
+# * [MOLY00127689] [UMOLY] MD check header v5 modification
+# * .
+# *
+# * 07 06 2015 carl.kao
+# * [MOLY00126195] [MT6755] [SystemService][Auto-Gen] TCM only load
+# * .
+# *
+# * 04 22 2015 carl.kao
+# * [MOLY00106652] [TK6291] [SystemService][Auto-Gen] add a dynamic switchable default cached MCU-RW, HW-RW section
+# * disable EMI MPU for MCU-RO, HW-RW
+# *
+# * 04 20 2015 carl.kao
+# * [MOLY00108312] [TK6291E1][Sanity][Blocking] Assert # ccci_apos.c #1117
+# * .
+# *
+# * 04 20 2015 carl.kao
+# * [MOLY00108312] [TK6291E1][Sanity][Blocking] Assert # ccci_apos.c #1117
+# * .
+# *
+# * 04 16 2015 carl.kao
+# * [MOLY00106652] [TK6291] [SystemService][Auto-Gen] add a dynamic switchable default cached MCU-RW, HW-RW section
+# * add 4 sections for EMI RMPU
+# * 1) (MCU RO, MDHW RW) DNC
+# * 2) (MCU RO, MDHW RW) NC
+# * 3) (MCU RW, MDHW RW) DNC
+# * 4) (MCU RW, MDHW RW) NC
+# *
+# * 03 19 2015 carl.kao
+# * [MOLY00099012] [TK6291E1][2G][PS][1stCall] assert at m12111.c 775
+# * .
+# *
+# * 02 09 2015 carl.kao
+# * [MOLY00095481] [SYSTEM SERVICE] [RegionInit] Disable RO, RW copy in region init if it is TCM only load
+# * .
+# *
+# * 01 19 2015 carl.kao
+# * [MOLY00092735] [UMOLY Trunk/Dev call for check in] add assembly symbol size for MPPT
+# * .
+# *
+# * 01 08 2015 carl.kao
+# * [MOLY00091599] [TK6291] CoSim Envrionment refinement
+# * .
+# *
+# * 12 09 2014 carl.kao
+# * [MOLY00087057] [TK6291] system initialization dual core sync flow implementation.
+# * .
+# *
+# * 11 27 2014 qmei.yang
+# * [MOLY00084752] [SystemService][DebuggingSuite][Internal Refinement] Merge sst to UMOLY trunk
+# * .
+# *
+# * 11 19 2014 carl.kao
+# * [MOLY00081733] [TK6291] fix init flow and make stack from rw to zi
+# * .
+# *
+# * 10 27 2014 carl.kao
+# * [MOLY00082288] [TK6291] Porting PCore ungate L1Core function
+# * .
+# *
+# * 08 19 2014 carl.kao
+# * [MOLY00075803] [SystemService][Auto-Gen][Request For Design Change] copy l1core reset vector from load view rather than l1core ROM base
+# * .
+# *
+# * 06 27 2014 carl.kao
+# * [MOLY00068605] [SystemService][Region init] Add INT_InitL1coreBootVector for pcore to init boot vector of l1core
+# * use linker symbol rather than hardcode
+# *
+# * 06 06 2014 carl.kao
+# * [MOLY00068605] [SystemService][Region init] Add INT_InitL1coreBootVector for pcore to init boot vector of l1core
+# * add .global/ .type for INT_InitL1coreBootVector()
+# *
+# * 06 05 2014 carl.kao
+# * [MOLY00068605] [SystemService][Region init] Add INT_InitL1coreBootVector for pore to init reset vector of l1core
+# * add INT_InitL1coreBootVector
+# *
+# * 04 07 2014 carl.kao
+# * [MOLY00061797] [SYSTEM SERVICE] porting features from U3G_TK6280_DEV and MOLY.U3G.90IT.DEV branches
+# * porting 8) region init for PCORE
+# *
+# * 03 28 2013 qmei.yang
+# * [MOLY00013019] [SystemService][region init][Internal Refinement] To make sure the 1st symbol be 4 bytes aligned
+# * .
+# *
+# * 03 28 2013 qmei.yang
+# * [MOLY00012756] [SystemService] To remove useless input section by requests
+# * .
+# *
+# * 11 05 2012 chin-chieh.hung
+# * [MOLY00005322] TATAKA merge to MOLY
+# * Integration change(SS part, exclude kal/sst/config)
+# *
+# * 11 05 2012 chin-chieh.hung
+# * [MOLY00005322] TATAKA merge to MOLY
+# * Integration change(SS part, exclude kal/sst/config)
+# *
+# * 11 05 2012 chin-chieh.hung
+# * [MOLY00005322] TATAKA merge to MOLY
+# * Integration change(SS part, exclude kal/sst/config)
+# *
+# * 11 05 2012 chin-chieh.hung
+# * [MOLY00005322] TATAKA merge to MOLY
+# * Integration change(SS part, exclude kal/sst/config)
+# *
+# * 11 05 2012 chin-chieh.hung
+# * [MOLY00005322] TATAKA merge to MOLY
+# * Integration change(SS part, exclude kal/sst/config)
+# *
+# * 08 27 2012 qmei.yang
+# * [MOLY00001774] [SystemService][Region_Init][Internal Refinement] Support MT6577 region init and remove useless regions and compile option
+# * .
+# *
+# *
+# * 02 09 2012 ken.lin
+# * [MAUI_03127715] [INIT][FixBug] remove redundant region init - SINGLE_BANK_CODE
+# * .
+# *
+# * 02 03 2012 ken.lin
+# * [MAUI_03112654] [System Service][MT6280] Check-in SS related modification for MT6280 E1 DVT
+# * .
+# *
+# * 01 16 2012 ken.lin
+# * [MAUI_03112654] [System Service][MT6280] Check-in SS related modification for MT6280 E1 DVT
+# * .
+# *
+# * 12 20 2011 ken.lin
+# * [MAUI_03101840] [System Service][TK6280] Merge SS modification for TK6280
+# * .
+# *
+# * 10 28 2011 ken.lin
+# * [MAUI_03063098] [System Service][BB Chip] Merge SS modification for MT6255
+# * .
+# *
+# * 10 07 2011 qmei.yang
+# * [MAUI_03045135] [SystemService][Auto-Gen][Sys Gen][scatGen][Request For Design Change] Isolate med and asm pool in scatter file for DSP shared memory
+# * Isolate med and asm pool in scatter file for DSP shared memory
+# *
+# * 09 15 2011 ken.lin
+# * [MAUI_03016796] [NVRAM] NVRAM LID Split
+# * .
+# *
+# * 09 05 2011 ken.lin
+# * [MAUI_03016796] [NVRAM] NVRAM LID Split
+# * .
+# *
+# * 06 03 2011 ken.lin
+# * [MAUI_02908670] [NewFeature][SystemService] add MT6575 support
+# * .
+# *
+# * 05 24 2011 ken.lin
+# * [MAUI_02931343] [Serial Flash] Leakage checking and recovery at boot time.
+# * .
+# *
+# * 04 08 2011 ken.lin
+# * [MAUI_02908700] [SystemService][FixBug] init DSP share memory and dump ccci share memory in MT6573
+# * .
+# *
+# * 03 16 2011 ken.lin
+# * [MAUI_02897468] [init][ChangeFeature] Resource Protect on 6251
+# * .
+# *
+# * 03 06 2011 ken.lin
+# * [MAUI_02869092] [Bootloader][Change feature] Add bootloader support on MT6252
+# * .
+# *
+# * 02 21 2011 ken.lin
+# * [MAUI_02869092] [Bootloader][Change feature] Add bootloader support on MT6252
+# * .
+# *
+# * 02 20 2011 ken.lin
+# * [MAUI_02873111] [init][ChangeFeature] modify region init for scatter file change
+# * .
+# *
+# * 02 12 2011 ken.lin
+# * [MAUI_02869092] [Bootloader][Change feature] Add bootloader support on MT6252
+# * .
+# *
+# * 01 27 2011 ken.lin
+# * [MAUI_02866548] [SystemService][NewFeature] EMB support
+# * .
+# *
+# * 01 03 2011 ken.lin
+# * [MAUI_02857100] [SystemService][ChangeFeature] remove MT6255 chip option
+# * .
+# *
+# * 11 25 2010 ken.lin
+# * [MAUI_02841889] [System Service][HAL] This CR is used for SSx to check in HAL activity
+# * .
+# *
+# * 11 18 2010 ken.lin
+# * [MAUI_02829741] [NewFeature][SystemService] add MT6258/MT6258H support
+# * .
+# *
+# * 11 17 2010 ken.lin
+# * [MAUI_02839016] [SystemService][SST] remove chip option - MT6253D
+# * .
+# *
+# * 11 10 2010 ken.lin
+# * [MAUI_02829741] [NewFeature][SystemService] add MT6258/MT6258H support
+# * .
+# *
+# * 09 19 2010 ken.lin
+# * [MAUI_02610051] [SystemService][NewFeature] add MT6573 support
+# * .
+# *
+# * 08 25 2010 ken.lin
+# * [MAUI_02610051] [SystemService][NewFeature] add MT6573 support
+# * add MT6573 support
+# *
+# * 08 05 2010 ken.lin
+# * [MAUI_02603197] [SystemService][NewFeature] add MT6253 E/L support
+# * add MT6253E/L support
+# *
+# * Jul 8 2010 mtk02554
+# * [MAUI_02581074] [SystemService][NewFeature] customer resource protection
+# * new region for protected resource
+# *
+# * Jun 30 2010 mtk02554
+# * [MAUI_02574496] [SystemService][NewFeature] add MT6251 support
+# * add MT6251 support
+# *
+# * Jun 18 2010 mtk02554
+# * [MAUI_02564887] [NewFeature][SystemService] add MT6276 support
+# * add MT6276 support
+# *
+# * Jun 16 2010 mtk02554
+# * [MAUI_02545018] [NewFeature][SystemService] add MT6255 support
+# * add MT6256 support
+# *
+# * Jun 4 2010 mtk02554
+# * [MAUI_02545018] [NewFeature][SystemService] add MT6255 support
+# * add MT6255 support
+# *
+# * Apr 15 2010 mtk02554
+# * [MAUI_02373549] [Gadget] code check in
+# * add EXTSRAM_GADGET
+# *
+# * Dec 16 2009 mtk02554
+# * [MAUI_02016794] [init][AddFeature] add support for MT6253D & MT6253 E8
+# * add support for MT6253AL (MT6253D+MT6253)
+# *
+# * Nov 22 2009 mtk02554
+# * [MAUI_01995103] [system service] [AddFeature] Merge MT6270A_DVT to MAUI
+# * add support for MT6270A
+# *
+# * Aug 27 2009 mtk00702
+# * [MAUI_01645273] [system service][AddFeature] add MT6268H support
+# * add MT6268H otpion
+# *
+# * Aug 23 2009 mtk02554
+# * [MAUI_01943549] [init][AddFeature] add MT6236 support
+# * add MT6236 and MT6236B support
+# *
+# * Feb 24 2009 mtk00702
+# * [MAUI_01635463] [init][AddFeature] add MT6253 supporting
+# * add MT6253 option
+# *
+# * Feb 9 2009 mtk01710
+# * [MAUI_01317678] [system service][add feature]support MT6268 chip
+# * Add MT6268 compile option
+# *
+# * Dec 2 2008 mtk01866
+# * [MAUI_01289041] [SystemService][NewFeature] Merge MT6516 Back to MainTrunk
+# * Merge MT6516 Back to MainTrunk
+# *
+# * Nov 12 2008 mtk01866
+# * [MAUI_01274087] [INIT][NewFeature] merge MT6253T back to MainTrunk
+# * merge MT6253T back to MainTrunk
+# *
+# * Oct 24 2008 mtk01866
+# * [MAUI_01257539] [INIT][ChangeFeature] modify the default name of CODE_PATCH_CODE to CACHED_CODE_PATC
+# * modify for NFB project
+# *
+# * Oct 17 2008 mtk01866
+# * [MAUI_01257539] [INIT][ChangeFeature] modify the default name of CODE_PATCH_CODE to CACHED_CODE_PATC
+# * add CACHED_CODE_PATCH_CODE to regioninit
+# *
+# * Oct 3 2008 mtk01866
+# * [MAUI_01248908] [NOR FDM/MTD][New Feature] Make SINGLE_BANK_CODE section cacheable on ARM9 platform.
+# * Rmove dummy code in bootarm.s and add ENSB new region support for ESNB
+# *
+# * Sep 6 2008 mtk01866
+# * [MAUI_01231807] [SystemService][NFB] modify compile option for NFB
+# * store the need register when do SYS_InitRegions
+# *
+# * Sep 3 2008 mtk01866
+# * [MAUI_01230636] [CS5] [DCACHE PHASE3] [MAUI/08A] [W08.37] [FEATURE] Phase-in MT623X_DCACHE_DEV into
+# * phase in for DCache phase3
+# *
+# * Jun 19 2008 mtk01866
+# * [MAUI_00790254] [System Service] Merge MT6268A to maintrunk
+# * Merge 6268A back to MainTrunk
+# *
+# * Apr 24 2008 mtk01077
+# * [MAUI_00740317] [SystemService][Auto-Gen][Scatter Gen][Sys Gen][Request For Design Change] Scatter G
+# *
+# *
+# * Apr 22 2008 mtk01866
+# * [MAUI_00749050] [SystemService][AddFeature] Merge TK6516 DVT to main trunk
+# * Add compile option for TK6516
+# *
+# * Apr 20 2008 mtk01077
+# * [MAUI_00740317] [SystemService][Auto-Gen][Scatter Gen][Sys Gen][Request For Design Change] Scatter G
+# *
+# *
+# * Apr 3 2008 mtk01866
+# * [MAUI_00749050] [SystemService][AddFeature] Merge TK6516 DVT to main trunk
+# * Merge 6516 Back to MainTrunk
+# *
+# * Apr 2 2008 mtk01866
+# * [MAUI_00747577] [BugFix][INIT] Fix RegionInit problem.
+# * Revise backward copy problem
+# *
+# * Apr 1 2008 mtk01866
+# * [MAUI_00747577] [BugFix][INIT] Fix RegionInit problem.
+# * Fix regioninit with backward copy problem
+# *
+# * Mar 31 2008 mtk01866
+# * [MAUI_00740317] [SystemService][Auto-Gen][Scatter Gen][Sys Gen][Request For Design Change] Scatter G
+# * add backward copy for MT6235/38
+# *
+# * Mar 15 2008 mtk01866
+# * [MAUI_00732430] [INIT][AddFeature] add MT6239 and MT6235B compiltion option
+# * add compilation for MT6239/6235B
+# *
+# * Feb 14 2008 mtk01866
+# * [MAUI_00611737] [SystemService][AddFeature] 6235 scatter file refinement.
+# * modify to support refined scatter file for 35/38
+# *
+# * Jan 23 2008 MTK01866
+# * [MAUI_00610146] [INIT][AddFeature] Merge Monza and 6268 Back to MainTrunk
+# * Merge Monza and 6268T related code
+# *
+# * Dec 13 2007 MTK01866
+# * [MAUI_00591116] [BufFix] Sync MT6223 and 6223P
+# * add MT6223P compilation
+# *
+# * Dec 3 2007 MTK01892
+# * [MAUI_00586601] [SystemService][Add Feature] move cacheable region to primary MAUI
+# * fix bootup slowly issue - move cachable region from secondary MAUI to primary MAUI.
+# *
+# * Nov 7 2007 mtk01866
+# * [MAUI_00573142] [SystemService][Add Feature] migrate from MT6235 DVT to MainTrunke
+# * Merge MT6235 DVT to MainTrunk.
+# *
+# * Oct 3 2007 mtk00702
+# * [MAUI_00410341] [init][AddFeature] ARM9 MMU porting
+# * 1. add INT_InitEMIInitCode() and INT_InitMMRegions()
+# * 2. refine INT_InitRegions()
+# *
+# * Sep 6 2007 mtk01568
+# * [MAUI_00541308] [System Service] [MT6238] Check-in MT6238 Compile Option into Maintrunk.
+# *
+# *
+# * Sep 2 2007 mtk01568
+# * [MAUI_00541308] [System Service] [MT6238] Check-in MT6238 Compile Option into Maintrunk.
+# *
+# *
+# * Sep 2 2007 mtk01568
+# * [MAUI_00541308] [System Service] [MT6238] Check-in MT6238 Compile Option into Maintrunk.
+# *
+# *
+# * Jul 15 2007 mtk01568
+# * [MAUI_00416979] [System Service] [6223P] Check-in 6223P compile option into MAUI/07A.
+# *
+# *
+# * Jul 5 2007 mtk01568
+# * [MAUI_00413251] [System Service] [6226D] Check-in 6226D compile option into MAUI/07A/06B.
+# *
+# *
+# * May 1 2007 MTK01568
+# * [MAUI_00384134] [System Service] [6223] Check-in 6223 related files into main trunk.
+# *
+# *
+# * Apr 9 2007 mtk01077
+# * [MAUI_00377311] [INIT] region_init platform condition syntax correction
+# *
+# *
+# * Mar 29 2007 mtk01077
+# * [MAUI_00377311] [INIT] region_init platform condition syntax correction
+# *
+# *
+# * Mar 25 2007 MTK01568
+# * [MAUI_00375788] [System Service] [6227D] Check-in 6227D related files into main trunk.
+# *
+# *
+# * Mar 23 2007 mtk00576
+# * [MAUI_00359377] [System Service][New Feature] Porting MAUI to support MT6223
+# * Bug fix, boot-up failure for MT6223.
+# *
+# * Feb 8 2007 mtk01337
+# * [MAUI_00361983] [NOR][FDM]Enhanced Single Bank NOR Flash Support
+# * modify SINGLE_BANK_SUPPORT define
+# *
+# * Feb 6 2007 mtk01337
+# * [MAUI_00361983] [NOR][FDM]Enhanced Single Bank NOR Flash Support
+# * add initialization code for single bank RAM code
+# *
+# * Jan 18 2007 mtk00576
+# * [MAUI_00359377] [System Service][New Feature] Porting MAUI to support MT6223
+# * Porting for MT6223.
+# *
+# * Dec 4 2006 mtk01077
+# * [MAUI_00348452] Custom\System\BB\* auto generator stage 3 phase-in , scatter file
+# *
+# *
+# * Nov 20 2006 mtk01077
+# * [MAUI_00344919] [INIT] speed up ZI procedure in region init
+# *
+# *
+# * Nov 10 2006 mtk00576
+# * [MAUI_00342298] [Bootloader, Init, Custom][Add Feature] MT6225 supports NFB
+# * Switch the order of INSTRAM_Multimedia.
+# *
+# * Oct 5 2006 mtk00702
+# * [MAUI_00323865] [system service][AddFeature] add MT6225 support in MAUI
+# * add compilation flag
+# *
+# * Aug 29 2006 mtk01077
+# * [MAUI_00325483] [INIT][Custom] Enable MPU on all RO-code and RO-data, Rearrange scattar file layout
+# *
+# *
+# * Jul 17 2006 mtk00702
+# * [MAUI_00211187] [System service][AddFeature] Add compilation flag to support MT6230
+# * add compilation flag MT6230
+#
+# Rev 1.14 Aug 15 2005 11:47:48 mtk00576
+# Copy and zero-initialize the INTSRAM_MULTIMEDIA region.
+# Resolution for 12335: [CUSTOM][Enhancement] Improve performance of multi-media
+#
+# Rev 1.13 Aug 02 2005 11:40:46 mtk00576
+# Remove redundant functions.
+# Resolution for 12098: [Init, Inc, drv, custom][Add Feature] Porting system to MT6226, MT6227 and MT6229
+#
+# Rev 1.12 Jul 28 2005 17:55:58 mtk00576
+# Porting to MT6226, MT6227 and MT6229.
+# Resolution for 12098: [Init, Inc, drv, custom][Add Feature] Porting system to MT6226, MT6227 and MT6229
+#
+# Rev 1.11 Jun 13 2005 09:27:22 BM
+# add copyright and disclaimer
+#
+# Rev 1.10 May 29 2005 12:43:44 mtk00576
+# Porting to MT6228
+# Resolution for 11274: [System][Enhancement] Support MT6228
+#
+# Rev 1.9 Feb 01 2005 17:06:58 mtk00702
+# 1. move the compile option- _SIMULATION
+# 2. replace "MOVE PC, R7" with "BX R7" such that InitRegions can be invoked by C code
+# Resolution for 9731: [INIT, SST][AddFeature] Add Chip UID feature
+#
+# Rev 1.8 Nov 08 2004 18:13:24 mtk00702
+# disable initialization of ZI region for co-sim
+# Resolution for 8658: [INIT, SST, DRV]Use compile option for co-sim load
+#
+# Rev 1.7 Oct 06 2004 10:16:26 mtk00576
+# Making MT6217 available.
+# Resolution for 8084: [System Service][Enhancement] Porting MAUI to MT6217
+#
+# Rev 1.6 Jun 06 2004 18:29:02 mtk00576
+# At MT6219, configure 256KB internal SRAM for Multi-media.
+#
+# Rev 1.5 Apr 30 2004 22:19:38 mtk00576
+# Activate internal SRAM in MT6219.
+#
+# Rev 1.4 Nov 20 2003 16:20:22 mtk00576
+# Modify InitRegions to meet both MT6218 and MT6218B.
+# Resolution for 3225: [Init][Add Feature]Porting to support MT6218B.
+#
+# Rev 1.3 Oct 29 2003 16:12:56 mtk00576
+# Porting to MT6218B.
+# Resolution for 3225: [Init][Add Feature]Porting to support MT6218B.
+#
+# Rev 1.2 Jun 06 2003 13:20:14 mtk00389
+# Modify to split INTSRAM_CODE and INTSRAM_DATA
+# Resolution for 93: Integration with MT6218
+#
+# Rev 1.1 Jun 03 2003 10:43:18 mtk00389
+# Modify for MT6218, add region init
+# Resolution for 93: Integration with MT6218
+#
+# Rev 1.0 Nov 30 2002 19:49:56 admin
+# Initial revision.
+# *------------------------------------------------------------------------------
+# * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+# *============================================================================
+# ****************************************************************************/
+
+#**************************************************************
+#* File: regioninit.s *
+#* Purpose: Application Startup Code *
+#**************************************************************
+#
+# This file contains the macro and supporting subroutines to
+# copy RO code and RW data from ROM to RAM and zero-initialize
+# the ZI data areas in RAM.
+
+
+# All of this should be set as an assembler argument using the -pd option.
+# For example to set support for Angel it would be -pd "MT6218 SETL {TRUE}"
+# see also make\comp.mak
+
+ #include "asm_def.h"
+
+#include <mips/m32c0.h>
+
+ /* Added by Anthony Chin 10/28/2001. */
+# CPU_ISA()
+# ISA_UNIFIED_SETTING()
+ .global INT_InitRegions
+ .global INT_InitShareRegions
+ .global INT_InitDspTxRxRegions
+ .global INT_InitEMIInitCode
+ .global INT_InitPreInitData
+ .global INT_InitMMRegions
+ .global SYS_InitRegions
+ .global INT_InitL1coreBootVector
+
+ .type INT_InitRegions, STT_FUNC
+ .type INT_InitShareRegions, STT_FUNC
+ .type INT_InitDspTxRxRegions, STT_FUNC
+ .type INT_InitEMIInitCode, STT_FUNC
+ .type INT_InitPreInitData, STT_FUNC
+ .type INT_InitMMRegions, STT_FUNC
+ .type SYS_InitRegions, STT_FUNC
+ .type INT_InitL1coreBootVector, STT_FUNC
+
+/*
+Labels with positive integers represent local labels,
+'b' after number represent backward reference;
+'f' after number represent forward reference.
+ex. label "1:" is referenced by "1b" or "1f".
+*/
+
+
+/* This macro:
+# a) copies RO code and/or RW data from ROM at Load$$area$$Base
+# to RAM at Image$$area$$Base, of length Image$$area$$Length bytes.
+# b) fills with zero the ZI data in RAM at Image$$area$$ZI$$Base,
+# of length Image$$area$$ZI$$Length bytes.*/
+
+
+#define BANK_MASK 0xF0000000
+#define PHY_BANK 0x00000000
+
+
+ .macro macro_SRAMRegionInit areaname
+
+#if 0 //defined(_SIMULATION) /* _SIMULATION == 0 */
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else /* _SIMULATION */
+
+# The following symbols are generated by the linker. They are .externed
+# WEAKly because they may not all have defined values. Those which are
+# undefined will take the value zero.
+
+ .equ copyloadsym, Load$$\areaname\($$Base)
+ .weak Load$$\areaname\($$Base)
+ .equ copybasesym, Image$$\areaname\($$Base)
+ .weak Image$$\areaname\($$Base)
+ .equ copylensym, Image$$\areaname\($$Length)
+ .weak Image$$\areaname\($$Length)
+ .equ zibasesym, Image$$\areaname\($$ZI$$Base)
+ .weak Image$$\areaname\($$ZI$$Base)
+ .equ zilensym, Image$$\areaname\($$ZI$$Length)
+ .weak Image$$\areaname\($$ZI$$Length)
+
+#if !defined(__TCM_ONLY_LOAD__)
+# LDR r0, =copyloadsym # copyloadsym: load address of region
+# LDR r1, =copybasesym # copybasesym: execution address of region
+# MOV r2, r1 # copy execution address into r2
+# LDR r4, =copylensym # copylensym
+# ADD r2, r2, r4 # add region length to execution address to...
+ # ...calculate address of word beyond end...
+ # ... of execution region
+# BL copy
+#endif
+# LDR r2, =zilensym # zilensym: get length of ZI region
+# LDR r0, =zibasesym # zibasesym: load base address of ZI region
+# MOV r1, r0 # copy base address of ZI region into r1
+# ADD r1, r1, r2 # add region length to base address to...
+ # ...calculate address of word beyond end...
+ # ... of ZI region
+# BL zi_init_32
+#endif /* _SIMULATION */
+
+ .endm
+
+
+ .macro macro_RegionInit areaname
+
+#if 0 //defined(_SIMULATION) /* _SIMULATION == 0 */
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else /* _SIMULATION */
+
+# The following symbols are generated by the linker. They are .externed
+# WEAKly because they may not all have defined values. Those which are
+# undefined will take the value zero.
+
+ .equ copyloadsym, Load$$\areaname\($$Base)
+ .weak Load$$\areaname\($$Base)
+ .equ copybasesym, Image$$\areaname\($$Base)
+ .weak Image$$\areaname\($$Base)
+ .equ copylensym, Image$$\areaname\($$Length)
+ .weak Image$$\areaname\($$Length)
+ .equ zibasesym, Image$$\areaname\($$ZI$$Base)
+ .weak Image$$\areaname\($$ZI$$Base)
+ .equ zilensym, Image$$\areaname\($$ZI$$Length)
+ .weak Image$$\areaname\($$ZI$$Length)
+
+#if !defined(__TCM_ONLY_LOAD__)
+# LDR r0, =copyloadsym # copyloadsym: load address of region
+# LDR r1, =copybasesym # copybasesym: execution address of region
+#if defined(__COSIM_BYPASS_DRV__)
+# BIC r1, r1, #BANK_MASK
+# ORR r1, r1, #PHY_BANK
+#endif
+# MOV r2, r1 # copy execution address into r2
+# LDR r4, =copylensym # copylensym
+# ADD r2, r2, r4 # add region length to execution address to...
+ # ...calculate address of word beyond end...
+ # ... of execution region
+# BL copy
+#endif
+
+# LDR r2, =zilensym # zilensym: get length of ZI region
+# LDR r0, =zibasesym # zibasesym: load base address of ZI region
+#if defined(__COSIM_BYPASS_DRV__)
+# BIC r0, r0, #BANK_MASK
+# ORR r0, r0, #PHY_BANK
+#endif
+# MOV r1, r0 # copy base address of ZI region into r1
+# ADD r1, r1, r2 # add region length to base address to...
+ # ...calculate address of word beyond end...
+ # ... of ZI region
+# BL zi_init_32
+#endif /* _SIMULATION */
+
+ .endm
+
+# This macro:
+# a) fills with zero the ZI data in RAM at Image$$area$$ZI$$Base,
+# of length Image$$area$$ZI$$Length bytes.
+
+ .macro macro_ZeroInit areaname
+
+#if 0 //defined(_SIMULATION) /* _SIMULATION == 0 */
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else /* _SIMULATION */
+
+# The following symbols are generated by the linker. They are .externed
+# WEAKly because they may not all have defined values. Those which are
+# undefined will take the value zero.
+
+ .equ copyloadsym, Load$$\areaname\($$Base)
+ .weak Load$$\areaname\($$Base)
+ .equ copybasesym, Image$$\areaname\($$Base)
+ .weak Image$$\areaname\($$Base)
+ .equ copylensym, Image$$\areaname\($$Length)
+ .weak Image$$\areaname\($$Length)
+ .equ zibasesym, Image$$\areaname\($$ZI$$Base)
+ .weak Image$$\areaname\($$ZI$$Base)
+ .equ zilensym, Image$$\areaname\($$ZI$$Length)
+ .weak Image$$\areaname\($$ZI$$Length)
+
+# LDR r2, =zilensym # zilensym: get length of ZI region
+# LDR r0, =zibasesym # zibasesym: load base address of ZI region
+#if defined(__COSIM_BYPASS_DRV__)
+# BIC r0, r0, #BANK_MASK
+# ORR r0, r0, #PHY_BANK
+#endif
+# MOV r1, r0 # copy base address of ZI region into r1
+# ADD r1, r1, r2 # add region length to base address to...
+ # ...calculate address of word beyond end...
+ # ... of ZI region
+# BL zi_init_32
+
+#endif /* _SIMULATION */
+
+ .endm
+
+# This macro:
+# a) copies RO code and/or RW data from ROM at Load$$area$$Base
+# to RAM at Image$$area$$Base, of length Image$$area$$Length bytes.
+
+ .macro macro_CopyRW areaname
+
+#if 0 //defined(_SIMULATION) /* _SIMULATION == 0 */
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else /* _SIMULATION */
+
+# The following symbols are generated by the linker. They are .externed
+# WEAKly because they may not all have defined values. Those which are
+# undefined will take the value zero.
+
+ .equ copyloadsym, Load$$\areaname\($$Base)
+ .weak Load$$\areaname\($$Base)
+ .equ copybasesym, Image$$\areaname\($$Base)
+ .weak Image$$\areaname\($$Base)
+ .equ copylensym, Image$$\areaname\($$Length)
+ .weak Image$$\areaname\($$Length)
+ .equ zibasesym, Image$$\areaname\($$ZI$$Base)
+ .weak Image$$\areaname\($$ZI$$Base)
+ .equ zilensym, Image$$\areaname\($$ZI$$Length)
+ .weak Image$$\areaname\($$ZI$$Length)
+
+#if !defined(__TCM_ONLY_LOAD__)
+# LDR r0, =copyloadsym # copyloadsym: load address of region
+# LDR r1, =copybasesym # copybasesym: execution address of region
+# MOV r2, r1 # copy execution address into r2
+# LDR r4, =copylensym
+# ADD r2, r2, r4 # add region length to execution address to...
+ # ...calculate address of word beyond end...
+ # ... of execution region
+# BL copy
+#endif
+
+#endif /* _SIMULATION */
+
+ .endm
+
+
+ .macro macro_BackwardCopyRW areaname
+
+#if 0 //defined(_SIMULATION) /* _SIMULATION == 0 */
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#else /* _SIMULATION */
+
+# The following symbols are generated by the linker. They are .externed
+# WEAKly because they may not all have defined values. Those which are
+# undefined will take the value zero.
+
+ .equ copyloadsym, Load$$\areaname\($$Base)
+ .weak Load$$\areaname\($$Base)
+ .equ copybasesym, Image$$\areaname\($$Base)
+ .weak Image$$\areaname\($$Base)
+ .equ copylensym, Image$$\areaname\($$Length)
+ .weak Image$$\areaname\($$Length)
+ .equ zibasesym, Image$$\areaname\($$ZI$$Base)
+ .weak Image$$\areaname\($$ZI$$Base)
+ .equ zilensym, Image$$\areaname\($$ZI$$Length)
+ .weak Image$$\areaname\($$ZI$$Length)
+
+# LDR r0, =copyloadsym # copyloadsym: load address of region
+# LDR r1, =copybasesym # copybasesym: execution address of region
+# MOV r2, r1 # copy execution address into r2
+# LDR r4, =copylensym # copylensym
+# SUB r4, r4, #4
+# ADD r0, r0, r4
+# ADD r1, r1, r4
+
+# BL backward_copy
+
+#endif /* _SIMULATION */
+
+ .endm
+
+#
+# NoteXXX: INT_InitXXXRegions is called from boot.s to initialize the specified execution regions.
+# The register r12 will be used in the bootarm.s. We should be careful not to
+# overwrite r12.
+#
+
+#
+#/*************************************************************************/
+#/* */
+#/* FUNCTION */
+#/* INT_InitEMIInitCode */
+#/* */
+#/* DESCRIPTION */
+#/* Initialize EMI INIT code */
+#/* */
+#/* INPUTS */
+#/* None */
+#/* */
+#/* OUTPUTS */
+#/* None */
+#/*************************************************************************/
+# VOID INT_InitEMIInitCode(VOID)
+# {
+#
+# FUNC_ATTR(INT_InitEMIInitCode)
+.align 2
+INT_InitEMIInitCode:
+ 1: b 1b
+ jr $ra
+
+# MOV r7,lr
+
+# macro_RegionInit EMIINIT_CODE
+# macro_RegionInit SINGLE_BANK_CODE
+
+# BX r7
+.size INT_InitEMIInitCode, .-INT_InitEMIInitCode
+# }
+#
+/*************************************************************************/
+/* */
+/* FUNCTION */
+/* INT_InitPreInitData */
+/* */
+/* DESCRIPTION */
+/* Initialize CACHED_PREINIT_ZI region */
+/* */
+/* INPUTS */
+/* None */
+/* */
+/* OUTPUTS */
+/* None */
+/*************************************************************************/
+# VOID INT_InitPreInitData(VOID)
+# {
+#
+# FUNC_ATTR(INT_InitPreInitData)
+INT_InitPreInitData:
+ 1: b 1b
+ jr $ra
+
+# MOV r7,lr
+
+# macro_ZeroInit CACHED_EXTSRAM_PREINIT_ZI
+
+# BX r7
+.size INT_InitPreInitData, .-INT_InitPreInitData
+# }
+#
+
+#
+#/*************************************************************************/
+#/* */
+#/* FUNCTION */
+#/* INT_InitMMRegions */
+#/* */
+#/* DESCRIPTION */
+#/* Initialize the multimedia region */
+#/* */
+#/* INPUTS */
+#/* None */
+#/* */
+#/* OUTPUTS */
+#/* None */
+#/*************************************************************************/
+# VOID INT_InitMMRegions(VOID)
+# {
+#
+# FUNC_ATTR(INT_InitMMRegions)
+INT_InitMMRegions:
+ 1: b 1b
+ jr $ra
+
+# BX lr # Return to caller
+.size INT_InitMMRegions, .-INT_InitMMRegions
+# }
+#
+
+
+#
+#/*************************************************************************/
+#/* */
+#/* FUNCTION */
+#/* INT_InitRegions */
+#/* */
+#/* DESCRIPTION */
+#/* Initialize the RW/ZI regions */
+#/* */
+#/* INPUTS */
+#/* None */
+#/* */
+#/* OUTPUTS */
+#/* None */
+#/*************************************************************************/
+# VOID INT_InitRegions(VOID)
+# {
+#
+ .global INT_InitRegions
+# FUNC_ATTR(INT_InitRegions)
+INT_InitRegions:
+ 1: b 1b
+ jr $ra
+
+# MOV r7,lr # do not use push PUSH {r0,r1,r2,r14} since stack will be set to zero in INTSRAM_DATA
+
+# macro_SRAMRegionInit INTSRAM_CODE
+# macro_SRAMRegionInit INTSRAM_DATA
+# macro_SRAMRegionInit INTSRAM_DATA_B1
+
+# macro_RegionInit CACHED_EXTSRAM
+# macro_RegionInit CACHED_EXTSRAM_NVRAM_LTABLE
+# macro_RegionInit DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_CACHEABLE_RW
+# macro_RegionInit DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_RW
+# macro_ZeroInit DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_ZI
+# macro_ZeroInit DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_CACHEABLE_ZI
+
+# macro_RegionInit EXTSRAM
+
+ # share region is init by INT_InitShareRegions
+ # dsp section is init by INT_InitDspTxRxRegions
+# BL INT_InitDspTxRxRegions
+
+ /* STACK GUARD pattern init */
+# BL INT_StackEnd_Guard
+
+# BX r7 # Return to caller
+.size INT_InitRegions, .-INT_InitRegions
+# }
+#
+
+
+#
+#/*************************************************************************/
+#/* */
+#/* FUNCTION */
+#/* INT_InitDspTxRxRegions */
+#/* */
+#/* DESCRIPTION */
+#/* Initialize the DSP TX/RX regions */
+#/* */
+#/* INPUTS */
+#/* None */
+#/* */
+#/* OUTPUTS */
+#/* None */
+#/*************************************************************************/
+# VOID INT_InitDspTxRxRegions(VOID)
+# {
+#
+ .global INT_InitDspTxRxRegions
+# FUNC_ATTR(INT_InitDspTxRxRegions)
+INT_InitDspTxRxRegions:
+ 1: b 1b
+ jr $ra
+
+# STMDB sp!, {lr} # save lr
+
+#if !defined(__TCM_ONLY_LOAD__)
+# LDR r0, =Load$$EXTSRAM_DSP_TX$$Base # copyloadsym: load address of region
+# LDR r1, =PCORE_EXTRAM_TXDATA$$Base # copybasesym: execution address of region
+# MOV r2, r1 # copy execution address into r2
+# LDR r4, =PCORE_EXTRAM_TXDATA$$Length
+# ADD r2, r2, r4 # add region length to execution address to...
+ # ...calculate address of word beyond end...
+ # ... of execution region
+# BL copy
+
+
+# LDR r0, =Load$$EXTSRAM_DSP_RX$$Base # copyloadsym: load address of region
+# LDR r1, =PCORE_EXTRAM_RXDATA$$Base # copybasesym: execution address of region
+# MOV r2, r1 # copy execution address into r2
+# LDR r4, =PCORE_EXTRAM_RXDATA$$Length
+# ADD r2, r2, r4 # add region length to execution address to...
+ # ...calculate address of word beyond end...
+ # ... of execution region
+# BL copy
+#endif
+
+# LDMIA sp!, {lr} # restore lr
+# BX lr # Return to caller
+
+.size INT_InitDspTxRxRegions, .-INT_InitDspTxRxRegions
+# }
+#
+
+
+#
+#/*************************************************************************/
+#/* */
+#/* FUNCTION */
+#/* INT_InitShareRegions */
+#/* */
+#/* DESCRIPTION */
+#/* Initialize the shared RW/ZI regions */
+#/* */
+#/* INPUTS */
+#/* None */
+#/* */
+#/* OUTPUTS */
+#/* None */
+#/*************************************************************************/
+# VOID INT_InitShareRegions(VOID)
+# {
+#
+ .global INT_InitShareRegions
+# FUNC_ATTR(INT_InitShareRegions)
+INT_InitShareRegions:
+ 1: b 1b
+ jr $ra
+
+# STMDB sp!, {lr} # save lr
+
+# macro_RegionInit SHARED_DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_RW
+# macro_ZeroInit SHARED_DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_ZI
+
+# macro_RegionInit SHARED_EXTSRAM
+# macro_ZeroInit SHARED_EXTSRAM_ZI
+
+# macro_RegionInit SHARED_DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_MCURO_HWRW
+# macro_ZeroInit SHARED_DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_MCURO_HWRW_ZI
+
+# macro_RegionInit SHARED_EXTSRAM_MCURO_HWRW
+# macro_ZeroInit SHARED_EXTSRAM_MCURO_HWRW_ZI
+# {
+# LDR r2, =SHARED_EXTSRAM_MCURO_HWRW_ZI$$ZI$$Length # zilensym: get length of ZI region
+# LDR r0, =SHARED_EXTSRAM_MCURO_HWRW_ZI$$ZI$$Base # zibasesym: load base address of ZI region
+#if defined(__COSIM_BYPASS_DRV__)
+# BIC r0, r0, #BANK_MASK
+# ORR r0, r0, #PHY_BANK
+#endif
+# MOV r1, r0 # copy base address of ZI region into r1
+# ADD r1, r1, r2 # add region length to base address to...
+ # calculate address of word beyond end of ZI region
+# BL zi_init_32
+# }
+
+# macro_RegionInit SHARED_DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_MCURW_HWRW
+# {
+# LDR r0, =Load$$SHARED_DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_MCURW_HWRW$$Base # copyloadsym: load address of region
+# LDR r1, =SHARED_ARM7_DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_MCURW_HWRW$$Length
+# ADD r0, r0, r1
+# LDR r1, =SHARED_DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_MCURW_HWRW$$Base # copybasesym: execution address of region
+# MOV r2, r1 # copy execution address into r2
+# LDR r4, =SHARED_DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_MCURW_HWRW$$Length
+# ADD r2, r2, r4 # add region length to execution address to...
+ # ...calculate address of word beyond end...
+ # ... of execution region
+# BL copy
+# }
+# macro_ZeroInit SHARED_DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_MCURW_HWRW_ZI
+
+# macro_RegionInit SHARED_EXTSRAM_MCURW_HWRW
+# macro_ZeroInit SHARED_EXTSRAM_MCURW_HWRW_ZI
+
+
+# LDMIA sp!, {lr} # restore lr
+# BX lr # Return to caller
+
+.size INT_InitShareRegions, .-INT_InitShareRegions
+# }
+#
+
+#
+#/*************************************************************************/
+#/* */
+#/* FUNCTION */
+#/* INT_InitL1coreBootVector */
+#/* */
+#/* DESCRIPTION */
+#/* Initialize boot vector of l1core by pcore */
+#/* */
+#/* INPUTS */
+#/* None */
+#/* */
+#/* OUTPUTS */
+#/* None */
+#/*************************************************************************/
+# VOID INT_InitL1coreBootVector(VOID)
+# {
+#
+# FUNC_ATTR(INT_InitL1coreBootVector)
+INT_InitL1coreBootVector:
+ 1: b 1b
+ jr $ra
+
+# PUSH {r0,r1,r2,r14}
+
+# LDR r1, =Image$$L1CORE_BOOT_VECTOR$$Base # execution address of region
+# MOV r2, r1 # copy execution address into r2
+# LDR r0, =Image$$L1CORE_BOOT_VECTOR$$Length # copylensym
+# ADD r2, r2, r0 # add region length to execution address to...
+ # ...calculate address of word beyond end...
+ # ... of execution region
+# LDR r0, =Load$$L1CORE_BOOT_VECTOR$$Base # load address of region
+
+# BL copy
+
+# POP {r0,r1,r2,pc}
+ #BX lr # Return to caller
+.size INT_InitL1coreBootVector, .-INT_InitL1coreBootVector
+# }
+#
+
+
+#
+#/*************************************************************************/
+#/* */
+#/* FUNCTION */
+#/* SYS_InitRegions */
+#/* */
+#/* DESCRIPTION */
+#/* Initialize the 2nd MAUI RW/ZI regions */
+#/* */
+#/* INPUTS */
+#/* None */
+#/* */
+#/* OUTPUTS */
+#/* None */
+#/*************************************************************************/
+# VOID SYS_InitRegions(VOID)
+# {
+#
+# FUNC_ATTR(SYS_InitRegions)
+SYS_InitRegions:
+ 1: b 1b
+ jr $ra
+
+ #/* save working regsters since this function may be called by a C-code caller */
+# BX lr # Return to caller
+.size SYS_InitRegions, .-SYS_InitRegions
+# }
+#
+
+
+# --- copy and zi_init subroutines
+
+# copy is a subroutine which copies a region, from an address given by
+# r0 to an address given by r1. The address of the word beyond the end
+# of this region is held in r2. r3 is used to hold the word being copied.
+.global copy
+#copy:
+# .word _copy
+
+# FUNC_ATTR(copy)
+copy:
+ 1: b 1b
+ jr $ra
+# CMP r0, r1
+# BEQ copy_exit
+copy_loop:
+ 1: b 1b
+ jr $ra
+# CMP r1, r2 # loop whilst r1 < r2
+# LDRLO r3, [r0], #4
+# STRLO r3, [r1], #4
+# BLO copy_loop
+copy_exit:
+ 1: b 1b
+ jr $ra
+# MOV pc, lr # return from subroutine copy
+.size copy, .-copy
+
+# backward_copy is a subroutine which copies a region, from an address given by
+# r0 to an address given by r1. The address of the word beyond the end
+# of this region is held in r2. r3 is used to hold the word being copied.
+.global backward_copy
+#backward_copy:
+# .word _backward_copy
+
+# FUNC_ATTR(backward_copy)
+backward_copy:
+ 1: b 1b
+ jr $ra
+# CMP r0, r1
+# BEQ backward_copy_exit
+backward_copy_loop:
+ 1: b 1b
+ jr $ra
+# CMP r1, r2 # loop whilst r1 < r2
+# LDRGE r3, [r0], #-4
+# STRGE r3, [r1], #-4
+# BGE backward_copy_loop
+backward_copy_exit:
+ 1: b 1b
+ jr $ra
+# MOV pc, lr # return from subroutine copy
+.size backward_copy, .-backward_copy
+
+# zi_init is a subroutine which zero-initialises a region,
+# starting at the address in r0. The address of the word
+# beyond the end of this region is held in r1.
+.global zi_init
+#zi_init:
+# .word _zi_init
+# FUNC_ATTR(zi_init)
+zi_init:
+ 1: b 1b
+ jr $ra
+# MOV r2, #0
+# CMP r0, r1 # loop whilst r0 < r1
+# STRLO r2, [r0], #4
+# BLO zi_init
+# MOV pc, lr # return from subroutine zi_init
+.size zi_init, .-zi_init
+
+# zi_init_32 is a subroutine which zero-initialises a region,
+# starting at the address in r0. The length is held in r2.
+# the address of the 4-byte beyound the end of this region is
+# held in r1. set 32 bytes zero per loop.
+.global zi_init_32
+#zi_init_32:
+# .word _zi_init_32
+
+# FUNC_ATTR(zi_init_32)
+zi_init_32:
+ 1: b 1b
+ jr $ra
+# STMDB sp!, {r8-r10} # save extra working register
+# MOV r3, #0
+# MOV r8, #0
+# MOV r9, #0
+# MOV r10, #0
+# SUBS r2, r2, #0x20 # loop while r2 > 32
+
+.global zi_init_32_loop
+.ent zi_init_32_loop
+#zi_init_32_loop:
+ #.word _zi_init_32_loop
+
+# FUNC_ATTR(zi_init_32_loop)
+zi_init_32_loop:
+ 1: b 1b
+ jr $ra
+# STMCSIA r0!, {r3,r8-r10}
+# STMCSIA r0!, {r3,r8-r10}
+# SUBCSS r2, r2, #0x20 # loop while r2 > 32
+# BCS zi_init_32_loop
+# LDMIA sp!, {r8-r10} # restore extra working register
+# B zi_init
+# MOV pc, lr # return from subroutine zi_init
+.size zi_init_32_loop, .-zi_init_32_loop
+ .end zi_init_32_loop
+
+
diff --git a/mcu/service/sys_svc/region/src/stack_gcc.S b/mcu/service/sys_svc/region/src/stack_gcc.S
new file mode 100644
index 0000000..ff4c82b
--- /dev/null
+++ b/mcu/service/sys_svc/region/src/stack_gcc.S
@@ -0,0 +1,291 @@
+#/*****************************************************************************
+#* 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:
+# * ---------
+# * ex_hdlr.s
+# *
+# * Project:
+# * --------
+# * Maui_Software
+# *
+# * Description:
+# * ------------
+# * This file provides exception related APIs in assembly.
+# *
+# * Author:
+# * -------
+# * Ken Lin (mtk02554)
+# *
+# *============================================================================
+# * HISTORY
+# * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+# *------------------------------------------------------------------------------
+# * $Revision: 1.38 $
+# * $Modtime: Aug 15 2005 18:13:06 $
+# * $Log: //mtkvs01/vmdata/Maui_sw/archives/mcu/SST/src/ex_hdlr.s-arc $
+# *
+# * 03 13 2018 tero.jarkko
+# * [MOLY00313013] [Gen97][SystemService][Auto-Gen]Fixed MT6297 build error
+# *
+# * .
+# *
+# * 12 07 2016 carl.kao
+# * [MOLY00216659] MIPS16 porting merge
+# * .
+# *
+# * 12 07 2016 carl.kao
+# * [MOLY00216659] MIPS16 porting merge
+# * .
+# *
+# * 05 04 2016 carl.kao
+# * [MOLY00177702] [LR12] [SYSTEM SERVICE] [SYS_SVC] Fix build warning in sys_svc lib
+# * .
+# *
+# * 08 07 2015 hc.yang
+# * [MOLY00136062] [System Service] Merge Nucleus/KAL changes from 91 Plus DEV to UMOLY Trunk
+# * check in common folder modification
+# *
+# * 05 13 2015 yh.peng
+# * [MOLY00110737] [MT6291+] Check in init code.
+# * .Fix all assembly code to sw break.
+# *
+# * 04 30 2015 hc.yang
+# * [MOLY00110489] [MT6291PLUS] Modify files for BASIC_P load
+# * Phase in necessary modified files for BASIC_P load for MIPS compiler.
+# *
+# * 05 20 2014 carl.kao
+# * [MOLY00066129] [SYSTEM SERVICE] [Region Init] Assembly Code Add Size Info for MPPT
+# * .
+# *
+# * 04 04 2013 qmei.yang
+# * [MOLY00013594] [SystemService] To remove useless input section in exception handling by requests
+# * .
+# *
+# * 09 30 2011 ken.lin
+# * [MAUI_03040331] [ChangeFeature][SST] dump ARM cp15 FSR/FAR registers
+# * .
+# *
+# * 11 03 2010 ken.lin
+# * [MAUI_02833592] [SystemService][ChangeFeature] remove exception-related APIs from init
+# * .
+# *
+# * 11 03 2010 ken.lin
+# * [MAUI_02833592] [SystemService][ChangeFeature] remove exception-related APIs from init
+# * .
+# *------------------------------------------------------------------------------
+# * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+# *============================================================================
+# ****************************************************************************/
+#
+
+#/*************************************************************************/
+#/* */
+#/* Copyright (c) 1994 -2000 Accelerated Technology, Inc. */
+#/* */
+#/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
+#/* subject matter of this material. All manufacturing, reproduction, */
+#/* use, and sales rights pertaining to this subject matter are governed */
+#/* by the license agreement. The recipient of this software implicitly */
+#/* accepts the terms of the license. */
+#/* */
+#/*************************************************************************/
+#
+#/*************************************************************************/
+#/* */
+#/* FILE NAME VERSION */
+#/* */
+#/* stack.s ARM 7/9/11 1.11.19 */
+#/* */
+#/* COMPONENT */
+#/* */
+#/* EX - Exception Handler */
+#/* */
+#/* DESCRIPTION */
+#/* */
+#/* This file provides switching stcak and running in assembly. */
+#/* */
+#/* */
+#/* DATA STRUCTURES */
+#/* */
+#/* */
+#/* FUNCTIONS */
+#/* */
+#/* INT_GetCurrentSP */
+#/* INT_SwitchStackAndBranch */
+#/* */
+#/* */
+#/*************************************************************************/
+
+ .global THUMB
+ .global ARM
+/* .if CONFIG == 16
+.set THUMB , 0
+.set ARM , 1
+ .code 32
+ .else
+.set THUMB , 1
+.set ARM , 0
+ .endif */
+
+# /*----------------------------*/
+# /* Definitions */
+# /*----------------------------*/
+#/* for single bank support */
+#if defined(SINGLE_BANK_SUPPORT)
+ .global SINGLE_BANK_SUPPORT
+.set SINGLE_BANK_SUPPORT, 1
+#endif /* SINGLE_BANK_SUPPORT */
+
+
+# /*----------------------------*/
+# /* Export functions */
+# /*----------------------------*/
+ .global INT_GetCurrentSP
+ .global INT_SwitchStackAndBranch
+ .type INT_GetCurrentSP,STT_FUNC
+ .type INT_SwitchStackAndBranch,STT_FUNC
+
+#if defined(SINGLE_BANK_SUPPORT)
+ #AREA |SNORCODE|, CODE, READONLY
+ .section "SNORCODE"#, "ax", %nobits
+#endif /* SINGLE_BANK_SUPPORT */
+
+#/*************************************************************************/
+#/* */
+#/* FUNCTION */
+#/* INT_GetCurrentSP */
+#/* */
+#/* DESCRIPTION */
+#/* Get the value of the current sp register. */
+#/* CALLS */
+#/* */
+#/* INPUTS */
+#/* None */
+#/* */
+#/* OUTPUTS */
+#/* current sp */
+#/*************************************************************************/
+# int INT_GetCurrentSP(VOID)
+# {
+INT_GetCurrentSP:
+ 1: b 1b
+ jr $ra
+
+# MOV r0, sp # get the current stack pointer
+
+# BX lr # Return to caller
+.size INT_GetCurrentSP, .-INT_GetCurrentSP
+#}
+
+#/*************************************************************************/
+#/* */
+#/* FUNCTION */
+#/* INT_SwitchStackAndBranch */
+#/* */
+#/* DESCRIPTION */
+#/* Switch current stack pointer to new_stack and then run */
+#/* func(argv). */
+#/* */
+#/* CALLED BY */
+#/* INT_SwitchStackToRun */
+#/* */
+#/* CALLS */
+#/* None */
+#/* */
+#/* INPUTS */
+#/* new_stack the new stack pointer which want to switch to */
+#/* func the pointer of function which want to run */
+#/* argc the number of arguments of func */
+#/* argv the list of arguments */
+#/* */
+#/* OUTPUTS */
+#/* The reture value of func */
+#/*************************************************************************/
+# kal_uint32 INT_SwitchStackAndBranch(kal_uint32 new_stack, kal_func_ptr func, kal_uint32 argc, va_list argv)
+# {
+.ent INT_SwitchStackAndBranch
+INT_SwitchStackAndBranch:
+ 1: b 1b
+ jr $ra
+
+# STMDB SP!, {R4-R7, LR}
+
+# MOV R7, SP # Backup original SP in R7
+# MOV R6, R3 # Load the poitner of argv
+# MOV R5, R0 # Backup new SP in R5
+# SUBS R2, R2, #4 # Check if need to copy stack?
+# BLS skip_copy_stack
+
+# ADD R6, R6, #16
+# SUB R5, R0, R2, LSL #2 # Reserve new stack to store arg4~n
+
+copy_stack:
+ 1: b 1b
+ jr $ra
+# LDRHI R4, [R6], #4 # Copy arg4~n from argv to new stack
+# STRHI R4, [R5], #4
+# CMP R0, R5
+# BHI copy_stack
+
+# SUB R5, R0, R2, LSL #2 # Change new stack pointer
+
+skip_copy_stack:
+ 1: b 1b
+ jr $ra
+# MOV R6, R1 # Backup function pointer
+# MOV R4, R3 # Backup the pointer of argv;
+
+# LDR R0, [R4] # Setup arguments of procedure call
+# LDR R1, [R4, #4]
+# LDR R2, [R4, #8]
+# LDR R3, [R4, #12]
+
+# MOV SP, R5 # Switch to new stack
+# ADR lr, func_return
+# BX R6 # Procedure call
+func_return:
+ 1: b 1b
+ jr $ra
+# MOV SP, R7 # Switch back to old stack
+
+# LDMIA SP!, {R4-R7, PC}
+.size INT_SwitchStackAndBranch, .-INT_SwitchStackAndBranch
+#}
+
+
+ .end INT_SwitchStackAndBranch