annotate loadtools/flmain.c @ 408:431023033c86

Intel flash: flash status command implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 17 Jun 2014 01:52:46 +0000
parents 0b8e5072abde
children 23ab8fe81764
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
2 * This module is the main entry point for fc-loadtool flash functions
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdint.h>
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <string.h>
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <strings.h>
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <stdlib.h>
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "flash.h"
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12
96
57b8dbb029c2 fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 65
diff changeset
13 /* K5A32xx device description */
57b8dbb029c2 fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 65
diff changeset
14
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
15 static struct flash_geom k5a32xx_topboot_geom = {
400
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
16 .total_size = 0x400000,
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
17 .nregions = 2,
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
18 .regions = {0x10000, 63, 0x2000, 8},
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
19 .total_sectors = 71,
96
57b8dbb029c2 fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 65
diff changeset
20 };
57b8dbb029c2 fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 65
diff changeset
21
203
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
22 static struct flash_idcheck k5a32xx_topboot_idcheck[2] = {
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
23 {0x00, 0x00EC},
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
24 {0x02, 0x22A0}
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
25 };
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
26
96
57b8dbb029c2 fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 65
diff changeset
27 static struct flash_bank_desc k5a32xx_topboot_bankdesc = {
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
28 0x400000, &k5a32xx_topboot_geom, k5a32xx_topboot_idcheck, 2
96
57b8dbb029c2 fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 65
diff changeset
29 };
57b8dbb029c2 fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 65
diff changeset
30
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 /* S{29,71}PL129N device description */
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
33 static struct flash_geom pl129n_ce1_geom = {
400
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
34 .total_size = 0x800000,
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
35 .nregions = 2,
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
36 .regions = {0x10000, 4, 0x40000, 31},
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
37 .total_sectors = 35,
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 };
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
40 static struct flash_geom pl129n_ce2_geom = {
400
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
41 .total_size = 0x800000,
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
42 .nregions = 2,
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
43 .regions = {0x40000, 31, 0x10000, 4},
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
44 .total_sectors = 35,
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 };
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46
203
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
47 static struct flash_idcheck pl129n_idcheck[4] = {
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
48 {0x00, 0x0001},
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
49 {0x02, 0x227E},
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
50 {0x1C, 0x2221},
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
51 {0x1E, 0x2200}
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
52 };
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
53
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 static struct flash_bank_desc pl129n_banks[2] = {
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
55 {0x800000, &pl129n_ce1_geom, pl129n_idcheck, 4},
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
56 {0x800000, &pl129n_ce2_geom, pl129n_idcheck, 4}
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 };
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58
401
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
59 /* bank configurations for CFI */
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
60
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
61 static struct flash_bank_desc cfi_4M_bankdesc = {
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
62 0x400000, 0, 0, 0
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
63 };
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
64
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
65 static struct flash_bank_desc cfi_8M_bankdesc = {
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
66 0x800000, 0, 0, 0
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
67 };
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
68
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 /* list of supported flash devices */
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
71 extern struct flash_cmdset flash_cmdset_amd;
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
72
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 struct flash_device_desc flash_device_list[] = {
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
74 {"cfi-4M", &cfi_4M_bankdesc, 1, 0},
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
75 {"cfi-8M", &cfi_8M_bankdesc, 1, 0},
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
76 {"k5a32xx_t", &k5a32xx_topboot_bankdesc, 1, &flash_cmdset_amd},
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
77 {"pl129n", pl129n_banks, 2, &flash_cmdset_amd},
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
78 {0, 0, 0, 0} /* array terminator */
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 };
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 /* the following variables describe our selected flash device */
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 struct flash_device_desc *selected_flash_device;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 struct flash_bank_info flash_bank_info[2];
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 /* called from hwparam.c config file parser */
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 void
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 set_flash_device(arg, filename_for_errs, lineno_for_errs)
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 char *arg;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 char *filename_for_errs;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 int lineno_for_errs;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 {
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 char *cp, *np, *ep;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 struct flash_device_desc *tp;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 int bank;
56
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
96 struct flash_bank_info *bi;
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 if (selected_flash_device) {
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 fprintf(stderr, "%s line %d: duplicate flash setting\n",
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 filename_for_errs, lineno_for_errs);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 exit(1);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 }
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 for (cp = arg; isspace(*cp); cp++)
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 ;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 if (!*cp || *cp == '#') {
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 too_few_arg: fprintf(stderr,
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 "%s line %d: flash setting: too few arguments\n",
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 filename_for_errs, lineno_for_errs);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 exit(1);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 }
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 for (np = cp; *cp && !isspace(*cp); cp++)
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 ;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 if (*cp)
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 *cp++ = '\0';
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 for (tp = flash_device_list; tp->name; tp++)
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 if (!strcmp(tp->name, np))
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 break;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 if (!tp->name) {
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 fprintf(stderr,
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 "%s line %d: unknown flash device \"%s\"\n",
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 filename_for_errs, lineno_for_errs, np);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 exit(1);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 }
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 selected_flash_device = tp;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 /* now initialize flash_bank_info */
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 for (bank = 0; bank < selected_flash_device->nbanks; bank++) {
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 while (isspace(*cp))
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 cp++;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 if (!*cp || *cp == '#')
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 goto too_few_arg;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 for (np = cp; *cp && !isspace(*cp); cp++)
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 ;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 if (*cp)
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 *cp++ = '\0';
56
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
136 bi = flash_bank_info + bank;
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
137 bi->base_addr = strtoul(np, &ep, 16);
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 if (*ep) {
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 fprintf(stderr,
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 "%s line %d: syntax error (base addr expected after flash device type)\n",
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 filename_for_errs, lineno_for_errs);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 exit(1);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 }
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 /* the rest comes from the flash device type */
56
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
145 bi->bank_desc = selected_flash_device->bank_desc + bank;
400
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
146 if (bi->base_addr & (bi->bank_desc->align_size - 1)) {
56
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
147 fprintf(stderr,
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
148 "%s line %d: flash bank %d base addr is not aligned to the bank size (0x%lx)\n",
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
149 filename_for_errs, lineno_for_errs, bank,
400
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
150 (u_long) bi->bank_desc->align_size);
56
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
151 exit(1);
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
152 }
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
153 bi->geom = bi->bank_desc->geom;
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
154 bi->ops = selected_flash_device->cmdset;
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 }
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 while (isspace(*cp))
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 cp++;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 if (*cp && *cp != '#') {
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 fprintf(stderr,
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 "%s line %d: flash setting: too many arguments\n",
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 filename_for_errs, lineno_for_errs);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 exit(1);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 }
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 }
58
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
165
105
02cb0206aa47 fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 99
diff changeset
166 flashcmd_help()
02cb0206aa47 fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 99
diff changeset
167 {
02cb0206aa47 fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 99
diff changeset
168 return loadtool_help("flash");
02cb0206aa47 fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 99
diff changeset
169 }
02cb0206aa47 fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 99
diff changeset
170
58
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
171 flashcmd_info(argc, argv, bank)
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
172 char **argv;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
173 {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
174 struct flash_bank_info *bi;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
175
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
176 if (argc > 2) {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
177 fprintf(stderr, "error: too many arguments\n");
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
178 return(-1);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
179 }
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
180 bi = flash_bank_info + bank;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
181 printf("Flash device type: %s\n", selected_flash_device->name);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
182 printf("Bank %d base address: %08lX\n", bank, (u_long) bi->base_addr);
400
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
183 if (flash_get_cfi(bank) < 0)
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
184 return(-1);
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
185 printf("Bank %d total size: %lx\n", bank,
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
186 (u_long) bi->geom->total_size);
400
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
187 printf("Sectors in bank %d: %u (%u regions)\n", bank,
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
188 bi->geom->total_sectors, bi->geom->nregions);
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
189 printf("Command set style: %s\n", bi->ops->cmdset_name);
205
cd12d1049f91 fc-loadtool: flash ID check moved into flash info, added to erase and program
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 204
diff changeset
190 flash_id_check(bank, 1);
58
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
191 if (selected_flash_device->nbanks == 2 && !bank)
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
192 printf("\nFlash device has 2 banks; flash2 command available\n");
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
193 return(0);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
194 }
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
195
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
196 extern int flashcmd_blankchk();
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
197 extern int flashcmd_dump2file();
62
6fb41cfa773d fc-loadtool: flash erase implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 61
diff changeset
198 extern int flashcmd_erase();
65
a7da6648a7f8 fc-loadtool: flash program-bin command implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 64
diff changeset
199 extern int flashcmd_progbin();
99
b78db17bfc85 fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 96
diff changeset
200 extern int flashcmd_program_m0();
b78db17bfc85 fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 96
diff changeset
201 extern int flashcmd_program_srec();
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
202 extern int flashcmd_quickprog();
406
0b8e5072abde fc-loadtool flash: reset to read mode added where appropriate
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 405
diff changeset
203 extern int flashcmd_reset();
61
a10491da8c3a fc-loadtool flash support: sector table generation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 60
diff changeset
204 extern int flashcmd_sectors();
408
431023033c86 Intel flash: flash status command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 406
diff changeset
205 extern int flashcmd_status();
61
a10491da8c3a fc-loadtool flash support: sector table generation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 60
diff changeset
206
58
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
207 static struct cmdtab {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
208 char *cmd;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
209 int (*func)();
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
210 } cmdtab[] = {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
211 {"blankchk", flashcmd_blankchk},
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
212 {"dump2bin", flashcmd_dump2file},
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
213 {"dump2srec", flashcmd_dump2file},
62
6fb41cfa773d fc-loadtool: flash erase implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 61
diff changeset
214 {"erase", flashcmd_erase},
105
02cb0206aa47 fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 99
diff changeset
215 {"help", flashcmd_help},
58
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
216 {"info", flashcmd_info},
65
a7da6648a7f8 fc-loadtool: flash program-bin command implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 64
diff changeset
217 {"program-bin", flashcmd_progbin},
99
b78db17bfc85 fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 96
diff changeset
218 {"program-m0", flashcmd_program_m0},
b78db17bfc85 fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 96
diff changeset
219 {"program-srec", flashcmd_program_srec},
64
a481d648278a fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 62
diff changeset
220 {"quickprog", flashcmd_quickprog},
406
0b8e5072abde fc-loadtool flash: reset to read mode added where appropriate
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 405
diff changeset
221 {"reset", flashcmd_reset},
61
a10491da8c3a fc-loadtool flash support: sector table generation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 60
diff changeset
222 {"sectors", flashcmd_sectors},
408
431023033c86 Intel flash: flash status command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 406
diff changeset
223 {"status", flashcmd_status},
58
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
224 {0, 0}
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
225 };
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
226
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
227 cmd_flash(argc, argv)
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
228 char **argv;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
229 {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
230 int bank;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
231 struct cmdtab *tp;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
232
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
233 if (!selected_flash_device) {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
234 fprintf(stderr, "No flash configuration defined\n");
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
235 return(-1);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
236 }
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
237 if (argv[0][5] == '2') {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
238 if (selected_flash_device->nbanks < 2) {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
239 fprintf(stderr, "Flash device %s has only one bank\n",
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
240 selected_flash_device->name);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
241 return(-1);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
242 }
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
243 bank = 1;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
244 } else
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
245 bank = 0;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
246 for (tp = cmdtab; tp->cmd; tp++)
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
247 if (!strcmp(tp->cmd, argv[1]))
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
248 break;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
249 if (!tp->func) {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
250 fprintf(stderr, "%s %s: unknown/unimplemented subcommand\n",
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
251 argv[0], argv[1]);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
252 return(-1);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
253 }
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
254 return tp->func(argc, argv, bank);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
255 }