FreeCalypso > hg > freecalypso-sw
annotate loadtools/ltflash.c @ 58:1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 24 Jun 2013 06:30:57 +0000 |
parents | d98137625c0d |
children | 048329d0888e |
rev | line source |
---|---|
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * In this module we are going to implement the flash operation commands |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * of fc-loadtool. |
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 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <sys/types.h> |
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 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 /* S{29,71}PL129N device description */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 static struct flash_region_desc pl129n_ce1_regions[] = { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 /* 4 sectors of 64 KiB each at the beginning, then 256 KiB sectors */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 {0x10000, 4}, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 {0x40000, 31}, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 {0, 0} /* array terminator */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 }; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 static struct flash_region_desc pl129n_ce2_regions[] = { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 /* the other way around now */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 {0x40000, 31}, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 {0x10000, 4}, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 {0, 0} /* array terminator */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 }; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 static struct flash_bank_desc pl129n_banks[2] = { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 {pl129n_ce1_regions, 0xFFFC0000}, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 {pl129n_ce2_regions, 0xFFFC0000} |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 }; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 /* list of supported flash devices */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 struct flash_device_desc flash_device_list[] = { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 {"pl129n", pl129n_banks, 2}, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 {0, 0, 0} /* array terminator */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 }; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 /* 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
|
43 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 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
|
45 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
|
46 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 /* 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
|
48 void |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 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
|
50 char *arg; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 char *filename_for_errs; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 int lineno_for_errs; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 char *cp, *np, *ep; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 struct flash_device_desc *tp; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 int bank; |
56
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
57 struct flash_bank_info *bi; |
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 if (selected_flash_device) { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 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
|
61 filename_for_errs, lineno_for_errs); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 exit(1); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 for (cp = arg; isspace(*cp); cp++) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 ; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 if (!*cp || *cp == '#') { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 too_few_arg: fprintf(stderr, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 "%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
|
69 filename_for_errs, lineno_for_errs); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 exit(1); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 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
|
73 ; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 if (*cp) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 *cp++ = '\0'; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 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
|
77 if (!strcmp(tp->name, np)) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 break; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 if (!tp->name) { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 fprintf(stderr, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 "%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
|
82 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
|
83 exit(1); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 selected_flash_device = tp; |
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 /* now initialize flash_bank_info */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 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
|
89 while (isspace(*cp)) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 cp++; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 if (!*cp || *cp == '#') |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 goto too_few_arg; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 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
|
94 ; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 if (*cp) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 *cp++ = '\0'; |
56
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
97 bi = flash_bank_info + bank; |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
98 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
|
99 if (*ep) { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 fprintf(stderr, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 "%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
|
102 filename_for_errs, lineno_for_errs); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 exit(1); |
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 /* 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
|
106 bi->bank_desc = selected_flash_device->bank_desc + bank; |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
107 compute_flash_totsize_nsecs(bank); |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
108 if (count_ones(bi->total_size) != 1) { |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
109 fprintf(stderr, |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
110 "fc-loadtool internal bug: flash bank %d size for %s is not a power of 2\n", |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
111 bank, selected_flash_device->name); |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
112 exit(1); |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
113 } |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
114 if (bi->base_addr & (bi->total_size - 1)) { |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
115 fprintf(stderr, |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
116 "%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
|
117 filename_for_errs, lineno_for_errs, bank, |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
118 (u_long) bi->total_size); |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
119 exit(1); |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
120 } |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 while (isspace(*cp)) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 cp++; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 if (*cp && *cp != '#') { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 fprintf(stderr, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 "%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
|
127 filename_for_errs, lineno_for_errs); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 exit(1); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 } |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
131 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
132 flashcmd_blankchk(argc, argv, bank) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
133 char **argv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
134 { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
135 printf("To be implemented\n"); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
136 return(1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
137 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
138 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
139 flashcmd_dump2file(argc, argv, bank) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
140 char **argv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
141 { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
142 struct flash_bank_info *bi; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
143 u_long offset, dumplen, maxlen; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
144 char *strtoul_endp; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
145 int format; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
146 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
147 if (argc < 3 || argc > 5) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
148 inv: fprintf(stderr, "usage: %s %s outfile [offset [length]]\n", |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
149 argv[0], argv[1]); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
150 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
151 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
152 bi = flash_bank_info + bank; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
153 if (argc >= 4) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
154 offset = strtoul(argv[3], &strtoul_endp, 16); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
155 if (*strtoul_endp) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
156 goto inv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
157 if (offset >= bi->total_size) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
158 fprintf(stderr, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
159 "error: specified offset exceeds flash bank size (0x%lx)\n", |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
160 (u_long) bi->total_size); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
161 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
162 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
163 } else |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
164 offset = 0; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
165 maxlen = bi->total_size - offset; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
166 if (argc >= 5) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
167 dumplen = strtoul(argv[4], &strtoul_endp, 16); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
168 if (*strtoul_endp) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
169 goto inv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
170 if (dumplen > maxlen) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
171 fprintf(stderr, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
172 "error: specified offset+length exceed flash bank size (0x%lx)\n", |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
173 (u_long) bi->total_size); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
174 return(-1); |
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 } else |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
177 dumplen = maxlen; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
178 switch (argv[1][5]) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
179 case 'b': |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
180 format = 0; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
181 break; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
182 case 's': |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
183 format = 1; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
184 break; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
185 default: |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
186 fprintf(stderr, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
187 "internal bug: bad format in flashcmd_dump2file()\n"); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
188 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
189 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
190 return loadtool_memdump(bi->base_addr + offset, dumplen, argv[2], |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
191 format); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
192 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
193 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
194 flashcmd_info(argc, argv, bank) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
195 char **argv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
196 { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
197 struct flash_bank_info *bi; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
198 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
199 if (argc > 2) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
200 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
|
201 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
202 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
203 bi = flash_bank_info + bank; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
204 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
|
205 printf("Bank %d base address: %08lX\n", bank, (u_long) bi->base_addr); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
206 printf("Bank %d total size: %lx\n", bank, (u_long) bi->total_size); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
207 printf("Sectors in bank %d: %u\n", bank, bi->nsectors); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
208 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
|
209 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
|
210 return(0); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
211 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
212 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
213 static struct cmdtab { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
214 char *cmd; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
215 int (*func)(); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
216 } cmdtab[] = { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
217 {"blankchk", flashcmd_blankchk}, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
218 {"dump2bin", flashcmd_dump2file}, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
219 {"dump2srec", flashcmd_dump2file}, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
220 {"info", flashcmd_info}, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
221 {0, 0} |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
222 }; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
223 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
224 cmd_flash(argc, argv) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
225 char **argv; |
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 int bank; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
228 struct cmdtab *tp; |
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 if (!selected_flash_device) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
231 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
|
232 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
233 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
234 if (argv[0][5] == '2') { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
235 if (selected_flash_device->nbanks < 2) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
236 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
|
237 selected_flash_device->name); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
238 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
239 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
240 bank = 1; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
241 } else |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
242 bank = 0; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
243 for (tp = cmdtab; tp->cmd; tp++) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
244 if (!strcmp(tp->cmd, argv[1])) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
245 break; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
246 if (!tp->func) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
247 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
|
248 argv[0], argv[1]); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
249 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
250 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
251 return tp->func(argc, argv, bank); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
252 } |