diff loadtools/flprogbin.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 a212b4968b29
line wrap: on
line diff
--- a/loadtools/flprogbin.c	Sun Jun 15 00:47:06 2014 +0000
+++ b/loadtools/flprogbin.c	Sun Jun 15 20:05:54 2014 +0000
@@ -35,11 +35,18 @@
 	flashoff = strtoul(argv[2], &strtoul_endp, 16);
 	if (*strtoul_endp)
 		goto inv;
+	if (flash_get_cfi(bank) < 0)
+		return(-1);
 	bi = flash_bank_info + bank;
-	if (flashoff >= bi->total_size) {
+	if (bi->cfi->cmdset_style != 2) {
+		fprintf(stderr,
+"error: this command is currently only implemented for AMD-style flash\n");
+		return(-1);
+	}
+	if (flashoff >= bi->cfi->total_size) {
 		fprintf(stderr,
 		"error: specified flash offset exceeds bank size (0x%lx)\n",
-			(u_long) bi->total_size);
+			(u_long) bi->cfi->total_size);
 		return(-1);
 	}
 	if (flashoff & 1) {
@@ -90,10 +97,10 @@
 		fclose(binf);
 		return(0);
 	}
-	if (len > bi->total_size - flashoff) {
+	if (len > bi->cfi->total_size - flashoff) {
 		fprintf(stderr,
 	"error: specified flash offset+length exceed bank size (0x%lx)\n",
-			(u_long) bi->total_size);
+			(u_long) bi->cfi->total_size);
 		fclose(binf);
 		return(-1);
 	}