comparison loadtools/flerase.c @ 400:f027c6fbe37e

fc-loadtool flash: first round of refactoring for CFI
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 15 Jun 2014 20:05:54 +0000
parents cd12d1049f91
children
comparison
equal deleted inserted replaced
399:d26a9e3de626 400:f027c6fbe37e
70 return(-1); 70 return(-1);
71 } 71 }
72 offset = strtoul(argv[2], &strtoul_endp, 16); 72 offset = strtoul(argv[2], &strtoul_endp, 16);
73 if (*strtoul_endp) 73 if (*strtoul_endp)
74 goto inv; 74 goto inv;
75 if (flash_get_cfi(bank) < 0)
76 return(-1);
75 bi = flash_bank_info + bank; 77 bi = flash_bank_info + bank;
76 if (offset >= bi->total_size) { 78 if (bi->cfi->cmdset_style != 2) {
79 fprintf(stderr,
80 "error: this command is currently only implemented for AMD-style flash\n");
81 return(-1);
82 }
83 if (offset >= bi->cfi->total_size) {
77 fprintf(stderr, 84 fprintf(stderr,
78 "error: specified offset exceeds flash bank size (0x%lx)\n", 85 "error: specified offset exceeds flash bank size (0x%lx)\n",
79 (u_long) bi->total_size); 86 (u_long) bi->cfi->total_size);
80 return(-1); 87 return(-1);
81 } 88 }
82 len = strtoul(argv[3], &strtoul_endp, 16); 89 len = strtoul(argv[3], &strtoul_endp, 16);
83 if (*strtoul_endp) 90 if (*strtoul_endp)
84 goto inv; 91 goto inv;
85 if (len > bi->total_size - offset) { 92 if (len > bi->cfi->total_size - offset) {
86 fprintf(stderr, 93 fprintf(stderr,
87 "error: specified offset+length exceed flash bank size (0x%lx)\n", 94 "error: specified offset+length exceed flash bank size (0x%lx)\n",
88 (u_long) bi->total_size); 95 (u_long) bi->cfi->total_size);
89 return(-1); 96 return(-1);
90 } 97 }
91 if (!len) { 98 if (!len) {
92 printf("Zero length specified - nothing to do!\n"); 99 printf("Zero length specified - nothing to do!\n");
93 return(0); 100 return(0);