diff loadtools/flprogbin.c @ 405:a212b4968b29

fc-loadtool flash: another refactoring: geometry vs. command set
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 17 Jun 2014 00:33:05 +0000
parents f027c6fbe37e
children 81d387690063
line wrap: on
line diff
--- a/loadtools/flprogbin.c	Mon Jun 16 01:15:17 2014 +0000
+++ b/loadtools/flprogbin.c	Tue Jun 17 00:33:05 2014 +0000
@@ -1,5 +1,5 @@
 /*
- * In this module we are going to implement the flash program-bin command:
+ * This module implements the flash program-bin command:
  * programming flash using a binary file as the data source.
  */
 
@@ -38,15 +38,10 @@
 	if (flash_get_cfi(bank) < 0)
 		return(-1);
 	bi = flash_bank_info + bank;
-	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) {
+	if (flashoff >= bi->geom->total_size) {
 		fprintf(stderr,
 		"error: specified flash offset exceeds bank size (0x%lx)\n",
-			(u_long) bi->cfi->total_size);
+			(u_long) bi->geom->total_size);
 		return(-1);
 	}
 	if (flashoff & 1) {
@@ -97,10 +92,10 @@
 		fclose(binf);
 		return(0);
 	}
-	if (len > bi->cfi->total_size - flashoff) {
+	if (len > bi->geom->total_size - flashoff) {
 		fprintf(stderr,
 	"error: specified flash offset+length exceed bank size (0x%lx)\n",
-			(u_long) bi->cfi->total_size);
+			(u_long) bi->geom->total_size);
 		fclose(binf);
 		return(-1);
 	}
@@ -116,7 +111,7 @@
 		return(-1);
 	}
 	sprintf(shortarg, "%lx", (u_long) bi->base_addr);
-	targv[0] = "AMFB";
+	targv[0] = bi->ops->loadagent_setbase_cmd;
 	targv[1] = shortarg;
 	targv[2] = 0;
 	printf("Setting flash base address: %s %s\n", targv[0], targv[1]);
@@ -131,7 +126,7 @@
 		return(cc);
 	}
 	fseek(binf, fileoff, SEEK_SET);
-	targv[0] = "AMFW";
+	targv[0] = bi->ops->loadagent_program_cmd;
 	targv[1] = shortarg;
 	targv[2] = longarg;
 	targv[3] = 0;