From patchwork Tue Jul 11 13:56:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 9834763 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 33BE9602BD for ; Tue, 11 Jul 2017 14:01:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24C2626AE3 for ; Tue, 11 Jul 2017 14:01:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1933A2821F; Tue, 11 Jul 2017 14:01:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B053F26AE3 for ; Tue, 11 Jul 2017 14:01:03 +0000 (UTC) Received: from localhost ([::1]:46501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUvio-0007b9-Ul for patchwork-qemu-devel@patchwork.kernel.org; Tue, 11 Jul 2017 10:01:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54631) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUvep-0004s9-7v for qemu-devel@nongnu.org; Tue, 11 Jul 2017 09:56:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUveo-0004AT-Ax for qemu-devel@nongnu.org; Tue, 11 Jul 2017 09:56:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39760) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dUveo-0004A8-2O for qemu-devel@nongnu.org; Tue, 11 Jul 2017 09:56:54 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D89DFC04D2EC; Tue, 11 Jul 2017 13:56:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D89DFC04D2EC Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D89DFC04D2EC Received: from thh440s.str.redhat.com (dhcp-200-180.str.redhat.com [10.33.200.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4094C5D964; Tue, 11 Jul 2017 13:56:51 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Christian Borntraeger , Cornelia Huck Date: Tue, 11 Jul 2017 15:56:31 +0200 Message-Id: <1499781397-19749-6-git-send-email-thuth@redhat.com> In-Reply-To: <1499781397-19749-1-git-send-email-thuth@redhat.com> References: <1499781397-19749-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 11 Jul 2017 13:56:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 05/11] pc-bios/s390-ccw: Move byteswap functions to a separate header X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Viktor Mihajlovski , Farhan Ali , Alexander Graf , David Hildenbrand Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We'll need them in code that is not related to bootmap.h, so they should reside in an independent header. Reviewed-by: Christian Borntraeger Acked-by: Cornelia Huck Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/bootmap.c | 1 + pc-bios/s390-ccw/bootmap.h | 26 -------------------------- pc-bios/s390-ccw/bswap.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 pc-bios/s390-ccw/bswap.h diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index 458d3da..67a6123 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -12,6 +12,7 @@ #include "s390-ccw.h" #include "bootmap.h" #include "virtio.h" +#include "bswap.h" #ifdef DEBUG /* #define DEBUG_FALLBACK */ diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h index 7f36782..cf99a4c 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -324,32 +324,6 @@ static inline int _memcmp(const void *s1, const void *s2, size_t n) return 0; } -/* from include/qemu/bswap.h */ - -/* El Torito is always little-endian */ -static inline uint16_t bswap16(uint16_t x) -{ - return ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8); -} - -static inline uint32_t bswap32(uint32_t x) -{ - return ((x & 0x000000ffU) << 24) | ((x & 0x0000ff00U) << 8) | - ((x & 0x00ff0000U) >> 8) | ((x & 0xff000000U) >> 24); -} - -static inline uint64_t bswap64(uint64_t x) -{ - return ((x & 0x00000000000000ffULL) << 56) | - ((x & 0x000000000000ff00ULL) << 40) | - ((x & 0x0000000000ff0000ULL) << 24) | - ((x & 0x00000000ff000000ULL) << 8) | - ((x & 0x000000ff00000000ULL) >> 8) | - ((x & 0x0000ff0000000000ULL) >> 24) | - ((x & 0x00ff000000000000ULL) >> 40) | - ((x & 0xff00000000000000ULL) >> 56); -} - static inline uint32_t iso_733_to_u32(uint64_t x) { return (uint32_t)x; diff --git a/pc-bios/s390-ccw/bswap.h b/pc-bios/s390-ccw/bswap.h new file mode 100644 index 0000000..a422604 --- /dev/null +++ b/pc-bios/s390-ccw/bswap.h @@ -0,0 +1,30 @@ +/* + * Byte swap functions - taken from include/qemu/bswap.h + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ + +static inline uint16_t bswap16(uint16_t x) +{ + return ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8); +} + +static inline uint32_t bswap32(uint32_t x) +{ + return ((x & 0x000000ffU) << 24) | ((x & 0x0000ff00U) << 8) | + ((x & 0x00ff0000U) >> 8) | ((x & 0xff000000U) >> 24); +} + +static inline uint64_t bswap64(uint64_t x) +{ + return ((x & 0x00000000000000ffULL) << 56) | + ((x & 0x000000000000ff00ULL) << 40) | + ((x & 0x0000000000ff0000ULL) << 24) | + ((x & 0x00000000ff000000ULL) << 8) | + ((x & 0x000000ff00000000ULL) >> 8) | + ((x & 0x0000ff0000000000ULL) >> 24) | + ((x & 0x00ff000000000000ULL) >> 40) | + ((x & 0xff00000000000000ULL) >> 56); +}