mirror of
				https://xff.cz/git/u-boot/
				synced 2025-10-31 10:26:10 +01:00 
			
		
		
		
	x86: ifdtool: Use a structure for the file/address list
Rather than two independent arrays, use a single array of a suitable structure. Also add a 'type' member since we will shortly add additional types. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
		| @@ -32,6 +32,16 @@ | |||||||
| #define FLREG_BASE(reg)		((reg & 0x00000fff) << 12); | #define FLREG_BASE(reg)		((reg & 0x00000fff) << 12); | ||||||
| #define FLREG_LIMIT(reg)	(((reg & 0x0fff0000) >> 4) | 0xfff); | #define FLREG_LIMIT(reg)	(((reg & 0x0fff0000) >> 4) | 0xfff); | ||||||
|  |  | ||||||
|  | enum input_file_type_t { | ||||||
|  | 	IF_normal, | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | struct input_file { | ||||||
|  | 	char *fname; | ||||||
|  | 	unsigned int addr; | ||||||
|  | 	enum input_file_type_t type; | ||||||
|  | }; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * find_fd() - Find the flash description in the ROM image |  * find_fd() - Find the flash description in the ROM image | ||||||
|  * |  * | ||||||
| @@ -790,8 +800,7 @@ int main(int argc, char *argv[]) | |||||||
| 	char *desc_fname = NULL, *addr_str = NULL; | 	char *desc_fname = NULL, *addr_str = NULL; | ||||||
| 	int region_type = -1, inputfreq = 0; | 	int region_type = -1, inputfreq = 0; | ||||||
| 	enum spi_frequency spifreq = SPI_FREQUENCY_20MHZ; | 	enum spi_frequency spifreq = SPI_FREQUENCY_20MHZ; | ||||||
| 	unsigned int addr[WRITE_MAX]; | 	struct input_file input_file[WRITE_MAX], *ifile; | ||||||
| 	char *wr_fname[WRITE_MAX]; |  | ||||||
| 	unsigned char wr_idx, wr_num = 0; | 	unsigned char wr_idx, wr_num = 0; | ||||||
| 	int rom_size = -1; | 	int rom_size = -1; | ||||||
| 	bool write_it; | 	bool write_it; | ||||||
| @@ -895,14 +904,16 @@ int main(int argc, char *argv[]) | |||||||
| 			exit(EXIT_SUCCESS); | 			exit(EXIT_SUCCESS); | ||||||
| 			break; | 			break; | ||||||
| 		case 'w': | 		case 'w': | ||||||
|  | 			ifile = &input_file[wr_num]; | ||||||
| 			mode_write = 1; | 			mode_write = 1; | ||||||
| 			if (wr_num < WRITE_MAX) { | 			if (wr_num < WRITE_MAX) { | ||||||
| 				if (get_two_words(optarg, &addr_str, | 				if (get_two_words(optarg, &addr_str, | ||||||
| 						  &wr_fname[wr_num])) { | 						  &ifile->fname)) { | ||||||
| 					print_usage(argv[0]); | 					print_usage(argv[0]); | ||||||
| 					exit(EXIT_FAILURE); | 					exit(EXIT_FAILURE); | ||||||
| 				} | 				} | ||||||
| 				addr[wr_num] = strtol(optarg, NULL, 0); | 				ifile->addr = strtol(optarg, NULL, 0); | ||||||
|  | 				ifile->type = IF_normal; | ||||||
| 				wr_num++; | 				wr_num++; | ||||||
| 			} else { | 			} else { | ||||||
| 				fprintf(stderr, | 				fprintf(stderr, | ||||||
| @@ -1022,8 +1033,9 @@ int main(int argc, char *argv[]) | |||||||
|  |  | ||||||
| 	if (mode_write) { | 	if (mode_write) { | ||||||
| 		for (wr_idx = 0; wr_idx < wr_num; wr_idx++) { | 		for (wr_idx = 0; wr_idx < wr_num; wr_idx++) { | ||||||
| 			ret = write_data(image, size, | 			ifile = &input_file[wr_idx]; | ||||||
| 					 addr[wr_idx], wr_fname[wr_idx]); | 			ret = write_data(image, size, ifile->addr, | ||||||
|  | 					 ifile->fname); | ||||||
| 			if (ret) | 			if (ret) | ||||||
| 				break; | 				break; | ||||||
| 		} | 		} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user