Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/coreboot.c | 1 - src/paravirt.c | 42 ++++++++++++++++++++++++++---------------- src/romfile.c | 1 + 3 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/src/coreboot.c b/src/coreboot.c index 5d5e03b..a7556d0 100644 --- a/src/coreboot.c +++ b/src/coreboot.c @@ -352,7 +352,6 @@ coreboot_cbfs_init(void) } memset(file, 0, sizeof(*file)); strtcpy(file->name, cfile->filename, sizeof(file->name)); - dprintf(3, "Found CBFS file: %s\n", file->name); file->size = file->rawsize = be32_to_cpu(cfile->len); file->id = (u32)cfile; file->copy = cbfs_copyfile; diff --git a/src/paravirt.c b/src/paravirt.c index cc64094..0d1fb35 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -133,7 +133,7 @@ qemu_cfg_select(u16 f) }
static void -qemu_cfg_read(u8 *buf, int len) +qemu_cfg_read(void *buf, int len) { insb(PORT_QEMU_CFG_DATA, buf, len); } @@ -416,14 +416,34 @@ u16 qemu_cfg_get_max_cpus(void) return cnt; }
-int qemu_cfg_read_file(struct romfile_s *file, void *dst, u32 maxlen) +static int +qemu_cfg_read_file(struct romfile_s *file, void *dst, u32 maxlen) { if (file->size > maxlen) return -1; - qemu_cfg_read_entry(dst, file->id, file->size); + qemu_cfg_select(file->id); + qemu_cfg_skip(file->rawsize); + qemu_cfg_read(dst, file->size); return file->size; }
+static void +qemu_romfile_add(char *name, int select, int skip, int size) +{ + struct romfile_s *file = malloc_tmp(sizeof(*file)); + if (!file) { + warn_noalloc(); + return; + } + memset(file, 0, sizeof(*file)); + strtcpy(file->name, name, sizeof(file->name)); + file->id = select; + file->rawsize = skip; // Use rawsize to indicate skip length. + file->size = size; + file->copy = qemu_cfg_read_file; + romfile_add(file); +} + struct QemuCfgFile { u32 size; /* file size */ u16 select; /* write this to 0x510 to read it */ @@ -442,18 +462,8 @@ void qemu_romfile_init(void) u32 e; for (e = 0; e < count; e++) { struct QemuCfgFile qfile; - qemu_cfg_read((void*)&qfile, sizeof(qfile)); - struct romfile_s *file = malloc_tmp(sizeof(*file)); - if (!file) { - warn_noalloc(); - return; - } - memset(file, 0, sizeof(*file)); - strtcpy(file->name, qfile.name, sizeof(file->name)); - file->size = be32_to_cpu(qfile.size); - file->id = be16_to_cpu(qfile.select); - file->copy = qemu_cfg_read_file; - romfile_add(file); - dprintf(3, "Found fw_cfg file: %s (size=%d)\n", file->name, file->size); + qemu_cfg_read(&qfile, sizeof(qfile)); + qemu_romfile_add(qfile.name, be16_to_cpu(qfile.select) + , 0, be32_to_cpu(qfile.size)); } } diff --git a/src/romfile.c b/src/romfile.c index b732e29..93ee3d6 100644 --- a/src/romfile.c +++ b/src/romfile.c @@ -12,6 +12,7 @@ static struct romfile_s *RomfileRoot; void romfile_add(struct romfile_s *file) { + dprintf(3, "Add romfile: %s (size=%d)\n", file->name, file->size); file->next = RomfileRoot; RomfileRoot = file; }