1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef __BOOT_UPG_START_UP_H 17 #define __BOOT_UPG_START_UP_H 18 19 #include <boot_upg_common.h> 20 21 #define ENV_REFRESH_NV 0x55 22 23 #define HI_UPG_MODE_NORMAL 0 /* normal mode */ 24 #define HI_UPG_MODE_UPGRADE 1 /* upgrade mode */ 25 #define UPG_MAX_BACKUP_CNT 3 26 27 #define HI_NV_FTM_STARTUP_CFG_ID 0x3 28 #define HI_NV_FTM_FACTORY_MODE 0x9 29 30 typedef struct { 31 uintptr_t addr_start; /* boot start address */ 32 hi_u16 mode; /* upgrade mode */ 33 hi_u8 file_type; /* file type:boot or code+nv */ 34 hi_u8 refresh_nv; /* refresh nv when the flag bit 0x55 is read */ 35 hi_u8 reset_cnt; /* number of restarts in upgrade mode */ 36 hi_u8 cnt_max; /* the maximum number of restarts (default value : 3) */ 37 hi_u16 reserved1; 38 uintptr_t addr_write; /* write kernel upgrade file address */ 39 hi_u32 reserved2; /* 2: reserved bytes */ 40 } hi_nv_ftm_startup_cfg; 41 42 typedef struct { 43 hi_u32 factory_mode; /* 0:normal_mode;1:factory_mode */ 44 uintptr_t factory_addr_start; /* factory bin start address */ 45 hi_u32 factory_size; /* factory bin size */ 46 hi_u32 factory_valid; /* 0:invalid;1:valid */ 47 }hi_nv_ftm_factory_mode; 48 49 hi_u32 boot_upg_save_cfg_to_nv(hi_void); 50 hi_void boot_upg_load_cfg_from_nv(hi_void); 51 hi_nv_ftm_startup_cfg *boot_upg_get_cfg(hi_void); 52 53 #endif /* __BOOT_UPG_START_UP_H */ 54