diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2012-08-09 19:52:22 +0200 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2012-08-09 19:52:22 +0200 |
commit | 6e710dcac95a402acb2f07db549a12f526b700a1 (patch) | |
tree | 79f1b1d8e8b2228610373bcf18c97d9c332c2745 /src | |
parent | b2883167d5db98d279687ea009950569568316a3 (diff) | |
download | 0xFFFF-6e710dcac95a402acb2f07db549a12f526b700a1.tar.bz2 |
Remove old hash.c code
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/flash.c | 5 | ||||
-rw-r--r-- | src/hash.c | 82 | ||||
-rw-r--r-- | src/hash.h | 10 | ||||
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/main.h | 1 |
6 files changed, 7 insertions, 99 deletions
diff --git a/src/Makefile b/src/Makefile index 531c956..fb9eedf 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,6 @@ include ../config.mk OBJ=main.o hexdump.o dump.o flash.o serial.o qmode.o -OBJ+=hash.o fpid.o query.o pieces.o utils.o devices.o console.o +OBJ+=fpid.o query.o pieces.o utils.o devices.o console.o OBJ+=squeue/squeue.o BIN=0xFFFF #LIBS=`${HAVE_USB} && echo -- '-lusb'` diff --git a/src/flash.c b/src/flash.c index 537dd82..e1f4f7b 100644 --- a/src/flash.c +++ b/src/flash.c @@ -18,7 +18,6 @@ #if HAVE_USB #include "main.h" -#include "hash.h" #include "hexdump.h" #include <stdio.h> #include <string.h> @@ -84,7 +83,7 @@ void flash_image(const char *filename, const char *piece, const char *device, co unsigned long long size, off; unsigned char bsize[4], tmp; unsigned char nolofiller[128]; - ushort hash = do_hash_file(filename, piece); + ushort hash = 0; //do_hash_file(filename, piece); if (piece == NULL) { //exit(1); @@ -152,6 +151,8 @@ void flash_image(const char *filename, const char *piece, const char *device, co printf("[=] Bulkwriting the %s piece...\n", piece); fflush(stdout); + #define BSIZE 0x20000 + for(off = 0; off<size; off += BSIZE) { char buf[BSIZE]; int bread, bsize = size-off; diff --git a/src/hash.c b/src/hash.c deleted file mode 100644 index 9090bad..0000000 --- a/src/hash.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 0xFFFF - Open Free Fiasco Firmware Flasher - * Copyright (C) 2007-2009 pancake <pancake@youterm.com> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <stdio.h> -#include <string.h> -#include "hash.h" - -usho do_hash(usho *b, int len) -{ - usho result = 0; - for(len>>=1;len--;b=b+1) - result^=b[0]; - return result; -} - -usho do_hash_file(const char *filename, const char *type) -{ - unsigned char buf[BSIZE]; - FILE *fd = fopen(filename, "r"); - usho hash = 0; - int align = 0; - int size; - int ret; - - if (fd == NULL) { - fprintf(stderr, "ERROR: File '%s' not found.\n", filename); - return -1; - } - - do { - ret = fread(&buf, 1, BSIZE, fd); - if (ret == -1) - return 0; - hash ^= do_hash((usho *)&buf, ret); - } while(ret); - - size = ftell(fd); - fclose(fd); - - /* mmc and kernel image must be aligned */ - if (type) { - if (strcmp(type, "mmc") == 0) - align = ((size >> 8) + 1) << 8; - else if (strcmp(type, "kernel") == 0) - align = ((size >> 7) + 1) << 7; - } - - if (align) { - printf("align from %d to %d\n", size, align); - buf[0] = 0xff; - while (size < align) { - hash ^= do_hash((usho *)&buf, 1); - ++size; - } - } - - return hash; -} - -#if 0 -main() -{ - usho us = do_hash_file("zImage"); - unsigned char *h= (unsigned char *)&us; - printf("%x %x\n",h[0],h[1]); -} -#endif diff --git a/src/hash.h b/src/hash.h deleted file mode 100644 index 03825ae..0000000 --- a/src/hash.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _INCLUDE_HASH_H_ -#define _INCLUDE_HASH_H_ - -#define usho unsigned short -#define BSIZE 0x20000 - -usho do_hash(usho *b, int len); -usho do_hash_file(const char *filename, const char *type); - -#endif @@ -416,9 +416,9 @@ int main(int argc, char **argv) while((c = getopt(argc, argv, "QC:cp:PvVhRu:ib:U:r:e:ld:I:D:f:F:s:xH:S:n")) != -1) { switch(c) { - case 'H': - printf("xorpair: %04x\n", do_hash_file(optarg, NULL)); - return 0; +// case 'H': +// printf("xorpair: %04x\n", do_hash_file(optarg, NULL)); +// return 0; case 'x': return dump_config(); #if HAVE_USB @@ -2,7 +2,6 @@ #ifndef _INCLUDE_MAIN_H_ #define _INCLUDE_MAIN_H_ -#include "hash.h" #include "nolo.h" #include "os.h" extern char strbuf[1024]; |