qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [RFC PATCH 6/8] libqos: fw_cfg
Date: Tue,  5 Mar 2013 07:53:30 -0600	[thread overview]
Message-ID: <1362491612-19226-7-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1362491612-19226-1-git-send-email-aliguori@us.ibm.com>

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 tests/Makefile        |  2 +-
 tests/fw_cfg-test.c   | 48 +-----------------------------------------------
 tests/libqos/fw_cfg.c | 39 +++++++++++++++++++++++++++++++++++++++
 tests/libqos/fw_cfg.h | 22 ++++++++++++++++++++++
 4 files changed, 63 insertions(+), 48 deletions(-)
 create mode 100644 tests/libqos/fw_cfg.c
 create mode 100644 tests/libqos/fw_cfg.h

diff --git a/tests/Makefile b/tests/Makefile
index 7482297..7e436c0 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -130,7 +130,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
+libqos-obj-y = tests/libqos/pci.o tests/libqos/fw_cfg.o
 libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o
 
 tests/rtc-test$(EXESUF): tests/rtc-test.o
diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index b784dc8..99643c0 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -2,18 +2,11 @@
 
 #include "libqtest.h"
 #include "hw/fw_cfg.h"
+#include "libqos/fw_cfg.h"
 
 #include <string.h>
 #include <glib.h>
 
-typedef struct QFWCFG QFWCFG;
-
-struct QFWCFG
-{
-    void (*select)(QFWCFG *fw_cfg, uint16_t key);
-    void (*read)(QFWCFG *fw_cfg, void *data, size_t len);
-};
-
 /* PC specific */
 
 static void pc_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
@@ -41,45 +34,6 @@ static QFWCFG *pc_fw_cfg_init(void)
     return fw_cfg;
 }
 
-/* Generic code */
-
-static void qfw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
-{
-    fw_cfg->select(fw_cfg, key);
-}
-
-static void qfw_cfg_read_data(QFWCFG *fw_cfg, void *data, size_t len)
-{
-    fw_cfg->read(fw_cfg, data, len);
-}
-
-static void qfw_cfg_get(QFWCFG *fw_cfg, uint16_t key, void *data, size_t len)
-{
-    qfw_cfg_select(fw_cfg, key);
-    qfw_cfg_read_data(fw_cfg, data, len);
-}
-
-static uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key)
-{
-    uint16_t value;
-    qfw_cfg_get(fw_cfg, key, &value, sizeof(value));
-    return value;
-}
-
-static uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key)
-{
-    uint32_t value;
-    qfw_cfg_get(fw_cfg, key, &value, sizeof(value));
-    return value;
-}
-
-static uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key)
-{
-    uint64_t value;
-    qfw_cfg_get(fw_cfg, key, &value, sizeof(value));
-    return value;
-}
-
 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.c b/tests/libqos/fw_cfg.c
new file mode 100644
index 0000000..f6f53c5
--- /dev/null
+++ b/tests/libqos/fw_cfg.c
@@ -0,0 +1,39 @@
+#include "libqos/fw_cfg.h"
+
+void qfw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
+{
+    fw_cfg->select(fw_cfg, key);
+}
+
+void qfw_cfg_read_data(QFWCFG *fw_cfg, void *data, size_t len)
+{
+    fw_cfg->read(fw_cfg, data, len);
+}
+
+void qfw_cfg_get(QFWCFG *fw_cfg, uint16_t key, void *data, size_t len)
+{
+    qfw_cfg_select(fw_cfg, key);
+    qfw_cfg_read_data(fw_cfg, data, len);
+}
+
+uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key)
+{
+    uint16_t value;
+    qfw_cfg_get(fw_cfg, key, &value, sizeof(value));
+    return value;
+}
+
+uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key)
+{
+    uint32_t value;
+    qfw_cfg_get(fw_cfg, key, &value, sizeof(value));
+    return value;
+}
+
+uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key)
+{
+    uint64_t value;
+    qfw_cfg_get(fw_cfg, key, &value, sizeof(value));
+    return value;
+}
+
diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
new file mode 100644
index 0000000..a82d2da
--- /dev/null
+++ b/tests/libqos/fw_cfg.h
@@ -0,0 +1,22 @@
+#ifndef LIBQOS_FW_CFG_H
+#define LIBQOS_FW_CFG_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+typedef struct QFWCFG QFWCFG;
+
+struct QFWCFG
+{
+    void (*select)(QFWCFG *fw_cfg, uint16_t key);
+    void (*read)(QFWCFG *fw_cfg, void *data, size_t len);
+};
+
+void qfw_cfg_select(QFWCFG *fw_cfg, uint16_t key);
+void qfw_cfg_read_data(QFWCFG *fw_cfg, void *data, size_t len);
+void qfw_cfg_get(QFWCFG *fw_cfg, uint16_t key, void *data, size_t len);
+uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key);
+uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key);
+uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key);
+
+#endif
-- 
1.8.0

  parent reply	other threads:[~2013-03-05 14:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-05 13:53 [Qemu-devel] [RFC PATCH 0/8] libqos support Anthony Liguori
2013-03-05 13:53 ` [Qemu-devel] [RFC PATCH 1/8] qtest: add libqos Anthony Liguori
2013-03-13 11:26   ` Kevin Wolf
2013-03-13 14:03     ` Anthony Liguori
2013-03-28 11:41       ` Kevin Wolf
2013-03-29  2:26         ` Anthony Liguori
2013-04-09  9:15           ` Kevin Wolf
2013-03-13 12:11   ` Andreas Färber
2013-03-05 13:53 ` [Qemu-devel] [RFC PATCH 2/8] i440fx-test: add test to compare default register values against spec Anthony Liguori
2013-03-05 13:53 ` [Qemu-devel] [RFC PATCH 3/8] i440fx-test: add test for PAM functionality Anthony Liguori
2013-03-05 13:53 ` [Qemu-devel] [RFC PATCH 4/8] pci: foreach Anthony Liguori
2013-03-05 13:53 ` [Qemu-devel] [RFC PATCH 5/8] fw_cfg: add qtest test harness Anthony Liguori
2013-03-05 13:53 ` Anthony Liguori [this message]
2013-03-05 13:53 ` [Qemu-devel] [RFC PATCH 7/8] libqos: add fw_cfg-pc Anthony Liguori
2013-03-05 13:53 ` [Qemu-devel] [RFC PATCH 8/8] libqos: add malloc Anthony Liguori
2013-03-13 13:44   ` Kevin Wolf
2013-03-13 14:53     ` Anthony Liguori
2013-03-05 14:15 ` [Qemu-devel] [RFC PATCH 0/8] libqos support Stefan Hajnoczi
2013-03-05 14:59   ` Anthony Liguori
2013-04-22 18:38 ` Anthony Liguori

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=1362491612-19226-7-git-send-email-aliguori@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).