lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Author(s): wang.yuesheng |
| 3 | * Date: 2009-02-26 |
| 4 | * Purpose: |
| 5 | * Description: bootË«°æ±¾ËÑË÷¼°Æô¶¯Ö§³Ö |
| 6 | */ |
| 7 | |
| 8 | #include <config.h> |
| 9 | |
| 10 | |
| 11 | |
| 12 | #ifndef _CMD_DOWNVER_H_ |
| 13 | #define _CMD_DOWNVER_H_ |
| 14 | |
| 15 | |
| 16 | /* °æ±¾×´Ì¬±êÖ¾²âÊÔλ */ |
| 17 | #define CFG_TB_LATELY 0x01 /* °æ±¾Ð¾ÉÐÔ±ê־λ */ |
| 18 | #define CFG_TB_INTACT 0x02 /* °æ±¾ÍêÕûÐÔ±ê־λ */ |
| 19 | #define CFG_TB_KERNEL 0x04 /* ÄÚºËÍêÕûÐÔ±ê־λ */ |
| 20 | #define CFG_TB_ROOTFS 0x08 /* ÎļþϵͳÍêÕûÐÔ±ê־λ */ |
| 21 | #define CFG_TB_SYNCED 0x10 /* °æ±¾À´Ô´±ê־λ */ |
| 22 | #define CFG_TB_HEADER 0x80 /* °æ±¾Í·ÍêÕûÐÔ±ê־λ */ |
| 23 | |
| 24 | /* ¸ùÎļþϵͳÀàÐͶ¨Òå */ |
| 25 | #define CFG_FS_NONE 0x00 /* none */ |
| 26 | #define CFG_FS_INITRAM 0x01 /* initramfs */ |
| 27 | #define CFG_FS_JFFS2 0x02 /* jffs2 */ |
| 28 | #define CFG_FS_SQUASH 0x04 /* squashfs */ |
| 29 | |
| 30 | /* ¸ùÎļþϵͳ»ÃÊý */ |
| 31 | #define SQUASHFS_MAGIC 0x73717368 |
| 32 | #define SQUASHFS_MAGIC_SWAP 0x68737173 |
| 33 | #ifdef __BIG_ENDIAN |
| 34 | #define JFFS2_DIRENT_MAGIC 0x1985E001 |
| 35 | #define JFFS2_INODE_MAGIC 0x1985E002 |
| 36 | #define JFFS2_CLEANMARKER_MAGIC 0x19852003 |
| 37 | #define JFFS2_PADDING_MAGIC 0x19852004 |
| 38 | #define JFFS2_SUMMARY_MAGIC 0x19852006 |
| 39 | #define JFFS2_RWDELETE_MAGIC 0x19850003 |
| 40 | #else |
| 41 | #define JFFS2_DIRENT_MAGIC 0xE0011985 |
| 42 | #define JFFS2_INODE_MAGIC 0xE0021985 |
| 43 | #define JFFS2_CLEANMARKER_MAGIC 0x20031985 |
| 44 | #define JFFS2_PADDING_MAGIC 0x20041985 |
| 45 | #define JFFS2_SUMMARY_MAGIC 0x20061985 |
| 46 | #define JFFS2_RWDELETE_MAGIC 0x00031985 |
| 47 | #endif |
| 48 | #define CFG_EMPTY_BITMASK 0xFFFFFFFF |
| 49 | #define CFG_IMAGE_OKAY 0x00000000 |
| 50 | |
| 51 | #define MAGIC_MAX 4 // »ÃÊý¸öÊý |
| 52 | #define DESC_LEN 32 // °æ±¾ÃèÊö³¤¶È |
| 53 | #define RESV_LEN 16 // ±£Áô×ֶγ¤¶È |
| 54 | #define CSP_HEADER_LEN 256 // °æ±¾Í·³¤¶È |
| 55 | #define CFG_ALLIGN_SIZE 16 |
| 56 | |
| 57 | /* °æ±¾Í·»ÃÊý */ |
| 58 | #define CSP_MAGIC0 0x99999999 |
| 59 | #define CSP_MAGIC1 0x44444444 |
| 60 | #define CSP_MAGIC2 0x55555555 |
| 61 | #define CSP_MAGIC3 0xaaaaaaaa |
| 62 | |
| 63 | #define IMAGE_BAD 0xffffffff // °æ±¾Ë𻵠|
| 64 | #define IMAGE_OKAY 0x00000000 // °æ±¾ÍêÕû |
| 65 | #define IMAGE_NEW 0xffffffff // а汾 |
| 66 | #define IMAGE_OLD 0x00000000 // ¾É°æ±¾ |
| 67 | #define IMAGE_UPGRADE 0xffffffff // À´Ô´ÓÚÉý¼¶ |
| 68 | #define IMAGE_SYNCED 0x00000000 // À´Ô´ÓÚͬ²½ |
| 69 | |
| 70 | /* ÓïÒôÐÒéÀàÐÍ */ |
| 71 | #define VOIP_PROTO_NULL 0 |
| 72 | #define VOIP_PROTO_H248 1 |
| 73 | #define VOIP_PROTO_SIP 2 |
| 74 | #define VOIP_PROTO_MGCP 3 |
| 75 | #define VOIP_PROTO_UNKNOWN 0xffff |
| 76 | |
| 77 | #define IH_HCRC_OFFSET (unsigned int)(&((hd_contend_desc*)0)->ih_hcrc) |
| 78 | #define ALIGN_SIZE16(x) (((x)/16+(((x)%16)?1:0))*16) |
| 79 | |
| 80 | typedef enum |
| 81 | { |
| 82 | FLASH_TYPE_NAND = 1, |
| 83 | FLASH_TYPE_NOR = 2, |
| 84 | FLASH_TYPE_INVALID = 255 |
| 85 | }FLASH_TYPE_E; |
| 86 | |
| 87 | |
| 88 | typedef enum VersionType |
| 89 | { |
| 90 | VERTYPE_BOOT = 1, |
| 91 | VERTYPE_KERNEL, |
| 92 | VERTYPE_ROOTFS, |
| 93 | VERTYPE_VERSION, |
| 94 | VERTYPE_INVALID = 255 |
| 95 | }VERSION_TYPE_E; |
| 96 | |
| 97 | |
| 98 | /* ƽ̨°æ±¾ÖвúÆ·´óÀà */ |
| 99 | typedef enum { |
| 100 | PRODUCT_SERIES_DHOME = 0, |
| 101 | PRODUCT_SERIES_XPON = 1, |
| 102 | PRODUCT_SERIES_STB = 2, |
| 103 | PRODUCT_SERIES_RFID = 3 |
| 104 | } PRODUCT_SERIES_ID; |
| 105 | |
| 106 | /* °æ±¾ÀàÐÍ: µ¥£¬Ë«£¬´óС */ |
| 107 | typedef enum { |
| 108 | VERSION_TYPE_SINGLE = 0, /* µ¥°æ±¾ */ |
| 109 | VERSION_TYPE_DOUBLE = 1, /* Ë«°æ±¾ */ |
| 110 | VERSION_TYPE_BIGSMALL= 2 /* ´óС°æ±¾ */ |
| 111 | } VERSION_TYPE_ID; |
| 112 | |
| 113 | |
| 114 | /* °æ±¾À´Ô´: δ֪£¬Éý¼¶¡¢Í¬²½ */ |
| 115 | typedef enum { |
| 116 | VERSION_FROM_UPGRAGE = 0, /* Éý¼¶°æ±¾ */ |
| 117 | VERSION_FROM_SYNC = 1 /* ͬ²½°æ±¾ */ |
| 118 | } VERSION_FROM_ID; |
| 119 | |
| 120 | |
| 121 | typedef struct { |
| 122 | short flags; /* °æ±¾×´Ì¬±ê־λ×é */ |
| 123 | short fstype; /* ¸ùÎļþϵͳµÄÀàÐÍ */ |
| 124 | long entry; /* °æ±¾Òýµ¼Èë¿ÚµØÖ· */ |
| 125 | unsigned int ih_size; /* Äں˴óС */ |
| 126 | } vstat_t; |
| 127 | |
| 128 | typedef struct { |
| 129 | int total; /* ËÑË÷µ½µÄ°æ±¾¸öÊý */ |
| 130 | vstat_t result[2]; /* ÓÐЧ°æ±¾µÄ״̬ */ |
| 131 | } search_desc; |
| 132 | |
| 133 | |
| 134 | typedef struct { |
| 135 | unsigned int ih_magic[MAGIC_MAX];/* °æ±¾Í·»ÃÊý */ |
| 136 | unsigned int ih_signatureSize; /* Ç©ÃûÇø´óС */ |
| 137 | char pSignature[0]; /* Ç©ÃûÇøÄÚÈÝ */ |
| 138 | } hd_magic_desc; |
| 139 | |
| 140 | typedef struct { |
| 141 | unsigned int productType; /* ²úÆ·´óÀà£DHome£¬STB£¬RFID£¬... */ |
| 142 | unsigned int firewareType; /* ¹Ì¼þÀàÐÍ£°æ±¾Îļþ£¬bootÎļþ£¬ÅäÖÃÎļþ£¬Ö¤ÊéÎļþ */ |
| 143 | unsigned int upgradeKey1; /* ͬһÀàCPEµ¥°åµÄ±àÂ룬Æä½â¾ö·½°¸Ïàͬ¡¢»ù±¾Ó²¼þÅäÖÃÏàͬ£¬¿ÉÔËÐжà¸ö²úÆ·µÄ°æ±¾ */ |
| 144 | unsigned int upgradeKey2; /* ͬһÀàCPEµ¥°å¶ÔÓ¦µÄÓжÀÁ¢°æ±¾µÄ²»Í¬²úÆ·±àÂë */ |
| 145 | char serialNum[16]; /* °æ±¾ºÅ */ |
| 146 | unsigned int headerVersion; /* Í·°æ±¾ºÅ£¬Ä¿Ç°±£Áô */ |
| 147 | unsigned int isExpanded; /* ÊÇ·ñʹÓø½¼Ó°æ±¾Í·£¬¸½¼Ó°æ±¾Í·ÔÙÀ©Õ¹256 ×Ö½Ú */ |
| 148 | unsigned int firewareSize; /* ¹Ì¼þ´óС£¬Ä¿Ç°±£Áô */ |
| 149 | }hd_general_desc; |
| 150 | |
| 151 | typedef struct { |
| 152 | unsigned int btMagic[4]; /* BOOT°æ±¾Í·»ÃÊý */ |
| 153 | char btNumbers[16]; /* BOOTÈí¼þ°æ±¾ºÅ */ |
| 154 | char btCtime[20]; /* BOOT°æ±¾µÄʱ¼ä */ |
| 155 | unsigned int btVerSize; /* BOOT°æ±¾µÄ³¤¶È */ |
| 156 | unsigned int btFlashOffset; /* BOOT°æ±¾FlashÆ«ÒÆµØÖ· */ |
| 157 | unsigned int btFlashSize; /* BOOT°æ±¾Flash·ÖÇø´óС */ |
| 158 | } hd_boot_file; |
| 159 | |
| 160 | |
| 161 | /* °æ±¾Í·ÄÚÈÝ */ |
| 162 | typedef struct { |
| 163 | unsigned short ih_form; /* °æ±¾ÐÎʽ£µ¥¡¢Ë«¡¢´óС°æ±¾ */ |
| 164 | unsigned short ih_type; /* °æ±¾ÀàÐÍ£°æ±¾¡¢Äںˡ¢Îļþϵͳ¡¢Ð¡°æ±¾¡¢´ó°æ±¾*/ |
| 165 | unsigned int ih_size; /* °æ±¾³¤¶È */ |
| 166 | |
| 167 | unsigned int ih_kern_size; /* Äں˴óС */ |
| 168 | unsigned int ih_kern_offset; /* ÄÚºËÔÚflashÖÐµÄÆ«ÒÆ */ |
| 169 | unsigned int ih_kern_dcrc; /* ÄÚºËУÑéºÍ */ |
| 170 | unsigned int ih_fs_size; /* ¸ùÎļþϵͳ´óС */ |
| 171 | unsigned int ih_fs_offset; /* ¸ùÎļþϵͳÔÚflashÖÐµÄÆ«ÒÆ*/ |
| 172 | unsigned int ih_fs_dcrc; /* ¸ùÎļþϵͳУÑéºÍ */ |
| 173 | |
| 174 | unsigned int ih_im0_offset; /* °æ±¾0ÔÚflashÖÐµÄÆ«ÒÆ */ |
| 175 | unsigned int ih_im0_size; /* °æ±¾0´óС */ |
| 176 | unsigned int ih_fs0_offset; /* Îļþϵͳ0ÔÚflashÖÐµÄÆ«ÒÆ */ |
| 177 | unsigned int ih_fs0_size; /* Îļþϵͳ0´óС */ |
| 178 | unsigned int ih_im1_offset; /* °æ±¾1ÔÚflashÖÐµÄÆ«ÒÆ */ |
| 179 | unsigned int ih_im1_size; /* °æ±¾1´óС */ |
| 180 | unsigned int ih_fs1_offset; /* Îļþϵͳ1ÔÚflashÖÐµÄÆ«ÒÆ */ |
| 181 | unsigned int ih_fs1_size; /* Îļþϵͳ1´óС */ |
| 182 | |
| 183 | char ih_desc[DESC_LEN]; /* °æ±¾ÎļþÃèÊö */ |
| 184 | |
| 185 | /* 2010/03/18, wys, boot°æ±¾ÃèÊö£¬¹²16×Ö½Ú */ |
| 186 | unsigned short ih_boot_included; /* ÊÇ·ñ°üº¬boot°æ±¾ */ |
| 187 | unsigned short ih_boot_upgrade; /* Ç¿ÖÆÉý¼¶bootʹÄÜ */ |
| 188 | unsigned int ih_boot_size; /* boot°æ±¾Êý¾Ý³¤¶È */ |
| 189 | unsigned int ih_boot_offset; /* boot°æ±¾Êý¾ÝÆ«ÒÆ */ |
| 190 | unsigned int ih_boot_dcrc; /* boot°æ±¾Êý¾ÝУÑé */ |
| 191 | /* 2010/03/18, wys, end */ |
| 192 | |
| 193 | unsigned int ih_isdefault; /* Éý¼¶ºóÊÇ·ñʹÓÃÔ°æ±¾µÄĬÈÏÅäÖà */ |
| 194 | unsigned int ih_endiantype; /* ´óСÐò */ |
| 195 | |
| 196 | unsigned int ih_hcrc; /* °æ±¾Í·Ð£ÑéºÍ£¬Ö®Ç°µÄÓò»á²Î¼ÓУÑé */ |
| 197 | |
| 198 | char ih_time[16]; /* °æ±¾´´½¨Ê±¼ä */ |
| 199 | unsigned int ih_isfull; /* °æ±¾ÊÇ·ñÍêÕû */ |
| 200 | unsigned int ih_isnewly; /* ÊÇ·ñΪ×îа汾 */ |
| 201 | unsigned int ih_fromsync; /* °æ±¾À´Ô´£Éý¼¶»òͬ²½ */ |
| 202 | unsigned int ih_flashsize; /* FlashÈÝÁ¿´óС */ |
| 203 | unsigned short ih_protocol; /* 0-NULL, 1-H248, 2-SIP, 3-MGCP */ |
| 204 | unsigned short ih_compatible; /* 32MB CSP2102/1027°æ±¾·ÖÇøÊÇ·ñ¼æÈÝ */ |
| 205 | char ih_csp_version[8]; /* CSPƽ̨°æ±¾ºÅ£¬ÀýÈ磺V1.0.27 */ |
| 206 | char ih_vidmask[24]; /*Ö§³ÖVIDµÄÑÚÂë*/ |
| 207 | } hd_contend_desc; |
| 208 | |
| 209 | typedef struct { |
| 210 | unsigned int ih_upgradetimes; |
| 211 | unsigned int ih_flashtimes; |
| 212 | } hd_config_file; |
| 213 | |
| 214 | typedef struct { |
| 215 | hd_general_desc general; |
| 216 | hd_contend_desc contend; |
| 217 | } header_version; |
| 218 | |
| 219 | typedef struct { |
| 220 | hd_general_desc general; |
| 221 | hd_config_file config; |
| 222 | } header_config; |
| 223 | |
| 224 | |
| 225 | |
| 226 | /* function declarations */ |
| 227 | int do_search (unsigned int start, unsigned int end, unsigned int step, search_desc *search); |
| 228 | int do_startup (search_desc *search); |
| 229 | int do_settings (int num, const search_desc *search); |
| 230 | |
| 231 | #endif /* _CMD_DOWNVER_H_ */ |
| 232 | |