From patchwork Tue Mar 5 13:53:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 225052 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6BCA92C02FE for ; Wed, 6 Mar 2013 01:32:01 +1100 (EST) Received: from localhost ([::1]:52222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCsU2-0002xB-6u for incoming@patchwork.ozlabs.org; Tue, 05 Mar 2013 09:04:46 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCsT4-00021c-I0 for qemu-devel@nongnu.org; Tue, 05 Mar 2013 09:03:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCsSy-0002As-Qg for qemu-devel@nongnu.org; Tue, 05 Mar 2013 09:03:46 -0500 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:57987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCsJo-0006nX-3w for qemu-devel@nongnu.org; Tue, 05 Mar 2013 08:54:12 -0500 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Mar 2013 23:46:34 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 5 Mar 2013 23:46:18 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id B8F162BB0023 for ; Wed, 6 Mar 2013 00:53:53 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r25DfIxY6947202 for ; Wed, 6 Mar 2013 00:41:18 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r25DrrNp016955 for ; Wed, 6 Mar 2013 00:53:53 +1100 Received: from titi.austin.rr.com (sig-9-65-237-165.mts.ibm.com [9.65.237.165]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r25DrYFj016593; Wed, 6 Mar 2013 00:53:51 +1100 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2013 07:53:30 -0600 Message-Id: <1362491612-19226-7-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1362491612-19226-1-git-send-email-aliguori@us.ibm.com> References: <1362491612-19226-1-git-send-email-aliguori@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13030513-3568-0000-0000-0000033EA6E5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.142 Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi Subject: [Qemu-devel] [RFC PATCH 6/8] libqos: fw_cfg X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Anthony Liguori --- 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 #include -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 +#include + +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