yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [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) 2006 |
| 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 | * fota_gprot.h |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * Maui_Software |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * This is the header file of exproted functions for MMI |
| 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 | *------------------------------------------------------------------------------ |
| 79 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 80 | *============================================================================ |
| 81 | ****************************************************************************/ |
| 82 | |
| 83 | #ifndef __FOTA_H__ |
| 84 | #define __FOTA_H__ |
| 85 | |
| 86 | /******************************************* |
| 87 | * Include File |
| 88 | ********************************************/ |
| 89 | |
| 90 | #include "kal_general_types.h" |
| 91 | #include "fota_error.h" |
| 92 | #include "custom_img_config.h" |
| 93 | #include "ssf_interface.h" |
| 94 | |
| 95 | |
| 96 | /******************************************* |
| 97 | * Structure and Macro Definition |
| 98 | ********************************************/ |
| 99 | typedef enum { |
| 100 | FOTA_UPDATE_SUCCEEDED, |
| 101 | FOTA_UPDATE_FAILED, |
| 102 | FOTA_UPDATE_NONE, |
| 103 | FOTA_UPDATE_END |
| 104 | } FOTA_update_result; |
| 105 | |
| 106 | /******************************************* |
| 107 | * Function and Variable Definition |
| 108 | ********************************************/ |
| 109 | |
| 110 | /* --------------------------------------------------------------------------------- |
| 111 | * MAUI FOTA driver API |
| 112 | --------------------------------------------------------------------------------- */ |
| 113 | |
| 114 | /* --------------------------------------------------------------------------------- |
| 115 | FUNCTION |
| 116 | FOTA_Initialize |
| 117 | DESCRIPTION |
| 118 | FOTA Initialization API |
| 119 | 1. Initialize data structure and progress initial step |
| 120 | 2. Register customized authentication function or encryption function |
| 121 | PARAMETER |
| 122 | NULL |
| 123 | RETURN |
| 124 | 0: means pass initialization step (ERROR_FOTA_SUCCESS) |
| 125 | < 0: means fail |
| 126 | ERROR_FOTA_CUSTOMIZATION: wrong customization |
| 127 | --------------------------------------------------------------------------------- */ |
| 128 | extern kal_int32 FOTA_Initialize(void); |
| 129 | |
| 130 | /* --------------------------------------------------------------------------------- |
| 131 | FUNCTION |
| 132 | FOTA_WriteData |
| 133 | DESCRIPTION |
| 134 | FOTA write data API |
| 135 | 1. This function is used to write data to spare image pool |
| 136 | 2. This API only allow sequentially writing mechanism |
| 137 | 3. Authentication mechanism is executed during writing |
| 138 | PARAMETER |
| 139 | Length: the length of writing (Unit: Bytes) |
| 140 | Buffer: the start address of buffer |
| 141 | RETURN |
| 142 | 0: means pass write success (ERROR_FOTA_SUCCESS) |
| 143 | < 0: writing action is fail |
| 144 | ERROR_FOTA_AUTH_ROMINFO: authentication fail, can't find rom info |
| 145 | ERROR_FOTA_AUTH_FATBEGIN: authentication fail, fat begin address is different |
| 146 | ERROR_FOTA_AUTH_FATLEN: authentication fail, fat length is different |
| 147 | ERROR_FOTA_AUTH_HCHECKSUM: authentication fail, header checksum fail |
| 148 | ERROR_FOTA_AUTH_ID: authentication fail, platform id is different |
| 149 | ERROR_FOTA_AUTH_VERSION: authentication fail, downgrade is not allowed |
| 150 | ERROR_FOTA_AUTH_IMAGELEN: authentication fail, image length too large |
| 151 | ERROR_FOTA_AUTH_FAIL: authentication fail before |
| 152 | ERROR_FOTA_OVERRANGE: write over the spare image pool range |
| 153 | ERROR_FOTA_NOT_INITIALIZED: not call FOTA_Initialize before |
| 154 | --------------------------------------------------------------------------------- */ |
| 155 | extern kal_int32 FOTA_WriteData(kal_uint32 Length, void* Buffer); |
| 156 | |
| 157 | /* --------------------------------------------------------------------------------- |
| 158 | FUNCTION |
| 159 | FOTA_ReadData |
| 160 | DESCRIPTION |
| 161 | FOTA read data API |
| 162 | 1. This function is used to read data from spare image pool |
| 163 | 2. This API only support sequentially read operation, i.e. from low address to high address |
| 164 | PARAMETER |
| 165 | Length: the length of writing (Unit: Bytes) |
| 166 | Buffer: the start address of buffer |
| 167 | RETURN |
| 168 | 0: means pass write success (ERROR_FOTA_SUCCESS) |
| 169 | < 0: writing action is fail |
| 170 | ERROR_FOTA_AUTH_ROMINFO: authentication fail, can't find rom info |
| 171 | ERROR_FOTA_AUTH_FATBEGIN: authentication fail, fat begin address is different |
| 172 | ERROR_FOTA_AUTH_FATLEN: authentication fail, fat length is different |
| 173 | ERROR_FOTA_AUTH_HCHECKSUM: authentication fail, header checksum fail |
| 174 | ERROR_FOTA_AUTH_ID: authentication fail, platform id is different |
| 175 | ERROR_FOTA_AUTH_VERSION: authentication fail, downgrade is not allowed |
| 176 | ERROR_FOTA_AUTH_IMAGELEN: authentication fail, image length too large |
| 177 | ERROR_FOTA_AUTH_FAIL: authentication fail before |
| 178 | ERROR_FOTA_OVERRANGE: write over the spare image pool range |
| 179 | ERROR_FOTA_NOT_INITIALIZED: not call FOTA_Initialize before |
| 180 | --------------------------------------------------------------------------------- */ |
| 181 | extern kal_int32 FOTA_ReadData(kal_uint32 Length, void* Buffer); |
| 182 | |
| 183 | /* --------------------------------------------------------------------------------- |
| 184 | FUNCTION |
| 185 | FOTA_Get_DownloadedPackageSize |
| 186 | DESCRIPTION |
| 187 | return currently downloaded package size |
| 188 | PARAMETER |
| 189 | NULL |
| 190 | RETURN |
| 191 | 0: means pass initialization step (ERROR_FOTA_SUCCESS) |
| 192 | < 0: means fail |
| 193 | ERROR_FOTA_CUSTOMIZATION: wrong customization |
| 194 | --------------------------------------------------------------------------------- */ |
| 195 | kal_int32 FOTA_Get_DownloadedPackageSize(kal_uint32 *curr_size); |
| 196 | |
| 197 | /* --------------------------------------------------------------------------------- |
| 198 | FUNCTION |
| 199 | FOTA_ClearPackageReservoir |
| 200 | DESCRIPTION |
| 201 | clear downloaded update package |
| 202 | PARAMETER |
| 203 | NULL |
| 204 | RETURN |
| 205 | 0: means pass initialization step (ERROR_FOTA_SUCCESS) |
| 206 | < 0: means fail |
| 207 | ERROR_FOTA_CUSTOMIZATION: wrong customization |
| 208 | --------------------------------------------------------------------------------- */ |
| 209 | kal_int32 FOTA_ClearPackageReservoir(void); |
| 210 | |
| 211 | /* --------------------------------------------------------------------------------- |
| 212 | FUNCTION |
| 213 | FOTA_Get_AvailablePackageSpace |
| 214 | DESCRIPTION |
| 215 | return currently downloaded package size |
| 216 | PARAMETER |
| 217 | NULL |
| 218 | RETURN |
| 219 | 0: means pass initialization step (ERROR_FOTA_SUCCESS) |
| 220 | < 0: means fail |
| 221 | ERROR_FOTA_CUSTOMIZATION: wrong customization |
| 222 | --------------------------------------------------------------------------------- */ |
| 223 | kal_int32 FOTA_Get_AvailablePackageSpace(kal_uint32 *avail_size); |
| 224 | |
| 225 | /* --------------------------------------------------------------------------------- |
| 226 | FUNCTION |
| 227 | FOTA_Get_TotalPackageSpace |
| 228 | DESCRIPTION |
| 229 | return currently downloaded package size |
| 230 | PARAMETER |
| 231 | NULL |
| 232 | RETURN |
| 233 | 0: means pass initialization step (ERROR_FOTA_SUCCESS) |
| 234 | < 0: means fail |
| 235 | ERROR_FOTA_CUSTOMIZATION: wrong customization |
| 236 | --------------------------------------------------------------------------------- */ |
| 237 | kal_int32 FOTA_Get_TotalPackageSpace(kal_uint32 *avail_size); |
| 238 | |
| 239 | /* --------------------------------------------------------------------------------- |
| 240 | FUNCTION |
| 241 | FOTA_WriteUpdateRecord |
| 242 | DESCRIPTION |
| 243 | FOTA update state information write API |
| 244 | download client and update agent use this information to communicate with each other |
| 245 | PARAMETER |
| 246 | NULL |
| 247 | RETURN |
| 248 | 0: means pass initialization step (ERROR_FOTA_SUCCESS) |
| 249 | < 0: means fail |
| 250 | ERROR_FOTA_CUSTOMIZATION: wrong customization |
| 251 | --------------------------------------------------------------------------------- */ |
| 252 | extern kal_int32 FOTA_WriteUpdateRecord(FOTA_Custom_Update_Info* record); |
| 253 | |
| 254 | /* --------------------------------------------------------------------------------- |
| 255 | FUNCTION |
| 256 | FOTA_ReadUpdateRecord |
| 257 | DESCRIPTION |
| 258 | FOTA update state information read API |
| 259 | download client and update agent use this information to communicate with each other |
| 260 | PARAMETER |
| 261 | NULL |
| 262 | RETURN |
| 263 | 0: means pass initialization step (ERROR_FOTA_SUCCESS) |
| 264 | < 0: means fail |
| 265 | ERROR_FOTA_CUSTOMIZATION: wrong customization |
| 266 | --------------------------------------------------------------------------------- */ |
| 267 | extern kal_int32 FOTA_ReadUpdateRecord(FOTA_Custom_Update_Info* record); |
| 268 | |
| 269 | /* --------------------------------------------------------------------------------- |
| 270 | FUNCTION |
| 271 | FOTA_Finalize |
| 272 | DESCRIPTION |
| 273 | FOTA finalization API |
| 274 | 1. compare calculated checksum with image checksum in the header after |
| 275 | whole image is written |
| 276 | 2. mark the status to UPDATE_NEEDED |
| 277 | PARAMETER |
| 278 | void |
| 279 | RETURN |
| 280 | 0: means pass error check step (ERROR_FOTA_SUCCESS) |
| 281 | < 0: means fail |
| 282 | ERROR_FOTA_AUTH_FAIL: authentication fail, final step is not allowed |
| 283 | ERROR_FOTA_IMAGE_CHECKSUM: image checksum error |
| 284 | --------------------------------------------------------------------------------- */ |
| 285 | extern kal_int32 FOTA_Finalize(void); |
| 286 | |
| 287 | /* --------------------------------------------------------------------------------- |
| 288 | FUNCTION |
| 289 | FOTA_InitializeUpdateRecord |
| 290 | DESCRIPTION |
| 291 | create an update record block or find out the existing update record block |
| 292 | PARAMETER |
| 293 | NULL |
| 294 | RETURN |
| 295 | 0: means pass initialization step (ERROR_FOTA_SUCCESS) |
| 296 | < 0: means fail |
| 297 | ERROR_FOTA_CUSTOMIZATION: wrong customization |
| 298 | --------------------------------------------------------------------------------- */ |
| 299 | kal_int32 FOTA_InitializeUpdateRecord(void); |
| 300 | |
| 301 | /* --------------------------------------------------------------------------------- |
| 302 | FUNCTION |
| 303 | FOTA_Inform_Update_State |
| 304 | DESCRIPTION |
| 305 | Query the status of triggered update process |
| 306 | PARAMETER |
| 307 | NONE |
| 308 | RETURN |
| 309 | NULL |
| 310 | --------------------------------------------------------------------------------- */ |
| 311 | FOTA_update_result FOTA_Inform_Update_State(void); |
| 312 | |
| 313 | /* --------------------------------------------------------------------------------- |
| 314 | FUNCTION |
| 315 | FOTA_Start_Download_State |
| 316 | DESCRIPTION |
| 317 | Download client use this function to query the result of update process |
| 318 | PARAMETER |
| 319 | NULL |
| 320 | RETURN |
| 321 | --------------------------------------------------------------------------------- */ |
| 322 | kal_int32 FOTA_Start_Download_State(void); |
| 323 | |
| 324 | /* --------------------------------------------------------------------------------- |
| 325 | FUNCTION |
| 326 | FOTA_Start_Update_State |
| 327 | DESCRIPTION |
| 328 | Download client use this function to query the result of update process |
| 329 | PARAMETER |
| 330 | NULL |
| 331 | RETURN |
| 332 | --------------------------------------------------------------------------------- */ |
| 333 | kal_int32 FOTA_Start_Update_State(void); |
| 334 | |
| 335 | #endif //__FOTA_H__ |
| 336 | |