Patchwork [RFC,7/8] libqos: add fw_cfg-pc

login
register
mail settings
Submitter Anthony Liguori
Date March 5, 2013, 1:53 p.m.
Message ID <1362491612-19226-8-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/225043/
State New
Headers show

Comments

Anthony Liguori - March 5, 2013, 1:53 p.m.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 tests/Makefile           |  2 +-
 tests/fw_cfg-test.c      | 29 +----------------------------
 tests/libqos/fw_cfg-pc.c | 28 ++++++++++++++++++++++++++++
 tests/libqos/fw_cfg-pc.h |  8 ++++++++
 4 files changed, 38 insertions(+), 29 deletions(-)
 create mode 100644 tests/libqos/fw_cfg-pc.c
 create mode 100644 tests/libqos/fw_cfg-pc.h

Patch

diff --git a/tests/Makefile b/tests/Makefile
index 7e436c0..bfeee5e 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -131,7 +131,7 @@  tests/test-visitor-serialization$(EXESUF): tests/test-visitor-serialization.o $(
 tests/test-mul64$(EXESUF): tests/test-mul64.o libqemuutil.a
 
 libqos-obj-y = tests/libqos/pci.o tests/libqos/fw_cfg.o
-libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o
+libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o tests/libqos/fw_cfg-pc.o
 
 tests/rtc-test$(EXESUF): tests/rtc-test.o
 tests/m48t59-test$(EXESUF): tests/m48t59-test.o
diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index 99643c0..03d62c8 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -2,38 +2,11 @@ 
 
 #include "libqtest.h"
 #include "hw/fw_cfg.h"
-#include "libqos/fw_cfg.h"
+#include "libqos/fw_cfg-pc.h"
 
 #include <string.h>
 #include <glib.h>
 
-/* PC specific */
-
-static void pc_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
-{
-    outw(0x510, key);
-}
-
-static void pc_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
-{
-    uint8_t *ptr = data;
-    int i;
-
-    for (i = 0; i < len; i++) {
-        ptr[i] = inb(0x511);
-    }
-}
-
-static QFWCFG *pc_fw_cfg_init(void)
-{
-    QFWCFG *fw_cfg = g_malloc0(sizeof(*fw_cfg));
-
-    fw_cfg->select = pc_fw_cfg_select;
-    fw_cfg->read = pc_fw_cfg_read;
-
-    return fw_cfg;
-}
-
 static uint64_t ram_size = 128 << 20;
 static uint16_t nb_cpus = 1;
 static uint16_t max_cpus = 1;
diff --git a/tests/libqos/fw_cfg-pc.c b/tests/libqos/fw_cfg-pc.c
new file mode 100644
index 0000000..9a5c1f8
--- /dev/null
+++ b/tests/libqos/fw_cfg-pc.c
@@ -0,0 +1,28 @@ 
+#include "libqos/fw_cfg-pc.h"
+#include "libqtest.h"
+#include <glib.h>
+
+static void pc_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
+{
+    outw(0x510, key);
+}
+
+static void pc_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
+{
+    uint8_t *ptr = data;
+    int i;
+
+    for (i = 0; i < len; i++) {
+        ptr[i] = inb(0x511);
+    }
+}
+
+QFWCFG *pc_fw_cfg_init(void)
+{
+    QFWCFG *fw_cfg = g_malloc0(sizeof(*fw_cfg));
+
+    fw_cfg->select = pc_fw_cfg_select;
+    fw_cfg->read = pc_fw_cfg_read;
+
+    return fw_cfg;
+}
diff --git a/tests/libqos/fw_cfg-pc.h b/tests/libqos/fw_cfg-pc.h
new file mode 100644
index 0000000..ba8c819
--- /dev/null
+++ b/tests/libqos/fw_cfg-pc.h
@@ -0,0 +1,8 @@ 
+#ifndef LIBQOS_FW_CFG_PC_H
+#define LIBQOS_FW_CFG_PC_H
+
+#include "libqos/fw_cfg.h"
+
+QFWCFG *pc_fw_cfg_init(void);
+
+#endif