xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @file pub_flags.h |
| 3 | * @brief flags·ÖÇø×Ö¶Î |
| 4 | * |
| 5 | * Copyright (C) 2023 Sanechips Technology Co., Ltd. |
| 6 | * @author |
| 7 | * @ingroup |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. £¨±ØÑ¡£ºGPLv2 Licence£© |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | |
| 16 | #ifndef _PUB_FLAGS_H |
| 17 | #define _PUB_FLAGS_H |
| 18 | |
| 19 | |
| 20 | /******************************************************************************* |
| 21 | * Include header files * |
| 22 | ******************************************************************************/ |
| 23 | |
| 24 | |
| 25 | /******************************************************************************* |
| 26 | * Macro definitions * |
| 27 | ******************************************************************************/ |
| 28 | /** |
| 29 | * @brief ÔÚflags·ÖÇøÀïÆ«ÒÆµØÖ· |
| 30 | */ |
| 31 | #define FLAGS_MAGIC (0x464C4147UL) |
| 32 | |
| 33 | #define DUALSYSTEM_STATUS_BOOTABLE (0xB0AB) /* ¿ÉÆô¶¯ */ |
| 34 | #define DUALSYSTEM_STATUS_SUCCESSFUL (0x5CCF) /* Äܳɹ¦Æô¶¯ */ |
| 35 | #define DUALSYSTEM_STATUS_UNBOOTABLE (0xBABE) /* ²»¿ÉÆô¶¯ */ |
| 36 | |
xf.li | ce87319 | 2023-11-08 17:10:35 -0800 | [diff] [blame] | 37 | #define OTA_PARTITION_NUM_MAX 15 |
| 38 | |
xf.li | 7ccf837 | 2024-03-07 00:08:02 -0800 | [diff] [blame] | 39 | #define IMG_NAME_LEN 16 |
| 40 | #define IMG_NUM_MAX 15 |
| 41 | |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 42 | |
| 43 | /******************************************************************************* |
| 44 | * Type definitions * |
| 45 | ******************************************************************************/ |
| 46 | typedef struct |
| 47 | { |
| 48 | int status; /* bootable/successful/unbootable */ |
| 49 | int try_cnt; |
| 50 | } T_DualSystem_Status; |
| 51 | |
| 52 | typedef enum |
| 53 | { |
| 54 | DUAL_SYSTEM = 0x875A, /* µÚÒ»¸öϵͳ */ |
| 55 | DUAL_SYSTEM2 = 0x986B, /* µÚ¶þ¸öϵͳ */ |
| 56 | } T_BOOT_TARGET; |
| 57 | |
xf.li | aa4d92f | 2023-09-13 00:18:58 -0700 | [diff] [blame] | 58 | #define NVRO_INIT (0) /* initial state */ |
| 59 | #define NVRO_BACKED_UP (0xBACE) /* nvro backed up already */ |
xf.li | e31de8b | 2023-12-26 23:38:58 -0800 | [diff] [blame] | 60 | #define NVRO_BACKING_UP (0xBAC1) /* nvro back up next boot */ |
xf.li | aa4d92f | 2023-09-13 00:18:58 -0700 | [diff] [blame] | 61 | #define NVRO_RESTORING (0x2E20) /* nvro restoring */ |
| 62 | #define NVRO_INVALID (0xDEAD) /* nvro invalid */ |
| 63 | |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 64 | /* ˫ϵͳÀàÐÍ */ |
| 65 | typedef enum |
| 66 | { |
| 67 | DUALSYSTEM_RECOVERY = 0x7575, /* normal-recovery˫ϵͳ */ |
| 68 | DUALSYSTEM_AA = 0xAAAA, /* AA˫ϵͳ */ |
| 69 | DUALSYSTEM_AB = 0xABAB /* AB˫ϵͳ */ |
| 70 | } T_BOOT_DUALSYSTEM_TYPE; |
| 71 | |
| 72 | typedef struct |
| 73 | { |
| 74 | T_BOOT_TARGET boot_to; /* µ±Ç°Æô¶¯ÏµÍ³±êÖ¾*/ |
| 75 | unsigned int fota_status; /* fota״̬ */ |
| 76 | T_DualSystem_Status system; /* µÚÒ»¸öϵͳ״̬ */ |
| 77 | T_DualSystem_Status system2; /* µÚ¶þ¸öϵͳ״̬ */ |
| 78 | } T_BOOT_FOTA_FLAG; |
| 79 | |
| 80 | typedef struct |
| 81 | { |
| 82 | T_BOOT_DUALSYSTEM_TYPE dualsys_type; /* ˫ϵͳÀàÐÍ */ |
| 83 | char system_boot_env[128]; |
| 84 | char system2_boot_env[128]; |
| 85 | } T_BOOT_ENV; |
| 86 | |
| 87 | typedef struct |
| 88 | { |
| 89 | int fs_status; /* ÎļþϵͳÒì³£±êʶ */ |
| 90 | char fs_mtd_name[16]; |
| 91 | char fs_ubi_vol_name[16]; |
| 92 | } T_UBIFS_STATUS; |
| 93 | |
xf.li | 7ccf837 | 2024-03-07 00:08:02 -0800 | [diff] [blame] | 94 | typedef struct |
| 95 | { |
xf.li | ce87319 | 2023-11-08 17:10:35 -0800 | [diff] [blame] | 96 | int mtdnum; |
| 97 | unsigned int len; |
| 98 | } T_AA_PARTITION_INFO; |
| 99 | |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 100 | typedef struct |
| 101 | { |
xf.li | 7ccf837 | 2024-03-07 00:08:02 -0800 | [diff] [blame] | 102 | char name[IMG_NAME_LEN]; |
| 103 | unsigned int size_a; |
| 104 | unsigned int size_b; |
| 105 | } T_IMG_SIZE; |
| 106 | |
| 107 | typedef struct |
| 108 | { |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 109 | unsigned int magic_start; /* Êý¾ÝÓÐЧÐÔħÊõ×Ö */ |
| 110 | |
| 111 | T_BOOT_FOTA_FLAG boot_fota_flag; |
| 112 | T_BOOT_ENV boot_env; |
| 113 | T_UBIFS_STATUS ubifs_status; |
xf.li | aa4d92f | 2023-09-13 00:18:58 -0700 | [diff] [blame] | 114 | unsigned int nvro_flag; |
xf.li | ce87319 | 2023-11-08 17:10:35 -0800 | [diff] [blame] | 115 | unsigned int crc32; |
| 116 | T_BOOT_TARGET ota_system; /* Éý¼¶Ê±ÊÇϵͳA»¹ÊÇϵͳB */ |
| 117 | T_AA_PARTITION_INFO ota_partiton_info[OTA_PARTITION_NUM_MAX]; /* ÈÝÄÉ×î¶à15¸öÉý¼¶·ÖÇøµÄimage¾µÏñ´óС */ |
xf.li | 7ccf837 | 2024-03-07 00:08:02 -0800 | [diff] [blame] | 118 | unsigned int poweron_time; |
| 119 | char reserve[48]; |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 120 | unsigned int magic_end; /* Êý¾ÝÓÐЧÐÔħÊõ×Ö */ |
xf.li | 7ccf837 | 2024-03-07 00:08:02 -0800 | [diff] [blame] | 121 | T_IMG_SIZE img_size[IMG_NUM_MAX]; /* ±£´æÏµÍ³¾µÏñÎļþ´óС */ |
| 122 | T_BOOT_TARGET sync_system; /* ͬ²½Ê±ÊÇϵͳA»¹ÊÇϵͳB */ |
| 123 | unsigned int crc32_1; |
| 124 | int reserve2[292]; /* ±£ÁôÀ©Õ¹×Ö¶Î */ |
xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame] | 125 | } T_FLAGS_INFO; |
| 126 | |
| 127 | |
| 128 | #endif // _PUB_FLAGS_H |
| 129 | |