From patchwork Tue Mar 5 13:53:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 225043 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 ADEEE2C0326 for ; Wed, 6 Mar 2013 00:56:55 +1100 (EST) Received: from localhost ([::1]:42655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCsMP-0004AO-LJ for incoming@patchwork.ozlabs.org; Tue, 05 Mar 2013 08:56:53 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCsM9-0004A2-0Z for qemu-devel@nongnu.org; Tue, 05 Mar 2013 08:56:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCsJd-0006lO-MG for qemu-devel@nongnu.org; Tue, 05 Mar 2013 08:54:17 -0500 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:53376) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCsJc-0006l5-Vx for qemu-devel@nongnu.org; Tue, 05 Mar 2013 08:54:01 -0500 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Mar 2013 23:49:05 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 5 Mar 2013 23:49:04 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 0196D2CE804D for ; Wed, 6 Mar 2013 00:53:56 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r25DfBGT1180088 for ; Wed, 6 Mar 2013 00:41:11 +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 r25DrtcG016992 for ; Wed, 6 Mar 2013 00:53:55 +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 r25DrYFk016593; Wed, 6 Mar 2013 00:53:54 +1100 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2013 07:53:31 -0600 Message-Id: <1362491612-19226-8-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-7014-0000-0000-000002AC5461 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.148 Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi Subject: [Qemu-devel] [RFC PATCH 7/8] libqos: add fw_cfg-pc 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 | 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 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 #include -/* 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 + +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