mb/emulation/qemu-i440fx: remove mm file listing

Remove memory mapped copy of the file list to use it also in romstage.
fw_cfg_find_file searches directly for the file on data port.

Change-Id: Ie97ed3f0c98a5bb18a35ab0eaf8c4777a53e5779
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/30847
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
This commit is contained in:
Thomas Heijligen
2019-01-10 17:39:00 +01:00
committed by Nico Huber
parent d7e5f4b7c5
commit 721c8b457b

View File

@ -26,7 +26,6 @@
#define FW_CFG_PORT_DATA 0x0511 #define FW_CFG_PORT_DATA 0x0511
static unsigned char fw_cfg_detected = 0xff; static unsigned char fw_cfg_detected = 0xff;
static FWCfgFiles *fw_files;
static int fw_cfg_present(void) static int fw_cfg_present(void)
{ {
@ -58,49 +57,30 @@ void fw_cfg_get(uint16_t entry, void *dst, int dstlen)
fw_cfg_read(dst, dstlen); fw_cfg_read(dst, dstlen);
} }
static void fw_cfg_init_file(void) static int fw_cfg_find_file(FWCfgFile *file, const char *name)
{ {
u32 i, size, count = 0; uint32_t count = 0;
if (fw_files != NULL) fw_cfg_select(FW_CFG_FILE_DIR);
return; fw_cfg_read(&count, sizeof(count));
count = be32_to_cpu(count);
fw_cfg_get(FW_CFG_FILE_DIR, &count, sizeof(count)); for (int i = 0; i < count; i++) {
count = swab32(count); fw_cfg_read(file, sizeof(*file));
size = count * sizeof(FWCfgFile) + sizeof(count); if (strcmp(file->name, name) == 0) {
printk(BIOS_DEBUG, "QEMU: %d files in fw_cfg\n", count); file->size = be32_to_cpu(file->size);
fw_files = malloc(size); file->select = be16_to_cpu(file->select);
fw_cfg_get(FW_CFG_FILE_DIR, fw_files, size); return 0;
fw_files->count = swab32(fw_files->count); }
for (i = 0; i < count; i++) {
fw_files->f[i].size = swab32(fw_files->f[i].size);
fw_files->f[i].select = swab16(fw_files->f[i].select);
printk(BIOS_DEBUG, "QEMU: %s [size=%d]\n",
fw_files->f[i].name, fw_files->f[i].size);
} }
} return -1;
static FWCfgFile *fw_cfg_find_file(const char *name)
{
int i;
fw_cfg_init_file();
for (i = 0; i < fw_files->count; i++)
if (strcmp(fw_files->f[i].name, name) == 0)
return fw_files->f + i;
return NULL;
} }
int fw_cfg_check_file(FWCfgFile *file, const char *name) int fw_cfg_check_file(FWCfgFile *file, const char *name)
{ {
FWCfgFile *f;
if (!fw_cfg_present()) if (!fw_cfg_present())
return -1; return -1;
f = fw_cfg_find_file(name); return fw_cfg_find_file(file, name);
if (!f)
return -1;
*file = *f;
return 0;
} }
int fw_cfg_max_cpus(void) int fw_cfg_max_cpus(void)