comparison packages/redboot/current/src/flash.c @ 284:3e80ecaaa3f8

* src/crc.c: Removed. Replaced with the CRC package. * src/cksum.c: Removed the posix_crc function. * src/flash.c: Use the crc package crc functions. * src/xyzModem.c: Ditto * include/redboot.h: Use the crc package include file. * cdl/redboot.cdl: removed crc.c
author asl
date Mon, 12 Aug 2002 07:54:52 +0000
parents 96e3418e1f5b
children 906a5d289c6d
comparison
equal deleted inserted replaced
283:f58bc1b2c2bc 284:3e80ecaaa3f8
771 img->mem_base = exec_addr_set ? exec_addr : (flash_addr_set ? flash_addr : mem_addr); 771 img->mem_base = exec_addr_set ? exec_addr : (flash_addr_set ? flash_addr : mem_addr);
772 img->entry_point = entry_addr_set ? entry_addr : (CYG_ADDRESS)entry_address; // Hope it's been set 772 img->entry_point = entry_addr_set ? entry_addr : (CYG_ADDRESS)entry_address; // Hope it's been set
773 img->size = length; 773 img->size = length;
774 img->data_length = img_size; 774 img->data_length = img_size;
775 #ifdef CYGSEM_REDBOOT_FIS_CRC_CHECK 775 #ifdef CYGSEM_REDBOOT_FIS_CRC_CHECK
776 img->file_cksum = crc32((unsigned char *)flash_addr, img_size); 776 img->file_cksum = cyg_crc32((unsigned char *)flash_addr, img_size);
777 #endif 777 #endif
778 fis_update_directory(); 778 fis_update_directory();
779 } 779 }
780 } 780 }
781 781
925 load_address_end = mem_addr + img->data_length; 925 load_address_end = mem_addr + img->data_length;
926 } 926 }
927 entry_address = (unsigned long)img->entry_point; 927 entry_address = (unsigned long)img->entry_point;
928 928
929 #ifdef CYGPKG_REDBOOT_FIS_CRC_CHECK 929 #ifdef CYGPKG_REDBOOT_FIS_CRC_CHECK
930 cksum = crc32((unsigned char *)mem_addr, img->data_length); 930 cksum = cyg_crc32((unsigned char *)mem_addr, img->data_length);
931 if (show_cksum) { 931 if (show_cksum) {
932 diag_printf("Checksum: 0x%08lx\n", cksum); 932 diag_printf("Checksum: 0x%08lx\n", cksum);
933 } 933 }
934 // When decompressing, leave CRC checking to decompressor 934 // When decompressing, leave CRC checking to decompressor
935 if (!decompress && img->file_cksum) { 935 if (!decompress && img->file_cksum) {
1802 #endif 1802 #endif
1803 1803
1804 config->len = sizeof(struct _config); 1804 config->len = sizeof(struct _config);
1805 config->key1 = CONFIG_KEY1; 1805 config->key1 = CONFIG_KEY1;
1806 config->key2 = CONFIG_KEY2; 1806 config->key2 = CONFIG_KEY2;
1807 config->cksum = crc32((unsigned char *)config, sizeof(struct _config)-sizeof(config->cksum)); 1807 config->cksum = cyg_crc32((unsigned char *)config, sizeof(struct _config)-sizeof(config->cksum));
1808 if (verify_action("Update RedBoot non-volatile configuration")) { 1808 if (verify_action("Update RedBoot non-volatile configuration")) {
1809 #ifdef CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG 1809 #ifdef CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG
1810 memcpy(fis_work_block, fis_addr, fisdir_size); 1810 memcpy(fis_work_block, fis_addr, fisdir_size);
1811 fis_update_directory(); 1811 fis_update_directory();
1812 #else // CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG 1812 #else // CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG
1902 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG_READONLY_FALLBACK 1902 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG_READONLY_FALLBACK
1903 // Did not find key. Is configuration data valid? 1903 // Did not find key. Is configuration data valid?
1904 // Check to see if the config data is valid, if not, revert to 1904 // Check to see if the config data is valid, if not, revert to
1905 // readonly mode, by setting config to readonly_config. We 1905 // readonly mode, by setting config to readonly_config. We
1906 // will set it back before we leave this function. 1906 // will set it back before we leave this function.
1907 if ( (config != readonly_config) && ((crc32((unsigned char *)config, 1907 if ( (config != readonly_config) && ((cyg_crc32((unsigned char *)config,
1908 sizeof(struct _config)-sizeof(config->cksum)) != config->cksum) || 1908 sizeof(struct _config)-sizeof(config->cksum)) != config->cksum) ||
1909 (config->key1 != CONFIG_KEY1)|| (config->key2 != CONFIG_KEY2))) { 1909 (config->key1 != CONFIG_KEY1)|| (config->key2 != CONFIG_KEY2))) {
1910 save_config = config; 1910 save_config = config;
1911 config = readonly_config; 1911 config = readonly_config;
1912 if ((crc32((unsigned char *)config, 1912 if ((cyg_crc32((unsigned char *)config,
1913 sizeof(struct _config)-sizeof(config->cksum)) != config->cksum) || 1913 sizeof(struct _config)-sizeof(config->cksum)) != config->cksum) ||
1914 (config->key1 != CONFIG_KEY1)|| (config->key2 != CONFIG_KEY2)) { 1914 (config->key1 != CONFIG_KEY1)|| (config->key2 != CONFIG_KEY2)) {
1915 diag_printf("FLASH configuration checksum error or invalid key\n"); 1915 diag_printf("FLASH configuration checksum error or invalid key\n");
1916 config = save_config; 1916 config = save_config;
1917 return false; 1917 return false;
1918 } 1918 }
2077 #endif 2077 #endif
2078 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG_READONLY_FALLBACK 2078 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG_READONLY_FALLBACK
2079 readonly_config = cfg_base; 2079 readonly_config = cfg_base;
2080 #endif 2080 #endif
2081 memcpy(config, cfg_base, sizeof(struct _config)); 2081 memcpy(config, cfg_base, sizeof(struct _config));
2082 if ((crc32((unsigned char *)config, 2082 if ((cyg_crc32((unsigned char *)config,
2083 sizeof(struct _config)-sizeof(config->cksum)) != config->cksum) || 2083 sizeof(struct _config)-sizeof(config->cksum)) != config->cksum) ||
2084 (config->key1 != CONFIG_KEY1)|| (config->key2 != CONFIG_KEY2)) { 2084 (config->key1 != CONFIG_KEY1)|| (config->key2 != CONFIG_KEY2)) {
2085 diag_printf("FLASH configuration checksum error or invalid key\n"); 2085 diag_printf("FLASH configuration checksum error or invalid key\n");
2086 config_init(); 2086 config_init();
2087 return; 2087 return;
2088 } 2088 }