annotate loadtools/flmain.c @ 551:2e662daa7441

L1: l1_cmplx.c compiles for IRAM
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 03 Aug 2014 18:32:58 +0000
parents b2487cfd68fd
children
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>
412
bf49e348576b fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 409
diff changeset
6 #include <ctype.h>
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdint.h>
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <string.h>
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <strings.h>
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include <stdlib.h>
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "flash.h"
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13
96
57b8dbb029c2 fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 65
diff changeset
14 /* K5A32xx device description */
57b8dbb029c2 fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 65
diff changeset
15
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
16 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
17 .total_size = 0x400000,
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
18 .nregions = 2,
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
19 .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
20 .total_sectors = 71,
96
57b8dbb029c2 fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 65
diff changeset
21 };
57b8dbb029c2 fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 65
diff changeset
22
203
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
23 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
24 {0x00, 0x00EC},
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
25 {0x02, 0x22A0}
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
26 };
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
27
96
57b8dbb029c2 fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 65
diff changeset
28 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
29 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
30 };
57b8dbb029c2 fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 65
diff changeset
31
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 /* S{29,71}PL129N device description */
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
34 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
35 .total_size = 0x800000,
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
36 .nregions = 2,
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
37 .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
38 .total_sectors = 35,
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 };
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
41 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
42 .total_size = 0x800000,
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
43 .nregions = 2,
f027c6fbe37e fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 205
diff changeset
44 .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
45 .total_sectors = 35,
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 };
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47
203
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
48 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
49 {0x00, 0x0001},
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
50 {0x02, 0x227E},
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
51 {0x1C, 0x2221},
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
52 {0x1E, 0x2200}
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
53 };
99c234bf6a9b fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 105
diff changeset
54
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 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
56 {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
57 {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
58 };
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59
401
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
60 /* bank configurations for CFI */
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
61
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
62 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
63 0x400000, 0, 0, 0
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
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
66 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
67 0x800000, 0, 0, 0
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
68 };
7ceeec049be4 fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 400
diff changeset
69
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 /* list of supported flash devices */
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
72 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
73
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 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
75 {"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
76 {"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
77 {"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
78 {"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
79 {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
80 };
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 /* 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
83
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 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
85 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
86
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 /* 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
88 void
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 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
90 char *arg;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 char *filename_for_errs;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 int lineno_for_errs;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 {
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 char *cp, *np, *ep;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 struct flash_device_desc *tp;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 int bank;
56
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
97 struct flash_bank_info *bi;
55
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 if (selected_flash_device) {
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 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
101 filename_for_errs, lineno_for_errs);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 exit(1);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 }
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 for (cp = arg; isspace(*cp); cp++)
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 ;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 if (!*cp || *cp == '#') {
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 too_few_arg: fprintf(stderr,
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 "%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
109 filename_for_errs, lineno_for_errs);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 exit(1);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 }
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 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
113 ;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 if (*cp)
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 *cp++ = '\0';
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 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
117 if (!strcmp(tp->name, np))
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 break;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 if (!tp->name) {
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 fprintf(stderr,
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 "%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
122 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
123 exit(1);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 }
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 selected_flash_device = tp;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 /* now initialize flash_bank_info */
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 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
129 while (isspace(*cp))
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 cp++;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 if (!*cp || *cp == '#')
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 goto too_few_arg;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 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
134 ;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 if (*cp)
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 *cp++ = '\0';
56
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
137 bi = flash_bank_info + bank;
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
138 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
139 if (*ep) {
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 fprintf(stderr,
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 "%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
142 filename_for_errs, lineno_for_errs);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 exit(1);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 }
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 /* 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
146 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
147 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
148 fprintf(stderr,
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
149 "%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
150 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
151 (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
152 exit(1);
d98137625c0d fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 55
diff changeset
153 }
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
154 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
155 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
156 }
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 while (isspace(*cp))
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 cp++;
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 if (*cp && *cp != '#') {
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 fprintf(stderr,
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 "%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
162 filename_for_errs, lineno_for_errs);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 exit(1);
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 }
278052b6afda loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 }
58
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
166
105
02cb0206aa47 fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 99
diff changeset
167 flashcmd_help()
02cb0206aa47 fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 99
diff changeset
168 {
02cb0206aa47 fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 99
diff changeset
169 return loadtool_help("flash");
02cb0206aa47 fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 99
diff changeset
170 }
02cb0206aa47 fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 99
diff changeset
171
58
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
172 flashcmd_info(argc, argv, bank)
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
173 char **argv;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
174 {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
175 struct flash_bank_info *bi;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
176
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
177 if (argc > 2) {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
178 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
179 return(-1);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
180 }
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
181 bi = flash_bank_info + bank;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
182 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
183 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
184 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
185 return(-1);
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
186 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
187 (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
188 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
189 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
190 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
191 flash_id_check(bank, 1);
58
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
192 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
193 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
194 return(0);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
195 }
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
196
405
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
197 extern int flashcmd_blankchk();
a212b4968b29 fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 401
diff changeset
198 extern int flashcmd_dump2file();
62
6fb41cfa773d fc-loadtool: flash erase implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 61
diff changeset
199 extern int flashcmd_erase();
415
b2487cfd68fd fc-loadtool: flash erase-program-boot implementation complete
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 412
diff changeset
200 extern int flashcmd_erase_program_boot();
65
a7da6648a7f8 fc-loadtool: flash program-bin command implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 64
diff changeset
201 extern int flashcmd_progbin();
99
b78db17bfc85 fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 96
diff changeset
202 extern int flashcmd_program_m0();
b78db17bfc85 fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 96
diff changeset
203 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
204 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
205 extern int flashcmd_reset();
61
a10491da8c3a fc-loadtool flash support: sector table generation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 60
diff changeset
206 extern int flashcmd_sectors();
408
431023033c86 Intel flash: flash status command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 406
diff changeset
207 extern int flashcmd_status();
409
23ab8fe81764 Intel flash: unlock command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 408
diff changeset
208 extern int flashcmd_unlock();
61
a10491da8c3a fc-loadtool flash support: sector table generation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 60
diff changeset
209
58
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
210 static struct cmdtab {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
211 char *cmd;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
212 int (*func)();
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
213 } cmdtab[] = {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
214 {"blankchk", flashcmd_blankchk},
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
215 {"dump2bin", flashcmd_dump2file},
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
216 {"dump2srec", flashcmd_dump2file},
62
6fb41cfa773d fc-loadtool: flash erase implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 61
diff changeset
217 {"erase", flashcmd_erase},
415
b2487cfd68fd fc-loadtool: flash erase-program-boot implementation complete
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 412
diff changeset
218 {"erase-program-boot", flashcmd_erase_program_boot},
105
02cb0206aa47 fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 99
diff changeset
219 {"help", flashcmd_help},
58
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
220 {"info", flashcmd_info},
65
a7da6648a7f8 fc-loadtool: flash program-bin command implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 64
diff changeset
221 {"program-bin", flashcmd_progbin},
99
b78db17bfc85 fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 96
diff changeset
222 {"program-m0", flashcmd_program_m0},
b78db17bfc85 fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 96
diff changeset
223 {"program-srec", flashcmd_program_srec},
64
a481d648278a fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 62
diff changeset
224 {"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
225 {"reset", flashcmd_reset},
61
a10491da8c3a fc-loadtool flash support: sector table generation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 60
diff changeset
226 {"sectors", flashcmd_sectors},
408
431023033c86 Intel flash: flash status command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 406
diff changeset
227 {"status", flashcmd_status},
409
23ab8fe81764 Intel flash: unlock command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 408
diff changeset
228 {"unlock", flashcmd_unlock},
58
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
229 {0, 0}
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
230 };
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
231
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
232 cmd_flash(argc, argv)
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
233 char **argv;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
234 {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
235 int bank;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
236 struct cmdtab *tp;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
237
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
238 if (!selected_flash_device) {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
239 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
240 return(-1);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
241 }
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
242 if (argv[0][5] == '2') {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
243 if (selected_flash_device->nbanks < 2) {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
244 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
245 selected_flash_device->name);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
246 return(-1);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
247 }
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
248 bank = 1;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
249 } else
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
250 bank = 0;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
251 for (tp = cmdtab; tp->cmd; tp++)
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
252 if (!strcmp(tp->cmd, argv[1]))
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
253 break;
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
254 if (!tp->func) {
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
255 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
256 argv[0], argv[1]);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
257 return(-1);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
258 }
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
259 return tp->func(argc, argv, bank);
1f9302b6f342 fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 56
diff changeset
260 }