yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @file upi_fotaflag_partition.h |
| 3 | * @brief °æ±¾·ÖÇøÅäÖÃÐÅÏ¢ |
| 4 | * |
| 5 | * Copyright (C) 2017 Sanechips Technology Co., Ltd. |
| 6 | * @author |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | #ifndef _UPI_FOTAFLAG_PARTITION_H |
| 11 | #define _UPI_FOTAFLAG_PARTITION_H |
| 12 | |
| 13 | /******************************************************************************* |
| 14 | * Include header files * |
| 15 | ******************************************************************************/ |
| 16 | |
| 17 | |
| 18 | /******************************************************************************* |
| 19 | * Macro definitions * |
| 20 | ******************************************************************************/ |
| 21 | |
| 22 | // fotaflagÔÚzftl5ÖÐÕ¼ÓõÄ×Ö½ÚÊý |
| 23 | #define FOTA_FLAG_SIZE (32) |
| 24 | |
| 25 | |
| 26 | |
| 27 | // fotaflag ±éÀúÓú궨Òå |
| 28 | #define ZTE_DUA_FOTAFLAG_PART ("/device/name") |
| 29 | #define ZTE_DUA_FOTAFLAG ("fotaflag") |
| 30 | #define ZTE_DUA_PART_UPDATED_DEV ("/dev") |
| 31 | #define ZTE_DUA_FOTAFLAG_BLOCK_PART ("/sys/class/block") |
| 32 | |
| 33 | |
| 34 | /* Êý¾ÝÀàÐÍ */ |
| 35 | typedef enum |
| 36 | { |
| 37 | SYSTEM_FLAG_FOTA_MAIN = 0, |
| 38 | SYSTEM_FLAG_FOTA_BACKUP, |
| 39 | } E_SYSTEM_FLAG_DATA_TYPE; |
| 40 | |
| 41 | |
| 42 | |
| 43 | /******************************************************************************* |
| 44 | * Type definitions * |
| 45 | ******************************************************************************/ |
| 46 | |
| 47 | /* ÔÚflags·ÖÇøÀïÆ«ÒÆµØÖ· */ |
| 48 | |
| 49 | #define FLAGS_MAGIC (0x464C4147UL) |
| 50 | |
| 51 | |
| 52 | |
| 53 | #define DUALSYSTEM_STATUS_BOOTABLE (0xB0AB) /* ¿ÉÆô¶¯ */ |
| 54 | #define DUALSYSTEM_STATUS_SUCCESSFUL (0x5CCF) /* Äܳɹ¦Æô¶¯ */ |
| 55 | #define DUALSYSTEM_STATUS_UNBOOTABLE (0xBABE) /* ²»¿ÉÆô¶¯ */ |
| 56 | |
| 57 | typedef struct |
| 58 | { |
| 59 | int status; /* bootable/successful/unbootable */ |
| 60 | int try_cnt; |
| 61 | } T_DualSystem_Status; |
| 62 | |
| 63 | typedef enum |
| 64 | { |
| 65 | DUAL_SYSTEM = 0x875A, /* µÚÒ»¸öϵͳ */ |
| 66 | DUAL_SYSTEM2 = 0x986B, /* µÚ¶þ¸öϵͳ */ |
| 67 | } T_BOOT_TARGET; |
| 68 | |
| 69 | /* ˫ϵͳÀàÐÍ */ |
| 70 | typedef enum |
| 71 | { |
| 72 | DUALSYSTEM_RECOVERY = 0x7575, /* normal-recovery˫ϵͳ */ |
| 73 | DUALSYSTEM_AA = 0xAAAA, /* AA˫ϵͳ */ |
| 74 | DUALSYSTEM_AB = 0xABAB /* AB˫ϵͳ */ |
| 75 | } T_BOOT_DUALSYSTEM_TYPE; |
| 76 | |
| 77 | typedef struct |
| 78 | { |
| 79 | unsigned int magic; /* Êý¾ÝÓÐЧÐÔħÊõ×Ö */ |
| 80 | T_BOOT_TARGET boot_to; /* µ±Ç°Æô¶¯ÏµÍ³±êÖ¾*/ |
| 81 | unsigned int fota_status; /* fota״̬ */ |
| 82 | T_DualSystem_Status system; /* µÚÒ»¸öϵͳ״̬ */ |
| 83 | T_DualSystem_Status system2; /* µÚ¶þ¸öϵͳ״̬ */ |
| 84 | } T_BOOT_FOTA_FLAG; |
| 85 | |
| 86 | typedef struct |
| 87 | { |
| 88 | unsigned int magic; /* Êý¾ÝÓÐЧÐÔħÊõ×Ö */ |
| 89 | T_BOOT_DUALSYSTEM_TYPE dualsys_type; /* ˫ϵͳÀàÐÍ */ |
| 90 | char system_boot_env[128]; |
| 91 | char system2_boot_env[128]; |
| 92 | } T_BOOT_ENV; |
| 93 | |
| 94 | |
| 95 | typedef struct |
| 96 | { |
| 97 | T_BOOT_FOTA_FLAG boot_flag; |
| 98 | T_BOOT_ENV boot_env; |
| 99 | } T_FOTA_FLAG_INFO; |
| 100 | |
| 101 | |
| 102 | |
| 103 | /******************************************************************************* |
| 104 | * Global variable declarations * |
| 105 | ******************************************************************************/ |
| 106 | |
| 107 | |
| 108 | /******************************************************************************* |
| 109 | * Global function declarations * |
| 110 | ******************************************************************************/ |
| 111 | |
| 112 | void upi_reboot(); |
| 113 | int check_fota_flag_partition(void); |
| 114 | |
| 115 | |
| 116 | |
| 117 | int upi_get_boot_env(T_BOOT_ENV* boot_env); |
| 118 | int upi_set_boot_fota_flag(T_BOOT_FOTA_FLAG* fota_flag); |
| 119 | int upi_get_system_boot_to(); |
| 120 | int upi_set_system_boot_to(int boot_to, int boot_to_status); |
| 121 | int upi_set_system_status(int system, int status); |
| 122 | |
| 123 | int upi_get_boot_flag(T_BOOT_FOTA_FLAG *boot_flag); |
| 124 | int init_fotaflag_partition(); |
| 125 | |
| 126 | int upi_get_system_info(T_FOTA_FLAG_INFO *p_system_info); |
| 127 | |
| 128 | // Éý¼¶ºófota±êÖ¾£¬Ö÷ÒªÓÃÀ´±êÖ¾ÊÇ·ñÐèҪͬ²½NV |
| 129 | int upi_get_system_fota_status(); |
| 130 | int upi_set_system_fota_stauts(int status); |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | /******************************************************************************* |
| 136 | * Inline function implementations * |
| 137 | ******************************************************************************/ |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | #endif // _UPI_FOTAFLAG_PARTITION_H |
| 143 | |