mb/emulation/qemu-i440fx: change file handling
Reduce the number of fw_find_file calls by returning the file structure
at fw_cfg_check_file. The file structure can then be used to allocate memory
and access the file content directly without recurrence searching.
Remove now unnecessary function fw_cfg_load_file.
Fixed breaking function calls and add include guard at fw_cfg_if.h.
Change-Id: I48cc943aaa999e4323e9d7e5dd666c5316533dcc
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/30845
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
diff --git a/src/mainboard/emulation/qemu-i440fx/northbridge.c b/src/mainboard/emulation/qemu-i440fx/northbridge.c
index 764e8a0..0ff4c54 100644
--- a/src/mainboard/emulation/qemu-i440fx/northbridge.c
+++ b/src/mainboard/emulation/qemu-i440fx/northbridge.c
@@ -59,17 +59,16 @@
struct resource *res;
unsigned long tomk = 0, high;
int idx = 10;
- int size;
+ FWCfgFile f;
pci_domain_read_resources(dev);
- size = fw_cfg_check_file("etc/e820");
- if (size > 0) {
+ if (!fw_cfg_check_file(&f, "etc/e820") && f.size > 0) {
/* supported by qemu 1.7+ */
- FwCfgE820Entry *list = malloc(size);
+ FwCfgE820Entry *list = malloc(f.size);
int i;
- fw_cfg_load_file("etc/e820", list);
- for (i = 0; i < size/sizeof(*list); i++) {
+ fw_cfg_get(f.select, list, f.size);
+ for (i = 0; i < f.size / sizeof(*list); i++) {
switch (list[i].type) {
case 1: /* RAM */
printk(BIOS_DEBUG, "QEMU: e820/ram: 0x%08llx +0x%08llx\n",