[SeaBIOS] [PATCH 7/8] Integrate qemu_cfg_preinit() into qemu_romfile_init().

Kevin O'Connor kevin at koconnor.net
Sun Feb 10 05:48:27 CET 2013


Now that only qemu_romfile_init() uses the fw_cfg interface, it only
needs to be detected in that function.

Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 src/paravirt.c | 38 ++++++++++++++------------------------
 src/paravirt.h |  3 +--
 src/post.c     |  3 +--
 3 files changed, 16 insertions(+), 28 deletions(-)

diff --git a/src/paravirt.c b/src/paravirt.c
index 9b288ac..aa4a421 100644
--- a/src/paravirt.c
+++ b/src/paravirt.c
@@ -1,5 +1,6 @@
 // Paravirtualization support.
 //
+// Copyright (C) 2013  Kevin O'Connor <kevin at koconnor.net>
 // Copyright (C) 2009 Red Hat Inc.
 //
 // Authors:
@@ -89,8 +90,8 @@ qemu_biostable_setup(void)
  * QEMU firmware config (fw_cfg) interface
  ****************************************************************/
 
-int qemu_cfg_present;
-
+// List of QEMU fw_cfg entries.  DO NOT ADD MORE.  (All new content
+// should be passed via the fw_cfg "file" interface.)
 #define QEMU_CFG_SIGNATURE              0x00
 #define QEMU_CFG_ID                     0x01
 #define QEMU_CFG_UUID                   0x02
@@ -130,26 +131,6 @@ qemu_cfg_read_entry(void *buf, int e, int len)
     qemu_cfg_read(buf, len);
 }
 
-void qemu_cfg_preinit(void)
-{
-    char *sig = "QEMU";
-    int i;
-
-    if (!CONFIG_QEMU)
-        return;
-
-    qemu_cfg_present = 1;
-
-    qemu_cfg_select(QEMU_CFG_SIGNATURE);
-
-    for (i = 0; i < 4; i++)
-        if (inb(PORT_QEMU_CFG_DATA) != sig[i]) {
-            qemu_cfg_present = 0;
-            break;
-        }
-    dprintf(4, "qemu_cfg_present=%d\n", qemu_cfg_present);
-}
-
 static int
 qemu_cfg_read_file(struct romfile_s *file, void *dst, u32 maxlen)
 {
@@ -273,11 +254,20 @@ struct QemuCfgFile {
     char name[56];
 };
 
-void qemu_romfile_init(void)
+void qemu_cfg_init(void)
 {
-    if (!CONFIG_QEMU || !qemu_cfg_present)
+    if (!CONFIG_QEMU)
         return;
 
+    // Detect fw_cfg interface.
+    qemu_cfg_select(QEMU_CFG_SIGNATURE);
+    char *sig = "QEMU";
+    int i;
+    for (i = 0; i < 4; i++)
+        if (inb(PORT_QEMU_CFG_DATA) != sig[i])
+            return;
+    dprintf(1, "Found QEMU fw_cfg\n");
+
     // Populate romfiles for legacy fw_cfg entries
     qemu_cfg_legacy();
 
diff --git a/src/paravirt.h b/src/paravirt.h
index 1d06e58..4438273 100644
--- a/src/paravirt.h
+++ b/src/paravirt.h
@@ -25,7 +25,6 @@ static inline int runningOnKVM(void) {
 
 void qemu_ramsize_preinit(void);
 void qemu_biostable_setup(void);
-void qemu_cfg_preinit(void);
-void qemu_romfile_init(void);
+void qemu_cfg_init(void);
 
 #endif
diff --git a/src/post.c b/src/post.c
index 2c5e34e..2d5dd4f 100644
--- a/src/post.c
+++ b/src/post.c
@@ -108,7 +108,7 @@ interface_init(void)
     malloc_fixupreloc_init();
 
     // Setup romfile items.
-    qemu_romfile_init();
+    qemu_cfg_init();
     coreboot_cbfs_init();
 
     // Setup ivt/bda/ebda
@@ -316,7 +316,6 @@ void VISIBLE32INIT
 dopost(void)
 {
     // Detect ram and setup internal malloc.
-    qemu_cfg_preinit();
     if (CONFIG_COREBOOT)
         coreboot_preinit();
     else if (runningOnXen())
-- 
1.7.11.7




More information about the SeaBIOS mailing list