mirror of
				https://gitlab.com/qemu-project/qboot.git
				synced 2024-02-13 08:33:40 +08:00 
			
		
		
		
	use DMA to read fw_cfg file names
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
		
							
								
								
									
										29
									
								
								fw_cfg.c
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								fw_cfg.c
									
									
									
									
									
								
							| @ -11,7 +11,8 @@ | ||||
| struct fw_cfg_file { | ||||
| 	uint32_t size; | ||||
| 	uint16_t select; | ||||
| 	char name[57]; | ||||
| 	uint16_t unused; | ||||
| 	char name[56]; | ||||
| }; | ||||
|  | ||||
| static int version; | ||||
| @ -30,20 +31,36 @@ void fw_cfg_setup(void) | ||||
| 	filecnt = n; | ||||
| 	files = malloc_fseg(sizeof(files[0]) * n); | ||||
|  | ||||
| 	fw_cfg_read(files, sizeof(files[0]) * n); | ||||
| 	for (i = 0; i < n; i++) { | ||||
| 		files[i].size = fw_cfg_readl_be(); | ||||
| 		files[i].select = fw_cfg_readw_be(); | ||||
| 		fw_cfg_readw_be(); | ||||
| 		fw_cfg_read(files[i].name, sizeof(files[i].name) - 1); | ||||
| 		struct fw_cfg_file *f = &files[i]; | ||||
| 		f->size = bswap32(f->size); | ||||
| 		f->select = bswap16(f->select); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| int filenamecmp(const char *a, const struct fw_cfg_file *f) | ||||
| { | ||||
|     int n = sizeof(f->name); | ||||
|     const char *b = f->name; | ||||
|     while (*a == *b) { | ||||
|         if (*a == '\0') { | ||||
|             break; | ||||
|         } | ||||
|         if (--n == 0) { | ||||
|             return *a; | ||||
|         } | ||||
|         ++a, ++b; | ||||
|     } | ||||
|     return *a - *b; | ||||
| } | ||||
|  | ||||
| int fw_cfg_file_id(char *name) | ||||
| { | ||||
| 	int i; | ||||
|  | ||||
| 	for (i = 0; i < filecnt; i++) | ||||
| 		if (!strcmp(name, files[i].name)) | ||||
| 		if (!filenamecmp(name, &files[i])) | ||||
| 			return i; | ||||
|  | ||||
| 	return -1; | ||||
|  | ||||
| @ -1,6 +1,11 @@ | ||||
| #ifndef BSWAP_H | ||||
| #define BSWAP_H 1 | ||||
|  | ||||
| static inline uint16_t bswap16(uint16_t x) | ||||
| { | ||||
| 	return __builtin_bswap16(x); | ||||
| } | ||||
|  | ||||
| static inline uint32_t bswap32(uint32_t x) | ||||
| { | ||||
| 	return __builtin_bswap32(x); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Paolo Bonzini
					Paolo Bonzini