FreeCalypso > hg > freecalypso-tools
comparison loadtools/flutil.c @ 669:ba9523ca6ed8
fc-loadtool code: preparations for e-program-* addition
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 08 Mar 2020 01:32:08 +0000 |
parents | 0dd2c87c1b63 |
children | 135de08c5d74 |
comparison
equal
deleted
inserted
replaced
668:cd48bc4c5460 | 669:ba9523ca6ed8 |
---|---|
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include "flash.h" | 9 #include "flash.h" |
10 | 10 |
11 extern struct flash_bank_info flash_bank_info[2]; | 11 extern struct flash_bank_info flash_bank_info[2]; |
12 | 12 |
13 get_flash_sector_table(bank) | 13 get_flash_sector_table(bi) |
14 struct flash_bank_info *bi; | |
14 { | 15 { |
15 struct flash_bank_info *bi; | |
16 struct flash_geom *geom; | 16 struct flash_geom *geom; |
17 struct flash_region_desc *reg; | 17 struct flash_region_desc *reg; |
18 struct sector_info *sp; | 18 struct sector_info *sp; |
19 uint32_t offset; | 19 uint32_t offset; |
20 int nr, i; | 20 int nr, i; |
21 | 21 |
22 bi = flash_bank_info + bank; | |
23 if (bi->sectors) | 22 if (bi->sectors) |
24 return(0); | 23 return(0); |
25 i = flash_detect(bank, 0); | |
26 if (i < 0) | |
27 return(i); | |
28 geom = bi->geom; | 24 geom = bi->geom; |
29 sp = (struct sector_info *) malloc(sizeof(struct sector_info) | 25 sp = (struct sector_info *) malloc(sizeof(struct sector_info) |
30 * (geom->total_sectors + 1)); | 26 * (geom->total_sectors + 1)); |
31 if (!sp) { | 27 if (!sp) { |
32 fprintf(stderr, | 28 fprintf(stderr, |
33 "unable to malloc buffer for flash bank %d sector table\n", | 29 "unable to malloc buffer for flash sector table\n"); |
34 bank); | |
35 return(-1); | 30 return(-1); |
36 } | 31 } |
37 bi->sectors = sp; | 32 bi->sectors = sp; |
38 /* now fill it */ | 33 /* now fill it */ |
39 offset = 0; | 34 offset = 0; |
71 | 66 |
72 if (argc > 2) { | 67 if (argc > 2) { |
73 fprintf(stderr, "error: too many arguments\n"); | 68 fprintf(stderr, "error: too many arguments\n"); |
74 return(-1); | 69 return(-1); |
75 } | 70 } |
76 if (get_flash_sector_table(bank) < 0) | 71 if (flash_detect(bank, 0) < 0) |
77 return(-1); | 72 return(-1); |
78 bi = flash_bank_info + bank; | 73 bi = flash_bank_info + bank; |
74 if (get_flash_sector_table(bi) < 0) | |
75 return(-1); | |
79 printf("%u sectors in flash bank %d:\n", bi->geom->total_sectors, bank); | 76 printf("%u sectors in flash bank %d:\n", bi->geom->total_sectors, bank); |
80 printf("Offset Size\n"); | 77 printf("Offset Size\n"); |
81 for (sp = bi->sectors; sp->size; sp++) | 78 for (sp = bi->sectors; sp->size; sp++) |
82 printf("%08lX %lx\n", (u_long) sp->start, (u_long) sp->size); | 79 printf("%08lX %lx\n", (u_long) sp->start, (u_long) sp->size); |
83 return(0); | 80 return(0); |