From patchwork Wed Jul 12 12:49:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 9836633 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 A4A72602BD for ; Wed, 12 Jul 2017 12:54:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 959B31FF13 for ; Wed, 12 Jul 2017 12:54:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89C0128438; Wed, 12 Jul 2017 12:54:51 +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 043731FF13 for ; Wed, 12 Jul 2017 12:54:51 +0000 (UTC) Received: from localhost ([::1]:52587 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHAI-0002Wn-5K for patchwork-qemu-devel@patchwork.kernel.org; Wed, 12 Jul 2017 08:54:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVH5q-0008HZ-BX for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVH5p-0004N4-22 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34230) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVH5o-0004MW-Ov for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:12 -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 9760E7D0F7; Wed, 12 Jul 2017 12:50:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9760E7D0F7 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9760E7D0F7 Received: from thh440s.redhat.com (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92D0E6DB67; Wed, 12 Jul 2017 12:50:05 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Christian Borntraeger , Cornelia Huck Date: Wed, 12 Jul 2017 14:49:43 +0200 Message-Id: <1499863793-18627-2-git-send-email-thuth@redhat.com> In-Reply-To: <1499863793-18627-1-git-send-email-thuth@redhat.com> References: <1499863793-18627-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.26]); Wed, 12 Jul 2017 12:50:11 +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 v5 01/11] pc-bios/s390-ccw: Move libc functions to 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: 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 The upcoming netboot code will use the libc from SLOF. To be able to still use s390-ccw.h there, the libc related functions in this header have to be moved to a different location. And while we're at it, remove the duplicate memcpy() function from sclp.c. Reviewed-by: Christian Borntraeger Reviewed-by: Cornelia Huck Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/bootmap.c | 1 + pc-bios/s390-ccw/libc.h | 45 ++++++++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/main.c | 1 + pc-bios/s390-ccw/s390-ccw.h | 29 --------------------------- pc-bios/s390-ccw/sclp.c | 10 ++-------- pc-bios/s390-ccw/virtio-scsi.c | 1 + pc-bios/s390-ccw/virtio.c | 1 + 7 files changed, 51 insertions(+), 37 deletions(-) create mode 100644 pc-bios/s390-ccw/libc.h diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index 523fa78..458d3da 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -8,6 +8,7 @@ * directory. */ +#include "libc.h" #include "s390-ccw.h" #include "bootmap.h" #include "virtio.h" diff --git a/pc-bios/s390-ccw/libc.h b/pc-bios/s390-ccw/libc.h new file mode 100644 index 0000000..0142ea8 --- /dev/null +++ b/pc-bios/s390-ccw/libc.h @@ -0,0 +1,45 @@ +/* + * libc-style definitions and functions + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef S390_CCW_LIBC_H +#define S390_CCW_LIBC_H + +typedef long size_t; +typedef int bool; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +static inline void *memset(void *s, int c, size_t n) +{ + int i; + unsigned char *p = s; + + for (i = 0; i < n; i++) { + p[i] = c; + } + + return s; +} + +static inline void *memcpy(void *s1, const void *s2, size_t n) +{ + uint8_t *dest = s1; + const uint8_t *src = s2; + int i; + + for (i = 0; i < n; i++) { + dest[i] = src[i]; + } + + return s1; +} + +#endif diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 1cacc1b..40cba8d 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -8,6 +8,7 @@ * directory. */ +#include "libc.h" #include "s390-ccw.h" #include "virtio.h" diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h index 2089274..43e2d42 100644 --- a/pc-bios/s390-ccw/s390-ccw.h +++ b/pc-bios/s390-ccw/s390-ccw.h @@ -18,12 +18,6 @@ typedef unsigned short u16; typedef unsigned int u32; typedef unsigned long long u64; typedef unsigned long ulong; -typedef long size_t; -typedef int bool; -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; typedef unsigned char __u8; typedef unsigned short __u16; typedef unsigned int __u32; @@ -88,18 +82,6 @@ ulong get_second(void); /* bootmap.c */ void zipl_load(void); -static inline void *memset(void *s, int c, size_t n) -{ - int i; - unsigned char *p = s; - - for (i = 0; i < n; i++) { - p[i] = c; - } - - return s; -} - static inline void fill_hex(char *out, unsigned char val) { const char hex[] = "0123456789abcdef"; @@ -169,17 +151,6 @@ static inline void sleep(unsigned int seconds) } } -static inline void *memcpy(void *s1, const void *s2, size_t n) -{ - uint8_t *p1 = s1; - const uint8_t *p2 = s2; - - while (n--) { - p1[n] = p2[n]; - } - return s1; -} - static inline void IPL_assert(bool term, const char *message) { if (!term) { diff --git a/pc-bios/s390-ccw/sclp.c b/pc-bios/s390-ccw/sclp.c index a1639ba..aa1c862 100644 --- a/pc-bios/s390-ccw/sclp.c +++ b/pc-bios/s390-ccw/sclp.c @@ -8,6 +8,7 @@ * directory. */ +#include "libc.h" #include "s390-ccw.h" #include "sclp.h" @@ -59,13 +60,6 @@ static int _strlen(const char *str) return i; } -static void _memcpy(char *dest, const char *src, int len) -{ - int i; - for (i = 0; i < len; i++) - dest[i] = src[i]; -} - void sclp_print(const char *str) { int len = _strlen(str); @@ -76,7 +70,7 @@ void sclp_print(const char *str) sccb->ebh.length = sizeof(EventBufferHeader) + len; sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA; sccb->ebh.flags = 0; - _memcpy(sccb->data, str, len); + memcpy(sccb->data, str, len); sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb); } diff --git a/pc-bios/s390-ccw/virtio-scsi.c b/pc-bios/s390-ccw/virtio-scsi.c index f61ecf0..c92f5d3 100644 --- a/pc-bios/s390-ccw/virtio-scsi.c +++ b/pc-bios/s390-ccw/virtio-scsi.c @@ -9,6 +9,7 @@ * directory. */ +#include "libc.h" #include "s390-ccw.h" #include "virtio.h" #include "scsi.h" diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c index 6ee93d5..8768331 100644 --- a/pc-bios/s390-ccw/virtio.c +++ b/pc-bios/s390-ccw/virtio.c @@ -8,6 +8,7 @@ * directory. */ +#include "libc.h" #include "s390-ccw.h" #include "virtio.h" #include "virtio-scsi.h"