rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2010 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /***************************************************************************** |
| 37 | * |
| 38 | * Filename: |
| 39 | * --------- |
| 40 | * flash_disk.h |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * Maui_Software |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * This is the header of NOR Flash raw disk code |
| 49 | * |
| 50 | * Author: |
| 51 | * ------- |
| 52 | * ------- |
| 53 | * |
| 54 | *============================================================================ |
| 55 | * HISTORY |
| 56 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 57 | *------------------------------------------------------------------------------ |
| 58 | * removed! |
| 59 | * removed! |
| 60 | * removed! |
| 61 | * |
| 62 | * removed! |
| 63 | * removed! |
| 64 | * removed! |
| 65 | * |
| 66 | * removed! |
| 67 | * removed! |
| 68 | * removed! |
| 69 | * |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * removed! |
| 73 | * |
| 74 | * removed! |
| 75 | * removed! |
| 76 | * removed! |
| 77 | * |
| 78 | * removed! |
| 79 | * removed! |
| 80 | * removed! |
| 81 | * |
| 82 | * removed! |
| 83 | * removed! |
| 84 | * removed! |
| 85 | * |
| 86 | * removed! |
| 87 | * removed! |
| 88 | * removed! |
| 89 | * |
| 90 | * removed! |
| 91 | * removed! |
| 92 | * removed! |
| 93 | * removed! |
| 94 | * |
| 95 | * removed! |
| 96 | * removed! |
| 97 | * removed! |
| 98 | * |
| 99 | * |
| 100 | *------------------------------------------------------------------------------ |
| 101 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 102 | *============================================================================== |
| 103 | ****************************************************************************/ |
| 104 | |
| 105 | #ifndef __FLASH_DISK_H__ |
| 106 | #define __FLASH_DISK_H__ |
| 107 | |
| 108 | #if defined __MTK_TARGET__ |
| 109 | #if !defined(_NAND_FLASH_BOOTING_) && !defined(__NOR_FDM5__) |
| 110 | |
| 111 | /******************************************* |
| 112 | * Include File |
| 113 | ********************************************/ |
| 114 | |
| 115 | #include "custom_MemoryDevice.h" |
| 116 | #include "flash_opt.h" |
| 117 | #include "flash_mtd.h" |
| 118 | #include "reg_base.h" |
| 119 | #include <stdio.h> |
| 120 | #include <stdlib.h> |
| 121 | #include "DrvFlash.h" |
| 122 | |
| 123 | |
| 124 | #ifdef __INTEL_SIBLEY__ |
| 125 | //MSBB remove #include "app_buff_alloc.h" //get control buffer |
| 126 | #endif //__INTEL_SIBLEY__ |
| 127 | |
| 128 | /******************************************* |
| 129 | * Error Code Definition |
| 130 | ********************************************/ |
| 131 | |
| 132 | #define RAW_DISK_ERR_NONE 0 |
| 133 | #define RAW_DISK_ERR_WRONG_ADDRESS 2 |
| 134 | #define RAW_DISK_ERR_NO_SPACE 3 |
| 135 | |
| 136 | |
| 137 | #define RAW_DISK_ERR_PROG_FAIL 5 |
| 138 | #define RAW_DISK_ERR_ERASE_FAIL 6 |
| 139 | |
| 140 | #define ERROR_NOR_SUCCESS (0) //(ERROR_FOTA_SUCCESS) |
| 141 | #define ERROR_NOR_READ (-13) //(ERROR_FOTA_READ) |
| 142 | #define ERROR_NOR_PROGRAM (-14) //(ERROR_FOTA_PROGRAM) |
| 143 | #define ERROR_NOR_ERASE (-15) //(ERROR_FOTA_ERASE) |
| 144 | #define ERROR_NOR_OVERRANGE (-1) //(ERROR_FOTA_OVERRANGE) |
| 145 | |
| 146 | /******************************************* |
| 147 | * Structure and Macro Definition |
| 148 | ********************************************/ |
| 149 | |
| 150 | #define FLASH_DISK_DONE FS_NO_ERROR |
| 151 | |
| 152 | #define NOR_FLASH_PAGE_SIZE 0x800 //default 2KB page |
| 153 | #define NOR_FLASH_PAGE_SHIFT 11 |
| 154 | |
| 155 | |
| 156 | /******************************************* |
| 157 | * Function and Variable Definition |
| 158 | ********************************************/ |
| 159 | |
| 160 | /* TC01 security partition API */ |
| 161 | #ifdef __CUSTOMER_TC01_DISK__ |
| 162 | #define TC01_DISK RAW_DISK1 |
| 163 | #define TC01_DISK_BLOCK_SIZE 0x4000 |
| 164 | #define TC01_DISK_PAGE_SIZE 0x800 //default 2KB page |
| 165 | #define TC01_DISK_PAGE_SHIFT 11 |
| 166 | kal_int32 EraseRawDataItem(kal_uint32 block_idx); |
| 167 | kal_int32 ReadRawDataItem(kal_uint32 block_idx, kal_uint32 page_idx, kal_uint32 length, kal_uint8* data_ptr); |
| 168 | kal_int32 WriteRawDataItem(kal_uint32 block_idx, kal_uint32 page_idx, kal_uint32 length, kal_uint8* data_ptr); |
| 169 | #endif //__CUSTOMER_TC01_DISK__ |
| 170 | |
| 171 | /* Backup partition API*/ |
| 172 | |
| 173 | /* NOR driver API for Secure Storage(in MAUI) */ |
| 174 | |
| 175 | kal_int32 NOR_init (void); |
| 176 | //kal_int32 NOR_QueryInfo (Logical_Flash_info info); |
| 177 | kal_int32 NOR_ReadPhysicalPage (kal_uint32 block_idx, kal_uint32 page_idx, kal_uint8 * data_ptr); |
| 178 | #ifdef __NOR_FULL_DRIVER__ |
| 179 | kal_int32 NOR_ProgramPhysicalPage (kal_uint32 block_idx, kal_uint32 page_idx, kal_uint8 * data_ptr); |
| 180 | kal_int32 NOR_ErasePhysicalBlock (kal_uint32 block_idx); |
| 181 | #endif //__NOR_FULL_DRIVER__ |
| 182 | kal_uint32 NOR_BlockSize(kal_uint32 block_idx); |
| 183 | kal_uint32 NOR_BlockIndex(kal_uint32 block_addr); |
| 184 | kal_int32 NOR_Addr2BlockIndexOffset(kal_uint32 block_addr, kal_uint32 *block_index, kal_uint32 *offset); |
| 185 | kal_int32 NOR_BlockIndexOffset2Addr(kal_uint32 block_index, kal_uint32 offset, kal_uint32 *addr); |
| 186 | |
| 187 | #endif // !_NAND_FLASH_BOOTING__ && !__NOR_FDM5__ |
| 188 | #endif //__MTK_TARGET__ |
| 189 | #endif //__FLASH_DISK_H__ |