From patchwork Fri Jun 14 11:15:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 251364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 62D432C008F for ; Fri, 14 Jun 2013 21:18:01 +1000 (EST) Received: from localhost ([::1]:58459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnS11-0004IS-4M for incoming@patchwork.ozlabs.org; Fri, 14 Jun 2013 07:17:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnRyZ-0000pi-42 for qemu-devel@nongnu.org; Fri, 14 Jun 2013 07:15:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnRyU-0004pB-Q4 for qemu-devel@nongnu.org; Fri, 14 Jun 2013 07:15:27 -0400 Received: from oxygen.pond.sub.org ([2a01:4f8:121:10e4::3]:44244) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnRyU-0004oQ-JO for qemu-devel@nongnu.org; Fri, 14 Jun 2013 07:15:22 -0400 Received: from blackfin.pond.sub.org (p5B32AD34.dip0.t-ipconnect.de [91.50.173.52]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 004F5A460D; Fri, 14 Jun 2013 13:15:20 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C78EB200BF; Fri, 14 Jun 2013 13:15:17 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 14 Jun 2013 13:15:12 +0200 Message-Id: <1371208516-7857-13-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1371208516-7857-1-git-send-email-armbru@redhat.com> References: <1371208516-7857-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:4f8:121:10e4::3 Cc: aliguori@us.ibm.com, jan.kiszka@siemens.com, Alexander Graf , alex.williamson@redhat.com, qemu-ppc@nongnu.org, aviksil@linux.vnet.ibm.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v3 12/16] boot-order-test: Code motion for better readability 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 Cc: Andreas Färber Cc: Alexander Graf Cc: qemu-ppc@nongnu.org Signed-off-by: Markus Armbruster --- tests/boot-order-test.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c index 23edacf..003140f 100644 --- a/tests/boot-order-test.c +++ b/tests/boot-order-test.c @@ -15,19 +15,15 @@ #include "libqtest.h" #include "qemu/bswap.h" -static uint8_t read_mc146818(uint16_t port, uint8_t reg) -{ - outb(port, reg); - return inb(port + 1); -} - -static uint64_t read_boot_order_pc(void) -{ - uint8_t b1 = read_mc146818(0x70, 0x38); - uint8_t b2 = read_mc146818(0x70, 0x3d); +#define NO_QEMU_PROTOS +#include "hw/nvram/fw_cfg.h" +#undef NO_QEMU_PROTOS - return b1 | (b2 << 8); -} +typedef struct { + const char *args; + uint64_t expected_boot; + uint64_t expected_reboot; +} boot_order_test; static void test_a_boot_order(const char *machine, const char *test_args, @@ -52,12 +48,6 @@ static void test_a_boot_order(const char *machine, g_free(args); } -typedef struct { - const char *args; - uint64_t expected_boot; - uint64_t expected_reboot; -} boot_order_test; - static void test_boot_orders(const char *machine, uint64_t (*read_boot_order)(void), const boot_order_test *tests) @@ -72,6 +62,20 @@ static void test_boot_orders(const char *machine, } } +static uint8_t read_mc146818(uint16_t port, uint8_t reg) +{ + outb(port, reg); + return inb(port + 1); +} + +static uint64_t read_boot_order_pc(void) +{ + uint8_t b1 = read_mc146818(0x70, 0x38); + uint8_t b2 = read_mc146818(0x70, 0x3d); + + return b1 | (b2 << 8); +} + static const boot_order_test test_cases_pc[] = { { "", 0x1230, 0x1230 }, @@ -103,12 +107,6 @@ static void test_pc_boot_order(void) test_boot_orders(NULL, read_boot_order_pc, test_cases_pc); } -#define PMAC_CFG_ADDR 0xf0000510 - -#define NO_QEMU_PROTOS -#include "hw/nvram/fw_cfg.h" -#undef NO_QEMU_PROTOS - static void read_fw_cfg(uint64_t cfg_addr, uint16_t cmd, void *buf, size_t len) { @@ -129,6 +127,8 @@ static uint16_t read_fw_cfg_i16(uint64_t cfg_addr, uint16_t cmd) return le16_to_cpu(value); } +#define PMAC_CFG_ADDR 0xf0000510 + static uint64_t read_boot_order_pmac(void) { return read_fw_cfg_i16(PMAC_CFG_ADDR, FW_CFG_BOOT_DEVICE);