[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/boot/common/src/uboot/include/cmd_downver.h b/boot/common/src/uboot/include/cmd_downver.h
new file mode 100644
index 0000000..6763ba3
--- /dev/null
+++ b/boot/common/src/uboot/include/cmd_downver.h
@@ -0,0 +1,232 @@
+/*
+ * Author(s):    wang.yuesheng
+ * Date:         2009-02-26
+ * Purpose:
+ * Description:  bootË«°æ±¾ËÑË÷¼°Æô¶¯Ö§³Ö
+ */
+ 
+#include <config.h>
+
+
+
+#ifndef _CMD_DOWNVER_H_
+#define _CMD_DOWNVER_H_
+
+
+/* °æ±¾×´Ì¬±êÖ¾²âÊÔλ */
+#define CFG_TB_LATELY				0x01	/* °æ±¾Ð¾ÉÐÔ±ê־λ */
+#define CFG_TB_INTACT				0x02	/* °æ±¾ÍêÕûÐÔ±ê־λ */
+#define CFG_TB_KERNEL				0x04	/* ÄÚºËÍêÕûÐÔ±ê־λ */
+#define CFG_TB_ROOTFS				0x08	/* ÎļþϵͳÍêÕûÐÔ±ê־λ */
+#define CFG_TB_SYNCED				0x10	/* °æ±¾À´Ô´±ê־λ   */
+#define CFG_TB_HEADER				0x80	/* °æ±¾Í·ÍêÕûÐÔ±ê־λ */
+
+/* ¸ùÎļþϵͳÀàÐͶ¨Òå */
+#define CFG_FS_NONE				0x00	/* none */
+#define CFG_FS_INITRAM				0x01	/* initramfs */
+#define CFG_FS_JFFS2				0x02	/* jffs2 */
+#define CFG_FS_SQUASH				0x04	/* squashfs */
+
+/* ¸ùÎļþϵͳ»ÃÊý */
+#define SQUASHFS_MAGIC				0x73717368
+#define SQUASHFS_MAGIC_SWAP		0x68737173
+#ifdef __BIG_ENDIAN
+#define JFFS2_DIRENT_MAGIC		       0x1985E001
+#define JFFS2_INODE_MAGIC			0x1985E002
+#define JFFS2_CLEANMARKER_MAGIC	0x19852003
+#define JFFS2_PADDING_MAGIC		0x19852004
+#define JFFS2_SUMMARY_MAGIC		0x19852006
+#define JFFS2_RWDELETE_MAGIC  	0x19850003
+#else
+#define JFFS2_DIRENT_MAGIC		       0xE0011985
+#define JFFS2_INODE_MAGIC			0xE0021985
+#define JFFS2_CLEANMARKER_MAGIC	0x20031985
+#define JFFS2_PADDING_MAGIC		0x20041985
+#define JFFS2_SUMMARY_MAGIC		0x20061985
+#define JFFS2_RWDELETE_MAGIC  	0x00031985
+#endif
+#define CFG_EMPTY_BITMASK			0xFFFFFFFF
+#define CFG_IMAGE_OKAY				0x00000000
+
+#define MAGIC_MAX			4		// »ÃÊý¸öÊý
+#define DESC_LEN			32		// °æ±¾ÃèÊö³¤¶È
+#define	RESV_LEN			16		// ±£Áô×ֶ㤶È
+#define CSP_HEADER_LEN		256		// °æ±¾Í·³¤¶È
+#define CFG_ALLIGN_SIZE     16
+
+/* °æ±¾Í·»ÃÊý */
+#define	CSP_MAGIC0		0x99999999
+#define CSP_MAGIC1		0x44444444
+#define CSP_MAGIC2		0x55555555
+#define CSP_MAGIC3		0xaaaaaaaa
+
+#define IMAGE_BAD		0xffffffff	// °æ±¾Ëð»µ
+#define IMAGE_OKAY		0x00000000	// °æ±¾ÍêÕû
+#define IMAGE_NEW		0xffffffff	// а汾
+#define IMAGE_OLD      	0x00000000	// ¾É°æ±¾
+#define IMAGE_UPGRADE	0xffffffff	// À´Ô´ÓÚÉý¼¶
+#define IMAGE_SYNCED	0x00000000	// À´Ô´ÓÚͬ²½
+
+/* ÓïÒôЭÒéÀàÐÍ */
+#define VOIP_PROTO_NULL      0
+#define VOIP_PROTO_H248      1
+#define VOIP_PROTO_SIP       2
+#define VOIP_PROTO_MGCP      3
+#define VOIP_PROTO_UNKNOWN   0xffff
+
+#define	IH_HCRC_OFFSET      (unsigned int)(&((hd_contend_desc*)0)->ih_hcrc)
+#define ALIGN_SIZE16(x)     (((x)/16+(((x)%16)?1:0))*16)
+
+typedef enum 
+{
+    FLASH_TYPE_NAND = 1,
+    FLASH_TYPE_NOR = 2,
+    FLASH_TYPE_INVALID = 255
+}FLASH_TYPE_E;
+
+
+typedef enum VersionType
+{
+    VERTYPE_BOOT = 1,
+    VERTYPE_KERNEL,
+    VERTYPE_ROOTFS,
+    VERTYPE_VERSION,
+    VERTYPE_INVALID = 255
+}VERSION_TYPE_E;
+
+
+/* ƽ̨°æ±¾ÖвúÆ·´óÀà */
+typedef enum {
+	PRODUCT_SERIES_DHOME = 0,
+	PRODUCT_SERIES_XPON  = 1,
+	PRODUCT_SERIES_STB   = 2,
+	PRODUCT_SERIES_RFID  = 3
+} PRODUCT_SERIES_ID;
+
+/* °æ±¾ÀàÐÍ: µ¥£¬Ë«£¬´óС */
+typedef enum {
+	VERSION_TYPE_SINGLE  = 0,		/* µ¥°æ±¾ */
+	VERSION_TYPE_DOUBLE  = 1,		/* Ë«°æ±¾ */
+	VERSION_TYPE_BIGSMALL= 2		/* ´óС°æ±¾ */
+} VERSION_TYPE_ID;
+
+
+/* °æ±¾À´Ô´: δ֪£¬Éý¼¶¡¢Í¬²½ */
+typedef enum {
+	VERSION_FROM_UPGRAGE = 0,		/* Éý¼¶°æ±¾ */
+	VERSION_FROM_SYNC    = 1			/* ͬ²½°æ±¾ */
+} VERSION_FROM_ID;
+
+
+typedef struct {
+	short	flags;		/* °æ±¾×´Ì¬±ê־λ×é */
+	short	fstype;		/* ¸ùÎļþϵͳµÄÀàÐÍ */
+	long	entry;		/* °æ±¾Òýµ¼Èë¿ÚµØÖ· */
+	unsigned int	ih_size;		/* Äں˴óС           */
+} vstat_t;
+
+typedef struct {
+	int		total;		/* ËÑË÷µ½µÄ°æ±¾¸öÊý */
+	vstat_t result[2];	/* ÓÐЧ°æ±¾µÄ״̬ */
+} search_desc;
+
+
+typedef struct {
+	unsigned int	ih_magic[MAGIC_MAX];/* °æ±¾Í·»ÃÊý */
+	unsigned int	ih_signatureSize;	/* Ç©ÃûÇø´óС */
+	char			pSignature[0];		/* Ç©ÃûÇøÄÚÈÝ */
+} hd_magic_desc;
+
+typedef struct {
+	unsigned int	productType;		/* ²úÆ·´óÀ࣭DHome£¬STB£¬RFID£¬... */
+	unsigned int	firewareType;		/* ¹Ì¼þÀàÐÍ£­°æ±¾Îļþ£¬bootÎļþ£¬ÅäÖÃÎļþ£¬Ö¤ÊéÎļþ */
+	unsigned int	upgradeKey1;		/* ͬһÀàCPEµ¥°åµÄ±àÂ룬Æä½â¾ö·½°¸Ïàͬ¡¢»ù±¾Ó²¼þÅäÖÃÏàͬ£¬¿ÉÔËÐжà¸ö²úÆ·µÄ°æ±¾ */
+	unsigned int	upgradeKey2;		/* ͬһÀàCPEµ¥°å¶ÔÓ¦µÄÓжÀÁ¢°æ±¾µÄ²»Í¬²úÆ·±àÂë */
+	char			serialNum[16];		/* °æ±¾ºÅ */
+	unsigned int	headerVersion;		/* Í·°æ±¾ºÅ£¬Ä¿Ç°±£Áô */
+	unsigned int	isExpanded;		/* ÊÇ·ñʹÓø½¼Ó°æ±¾Í·£¬¸½¼Ó°æ±¾Í·ÔÙÀ©Õ¹256 ×Ö½Ú */
+	unsigned int	firewareSize;		/* ¹Ì¼þ´óС£¬Ä¿Ç°±£Áô */
+}hd_general_desc;
+
+typedef struct {
+	unsigned int	btMagic[4];	/* BOOT°æ±¾Í·»ÃÊý */
+	char			btNumbers[16];		/* BOOTÈí¼þ°æ±¾ºÅ */
+	char			btCtime[20];		/* BOOT°æ±¾µÄʱ¼ä */
+	unsigned int	btVerSize;			/* BOOT°æ±¾µÄ³¤¶È */
+	unsigned int	btFlashOffset;		/* BOOT°æ±¾FlashÆ«ÒÆµØÖ· */
+	unsigned int	btFlashSize;		/* BOOT°æ±¾Flash·ÖÇø´óС */
+} hd_boot_file;
+
+
+/* °æ±¾Í·ÄÚÈÝ */
+typedef struct {
+	unsigned short	ih_form;			/* °æ±¾ÐÎʽ£­µ¥¡¢Ë«¡¢´óС°æ±¾ */
+	unsigned short	ih_type;			/* °æ±¾ÀàÐÍ£­°æ±¾¡¢Äںˡ¢Îļþϵͳ¡¢Ð¡°æ±¾¡¢´ó°æ±¾*/
+	unsigned int	ih_size;			/* °æ±¾³¤¶È */
+	
+	unsigned int	ih_kern_size;		/* Äں˴óС                 */
+	unsigned int	ih_kern_offset;	/* ÄÚºËÔÚflashÖÐµÄÆ«ÒÆ      */
+	unsigned int	ih_kern_dcrc;		/* ÄÚºËУÑéºÍ               */
+	unsigned int	ih_fs_size;		/* ¸ùÎļþϵͳ´óС           */
+	unsigned int	ih_fs_offset;		/* ¸ùÎļþϵͳÔÚflashÖÐµÄÆ«ÒÆ*/
+	unsigned int	ih_fs_dcrc;		/* ¸ùÎļþϵͳУÑéºÍ         */
+
+	unsigned int	ih_im0_offset;		/* °æ±¾0ÔÚflashÖÐµÄÆ«ÒÆ     */
+	unsigned int	ih_im0_size;		/* °æ±¾0´óС                */
+	unsigned int	ih_fs0_offset;		/* Îļþϵͳ0ÔÚflashÖÐµÄÆ«ÒÆ */
+	unsigned int	ih_fs0_size;		/* Îļþϵͳ0´óС            */
+	unsigned int	ih_im1_offset;		/* °æ±¾1ÔÚflashÖÐµÄÆ«ÒÆ     */
+	unsigned int	ih_im1_size;		/* °æ±¾1´óС                */
+	unsigned int	ih_fs1_offset;		/* Îļþϵͳ1ÔÚflashÖÐµÄÆ«ÒÆ */
+	unsigned int	ih_fs1_size;		/* Îļþϵͳ1´óС            */
+
+	char			ih_desc[DESC_LEN];	/* °æ±¾ÎļþÃèÊö */
+	
+	/* 2010/03/18, wys, boot°æ±¾ÃèÊö£¬¹²16×Ö½Ú */
+	unsigned short	ih_boot_included;	/* ÊÇ·ñ°üº¬boot°æ±¾ */
+	unsigned short	ih_boot_upgrade;	/* Ç¿ÖÆÉý¼¶bootʹÄÜ */
+	unsigned int	ih_boot_size;		/* boot°æ±¾Êý¾Ý³¤¶È */
+	unsigned int	ih_boot_offset;	/* boot°æ±¾Êý¾ÝÆ«ÒÆ */
+	unsigned int	ih_boot_dcrc;		/* boot°æ±¾Êý¾ÝУÑé */
+	/* 2010/03/18, wys, end */
+
+	unsigned int	ih_isdefault;		/* Éý¼¶ºóÊÇ·ñʹÓÃÔ­°æ±¾µÄĬÈÏÅäÖà */
+	unsigned int	ih_endiantype;		/* ´óСÐò */
+	
+	unsigned int	ih_hcrc;			/* °æ±¾Í·Ð£ÑéºÍ£¬Ö®Ç°µÄÓò»á²Î¼ÓУÑé */
+	
+	char			ih_time[16];		/* °æ±¾´´½¨Ê±¼ä         */
+	unsigned int	ih_isfull;			/* °æ±¾ÊÇ·ñÍêÕû         */
+	unsigned int	ih_isnewly;		/* ÊÇ·ñΪ×îа汾       */
+	unsigned int	ih_fromsync;		/* °æ±¾À´Ô´£­Éý¼¶»òͬ²½ */
+	unsigned int    ih_flashsize;		/* FlashÈÝÁ¿´óС */
+	unsigned short	ih_protocol;		/* 0-NULL, 1-H248, 2-SIP, 3-MGCP */
+	unsigned short	ih_compatible;		/* 32MB CSP2102/1027°æ±¾·ÖÇøÊÇ·ñ¼æÈÝ */
+	char			ih_csp_version[8];	/* CSPƽ̨°æ±¾ºÅ£¬ÀýÈ磺V1.0.27 */
+	char            ih_vidmask[24];     /*Ö§³ÖVIDµÄÑÚÂë*/
+} hd_contend_desc;
+
+typedef struct {
+	unsigned int	ih_upgradetimes;
+	unsigned int	ih_flashtimes;
+} hd_config_file;
+
+typedef struct {
+	hd_general_desc	general;
+	hd_contend_desc contend;
+} header_version;
+
+typedef struct {
+	hd_general_desc	general;
+	hd_config_file	config;
+} header_config;
+
+
+
+/* function declarations */
+int do_search (unsigned int start, unsigned int end, unsigned int step, search_desc *search);
+int do_startup (search_desc *search);
+int do_settings (int num, const search_desc *search);
+
+#endif /* _CMD_DOWNVER_H_ */
+