Hi,
qemu is about to change the way how option roms are loaded. pci roms will be loaded into a option rom bar (like real hardware does). non-pci roms can be loaded using the qemu firmware interface.
With this change seabios will deploy all roms instead of having qemu copy them to the 0xc0000 -> 0e0000 range. Advantages are:
* roms can be packed better, especially in case they resize themself (like the gPXE roms do). * rom area is a bit larger as seabios can additionally use the unused regions of the 0xe0000 segment. * the whole process comes closer to what happens on real hardware.
cheers, Gerd
From: Anthony Liguori aliguori@us.ibm.com
As we are going to disable CONFIG_OPTIONROMS_DEPLOYED under QEMU so that we can make proper use of DDIM.
Signed-off-by: Anthony Liguori aliguori@us.ibm.com Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/shadow.c | 20 ++++++++------------ 1 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/src/shadow.c b/src/shadow.c index f0f97c5..3f443ed 100644 --- a/src/shadow.c +++ b/src/shadow.c @@ -29,18 +29,14 @@ __make_bios_writable(u16 bdf) int clear = 0; int i; for (i=0; i<6; i++) { - if (CONFIG_OPTIONROMS_DEPLOYED) { - int reg = pci_config_readb(bdf, 0x5a + i); - if ((reg & 0x11) != 0x11) { - // Need to copy optionroms to work around qemu implementation - void *mem = (void*)(BUILD_ROM_START + i * 32*1024); - memcpy((void*)BUILD_BIOS_TMP_ADDR, mem, 32*1024); - pci_config_writeb(bdf, 0x5a + i, 0x33); - memcpy(mem, (void*)BUILD_BIOS_TMP_ADDR, 32*1024); - clear = 1; - } else { - pci_config_writeb(bdf, 0x5a + i, 0x33); - } + int reg = pci_config_readb(bdf, 0x5a + i); + if ((reg & 0x11) != 0x11) { + // Need to copy optionroms to work around qemu implementation + void *mem = (void*)(BUILD_ROM_START + i * 32*1024); + memcpy((void*)BUILD_BIOS_TMP_ADDR, mem, 32*1024); + pci_config_writeb(bdf, 0x5a + i, 0x33); + memcpy(mem, (void*)BUILD_BIOS_TMP_ADDR, 32*1024); + clear = 1; } else { pci_config_writeb(bdf, 0x5a + i, 0x33); }
From: Anthony Liguori aliguori@us.ibm.com
Since qemu now supports loading option roms through PCI
Signed-off-by: Anthony Liguori aliguori@us.ibm.com Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/config.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/config.h b/src/config.h index 91e322d..c1f151d 100644 --- a/src/config.h +++ b/src/config.h @@ -87,7 +87,7 @@ // Support finding and running option roms during post. #define CONFIG_OPTIONROMS 1 // Set if option roms are already copied to 0xc0000-0xf0000 -#define CONFIG_OPTIONROMS_DEPLOYED 1 +#define CONFIG_OPTIONROMS_DEPLOYED 0 // When option roms are not pre-deployed, SeaBIOS can copy an optionrom // from flash for up to 2 devices. #define OPTIONROM_VENDEV_1 0x00000000
As the next patch will add one more user of the macros move them to util.h. Also add the 16bit variants.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/coreboot.c | 5 ----- src/util.h | 7 +++++++ 2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/coreboot.c b/src/coreboot.c index 7fa18e4..3dc6a7f 100644 --- a/src/coreboot.c +++ b/src/coreboot.c @@ -351,11 +351,6 @@ ulzma(u8 *dst, u32 maxlen, const u8 *src, u32 srclen) * Coreboot flash format ****************************************************************/
-// XXX - optimize -#define ntohl(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | \ - (((x)&0xff0000) >> 8) | (((x)&0xff000000) >> 24)) -#define htonl(x) ntohl(x) - #define CBFS_HEADER_MAGIC 0x4F524243 #define CBFS_HEADPTR_ADDR 0xFFFFFFFc #define CBFS_VERSION1 0x31313131 diff --git a/src/util.h b/src/util.h index 1eafce0..24e39d1 100644 --- a/src/util.h +++ b/src/util.h @@ -367,4 +367,11 @@ extern u8 BiosChecksum; // version (auto generated file out/version.c) extern const char VERSION[];
+// XXX - optimize +#define ntohl(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | \ + (((x)&0xff0000) >> 8) | (((x)&0xff000000) >> 24)) +#define htonl(x) ntohl(x) +#define ntohs(x) ((((x)&0xff)<<8) | (((x)&0xff00)>>8)) +#define htons(x) ntohs(x) + #endif // util.h
Add support for loading roms using the qemu fw_cfg interface, modeled after the existing cbfs support. Use it to look for vgabios (vgaroms/*) and option roms (genroms/*).
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- src/optionroms.c | 22 ++++++++++++++++++++++ src/paravirt.c | 37 +++++++++++++++++++++++++++++++++++++ src/paravirt.h | 11 +++++++++++ 3 files changed, 70 insertions(+), 0 deletions(-)
diff --git a/src/optionroms.c b/src/optionroms.c index 27465ad..c5de1ad 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -247,6 +247,26 @@ run_cbfs_roms(const char *prefix, int isvga) } }
+static void +run_qemu_roms(const char *prefix, int isvga) +{ + struct QemuCfgFile entry; + int plen = strlen(prefix); + int rc, dlen; + + rc = qemu_cfg_first_file(&entry); + while (rc > 0) { + if (memcmp(prefix, entry.name, plen) == 0) { + dlen = qemu_cfg_read_file(&entry, (void*)RomEnd, max_rom() - RomEnd); + if (dlen > 0) { + dprintf(1, "init qemu rom: %s\n", entry.name); + init_optionrom((void*)RomEnd, 0, isvga); + } + } + rc = qemu_cfg_next_file(&entry); + } +} +
/**************************************************************** * PCI roms @@ -375,6 +395,7 @@ optionrom_setup()
// Find and deploy CBFS roms not associated with a device. run_cbfs_roms("genroms/", 0); + run_qemu_roms("genroms/", 0); }
// All option roms found and deployed - now build BEV/BCV vectors. @@ -434,6 +455,7 @@ vga_setup()
// Find and deploy CBFS vga-style roms not associated with a device. run_cbfs_roms("vgaroms/", 1); + run_qemu_roms("vgaroms/", 1); }
if (RomEnd == BUILD_ROM_START) { diff --git a/src/paravirt.c b/src/paravirt.c index 6f48d2e..7171bac 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -8,6 +8,7 @@ // This file may be distributed under the terms of the GNU LGPLv3 license.
#include "config.h" // CONFIG_COREBOOT +#include "util.h" // ntoh[ls] #include "ioport.h" // outw #include "paravirt.h" // qemu_cfg_port_probe #include "smbios.h" // struct smbios_structure_header @@ -287,3 +288,39 @@ u16 qemu_cfg_get_max_cpus(void)
return cnt; } + +u16 qemu_cfg_first_file(QemuCfgFile *entry) +{ + memset(entry, 0, sizeof(*entry)); + return qemu_cfg_next_file(entry); +} + +u16 qemu_cfg_next_file(QemuCfgFile *entry) +{ + u16 last = ntohs(entry->select); + u32 e,count; + + if (!qemu_cfg_present) + return 0; + + qemu_cfg_read_entry(&count, QEMU_CFG_FILE_DIR, sizeof(count)); + for (e = 0; e < ntohl(count); e++) { + qemu_cfg_read((void*)entry, sizeof(*entry)); + if (ntohs(entry->select) > last) { + return 1; + } + } + return 0; +} + +u32 qemu_cfg_read_file(QemuCfgFile *entry, void *dst, u32 maxlen) +{ + int len = ntohl(entry->size); + + if (!qemu_cfg_present) + return 0; + if (len > maxlen) + return 0; + qemu_cfg_read_entry(dst, ntohs(entry->select), len); + return len; +} diff --git a/src/paravirt.h b/src/paravirt.h index 29a2c04..d33e10d 100644 --- a/src/paravirt.h +++ b/src/paravirt.h @@ -31,6 +31,7 @@ static inline int kvm_para_available(void) #define QEMU_CFG_NUMA 0x0d #define QEMU_CFG_BOOT_MENU 0x0e #define QEMU_CFG_MAX_CPUS 0x0f +#define QEMU_CFG_FILE_DIR 0x19 #define QEMU_CFG_ARCH_LOCAL 0x8000 #define QEMU_CFG_ACPI_TABLES (QEMU_CFG_ARCH_LOCAL + 0) #define QEMU_CFG_SMBIOS_ENTRIES (QEMU_CFG_ARCH_LOCAL + 1) @@ -53,4 +54,14 @@ int qemu_cfg_get_numa_nodes(void); void qemu_cfg_get_numa_data(u64 *data, int n); u16 qemu_cfg_get_max_cpus(void);
+typedef struct QemuCfgFile { + u32 size; /* file size */ + u16 select; /* write this to 0x510 to read it */ + u16 reserved; + char name[56]; +} QemuCfgFile; + +u16 qemu_cfg_first_file(QemuCfgFile *entry); +u16 qemu_cfg_next_file(QemuCfgFile *entry); + #endif
I needed the following patch for this series to build:
diff --git a/src/optionroms.c b/src/optionroms.c index c5de1ad..0be6852 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -13,6 +13,7 @@ #include "pci_regs.h" // PCI_ROM_ADDRESS #include "pci_ids.h" // PCI_CLASS_DISPLAY_VGA #include "boot.h" // IPL +#include "paravirt.h" // qemu_cfg_*
/**************************************************************** diff --git a/src/paravirt.h b/src/paravirt.h index d33e10d..4cef48e 100644 --- a/src/paravirt.h +++ b/src/paravirt.h @@ -63,5 +63,6 @@ typedef struct QemuCfgFile {
u16 qemu_cfg_first_file(QemuCfgFile *entry); u16 qemu_cfg_next_file(QemuCfgFile *entry); +u32 qemu_cfg_read_file(QemuCfgFile *entry, void *dst, u32 maxlen);
#endif
Regards,
Anthony Liguori
On 12/18/09 16:41, Anthony Liguori wrote:
I needed the following patch for this series to build:
--- a/src/optionroms.c +++ b/src/optionroms.c @@ -13,6 +13,7 @@ +#include "paravirt.h" // qemu_cfg_*
--- a/src/paravirt.h +++ b/src/paravirt.h +u32 qemu_cfg_read_file(QemuCfgFile *entry, void *dst, u32 maxlen);
Patch is very reasonable.
/me wonders how it did build for me without warning about the missing prototype ...
cheers, Gerd
Gerd Hoffmann wrote:
On 12/18/09 16:41, Anthony Liguori wrote:
I needed the following patch for this series to build:
--- a/src/optionroms.c +++ b/src/optionroms.c @@ -13,6 +13,7 @@ +#include "paravirt.h" // qemu_cfg_*
--- a/src/paravirt.h +++ b/src/paravirt.h +u32 qemu_cfg_read_file(QemuCfgFile *entry, void *dst, u32 maxlen);
Patch is very reasonable.
/me wonders how it did build for me without warning about the missing prototype ...
I think your fw_cfg.h changes also broke the optionroms/multiboot build. Haven't debugged yet though.
Regards,
Anthony Liguori
On 12/18/09 17:22, Anthony Liguori wrote:
I think your fw_cfg.h changes also broke the optionroms/multiboot build. Haven't debugged yet though.
That one is easy to fix, see attachment
cheers, Gerd
On Fri, Dec 18, 2009 at 04:52:08PM +0100, Gerd Hoffmann wrote:
On 12/18/09 16:41, Anthony Liguori wrote:
I needed the following patch for this series to build:
--- a/src/optionroms.c +++ b/src/optionroms.c @@ -13,6 +13,7 @@ +#include "paravirt.h" // qemu_cfg_*
--- a/src/paravirt.h +++ b/src/paravirt.h +u32 qemu_cfg_read_file(QemuCfgFile *entry, void *dst, u32 maxlen);
Patch is very reasonable.
/me wonders how it did build for me without warning about the missing prototype ...
SeaBIOS tries to use -fwhole-program to optimize the build. Unfortunately, that option appears to be a bit "bleeding edge", and some gcc versions have a hard time with it. So, SeaBIOS supports two ways to build with -fwhole-program - one with "-combine", and one with a textual inclusion of all files. Unfortunately, some errors can be masked in one type of build that are exposed in the other type.
The next major version of gcc should have support for "-flto". Once distros start shipping it, I think seabios should just support the new lto mechanism and the standard non-whole-program build. That should simplify these build issues.
-Kevin
On Fri, Dec 18, 2009 at 12:16:00PM +0100, Gerd Hoffmann wrote:
Hi,
qemu is about to change the way how option roms are loaded. pci roms will be loaded into a option rom bar (like real hardware does). non-pci roms can be loaded using the qemu firmware interface.
With this change seabios will deploy all roms instead of having qemu copy them to the 0xc0000 -> 0e0000 range. Advantages are:
- roms can be packed better, especially in case they resize themself (like the gPXE roms do).
- rom area is a bit larger as seabios can additionally use the unused regions of the 0xe0000 segment.
- the whole process comes closer to what happens on real hardware.
The SeaBIOS changes all look reasonable to me. Just need to make sure they are coordinated with the associated qemu changes.
Anthony - it looks like you've made some changes to your seabios repo, but I don't think you've pushed them yet.
-Kevin
Kevin O'Connor wrote:
On Fri, Dec 18, 2009 at 12:16:00PM +0100, Gerd Hoffmann wrote:
Hi,
qemu is about to change the way how option roms are loaded. pci roms will be loaded into a option rom bar (like real hardware does). non-pci roms can be loaded using the qemu firmware interface.
With this change seabios will deploy all roms instead of having qemu copy them to the 0xc0000 -> 0e0000 range. Advantages are:
- roms can be packed better, especially in case they resize themself (like the gPXE roms do).
- rom area is a bit larger as seabios can additionally use the unused regions of the 0xe0000 segment.
- the whole process comes closer to what happens on real hardware.
The SeaBIOS changes all look reasonable to me. Just need to make sure they are coordinated with the associated qemu changes.
Anthony - it looks like you've made some changes to your seabios repo, but I don't think you've pushed them yet.
I've pushed now. Don't worry about merging them from me though, it's easy enough to let git do it's magic here.
Regards,
Anthony Liguori
On Fri, Dec 18, 2009 at 08:55:38PM -0600, Anthony Liguori wrote:
Anthony - it looks like you've made some changes to your seabios repo, but I don't think you've pushed them yet.
I've pushed now. Don't worry about merging them from me though, it's easy enough to let git do it's magic here.
I've merged the changes. Thanks Gerd. Thanks Anthony.
-Kevin