Changeset 1482
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli_classic.c
r1479 r1482 296 296 break; 297 297 case 'i': 298 /* FIXME: -l has to be specified before -i. */299 298 tempstr = strdup(optarg); 300 if (find_romentry(tempstr) < 0) { 301 fprintf(stderr, "Error: image %s not found in " 302 "layout file or -i specified before " 303 "-l\n", tempstr); 304 cli_classic_abort_usage(); 305 } 299 if (register_include_arg(tempstr)) 300 cli_classic_abort_usage(); 306 301 break; 307 302 case 'L': … … 395 390 cli_classic_abort_usage(); 396 391 } 392 393 if (process_include_args()) 394 cli_classic_abort_usage(); 397 395 398 396 /* FIXME: Print the actions flashrom will take. */ -
trunk/flash.h
r1475 r1482 290 290 291 291 /* layout.c */ 292 int register_include_arg(char *name); 293 int process_include_args(void); 292 294 int read_romlayout(char *name); 293 int find_romentry(char *name);294 295 int handle_romentries(struct flashctx *flash, uint8_t *oldcontents, uint8_t *newcontents); 295 296 -
trunk/layout.c
r1481 r1482 42 42 } romlayout_t; 43 43 44 /* include_args lists arguments specified at the command line with -i. They 45 * must be processed at some point so that desired regions are marked as 46 * "included" in the rom_entries list. 47 */ 48 static char *include_args[MAX_ROMLAYOUT]; 49 static int num_include_args = 0; /* the number of valid entries. */ 44 50 static romlayout_t rom_entries[MAX_ROMLAYOUT]; 45 51 … … 157 163 if (romimages >= MAX_ROMLAYOUT) { 158 164 msg_gerr("Maximum number of ROM images (%i) in layout " 159 "file reached before end of layout file.\n", 160 MAX_ROMLAYOUT); 161 msg_gerr("Ignoring the rest of the layout file.\n"); 162 break; 165 "file reached.\n", MAX_ROMLAYOUT); 166 return 1; 163 167 } 164 168 if (2 != fscanf(romlayout, "%s %s\n", tempstr, rom_entries[romimages].name)) … … 195 199 #endif 196 200 197 int find_romentry(char *name) 201 /* register an include argument (-i) for later processing */ 202 int register_include_arg(char *name) 203 { 204 if (num_include_args >= MAX_ROMLAYOUT) { 205 msg_gerr("Too many regions included (%i).\n", num_include_args); 206 return 1; 207 } 208 209 if (name == NULL) { 210 msg_gerr("<NULL> is a bad region name.\n"); 211 return 1; 212 } 213 214 include_args[num_include_args] = name; 215 num_include_args++; 216 return 0; 217 } 218 219 /* returns the index of the entry (or a negative value if it is not found) */ 220 static int find_romentry(char *name) 198 221 { 199 222 int i; … … 202 225 return -1; 203 226 204 msg_ginfo("Looking for \"%s\"... ", name); 205 227 msg_gspew("Looking for region \"%s\"... ", name); 206 228 for (i = 0; i < romimages; i++) { 207 229 if (!strcmp(rom_entries[i].name, name)) { 208 230 rom_entries[i].included = 1; 209 msg_g info("found.\n");231 msg_gspew("found.\n"); 210 232 return i; 211 233 } 212 234 } 213 msg_ginfo("not found.\n"); // Not found. Error. 214 235 msg_gspew("not found.\n"); 215 236 return -1; 237 } 238 239 /* process -i arguments 240 * returns 0 to indicate success, >0 to indicate failure 241 */ 242 int process_include_args(void) 243 { 244 int i; 245 unsigned int found = 0; 246 247 if (num_include_args == 0) 248 return 0; 249 250 for (i = 0; i < num_include_args; i++) { 251 /* User has specified an area, but no layout file is loaded. */ 252 if (!romimages) { 253 msg_gerr("Region requested (with -i \"%s\"), " 254 "but no layout data is available.\n", 255 include_args[i]); 256 return 1; 257 } 258 259 if (find_romentry(include_args[i]) < 0) { 260 msg_gerr("Invalid region specified: \"%s\"\n", 261 include_args[i]); 262 return 1; 263 } 264 found++; 265 } 266 267 msg_ginfo("Using region%s: \"%s\"", num_include_args > 1 ? "s" : "", 268 include_args[0]); 269 for (i = 1; i < num_include_args; i++) 270 msg_ginfo(", \"%s\"", include_args[i]); 271 msg_ginfo(".\n"); 272 return 0; 216 273 } 217 274 … … 249 306 unsigned int size = flash->total_size * 1024; 250 307 251 /* If no layout file was specified or the layout file was empty, assume 252 * that the user wants to flash the complete new image. 253 */ 254 if (!romimages) 255 return 0; 308 /* If no regions were specified for inclusion, assume 309 * that the user wants to write the complete new image. 310 */ 311 if (num_include_args == 0) 312 return 0; 313 256 314 /* Non-included romentries are ignored. 257 315 * The union of all included romentries is used from the new image. … … 265 323 break; 266 324 } 325 /* For non-included region, copy from old content. */ 267 326 if (entry->start > start) 268 327 memcpy(newcontents + start, oldcontents + start,
Note: See TracChangeset
for help on using the changeset viewer.
