FreeCalypso > hg > freecalypso-sw
comparison loadtools/ltflash.c @ 56:d98137625c0d
fc-loadtool flash: total_size logic implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 23 Jun 2013 20:50:41 +0000 |
parents | 278052b6afda |
children | 1f9302b6f342 |
comparison
equal
deleted
inserted
replaced
55:278052b6afda | 56:d98137625c0d |
---|---|
52 int lineno_for_errs; | 52 int lineno_for_errs; |
53 { | 53 { |
54 char *cp, *np, *ep; | 54 char *cp, *np, *ep; |
55 struct flash_device_desc *tp; | 55 struct flash_device_desc *tp; |
56 int bank; | 56 int bank; |
57 struct flash_bank_info *bi; | |
57 | 58 |
58 if (selected_flash_device) { | 59 if (selected_flash_device) { |
59 fprintf(stderr, "%s line %d: duplicate flash setting\n", | 60 fprintf(stderr, "%s line %d: duplicate flash setting\n", |
60 filename_for_errs, lineno_for_errs); | 61 filename_for_errs, lineno_for_errs); |
61 exit(1); | 62 exit(1); |
91 goto too_few_arg; | 92 goto too_few_arg; |
92 for (np = cp; *cp && !isspace(*cp); cp++) | 93 for (np = cp; *cp && !isspace(*cp); cp++) |
93 ; | 94 ; |
94 if (*cp) | 95 if (*cp) |
95 *cp++ = '\0'; | 96 *cp++ = '\0'; |
96 flash_bank_info[bank].base_addr = strtoul(np, &ep, 16); | 97 bi = flash_bank_info + bank; |
98 bi->base_addr = strtoul(np, &ep, 16); | |
97 if (*ep) { | 99 if (*ep) { |
98 fprintf(stderr, | 100 fprintf(stderr, |
99 "%s line %d: syntax error (base addr expected after flash device type)\n", | 101 "%s line %d: syntax error (base addr expected after flash device type)\n", |
100 filename_for_errs, lineno_for_errs); | 102 filename_for_errs, lineno_for_errs); |
101 exit(1); | 103 exit(1); |
102 } | 104 } |
103 /* the rest comes from the flash device type */ | 105 /* the rest comes from the flash device type */ |
104 flash_bank_info[bank].bank_desc = | 106 bi->bank_desc = selected_flash_device->bank_desc + bank; |
105 selected_flash_device->bank_desc + bank; | 107 compute_flash_totsize_nsecs(bank); |
106 /* TODO: call function to init total_size and nsectors */ | 108 if (count_ones(bi->total_size) != 1) { |
109 fprintf(stderr, | |
110 "fc-loadtool internal bug: flash bank %d size for %s is not a power of 2\n", | |
111 bank, selected_flash_device->name); | |
112 exit(1); | |
113 } | |
114 if (bi->base_addr & (bi->total_size - 1)) { | |
115 fprintf(stderr, | |
116 "%s line %d: flash bank %d base addr is not aligned to the bank size (0x%lx)\n", | |
117 filename_for_errs, lineno_for_errs, bank, | |
118 (u_long) bi->total_size); | |
119 exit(1); | |
120 } | |
107 } | 121 } |
108 while (isspace(*cp)) | 122 while (isspace(*cp)) |
109 cp++; | 123 cp++; |
110 if (*cp && *cp != '#') { | 124 if (*cp && *cp != '#') { |
111 fprintf(stderr, | 125 fprintf(stderr, |