From: Kevin O'Connor Date: Fri, 24 Dec 2010 18:53:32 +0000 (-0500) Subject: Support qemu based romfile wrappers called out of order. X-Git-Tag: rel-0.6.2~38 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c6629e0de1f5c2d359705f27f3b822563b1882c2;p=seabios.git Support qemu based romfile wrappers called out of order. If the file requested isn't the last file read, then reread the index to find the given file. --- diff --git a/src/paravirt.c b/src/paravirt.c index 74d3743..09e3d23 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -338,26 +338,43 @@ u32 qemu_cfg_find_file(const char *name) return __cfg_next_prefix_file(name, strlen(name) + 1, 0); } +static int +__qemu_cfg_set_file(u32 select) +{ + if (!qemu_cfg_present || !select) + return -1; + if (select == ntohs(LastFile.select)) + return 0; + + u32 count; + qemu_cfg_read_entry(&count, QEMU_CFG_FILE_DIR, sizeof(count)); + count = ntohl(count); + u32 e; + for (e = 0; e < count; e++) { + qemu_cfg_read((void*)&LastFile, sizeof(LastFile)); + if (select == ntohs(LastFile.select)) + return 0; + } + return -1; +} + int qemu_cfg_size_file(u32 select) { - if (select != ntohs(LastFile.select)) + if (__qemu_cfg_set_file(select)) return -1; return ntohl(LastFile.size); } - const char* qemu_cfg_name_file(u32 select) { - if (select != ntohs(LastFile.select)) + if (__qemu_cfg_set_file(select)) return NULL; return LastFile.name; } int qemu_cfg_read_file(u32 select, void *dst, u32 maxlen) { - if (!qemu_cfg_present) - return -1; - if (!select || select != ntohs(LastFile.select)) + if (__qemu_cfg_set_file(select)) return -1; int len = qemu_cfg_size_file(select); if (len < 0 || len > maxlen)