From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org, seabios@seabios.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 4/4] qemu: add rom loading via fw_cfg
Date: Fri, 18 Dec 2009 12:16:04 +0100 [thread overview]
Message-ID: <1261134964-12427-5-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1261134964-12427-1-git-send-email-kraxel@redhat.com>
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
--
1.6.5.2
next prev parent reply other threads:[~2009-12-18 11:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-18 11:16 [Qemu-devel] [PATCH 0/4] qemu option loading Gerd Hoffmann
2009-12-18 11:16 ` [Qemu-devel] [PATCH 1/4] Do not guard qemu shadow ram work around in CONFIG_OPTIONROMS_DEPLOYED Gerd Hoffmann
2009-12-18 11:16 ` [Qemu-devel] [PATCH 2/4] Disable CONFIG_OPTIONROMS_DEPLOYED by default Gerd Hoffmann
2009-12-18 11:16 ` [Qemu-devel] [PATCH 3/4] move htonl() + friends to util.h Gerd Hoffmann
2009-12-18 11:16 ` Gerd Hoffmann [this message]
2009-12-18 15:41 ` [Qemu-devel] Re: [SeaBIOS] [PATCH 0/4] qemu option loading Anthony Liguori
2009-12-18 15:52 ` Gerd Hoffmann
2009-12-18 16:22 ` Anthony Liguori
2009-12-18 16:37 ` Gerd Hoffmann
2009-12-18 23:40 ` Kevin O'Connor
2009-12-19 0:37 ` Kevin O'Connor
2009-12-19 2:55 ` Anthony Liguori
2009-12-19 3:37 ` Kevin O'Connor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1261134964-12427-5-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=seabios@seabios.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).