mirror of https://github.com/xemu-project/xemu.git
fw_cfg: rom loader tweaks.
Changes: - make dir argument mandatory, we allways have one anyway (vgaroms or genroms). - check for duplicates, skip loading if found. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
bdb5ee3064
commit
de9352bcae
18
hw/fw_cfg.c
18
hw/fw_cfg.c
|
@ -278,7 +278,7 @@ int fw_cfg_add_file(FWCfgState *s, const char *dir, const char *filename,
|
||||||
uint8_t *data, uint32_t len)
|
uint8_t *data, uint32_t len)
|
||||||
{
|
{
|
||||||
const char *basename;
|
const char *basename;
|
||||||
int index;
|
int i, index;
|
||||||
|
|
||||||
if (!s->files) {
|
if (!s->files) {
|
||||||
int dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS;
|
int dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS;
|
||||||
|
@ -300,13 +300,17 @@ int fw_cfg_add_file(FWCfgState *s, const char *dir, const char *filename,
|
||||||
} else {
|
} else {
|
||||||
basename = filename;
|
basename = filename;
|
||||||
}
|
}
|
||||||
if (dir) {
|
|
||||||
snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),
|
snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),
|
||||||
"%s/%s", dir, basename);
|
"%s/%s", dir, basename);
|
||||||
} else {
|
for (i = 0; i < index; i++) {
|
||||||
snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),
|
if (strcmp(s->files->f[index].name, s->files->f[i].name) == 0) {
|
||||||
"%s", basename);
|
FW_CFG_DPRINTF("%s: skip duplicate: %s\n", __FUNCTION__,
|
||||||
|
s->files->f[index].name);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s->files->f[index].size = cpu_to_be32(len);
|
s->files->f[index].size = cpu_to_be32(len);
|
||||||
s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);
|
s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);
|
||||||
FW_CFG_DPRINTF("%s: #%d: %s (%d bytes)\n", __FUNCTION__,
|
FW_CFG_DPRINTF("%s: #%d: %s (%d bytes)\n", __FUNCTION__,
|
||||||
|
|
Loading…
Reference in New Issue