aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm63xx/files/arch
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2010-04-01 21:20:43 +0000
committerFlorian Fainelli <florian@openwrt.org>2010-04-01 21:20:43 +0000
commit9b32abb33e5a0154cc15e9847da14d4f802d981a (patch)
tree1b00423ca5467424b69a4fb97f6d786129b1d507 /target/linux/brcm63xx/files/arch
parenta03c780f9388d6fca86f1ef6a0dacdf43a1ce0a3 (diff)
downloadupstream-9b32abb33e5a0154cc15e9847da14d4f802d981a.tar.gz
upstream-9b32abb33e5a0154cc15e9847da14d4f802d981a.tar.bz2
upstream-9b32abb33e5a0154cc15e9847da14d4f802d981a.zip
[brcm63xx] flashmap and image generation: reduced union bcm_tag to a single struct
combining the elements so that it is no longer necessary to create an openwrt-only tagid and tagcrc, and elimate the tagid detection and switch statements which made dealing with imagetags overly complicated, especially since the logic would need analogs in all code that touched the imagetag. Patch from cshore. git-svn-id: svn://svn.openwrt.org/openwrt/trunk@20652 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/brcm63xx/files/arch')
-rw-r--r--target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h219
1 files changed, 55 insertions, 164 deletions
diff --git a/target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h b/target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h
index c06f668942..d792562728 100644
--- a/target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h
+++ b/target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h
@@ -1,178 +1,69 @@
#ifndef __BCM63XX_TAG_H
#define __BCM63XX_TAG_H
-#define IMAGE_LEN 10 /* Length of Length Field */
-#define ADDRESS_LEN 12 /* Length of Address field */
-#define TAGID_LEN 6 /* Length of tag ID */
-#define TAGINFO_LEN 20 /* Length of vendor information field in tag */
#define TAGVER_LEN 4 /* Length of Tag Version */
#define TAGLAYOUT_LEN 4 /* Length of FlashLayoutVer */
+#define SIG1_LEN 20 /* Company Signature 1 Length */
+#define SIG2_LEN 14 /* Company Signature 2 Lenght */
+#define BOARDID_LEN 16 /* Length of BoardId */
+#define ENDIANFLAG_LEN 2 /* Endian Flag Length */
+#define CHIPID_LEN 6 /* Chip Id Length */
+#define IMAGE_LEN 10 /* Length of Length Field */
+#define ADDRESS_LEN 12 /* Length of Address field */
+#define DUALFLAG_LEN 2 /* Dual Image flag Length */
+#define INACTIVEFLAG_LEN 2 /* Inactie Flag Length */
+#define RSASIG_LEN 20 /* Length of RSA Signature in tag */
+#define TAGINFO1_LEN 30 /* Length of vendor information field1 in tag */
+#define FLASHLAYOUTVER_LEN 4 /* Length of Flash Layout Version String tag */
+#define TAGINFO2_LEN 16 /* Length of vendor information field2 in tag */
+#define CRC_LEN 4 /* Length of CRC in bytes */
+#define ALTTAGINFO_LEN 54 /* Alternate length for vendor information; Pirelli */
-#define NUM_TAGID 5
+#define NUM_PIRELLI 2
#define IMAGETAG_CRC_START 0xFFFFFFFF
-struct tagiddesc_t {
- char tagid[TAGID_LEN + 1];
- char tagiddesc[80];
-};
-
- // bc221 is used by BT Voyager and should be right
- // bc310 should be right, and may apply to 3.08 code as well
-#define TAGID_DEFINITIONS { \
- { "bccfe", "Broadcom CFE flash image" }, \
- { "bc300", "Broadcom code version 3.00-3.06 and all ftp/tftp flash" }, \
- { "ag306", "Alice Gate (Pirelli, based on Broadcom 3.06)" }, \
- { "bc221", "Broadcom code version 2.21" }, \
- { "bc310", "Broadcom code version 3.10-3.12" }, \
+#define PIRELLI_BOARDS { \
+ "AGPF_S0", \
+ "DWV_SO", \
}
-struct bcm_tag_bccfe {
- unsigned char tagVersion[TAGVER_LEN]; // 0-3: Version of the image tag
- unsigned char sig_1[20]; // 4-23: Company Line 1
- unsigned char sig_2[14]; // 24-37: Company Line 2
- unsigned char chipid[6]; // 38-43: Chip this image is for
- unsigned char boardid[16]; // 44-59: Board name
- unsigned char big_endian[2]; // 60-61: Map endianness -- 1 BE 0 LE
- unsigned char totalLength[IMAGE_LEN]; // 62-71: Total length of image
- unsigned char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE
- unsigned char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE
- unsigned char rootAddress[ADDRESS_LEN]; // 94-105: Address in memory of rootfs
- unsigned char rootLength[IMAGE_LEN]; // 106-115: Size of rootfs
- unsigned char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel
- unsigned char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel
- unsigned char dualImage[2]; // 138-139: Unused at present
- unsigned char inactiveFlag[2]; // 140-141: Unused at present
- unsigned char information1[TAGINFO_LEN]; // 142-161: Unused at present
- unsigned char tagId[TAGID_LEN]; // 162-167: Identifies which type of tag this is, currently two-letter company code, and then three digits for version of broadcom code in which this tag was first introduced
- unsigned char tagIdCRC[4]; // 168-171: CRC32 of tagId
- unsigned char reserved1[44]; // 172-215: Reserved area not in use
- unsigned char imageCRC[4]; // 216-219: CRC32 of images
- unsigned char reserved2[16]; // 220-235: Unused at present
- unsigned char headerCRC[4]; // 236-239: CRC32 of header excluding tagVersion
- unsigned char reserved3[16]; // 240-255: Unused at present
-};
-
-struct bcm_tag_bc300 {
- unsigned char tagVersion[TAGVER_LEN]; // 0-3: Version of the image tag
- unsigned char sig_1[20]; // 4-23: Company Line 1
- unsigned char sig_2[14]; // 24-37: Company Line 2
- unsigned char chipid[6]; // 38-43: Chip this image is for
- unsigned char boardid[16]; // 44-59: Board name
- unsigned char big_endian[2]; // 60-61: Map endianness -- 1 BE 0 LE
- unsigned char totalLength[IMAGE_LEN]; // 62-71: Total length of image
- unsigned char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE
- unsigned char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE
- unsigned char flashImageStart[ADDRESS_LEN]; // 94-105: Address in memory of kernel (start of image)
- unsigned char flashRootLength[IMAGE_LEN]; // 106-115: Size of rootfs + deadcode (web flash uses this + kernelLength to determine the size of the kernel+rootfs flash image)
- unsigned char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel
- unsigned char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel
- unsigned char dualImage[2]; // 138-139: Unused at present
- unsigned char inactiveFlag[2]; // 140-141: Unused at present
- unsigned char information1[TAGINFO_LEN]; // 142-161: Unused at present
- unsigned char tagId[TAGID_LEN]; // 162-167: Identifies which type of tag this is, currently two-letter company code, and then three digits for version of broadcom code in which this tag was first introduced
- unsigned char tagIdCRC[4]; // 168-173: CRC32 to ensure validity of tagId
- unsigned char rootAddress[ADDRESS_LEN]; // 174-183: Address in memory of rootfs partition
- unsigned char rootLength[IMAGE_LEN]; // 184-193: Size of rootfs partition
- unsigned char reserved1[22]; // 194-215: Reserved area not in use
- unsigned char imageCRC[4]; // 216-219: CRC32 of images
- unsigned char reserved2[16]; // 220-235: Unused at present
- unsigned char headerCRC[4]; // 236-239: CRC32 of header excluding tagVersion
- unsigned char reserved3[16]; // 240-255: Unused at present
-};
-
-struct bcm_tag_ag306 {
- unsigned char tagVersion[TAGVER_LEN]; // 0-3: Version of the image tag
- unsigned char sig_1[20]; // 4-23: Company Line 1
- unsigned char sig_2[14]; // 24-37: Company Line 2
- unsigned char chipid[6]; // 38-43: Chip this image is for
- unsigned char boardid[16]; // 44-59: Board name
- unsigned char big_endian[2]; // 60-61: Map endianness -- 1 BE 0 LE
- unsigned char totalLength[IMAGE_LEN]; // 62-71: Total length of image
- unsigned char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE
- unsigned char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE
- unsigned char flashImageStart[ADDRESS_LEN]; // 94-105: Address in memory of kernel (start of image)
- unsigned char flashRootLength[IMAGE_LEN]; // 106-115: Size of rootfs + deadcode (web flash uses this + kernelLength to determine the size of the kernel+rootfs flash image)
- unsigned char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel
- unsigned char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel
- unsigned char dualImage[2]; // 138-139: Unused at present
- unsigned char inactiveFlag[2]; // 140-141: Unused at present
- unsigned char information1[TAGINFO_LEN]; // 142-161: Unused at present
- unsigned char information2[54]; // 162-215: Compilation and related information (not generated/used by OpenWRT)
- unsigned char kernelCRC[4] ; // 216-219: CRC32 of images
- unsigned char rootAddress[ADDRESS_LEN]; // 220-231: Address in memory of rootfs partition
- unsigned char tagIdCRC[4]; // 232-235: Checksum to ensure validity of tagId
- unsigned char headerCRC[4]; // 236-239: CRC32 of header excluding tagVersion
- unsigned char rootLength[IMAGE_LEN]; // 240-249: Size of rootfs
- unsigned char tagId[TAGID_LEN]; // 250-255: Identifies which type of tag this is, currently two-letter company code, and then three digits for version of broadcom code in which this tag was first introduced
-};
-
-struct bcm_tag_bc221 {
- unsigned char tagVersion[TAGVER_LEN]; // 0-3: Version of the image tag
- unsigned char sig_1[20]; // 4-23: Company Line 1
- unsigned char sig_2[14]; // 24-37: Company Line 2
- unsigned char chipid[6]; // 38-43: Chip this image is for
- unsigned char boardid[16]; // 44-59: Board name
- unsigned char big_endian[2]; // 60-61: Map endianness -- 1 BE 0 LE
- unsigned char totalLength[IMAGE_LEN]; // 62-71: Total length of image
- unsigned char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE
- unsigned char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE
- unsigned char flashImageStart[ADDRESS_LEN]; // 94-105: Address in memory of kernel (start of image)
- unsigned char flashRootLength[IMAGE_LEN]; // 106-115: Size of rootfs + deadcode (web flash uses this + kernelLength to determine the size of the kernel+rootfs flash image)
- unsigned char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel
- unsigned char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel
- unsigned char dualImage[2]; // 138-139: Unused at present
- unsigned char inactiveFlag[2]; // 140-141: Unused at present
- unsigned char rsa_signature[TAGINFO_LEN]; // 142-161: RSA Signature (unused at present; some vendors may use this)
- unsigned char reserved5[2]; // 162-163: Unused at present
- unsigned char tagId[TAGID_LEN]; // 164-169: Identifies which type of tag this is, currently two-letter company code, and then three digits for version of broadcom code in which this tag was first introduced
- unsigned char rootAddress[ADDRESS_LEN]; // 170-181: Address in memory of rootfs partition
- unsigned char rootLength[IMAGE_LEN]; // 182-191: Size of rootfs partition
- unsigned char flashLayoutVer[4]; // 192-195: Version flash layout
- unsigned char fskernelCRC[4]; // 196-199: Guessed to be kernel CRC
- unsigned char reserved4[16]; // 200-215: Reserved area; unused at present
- unsigned char imageCRC[4]; // 216-219: CRC32 of images
- unsigned char reserved2[12]; // 220-231: Unused at present
- unsigned char tagIdCRC[4]; // 232-235: CRC32 to ensure validity of tagId
- unsigned char headerCRC[4]; // 236-239: CRC32 of header excluding tagVersion
- unsigned char reserved3[16]; // 240-255: Unused at present
-};
-
-struct bcm_tag_bc310 {
- unsigned char tagVersion[4]; // 0-3: Version of the image tag
- unsigned char sig_1[20]; // 4-23: Company Line 1
- unsigned char sig_2[14]; // 24-37: Company Line 2
- unsigned char chipid[6]; // 38-43: Chip this image is for
- unsigned char boardid[16]; // 44-59: Board name
- unsigned char big_endian[2]; // 60-61: Map endianness -- 1 BE 0 LE
- unsigned char totalLength[IMAGE_LEN]; // 62-71: Total length of image
- unsigned char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE
- unsigned char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE
- unsigned char flashImageStart[ADDRESS_LEN]; // 94-105: Address in memory of kernel (start of image)
- unsigned char flashRootLength[IMAGE_LEN]; // 106-115: Size of rootfs + deadcode (web flash uses this + kernelLength to determine the size of the kernel+rootfs flash image)
- unsigned char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel
- unsigned char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel
- unsigned char dualImage[2]; // 138-139: Unused at present
- unsigned char inactiveFlag[2]; // 140-141: Unused at present
- unsigned char information1[TAGINFO_LEN]; // 142-161: Unused at present; Some vendors use this for optional information
- unsigned char tagId[6]; // 162-167: Identifies which type of tag this is, currently two-letter company code, and then three digits for version of broadcom code in which this tag was first introduced
- unsigned char tagIdCRC[4]; // 168-171: CRC32 to ensure validity of tagId
- unsigned char rootAddress[ADDRESS_LEN]; // 172-183: Address in memory of rootfs partition
- unsigned char rootLength[IMAGE_LEN]; // 184-193: Size of rootfs partition
- unsigned char reserved1[22]; // 193-215: Reserved area not in use
- unsigned char imageCRC[4]; // 216-219: CRC32 of images
- unsigned char rootfsCRC[4]; // 220-227: CRC32 of rootfs partition
- unsigned char kernelCRC[4]; // 224-227: CRC32 of kernel partition
- unsigned char reserved2[8]; // 228-235: Unused at present
- unsigned char headerCRC[4]; // 235-239: CRC32 of header excluding tagVersion
- unsigned char reserved3[16]; // 240-255: Unused at present
-};
+/*
+ * The broadcom firmware assumes the rootfs starts the image,
+ * therefore uses the rootfs start (flashImageAddress)
+ * to determine where to flash the image. Since we have the kernel first
+ * we have to give it the kernel address, but the crc uses the length
+ * associated with this address (rootLength), which is added to the kernel
+ * length (kernelLength) to determine the length of image to flash and thus
+ * needs to be rootfs + deadcode (jffs2 EOF marker)
+*/
-union bcm_tag {
- struct bcm_tag_bccfe bccfe;
- struct bcm_tag_bc300 bc300;
- struct bcm_tag_ag306 ag306;
- struct bcm_tag_bc221 bc221;
- struct bcm_tag_bc310 bc310;
+struct bcm_tag {
+ char tagVersion[TAGVER_LEN]; // 0-3: Version of the image tag
+ char sig_1[SIG1_LEN]; // 4-23: Company Line 1
+ char sig_2[SIG2_LEN]; // 24-37: Company Line 2
+ char chipid[CHIPID_LEN]; // 38-43: Chip this image is for
+ char boardid[BOARDID_LEN]; // 44-59: Board name
+ char big_endian[ENDIANFLAG_LEN]; // 60-61: Map endianness -- 1 BE 0 LE
+ char totalLength[IMAGE_LEN]; // 62-71: Total length of image
+ char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE
+ char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE
+ char flashImageStart[ADDRESS_LEN]; // 94-105: Address in memory of image start (kernel for OpenWRT, rootfs for stock firmware)
+ char rootLength[IMAGE_LEN]; // 106-115: Size of rootfs
+ char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel
+ char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel
+ char dualImage[DUALFLAG_LEN]; // 138-139: Unused at present
+ char inactiveFlag[INACTIVEFLAG_LEN]; // 140-141: Unused at present
+ char rsa_signature[RSASIG_LEN]; // 142-161: RSA Signature (unused at present; some vendors may use this)
+ char information1[TAGINFO1_LEN]; // 162-191: Compilation and related information (not generated/used by OpenWRT)
+ char flashLayoutVer[FLASHLAYOUTVER_LEN];// 192-195: Version flash layout
+ char fskernelCRC[CRC_LEN]; // 196-199: kernel+rootfs CRC32
+ char information2[TAGINFO2_LEN]; // 200-215: Unused at present except Alice Gate where is is information
+ char imageCRC[CRC_LEN]; // 216-219: CRC32 of image less imagetag (kernel for Alice Gate)
+ char rootfsCRC[CRC_LEN]; // 220-223: CRC32 of rootfs partition
+ char kernelCRC[CRC_LEN]; // 224-227: CRC32 of kernel partition
+ char reserved1[8]; // 228-235: Unused at present
+ char headerCRC[CRC_LEN]; // 236-239: CRC32 of header excluding tagVersion
+ char reserved2[16]; // 240-255: Unused at present
};
#endif /* __BCM63XX_TAG_H */