qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, jan.kiszka@siemens.com, mjt@tls.msk.ru,
	alex.williamson@redhat.com, aviksil@linux.vnet.ibm.com,
	afaerber@suse.de
Subject: [Qemu-devel] [PATCH v4 11/12] libqos: Generalize I/O-mapped fw_cfg
Date: Wed, 26 Jun 2013 15:52:22 +0200	[thread overview]
Message-ID: <1372254743-15808-12-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1372254743-15808-1-git-send-email-armbru@redhat.com>

Provide a constructor that takes the base address in addition to the
PC-specific one.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/Makefile           |  2 +-
 tests/fw_cfg-test.c      |  2 +-
 tests/libqos/fw_cfg-pc.c | 40 ----------------------------------------
 tests/libqos/fw_cfg-pc.h | 20 --------------------
 tests/libqos/fw_cfg.c    | 26 ++++++++++++++++++++++++++
 tests/libqos/fw_cfg.h    |  6 ++++++
 tests/libqos/malloc-pc.c |  2 +-
 7 files changed, 35 insertions(+), 63 deletions(-)
 delete mode 100644 tests/libqos/fw_cfg-pc.c
 delete mode 100644 tests/libqos/fw_cfg-pc.h

diff --git a/tests/Makefile b/tests/Makefile
index 8c7352d..708eb79 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -124,7 +124,7 @@ tests/test-mul64$(EXESUF): tests/test-mul64.o libqemuutil.a
 
 libqos-obj-y = tests/libqos/pci.o tests/libqos/fw_cfg.o
 libqos-obj-y += tests/libqos/i2c.o
-libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o tests/libqos/fw_cfg-pc.o
+libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o
 libqos-pc-obj-y += tests/libqos/malloc-pc.o
 libqos-omap-obj-y = $(libqos-obj-y) tests/libqos/i2c-omap.o
 
diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index c284c4d..b86e49a 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -14,7 +14,7 @@
 
 #include "libqtest.h"
 #include "hw/nvram/fw_cfg.h"
-#include "libqos/fw_cfg-pc.h"
+#include "libqos/fw_cfg.h"
 
 #include <string.h>
 #include <glib.h>
diff --git a/tests/libqos/fw_cfg-pc.c b/tests/libqos/fw_cfg-pc.c
deleted file mode 100644
index 613604d..0000000
--- a/tests/libqos/fw_cfg-pc.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * libqos fw_cfg support for PC
- *
- * Copyright IBM, Corp. 2012-2013
- *
- * Authors:
- *  Anthony Liguori   <aliguori@us.ibm.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#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
deleted file mode 100644
index 444bd79..0000000
--- a/tests/libqos/fw_cfg-pc.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * libqos fw_cfg support for PC
- *
- * Copyright IBM, Corp. 2012-2013
- *
- * Authors:
- *  Anthony Liguori   <aliguori@us.ibm.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef LIBQOS_FW_CFG_PC_H
-#define LIBQOS_FW_CFG_PC_H
-
-#include "libqos/fw_cfg.h"
-
-QFWCFG *pc_fw_cfg_init(void);
-
-#endif
diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c
index 49d1683..ef00fed 100644
--- a/tests/libqos/fw_cfg.c
+++ b/tests/libqos/fw_cfg.c
@@ -79,3 +79,29 @@ QFWCFG *mm_fw_cfg_init(uint64_t base)
 
     return fw_cfg;
 }
+
+static void io_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
+{
+    outw(fw_cfg->base, key);
+}
+
+static void io_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(fw_cfg->base + 1);
+    }
+}
+
+QFWCFG *io_fw_cfg_init(uint16_t base)
+{
+    QFWCFG *fw_cfg = g_malloc0(sizeof(*fw_cfg));
+
+    fw_cfg->base = base;
+    fw_cfg->select = io_fw_cfg_select;
+    fw_cfg->read = io_fw_cfg_read;
+
+    return fw_cfg;
+}
diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
index 19bb053..61b1548 100644
--- a/tests/libqos/fw_cfg.h
+++ b/tests/libqos/fw_cfg.h
@@ -33,5 +33,11 @@ uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key);
 uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key);
 
 QFWCFG *mm_fw_cfg_init(uint64_t base);
+QFWCFG *io_fw_cfg_init(uint16_t base);
+
+static inline QFWCFG *pc_fw_cfg_init(void)
+{
+    return io_fw_cfg_init(0x510);
+}
 
 #endif
diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c
index adc36c4..db1496c 100644
--- a/tests/libqos/malloc-pc.c
+++ b/tests/libqos/malloc-pc.c
@@ -11,7 +11,7 @@
  */
 
 #include "libqos/malloc-pc.h"
-#include "libqos/fw_cfg-pc.h"
+#include "libqos/fw_cfg.h"
 
 #define NO_QEMU_PROTOS
 #include "hw/nvram/fw_cfg.h"
-- 
1.7.11.7

  parent reply	other threads:[~2013-06-26 13:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-26 13:52 [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 01/12] qtest: Don't reset on qtest chardev connect Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 02/12] boot-order-test: New; covering just PC for now Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 03/12] libqos: include dependencies Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 04/12] libqos: Add support for memory-mapped fw_cfg Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 05/12] boot-order-test: Add tests for PowerMacs Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 06/12] boot-order-test: Cover -boot once in ppc tests Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 07/12] boot-order-test: Better separate target-specific and generic parts Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 08/12] boot-order-test: Code motion for better readability Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 09/12] boot-order-test: Add tests for PowerPC PREP Markus Armbruster
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 10/12] boot-order-test: Add tests for Sun4m Markus Armbruster
2013-06-26 13:52 ` Markus Armbruster [this message]
2013-06-26 13:52 ` [Qemu-devel] [PATCH v4 12/12] boot-order-test: Add tests for Sun4u Markus Armbruster
2013-07-18 16:33 ` [Qemu-devel] [PATCH v4 00/12] Boot order tests Markus Armbruster
2013-07-23 19:04 ` 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=1372254743-15808-12-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=afaerber@suse.de \
    --cc=alex.williamson@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=aviksil@linux.vnet.ibm.com \
    --cc=jan.kiszka@siemens.com \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.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).