diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2010-12-24 13:53:32 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2010-12-24 13:53:32 -0500 |
commit | c6629e0de1f5c2d359705f27f3b822563b1882c2 (patch) | |
tree | ba23889adf35376dd4976db2b2dfa02230491f5a | |
parent | d1a1746c5c8610041a706aa8f4819cea794dd5af (diff) | |
download | seabios-c6629e0de1f5c2d359705f27f3b822563b1882c2.tar.gz |
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.
-rw-r--r-- | src/paravirt.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/paravirt.c b/src/paravirt.c index 74d3743e..09e3d23b 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) |