From nobody Sun Apr 28 06:40:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499864122569890.783616724309; Wed, 12 Jul 2017 05:55:22 -0700 (PDT) Received: from localhost ([::1]:52591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHAm-0003v3-64 for importer@patchew.org; Wed, 12 Jul 2017 08:55:20 -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) 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) 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 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. */ =20 +#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 =3D s; + + for (i =3D 0; i < n; i++) { + p[i] =3D c; + } + + return s; +} + +static inline void *memcpy(void *s1, const void *s2, size_t n) +{ + uint8_t *dest =3D s1; + const uint8_t *src =3D s2; + int i; + + for (i =3D 0; i < n; i++) { + dest[i] =3D 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. */ =20 +#include "libc.h" #include "s390-ccw.h" #include "virtio.h" =20 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); =20 -static inline void *memset(void *s, int c, size_t n) -{ - int i; - unsigned char *p =3D s; - - for (i =3D 0; i < n; i++) { - p[i] =3D c; - } - - return s; -} - static inline void fill_hex(char *out, unsigned char val) { const char hex[] =3D "0123456789abcdef"; @@ -169,17 +151,6 @@ static inline void sleep(unsigned int seconds) } } =20 -static inline void *memcpy(void *s1, const void *s2, size_t n) -{ - uint8_t *p1 =3D s1; - const uint8_t *p2 =3D s2; - - while (n--) { - p1[n] =3D 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. */ =20 +#include "libc.h" #include "s390-ccw.h" #include "sclp.h" =20 @@ -59,13 +60,6 @@ static int _strlen(const char *str) return i; } =20 -static void _memcpy(char *dest, const char *src, int len) -{ - int i; - for (i =3D 0; i < len; i++) - dest[i] =3D src[i]; -} - void sclp_print(const char *str) { int len =3D _strlen(str); @@ -76,7 +70,7 @@ void sclp_print(const char *str) sccb->ebh.length =3D sizeof(EventBufferHeader) + len; sccb->ebh.type =3D SCLP_EVENT_ASCII_CONSOLE_DATA; sccb->ebh.flags =3D 0; - _memcpy(sccb->data, str, len); + memcpy(sccb->data, str, len); =20 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. */ =20 +#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. */ =20 +#include "libc.h" #include "s390-ccw.h" #include "virtio.h" #include "virtio-scsi.h" --=20 1.8.3.1 From nobody Sun Apr 28 06:40:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499864251496721.7281625964368; Wed, 12 Jul 2017 05:57:31 -0700 (PDT) Received: from localhost ([::1]:52608 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHCr-0005tt-4A for importer@patchew.org; Wed, 12 Jul 2017 08:57:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVH5v-0008Mh-Nb for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVH5s-0004PJ-NS for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34680) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVH5s-0004Os-F6 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:16 -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 291FA61D19; Wed, 12 Jul 2017 12:50:15 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 231666DA86; Wed, 12 Jul 2017 12:50:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 291FA61D19 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 291FA61D19 From: Thomas Huth To: qemu-devel@nongnu.org, Christian Borntraeger , Cornelia Huck Date: Wed, 12 Jul 2017 14:49:44 +0200 Message-Id: <1499863793-18627-3-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.39]); Wed, 12 Jul 2017 12:50:15 +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 02/11] pc-bios/s390-ccw: Move ebc2asc to sclp.c 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We will later need this array in a file that we will link to the netboot code, too. Since there is some ebcdic conversion done in sclp_get_loadparm_ascii(), the sclp.c file seems to be a good candidate. Acked-by: Cornelia Huck Reviewed-by: David Hildenbrand Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/main.c | 11 ----------- pc-bios/s390-ccw/sclp.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 40cba8d..0580eac 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -17,17 +17,6 @@ static SubChannelId blk_schid =3D { .one =3D 1 }; IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE))); static char loadparm[8] =3D { 0, 0, 0, 0, 0, 0, 0, 0 }; =20 -const unsigned char ebc2asc[256] =3D - /* 0123456789abcdef0123456789abcdef */ - "................................" /* 1F */ - "................................" /* 3F */ - " ...........<(+|&.........!$*);." /* 5F first.chr.here.is.real.sp= ace */ - "-/.........,%_>?.........`:#@'=3D\""/* 7F */ - ".abcdefghi.......jklmnopqr......" /* 9F */ - "..stuvwxyz......................" /* BF */ - ".ABCDEFGHI.......JKLMNOPQR......" /* DF */ - "..STUVWXYZ......0123456789......";/* FF */ - /* * Priniciples of Operations (SA22-7832-09) chapter 17 requires that * a subsystem-identification is at 184-187 and bytes 188-191 are zero diff --git a/pc-bios/s390-ccw/sclp.c b/pc-bios/s390-ccw/sclp.c index aa1c862..2ee204a 100644 --- a/pc-bios/s390-ccw/sclp.c +++ b/pc-bios/s390-ccw/sclp.c @@ -14,6 +14,17 @@ =20 static char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096))); =20 +const unsigned char ebc2asc[256] =3D + /* 0123456789abcdef0123456789abcdef */ + "................................" /* 1F */ + "................................" /* 3F */ + " ...........<(+|&.........!$*);." /* 5F first.chr.here.is.real.sp= ace */ + "-/.........,%_>?.........`:#@'=3D\""/* 7F */ + ".abcdefghi.......jklmnopqr......" /* 9F */ + "..stuvwxyz......................" /* BF */ + ".ABCDEFGHI.......JKLMNOPQR......" /* DF */ + "..STUVWXYZ......0123456789......";/* FF */ + /* Perform service call. Return 0 on success, non-zero otherwise. */ static int sclp_service_call(unsigned int command, void *sccb) { --=20 1.8.3.1 From nobody Sun Apr 28 06:40:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499864654726354.2684300712608; Wed, 12 Jul 2017 06:04:14 -0700 (PDT) Received: from localhost ([::1]:52640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHJH-0003JL-7Q for importer@patchew.org; Wed, 12 Jul 2017 09:04:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVH64-0008Rt-8u for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVH61-0004So-51 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46614) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVH60-0004SL-RO for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:25 -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 5D5DBC057FA4; Wed, 12 Jul 2017 12:50:23 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id B63946DA81; Wed, 12 Jul 2017 12:50:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5D5DBC057FA4 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5D5DBC057FA4 From: Thomas Huth To: qemu-devel@nongnu.org, Christian Borntraeger , Cornelia Huck Date: Wed, 12 Jul 2017 14:49:45 +0200 Message-Id: <1499863793-18627-4-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.32]); Wed, 12 Jul 2017 12:50:23 +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 03/11] pc-bios/s390-ccw: Move virtio-block related functions into a separate file 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The netboot code is going to link against the code from virtio.c, too, so we've got to move the virtio-block and -scsi related code out of the way. Reviewed-by: Cornelia Huck Reviewed-by: David Hildenbrand Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/main.c | 2 +- pc-bios/s390-ccw/s390-ccw.h | 2 +- pc-bios/s390-ccw/virtio-blkdev.c | 296 +++++++++++++++++++++++++++++++++++= ++++ pc-bios/s390-ccw/virtio.c | 277 +----------------------------------- pc-bios/s390-ccw/virtio.h | 6 + 6 files changed, 311 insertions(+), 274 deletions(-) create mode 100644 pc-bios/s390-ccw/virtio-blkdev.c diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile index fb88c13..82b41ef 100644 --- a/pc-bios/s390-ccw/Makefile +++ b/pc-bios/s390-ccw/Makefile @@ -9,7 +9,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw) =20 .PHONY : all clean build-all =20 -OBJECTS =3D start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o +OBJECTS =3D start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o virtio-= blkdev.o QEMU_CFLAGS :=3D $(filter -W%, $(QEMU_CFLAGS)) QEMU_CFLAGS +=3D -ffreestanding -fno-delete-null-pointer-checks -msoft-flo= at QEMU_CFLAGS +=3D -march=3Dz900 -fPIE -fno-strict-aliasing diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 0580eac..401e9db 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -144,7 +144,7 @@ static void virtio_setup(void) sclp_print("Network boot device detected\n"); vdev->netboot_start_addr =3D iplb.ccw.netboot_start_addr; } else { - virtio_setup_device(blk_schid); + virtio_blk_setup_device(blk_schid); =20 IPL_assert(virtio_ipl_disk_is_valid(), "No valid IPL device detect= ed"); } diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h index 43e2d42..6fdc858 100644 --- a/pc-bios/s390-ccw/s390-ccw.h +++ b/pc-bios/s390-ccw/s390-ccw.h @@ -74,7 +74,7 @@ void sclp_get_loadparm_ascii(char *loadparm); unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2, ulong subchan_id, void *load_addr); bool virtio_is_supported(SubChannelId schid); -void virtio_setup_device(SubChannelId schid); +void virtio_blk_setup_device(SubChannelId schid); int virtio_read(ulong sector, void *load_addr); int enable_mss_facility(void); ulong get_second(void); diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blk= dev.c new file mode 100644 index 0000000..11c5626 --- /dev/null +++ b/pc-bios/s390-ccw/virtio-blkdev.c @@ -0,0 +1,296 @@ +/* + * Virtio driver bits + * + * Copyright (c) 2013 Alexander Graf + * + * 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. + */ + +#include "libc.h" +#include "s390-ccw.h" +#include "virtio.h" +#include "virtio-scsi.h" + +static int virtio_blk_read_many(VDev *vdev, ulong sector, void *load_addr, + int sec_num) +{ + VirtioBlkOuthdr out_hdr; + u8 status; + VRing *vr =3D &vdev->vrings[vdev->cmd_vr_idx]; + + /* Tell the host we want to read */ + out_hdr.type =3D VIRTIO_BLK_T_IN; + out_hdr.ioprio =3D 99; + out_hdr.sector =3D virtio_sector_adjust(sector); + + vring_send_buf(vr, &out_hdr, sizeof(out_hdr), VRING_DESC_F_NEXT); + + /* This is where we want to receive data */ + vring_send_buf(vr, load_addr, virtio_get_block_size() * sec_num, + VRING_DESC_F_WRITE | VRING_HIDDEN_IS_CHAIN | + VRING_DESC_F_NEXT); + + /* status field */ + vring_send_buf(vr, &status, sizeof(u8), + VRING_DESC_F_WRITE | VRING_HIDDEN_IS_CHAIN); + + /* Now we can tell the host to read */ + vring_wait_reply(); + + if (drain_irqs(vr->schid)) { + /* Well, whatever status is supposed to contain... */ + status =3D 1; + } + return status; +} + +int virtio_read_many(ulong sector, void *load_addr, int sec_num) +{ + VDev *vdev =3D virtio_get_device(); + + switch (vdev->senseid.cu_model) { + case VIRTIO_ID_BLOCK: + return virtio_blk_read_many(vdev, sector, load_addr, sec_num); + case VIRTIO_ID_SCSI: + return virtio_scsi_read_many(vdev, sector, load_addr, sec_num); + } + panic("\n! No readable IPL device !\n"); + return -1; +} + +unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2, + ulong subchan_id, void *load_addr) +{ + u8 status; + int sec =3D rec_list1; + int sec_num =3D ((rec_list2 >> 32) & 0xffff) + 1; + int sec_len =3D rec_list2 >> 48; + ulong addr =3D (ulong)load_addr; + + if (sec_len !=3D virtio_get_block_size()) { + return -1; + } + + sclp_print("."); + status =3D virtio_read_many(sec, (void *)addr, sec_num); + if (status) { + panic("I/O Error"); + } + addr +=3D sec_num * virtio_get_block_size(); + + return addr; +} + +int virtio_read(ulong sector, void *load_addr) +{ + return virtio_read_many(sector, load_addr, 1); +} + +/* + * Other supported value pairs, if any, would need to be added here. + * Note: head count is always 15. + */ +static inline u8 virtio_eckd_sectors_for_block_size(int size) +{ + switch (size) { + case 512: + return 49; + case 1024: + return 33; + case 2048: + return 21; + case 4096: + return 12; + } + return 0; +} + +VirtioGDN virtio_guessed_disk_nature(void) +{ + return virtio_get_device()->guessed_disk_nature; +} + +void virtio_assume_scsi(void) +{ + VDev *vdev =3D virtio_get_device(); + + switch (vdev->senseid.cu_model) { + case VIRTIO_ID_BLOCK: + vdev->guessed_disk_nature =3D VIRTIO_GDN_SCSI; + vdev->config.blk.blk_size =3D VIRTIO_SCSI_BLOCK_SIZE; + vdev->config.blk.physical_block_exp =3D 0; + vdev->blk_factor =3D 1; + break; + case VIRTIO_ID_SCSI: + vdev->scsi_block_size =3D VIRTIO_SCSI_BLOCK_SIZE; + break; + } +} + +void virtio_assume_iso9660(void) +{ + VDev *vdev =3D virtio_get_device(); + + switch (vdev->senseid.cu_model) { + case VIRTIO_ID_BLOCK: + vdev->guessed_disk_nature =3D VIRTIO_GDN_SCSI; + vdev->config.blk.blk_size =3D VIRTIO_ISO_BLOCK_SIZE; + vdev->config.blk.physical_block_exp =3D 0; + vdev->blk_factor =3D VIRTIO_ISO_BLOCK_SIZE / VIRTIO_SECTOR_SIZE; + break; + case VIRTIO_ID_SCSI: + vdev->scsi_block_size =3D VIRTIO_ISO_BLOCK_SIZE; + break; + } +} + +void virtio_assume_eckd(void) +{ + VDev *vdev =3D virtio_get_device(); + + vdev->guessed_disk_nature =3D VIRTIO_GDN_DASD; + vdev->blk_factor =3D 1; + vdev->config.blk.physical_block_exp =3D 0; + switch (vdev->senseid.cu_model) { + case VIRTIO_ID_BLOCK: + vdev->config.blk.blk_size =3D 4096; + break; + case VIRTIO_ID_SCSI: + vdev->config.blk.blk_size =3D vdev->scsi_block_size; + break; + } + vdev->config.blk.geometry.heads =3D 15; + vdev->config.blk.geometry.sectors =3D + virtio_eckd_sectors_for_block_size(vdev->config.blk.blk_size); +} + +bool virtio_disk_is_scsi(void) +{ + VDev *vdev =3D virtio_get_device(); + + if (vdev->guessed_disk_nature =3D=3D VIRTIO_GDN_SCSI) { + return true; + } + switch (vdev->senseid.cu_model) { + case VIRTIO_ID_BLOCK: + return (vdev->config.blk.geometry.heads =3D=3D 255) + && (vdev->config.blk.geometry.sectors =3D=3D 63) + && (virtio_get_block_size() =3D=3D VIRTIO_SCSI_BLOCK_SIZE); + case VIRTIO_ID_SCSI: + return true; + } + return false; +} + +bool virtio_disk_is_eckd(void) +{ + VDev *vdev =3D virtio_get_device(); + const int block_size =3D virtio_get_block_size(); + + if (vdev->guessed_disk_nature =3D=3D VIRTIO_GDN_DASD) { + return true; + } + switch (vdev->senseid.cu_model) { + case VIRTIO_ID_BLOCK: + return (vdev->config.blk.geometry.heads =3D=3D 15) + && (vdev->config.blk.geometry.sectors =3D=3D + virtio_eckd_sectors_for_block_size(block_size)); + case VIRTIO_ID_SCSI: + return false; + } + return false; +} + +bool virtio_ipl_disk_is_valid(void) +{ + return virtio_disk_is_scsi() || virtio_disk_is_eckd(); +} + +int virtio_get_block_size(void) +{ + VDev *vdev =3D virtio_get_device(); + + switch (vdev->senseid.cu_model) { + case VIRTIO_ID_BLOCK: + return vdev->config.blk.blk_size << vdev->config.blk.physical_bloc= k_exp; + case VIRTIO_ID_SCSI: + return vdev->scsi_block_size; + } + return 0; +} + +uint8_t virtio_get_heads(void) +{ + VDev *vdev =3D virtio_get_device(); + + switch (vdev->senseid.cu_model) { + case VIRTIO_ID_BLOCK: + return vdev->config.blk.geometry.heads; + case VIRTIO_ID_SCSI: + return vdev->guessed_disk_nature =3D=3D VIRTIO_GDN_DASD + ? vdev->config.blk.geometry.heads : 255; + } + return 0; +} + +uint8_t virtio_get_sectors(void) +{ + VDev *vdev =3D virtio_get_device(); + + switch (vdev->senseid.cu_model) { + case VIRTIO_ID_BLOCK: + return vdev->config.blk.geometry.sectors; + case VIRTIO_ID_SCSI: + return vdev->guessed_disk_nature =3D=3D VIRTIO_GDN_DASD + ? vdev->config.blk.geometry.sectors : 63; + } + return 0; +} + +uint64_t virtio_get_blocks(void) +{ + VDev *vdev =3D virtio_get_device(); + const uint64_t factor =3D virtio_get_block_size() / VIRTIO_SECTOR_SIZE; + + switch (vdev->senseid.cu_model) { + case VIRTIO_ID_BLOCK: + return vdev->config.blk.capacity / factor; + case VIRTIO_ID_SCSI: + return vdev->scsi_last_block / factor; + } + return 0; +} + +void virtio_blk_setup_device(SubChannelId schid) +{ + VDev *vdev =3D virtio_get_device(); + + vdev->schid =3D schid; + virtio_setup_ccw(vdev); + + switch (vdev->senseid.cu_model) { + case VIRTIO_ID_BLOCK: + sclp_print("Using virtio-blk.\n"); + if (!virtio_ipl_disk_is_valid()) { + /* make sure all getters but blocksize return 0 for + * invalid IPL disk + */ + memset(&vdev->config.blk, 0, sizeof(vdev->config.blk)); + virtio_assume_scsi(); + } + break; + case VIRTIO_ID_SCSI: + IPL_assert(vdev->config.scsi.sense_size =3D=3D VIRTIO_SCSI_SENSE_S= IZE, + "Config: sense size mismatch"); + IPL_assert(vdev->config.scsi.cdb_size =3D=3D VIRTIO_SCSI_CDB_SIZE, + "Config: CDB size mismatch"); + + sclp_print("Using virtio-scsi.\n"); + virtio_scsi_setup(vdev); + break; + default: + panic("\n! No IPL device available !\n"); + } +} diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c index 8768331..9d9e61f 100644 --- a/pc-bios/s390-ccw/virtio.c +++ b/pc-bios/s390-ccw/virtio.c @@ -70,7 +70,7 @@ static long virtio_notify(SubChannelId schid, int vq_idx,= long cookie) * Virtio functions * ***********************************************/ =20 -static int drain_irqs(SubChannelId schid) +int drain_irqs(SubChannelId schid) { Irb irb =3D {}; int r =3D 0; @@ -149,13 +149,13 @@ static void vring_init(VRing *vr, VqInfo *info) debug_print_addr("init vr", vr); } =20 -static bool vring_notify(VRing *vr) +bool vring_notify(VRing *vr) { vr->cookie =3D virtio_notify(vr->schid, vr->id, vr->cookie); return vr->cookie >=3D 0; } =20 -static void vring_send_buf(VRing *vr, void *p, int len, int flags) +void vring_send_buf(VRing *vr, void *p, int len, int flags) { /* For follow-up chains we need to keep the first entry point */ if (!(flags & VRING_HIDDEN_IS_CHAIN)) { @@ -188,7 +188,7 @@ ulong get_second(void) return (get_clock() >> 12) / 1000000; } =20 -static int vr_poll(VRing *vr) +int vr_poll(VRing *vr) { if (vr->used->idx =3D=3D vr->used_idx) { vring_notify(vr); @@ -210,7 +210,7 @@ static int vr_poll(VRing *vr) * * Returns 0 on success, 1 on timeout. */ -static int vring_wait_reply(void) +int vring_wait_reply(void) { ulong target_second =3D get_second() + vdev.wait_reply_timeout; =20 @@ -247,242 +247,7 @@ int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd) return 0; } =20 -/*********************************************** - * Virtio block * - ***********************************************/ - -static int virtio_blk_read_many(VDev *vdev, - ulong sector, void *load_addr, int sec_num) -{ - VirtioBlkOuthdr out_hdr; - u8 status; - VRing *vr =3D &vdev->vrings[vdev->cmd_vr_idx]; - - /* Tell the host we want to read */ - out_hdr.type =3D VIRTIO_BLK_T_IN; - out_hdr.ioprio =3D 99; - out_hdr.sector =3D virtio_sector_adjust(sector); - - vring_send_buf(vr, &out_hdr, sizeof(out_hdr), VRING_DESC_F_NEXT); - - /* This is where we want to receive data */ - vring_send_buf(vr, load_addr, virtio_get_block_size() * sec_num, - VRING_DESC_F_WRITE | VRING_HIDDEN_IS_CHAIN | - VRING_DESC_F_NEXT); - - /* status field */ - vring_send_buf(vr, &status, sizeof(u8), - VRING_DESC_F_WRITE | VRING_HIDDEN_IS_CHAIN); - - /* Now we can tell the host to read */ - vring_wait_reply(); - - if (drain_irqs(vr->schid)) { - /* Well, whatever status is supposed to contain... */ - status =3D 1; - } - return status; -} - -int virtio_read_many(ulong sector, void *load_addr, int sec_num) -{ - switch (vdev.senseid.cu_model) { - case VIRTIO_ID_BLOCK: - return virtio_blk_read_many(&vdev, sector, load_addr, sec_num); - case VIRTIO_ID_SCSI: - return virtio_scsi_read_many(&vdev, sector, load_addr, sec_num); - } - panic("\n! No readable IPL device !\n"); - return -1; -} - -unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2, - ulong subchan_id, void *load_addr) -{ - u8 status; - int sec =3D rec_list1; - int sec_num =3D ((rec_list2 >> 32) & 0xffff) + 1; - int sec_len =3D rec_list2 >> 48; - ulong addr =3D (ulong)load_addr; - - if (sec_len !=3D virtio_get_block_size()) { - return -1; - } - - sclp_print("."); - status =3D virtio_read_many(sec, (void *)addr, sec_num); - if (status) { - panic("I/O Error"); - } - addr +=3D sec_num * virtio_get_block_size(); - - return addr; -} - -int virtio_read(ulong sector, void *load_addr) -{ - return virtio_read_many(sector, load_addr, 1); -} - -/* - * Other supported value pairs, if any, would need to be added here. - * Note: head count is always 15. - */ -static inline u8 virtio_eckd_sectors_for_block_size(int size) -{ - switch (size) { - case 512: - return 49; - case 1024: - return 33; - case 2048: - return 21; - case 4096: - return 12; - } - return 0; -} - -VirtioGDN virtio_guessed_disk_nature(void) -{ - return vdev.guessed_disk_nature; -} - -void virtio_assume_scsi(void) -{ - switch (vdev.senseid.cu_model) { - case VIRTIO_ID_BLOCK: - vdev.guessed_disk_nature =3D VIRTIO_GDN_SCSI; - vdev.config.blk.blk_size =3D VIRTIO_SCSI_BLOCK_SIZE; - vdev.config.blk.physical_block_exp =3D 0; - vdev.blk_factor =3D 1; - break; - case VIRTIO_ID_SCSI: - vdev.scsi_block_size =3D VIRTIO_SCSI_BLOCK_SIZE; - break; - } -} - -void virtio_assume_iso9660(void) -{ - switch (vdev.senseid.cu_model) { - case VIRTIO_ID_BLOCK: - vdev.guessed_disk_nature =3D VIRTIO_GDN_SCSI; - vdev.config.blk.blk_size =3D VIRTIO_ISO_BLOCK_SIZE; - vdev.config.blk.physical_block_exp =3D 0; - vdev.blk_factor =3D VIRTIO_ISO_BLOCK_SIZE / VIRTIO_SECTOR_SIZE; - break; - case VIRTIO_ID_SCSI: - vdev.scsi_block_size =3D VIRTIO_ISO_BLOCK_SIZE; - break; - } -} - -void virtio_assume_eckd(void) -{ - vdev.guessed_disk_nature =3D VIRTIO_GDN_DASD; - vdev.blk_factor =3D 1; - vdev.config.blk.physical_block_exp =3D 0; - switch (vdev.senseid.cu_model) { - case VIRTIO_ID_BLOCK: - vdev.config.blk.blk_size =3D 4096; - break; - case VIRTIO_ID_SCSI: - vdev.config.blk.blk_size =3D vdev.scsi_block_size; - break; - } - vdev.config.blk.geometry.heads =3D 15; - vdev.config.blk.geometry.sectors =3D - virtio_eckd_sectors_for_block_size(vdev.config.blk.blk_size); -} - -bool virtio_disk_is_scsi(void) -{ - if (vdev.guessed_disk_nature =3D=3D VIRTIO_GDN_SCSI) { - return true; - } - switch (vdev.senseid.cu_model) { - case VIRTIO_ID_BLOCK: - return (vdev.config.blk.geometry.heads =3D=3D 255) - && (vdev.config.blk.geometry.sectors =3D=3D 63) - && (virtio_get_block_size() =3D=3D VIRTIO_SCSI_BLOCK_SIZE); - case VIRTIO_ID_SCSI: - return true; - } - return false; -} - -bool virtio_disk_is_eckd(void) -{ - const int block_size =3D virtio_get_block_size(); - - if (vdev.guessed_disk_nature =3D=3D VIRTIO_GDN_DASD) { - return true; - } - switch (vdev.senseid.cu_model) { - case VIRTIO_ID_BLOCK: - return (vdev.config.blk.geometry.heads =3D=3D 15) - && (vdev.config.blk.geometry.sectors =3D=3D - virtio_eckd_sectors_for_block_size(block_size)); - case VIRTIO_ID_SCSI: - return false; - } - return false; -} - -bool virtio_ipl_disk_is_valid(void) -{ - return virtio_disk_is_scsi() || virtio_disk_is_eckd(); -} - -int virtio_get_block_size(void) -{ - switch (vdev.senseid.cu_model) { - case VIRTIO_ID_BLOCK: - return vdev.config.blk.blk_size << vdev.config.blk.physical_block_= exp; - case VIRTIO_ID_SCSI: - return vdev.scsi_block_size; - } - return 0; -} - -uint8_t virtio_get_heads(void) -{ - switch (vdev.senseid.cu_model) { - case VIRTIO_ID_BLOCK: - return vdev.config.blk.geometry.heads; - case VIRTIO_ID_SCSI: - return vdev.guessed_disk_nature =3D=3D VIRTIO_GDN_DASD - ? vdev.config.blk.geometry.heads : 255; - } - return 0; -} - -uint8_t virtio_get_sectors(void) -{ - switch (vdev.senseid.cu_model) { - case VIRTIO_ID_BLOCK: - return vdev.config.blk.geometry.sectors; - case VIRTIO_ID_SCSI: - return vdev.guessed_disk_nature =3D=3D VIRTIO_GDN_DASD - ? vdev.config.blk.geometry.sectors : 63; - } - return 0; -} - -uint64_t virtio_get_blocks(void) -{ - const uint64_t factor =3D virtio_get_block_size() / VIRTIO_SECTOR_SIZE; - switch (vdev.senseid.cu_model) { - case VIRTIO_ID_BLOCK: - return vdev.config.blk.capacity / factor; - case VIRTIO_ID_SCSI: - return vdev.scsi_last_block / factor; - } - return 0; -} - -static void virtio_setup_ccw(VDev *vdev) +void virtio_setup_ccw(VDev *vdev) { int i, cfg_size =3D 0; unsigned char status =3D VIRTIO_CONFIG_S_DRIVER_OK; @@ -544,36 +309,6 @@ static void virtio_setup_ccw(VDev *vdev) "Could not write status to host"); } =20 -void virtio_setup_device(SubChannelId schid) -{ - vdev.schid =3D schid; - virtio_setup_ccw(&vdev); - - switch (vdev.senseid.cu_model) { - case VIRTIO_ID_BLOCK: - sclp_print("Using virtio-blk.\n"); - if (!virtio_ipl_disk_is_valid()) { - /* make sure all getters but blocksize return 0 for - * invalid IPL disk - */ - memset(&vdev.config.blk, 0, sizeof(vdev.config.blk)); - virtio_assume_scsi(); - } - break; - case VIRTIO_ID_SCSI: - IPL_assert(vdev.config.scsi.sense_size =3D=3D VIRTIO_SCSI_SENSE_SI= ZE, - "Config: sense size mismatch"); - IPL_assert(vdev.config.scsi.cdb_size =3D=3D VIRTIO_SCSI_CDB_SIZE, - "Config: CDB size mismatch"); - - sclp_print("Using virtio-scsi.\n"); - virtio_scsi_setup(&vdev); - break; - default: - panic("\n! No IPL device available !\n"); - } -} - bool virtio_is_supported(SubChannelId schid) { vdev.schid =3D schid; diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h index 1eaf865..024e9a6 100644 --- a/pc-bios/s390-ccw/virtio.h +++ b/pc-bios/s390-ccw/virtio.h @@ -291,6 +291,12 @@ struct VirtioCmd { }; typedef struct VirtioCmd VirtioCmd; =20 +bool vring_notify(VRing *vr); +int drain_irqs(SubChannelId schid); +void vring_send_buf(VRing *vr, void *p, int len, int flags); +int vr_poll(VRing *vr); +int vring_wait_reply(void); int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd); +void virtio_setup_ccw(VDev *vdev); =20 #endif /* VIRTIO_H */ --=20 1.8.3.1 From nobody Sun Apr 28 06:40:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499864826904221.44390288786155; Wed, 12 Jul 2017 06:07:06 -0700 (PDT) Received: from localhost ([::1]:52657 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHM2-0005pj-Bm for importer@patchew.org; Wed, 12 Jul 2017 09:06:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVH6A-0008Uh-2K for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVH69-0004WJ-D3 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14984) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVH69-0004Vw-77 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:33 -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 A3EFDC0587E8; Wed, 12 Jul 2017 12:50:31 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id B75E26DB95; Wed, 12 Jul 2017 12:50:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A3EFDC0587E8 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A3EFDC0587E8 From: Thomas Huth To: qemu-devel@nongnu.org, Christian Borntraeger , Cornelia Huck Date: Wed, 12 Jul 2017 14:49:46 +0200 Message-Id: <1499863793-18627-5-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.32]); Wed, 12 Jul 2017 12:50:32 +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 04/11] pc-bios/s390-ccw: Add a write() function for stdio 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The stdio functions from the SLOF libc need a write() function for printing text to stdout/stderr. Let's implement this function by refactoring the code from sclp_print(). Acked-by: Cornelia Huck Reviewed-by: David Hildenbrand Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/sclp.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pc-bios/s390-ccw/sclp.c b/pc-bios/s390-ccw/sclp.c index 2ee204a..b1fc8ff 100644 --- a/pc-bios/s390-ccw/sclp.c +++ b/pc-bios/s390-ccw/sclp.c @@ -12,6 +12,8 @@ #include "s390-ccw.h" #include "sclp.h" =20 +long write(int fd, const void *str, size_t len); + static char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096))); =20 const unsigned char ebc2asc[256] =3D @@ -71,11 +73,14 @@ static int _strlen(const char *str) return i; } =20 -void sclp_print(const char *str) +long write(int fd, const void *str, size_t len) { - int len =3D _strlen(str); WriteEventData *sccb =3D (void *)_sccb; =20 + if (fd !=3D 1 && fd !=3D 2) { + return -EIO; + } + sccb->h.length =3D sizeof(WriteEventData) + len; sccb->h.function_code =3D SCLP_FC_NORMAL_WRITE; sccb->ebh.length =3D sizeof(EventBufferHeader) + len; @@ -84,6 +89,13 @@ void sclp_print(const char *str) memcpy(sccb->data, str, len); =20 sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb); + + return len; +} + +void sclp_print(const char *str) +{ + write(1, str, _strlen(str)); } =20 void sclp_get_loadparm_ascii(char *loadparm) --=20 1.8.3.1 From nobody Sun Apr 28 06:40:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499864464805374.92192831072134; Wed, 12 Jul 2017 06:01:04 -0700 (PDT) Received: from localhost ([::1]:52628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHGH-0000h3-As for importer@patchew.org; Wed, 12 Jul 2017 09:01:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVH6E-00007B-3t for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVH6D-0004cM-38 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVH6C-0004ab-OP for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:36 -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 7EB183D95F; Wed, 12 Jul 2017 12:50:35 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12F67779F1; Wed, 12 Jul 2017 12:50:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7EB183D95F Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7EB183D95F From: Thomas Huth To: qemu-devel@nongnu.org, Christian Borntraeger , Cornelia Huck Date: Wed, 12 Jul 2017 14:49:47 +0200 Message-Id: <1499863793-18627-6-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.30]); Wed, 12 Jul 2017 12:50:35 +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 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: Viktor Mihajlovski , Farhan Ali , Alexander Graf , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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" =20 #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; } =20 -/* 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); +} --=20 1.8.3.1 From nobody Sun Apr 28 06:40:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499864994497300.6663951019689; Wed, 12 Jul 2017 06:09:54 -0700 (PDT) Received: from localhost ([::1]:52668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHOo-0008OI-Qy for importer@patchew.org; Wed, 12 Jul 2017 09:09:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVH6Q-0000JM-BN for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVH6N-0004rE-9n for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51224) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVH6N-0004pm-3f for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:47 -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 D80EA4E4D9; Wed, 12 Jul 2017 12:50:45 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32D8F5D9C8; Wed, 12 Jul 2017 12:50:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D80EA4E4D9 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D80EA4E4D9 From: Thomas Huth To: qemu-devel@nongnu.org, Christian Borntraeger , Cornelia Huck Date: Wed, 12 Jul 2017 14:49:48 +0200 Message-Id: <1499863793-18627-7-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.38]); Wed, 12 Jul 2017 12:50:46 +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 06/11] pc-bios/s390-ccw: Remove unused structs from virtio.h 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Looks like they have never been used, so let's simply remove them. Acked-by: Cornelia Huck Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/virtio.h | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h index 024e9a6..d733780 100644 --- a/pc-bios/s390-ccw/virtio.h +++ b/pc-bios/s390-ccw/virtio.h @@ -32,24 +32,6 @@ enum VirtioDevType { }; typedef enum VirtioDevType VirtioDevType; =20 -struct VirtioDevHeader { - VirtioDevType type:8; - uint8_t num_vq; - uint8_t feature_len; - uint8_t config_len; - uint8_t status; - uint8_t vqconfig[]; -} __attribute__((packed)); -typedef struct VirtioDevHeader VirtioDevHeader; - -struct VirtioVqConfig { - uint64_t token; - uint64_t address; - uint16_t num; - uint8_t pad[6]; -} __attribute__((packed)); -typedef struct VirtioVqConfig VirtioVqConfig; - struct VqInfo { uint64_t queue; uint32_t align; @@ -64,15 +46,6 @@ struct VqConfig { } __attribute__((packed)); typedef struct VqConfig VqConfig; =20 -struct VirtioDev { - VirtioDevHeader *header; - VirtioVqConfig *vqconfig; - char *host_features; - char *guest_features; - char *config; -}; -typedef struct VirtioDev VirtioDev; - #define VIRTIO_RING_SIZE (PAGE_SIZE * 8) #define VIRTIO_MAX_VQS 3 #define KVM_S390_VIRTIO_RING_ALIGN 4096 --=20 1.8.3.1 From nobody Sun Apr 28 06:40:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149986423107259.855452255201385; Wed, 12 Jul 2017 05:57:11 -0700 (PDT) Received: from localhost ([::1]:52607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHCW-0005cy-Oz for importer@patchew.org; Wed, 12 Jul 2017 08:57:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVH6S-0000Ly-T7 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVH6R-0004y9-U3 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38422) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVH6R-0004xW-KN for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:51 -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 79DE180E72; Wed, 12 Jul 2017 12:50:50 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D8585D9CB; Wed, 12 Jul 2017 12:50:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 79DE180E72 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 79DE180E72 From: Thomas Huth To: qemu-devel@nongnu.org, Christian Borntraeger , Cornelia Huck Date: Wed, 12 Jul 2017 14:49:49 +0200 Message-Id: <1499863793-18627-8-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.25]); Wed, 12 Jul 2017 12:50:50 +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 07/11] pc-bios/s390-ccw: Add code for virtio feature negotiation 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The upcoming virtio-net driver needs to negotiate some features, so we need the possibility to do this in the core virtio code. Reviewed-by: Cornelia Huck Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/s390-ccw.h | 2 ++ pc-bios/s390-ccw/virtio.c | 23 +++++++++++++++++------ pc-bios/s390-ccw/virtio.h | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h index 6fdc858..25d4d21 100644 --- a/pc-bios/s390-ccw/s390-ccw.h +++ b/pc-bios/s390-ccw/s390-ccw.h @@ -44,6 +44,8 @@ typedef unsigned long long __u64; ((b) =3D=3D 0 ? (a) : (MIN(a, b)))) #endif =20 +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) + #include "cio.h" #include "iplb.h" =20 diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c index 9d9e61f..18fc5d1 100644 --- a/pc-bios/s390-ccw/virtio.c +++ b/pc-bios/s390-ccw/virtio.c @@ -12,6 +12,7 @@ #include "s390-ccw.h" #include "virtio.h" #include "virtio-scsi.h" +#include "bswap.h" =20 #define VRING_WAIT_REPLY_TIMEOUT 3 =20 @@ -249,8 +250,12 @@ int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd) =20 void virtio_setup_ccw(VDev *vdev) { - int i, cfg_size =3D 0; + int i, rc, cfg_size =3D 0; unsigned char status =3D VIRTIO_CONFIG_S_DRIVER_OK; + struct VirtioFeatureDesc { + uint32_t features; + uint8_t index; + } __attribute__((packed)) feats; =20 IPL_assert(virtio_is_supported(vdev->schid), "PE"); /* device ID has been established now */ @@ -277,11 +282,17 @@ void virtio_setup_ccw(VDev *vdev) IPL_assert(run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size) = =3D=3D 0, "Could not get block device configuration"); =20 - /* - * Skipping CCW_CMD_READ_FEAT. We're not doing anything fancy, and - * we'll just stop dead anyway if anything does not work like we - * expect it. - */ + /* Feature negotiation */ + for (i =3D 0; i < ARRAY_SIZE(vdev->guest_features); i++) { + feats.features =3D 0; + feats.index =3D i; + rc =3D run_ccw(vdev, CCW_CMD_READ_FEAT, &feats, sizeof(feats)); + IPL_assert(rc =3D=3D 0, "Could not get features bits"); + vdev->guest_features[i] &=3D bswap32(feats.features); + feats.features =3D bswap32(vdev->guest_features[i]); + rc =3D run_ccw(vdev, CCW_CMD_WRITE_FEAT, &feats, sizeof(feats)); + IPL_assert(rc =3D=3D 0, "Could not set features bits"); + } =20 for (i =3D 0; i < vdev->nr_vqs; i++) { VqInfo info =3D { diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h index d733780..a00a320 100644 --- a/pc-bios/s390-ccw/virtio.h +++ b/pc-bios/s390-ccw/virtio.h @@ -251,6 +251,7 @@ struct VDev { ScsiDevice selected_scsi_device; uint64_t netboot_start_addr; uint32_t max_transfer; + uint32_t guest_features[2]; }; typedef struct VDev VDev; =20 --=20 1.8.3.1 From nobody Sun Apr 28 06:40:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14998643691591011.3839246875478; Wed, 12 Jul 2017 05:59:29 -0700 (PDT) Received: from localhost ([::1]:52615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHEk-0007cL-Tt for importer@patchew.org; Wed, 12 Jul 2017 08:59:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVH6c-0000U7-EW for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:51:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVH6Z-00054t-EA for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:51:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51704) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVH6Z-00054U-8D for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:59 -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 256CD4E909; Wed, 12 Jul 2017 12:50:58 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2767561B74; Wed, 12 Jul 2017 12:50:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 256CD4E909 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 256CD4E909 From: Thomas Huth To: qemu-devel@nongnu.org, Christian Borntraeger , Cornelia Huck Date: Wed, 12 Jul 2017 14:49:50 +0200 Message-Id: <1499863793-18627-9-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.38]); Wed, 12 Jul 2017 12:50:58 +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 08/11] roms/SLOF: Update submodule to latest status 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We need the latest fixes for building the libc and libnet of SLOF for the s390-ccw network bootloader firmware. Signed-off-by: Thomas Huth --- roms/SLOF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roms/SLOF b/roms/SLOF index 66d250e..834113a 160000 --- a/roms/SLOF +++ b/roms/SLOF @@ -1 +1 @@ -Subproject commit 66d250ef0fd06bb88b7399b9563b5008201f2d63 +Subproject commit 834113a1c67d6fb53dea153c3313d182238f2d36 --=20 1.8.3.1 From nobody Sun Apr 28 06:40:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499865155620389.08874458787466; Wed, 12 Jul 2017 06:12:35 -0700 (PDT) Received: from localhost ([::1]:52682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHRN-000287-TZ for importer@patchew.org; Wed, 12 Jul 2017 09:12:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVH6f-0000Wa-DN for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:51:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVH6d-00058X-QG for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:51:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33702) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVH6d-000584-Gs for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:51:03 -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 5BEAE3D957; Wed, 12 Jul 2017 12:51:02 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDA495D9CB; Wed, 12 Jul 2017 12:50:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5BEAE3D957 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5BEAE3D957 From: Thomas Huth To: qemu-devel@nongnu.org, Christian Borntraeger , Cornelia Huck Date: Wed, 12 Jul 2017 14:49:51 +0200 Message-Id: <1499863793-18627-10-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.30]); Wed, 12 Jul 2017 12:51:02 +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 09/11] pc-bios/s390-ccw: Add core files for the network bootloading program 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is just a preparation for the next steps: Add a makefile and a stripped down copy of pc-bios/s390-ccw/main.c as a basis for the network bootloader program, linked against the libc from SLOF already (which we will need for SLOF's libnet). The networking code is not included yet. Reviewed-by: Cornelia Huck Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/Makefile | 11 +++- pc-bios/s390-ccw/netboot.mak | 47 +++++++++++++++ pc-bios/s390-ccw/netmain.c | 136 +++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 pc-bios/s390-ccw/netboot.mak create mode 100644 pc-bios/s390-ccw/netmain.c diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile index 82b41ef..cbae745 100644 --- a/pc-bios/s390-ccw/Makefile +++ b/pc-bios/s390-ccw/Makefile @@ -16,7 +16,7 @@ QEMU_CFLAGS +=3D -march=3Dz900 -fPIE -fno-strict-aliasing QEMU_CFLAGS +=3D $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector) LDFLAGS +=3D -Wl,-pie -nostdlib =20 -build-all: s390-ccw.img +build-all: s390-ccw.img s390-netboot.img =20 s390-ccw.elf: $(OBJECTS) $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $(OBJECTS),"BUILD","$(TARGET_= DIR)$@") @@ -28,5 +28,12 @@ s390-ccw.img: s390-ccw.elf =20 $(OBJECTS): Makefile =20 +ifneq ($(wildcard $(SRC_PATH)/roms/SLOF/lib/libnet),) +include $(SRC_PATH)/pc-bios/s390-ccw/netboot.mak +else +s390-netboot.img: + @echo "s390-netboot.img not built since roms/SLOF/ is not available." +endif + clean: - rm -f *.o *.d *.img *.elf *~ + $(RM) *.o *.d *.img *.elf *~ *.a diff --git a/pc-bios/s390-ccw/netboot.mak b/pc-bios/s390-ccw/netboot.mak new file mode 100644 index 0000000..44b7645 --- /dev/null +++ b/pc-bios/s390-ccw/netboot.mak @@ -0,0 +1,47 @@ + +SLOF_DIR :=3D $(SRC_PATH)/roms/SLOF + +NETOBJS :=3D start.o sclp.o virtio.o netmain.o libc.a + +LIBC_INC :=3D -nostdinc -I$(SLOF_DIR)/lib/libc/include +LIBNET_INC :=3D -I$(SLOF_DIR)/lib/libnet + +NETLDFLAGS :=3D $(LDFLAGS) -Ttext=3D0x7800000 + +$(NETOBJS): QEMU_CFLAGS +=3D $(LIBC_INC) $(LIBNET_INC) + +s390-netboot.elf: $(NETOBJS) + $(call quiet-command,$(CC) $(NETLDFLAGS) -o $@ $(NETOBJS),"BUILD","$(TARG= ET_DIR)$@") + +s390-netboot.img: s390-netboot.elf + $(call quiet-command,$(STRIP) --strip-unneeded $< -o $@,"STRIP","$(TARGET= _DIR)$@") + +# libc files: + +LIBC_CFLAGS :=3D $(QEMU_CFLAGS) $(LIBC_INC) $(LIBNET_INC) + +CTYPE_OBJS =3D isdigit.o isxdigit.o toupper.o +%.o : $(SLOF_DIR)/lib/libc/ctype/%.c + $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)= $@") + +STRING_OBJS =3D strcat.o strchr.o strcmp.o strcpy.o strlen.o strncmp.o str= ncpy.o \ + strstr.o memset.o memcpy.o memmove.o memcmp.o +%.o : $(SLOF_DIR)/lib/libc/string/%.c + $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)= $@") + +STDLIB_OBJS =3D atoi.o atol.o strtoul.o strtol.o rand.o malloc.o free.o +%.o : $(SLOF_DIR)/lib/libc/stdlib/%.c + $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)= $@") + +STDIO_OBJS =3D sprintf.o vfprintf.o vsnprintf.o vsprintf.o fprintf.o \ + printf.o putc.o puts.o putchar.o stdchnls.o fileno.o +%.o : $(SLOF_DIR)/lib/libc/stdio/%.c + $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)= $@") + +sbrk.o: $(SLOF_DIR)/slof/sbrk.c + $(call quiet-command,$(CC) $(LIBC_CFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR)= $@") + +LIBCOBJS :=3D $(STRING_OBJS) $(CTYPE_OBJS) $(STDLIB_OBJS) $(STDIO_OBJS) sb= rk.o + +libc.a: $(LIBCOBJS) + $(call quiet-command,$(AR) -rc $@ $^,"AR","$(TARGET_DIR)$@") diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c new file mode 100644 index 0000000..a69b3dd --- /dev/null +++ b/pc-bios/s390-ccw/netmain.c @@ -0,0 +1,136 @@ +/* + * S390 virtio-ccw network boot loading program + * + * Copyright 2017 Thomas Huth, Red Hat Inc. + * + * Based on the S390 virtio-ccw loading program (main.c) + * Copyright (c) 2013 Alexander Graf + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "s390-ccw.h" +#include "virtio.h" + +extern char _start[]; + +char stack[PAGE_SIZE * 8] __attribute__((aligned(PAGE_SIZE))); +IplParameterBlock iplb __attribute__((aligned(PAGE_SIZE))); + +static SubChannelId net_schid =3D { .one =3D 1 }; +static uint64_t dest_timer; + +static uint64_t get_timer_ms(void) +{ + uint64_t clk; + + asm volatile(" stck %0 " : : "Q"(clk) : "memory"); + + /* Bit 51 is incremented each microsecond */ + return (clk >> (63 - 51)) / 1000; +} + +void set_timer(int val) +{ + dest_timer =3D get_timer_ms() + val; +} + +int get_timer(void) +{ + return dest_timer - get_timer_ms(); +} + +int get_sec_ticks(void) +{ + return 1000; /* number of ticks in 1 second */ +} + +void panic(const char *string) +{ + sclp_print(string); + for (;;) { + disabled_wait(); + } +} + +static bool find_net_dev(Schib *schib, int dev_no) +{ + int i, r; + + for (i =3D 0; i < 0x10000; i++) { + net_schid.sch_no =3D i; + r =3D stsch_err(net_schid, schib); + if (r =3D=3D 3 || r =3D=3D -EIO) { + break; + } + if (!schib->pmcw.dnv) { + continue; + } + if (!virtio_is_supported(net_schid)) { + continue; + } + if (virtio_get_device_type() !=3D VIRTIO_ID_NET) { + continue; + } + if (dev_no < 0 || schib->pmcw.dev =3D=3D dev_no) { + return true; + } + } + + return false; +} + +static void virtio_setup(void) +{ + Schib schib; + int ssid; + bool found =3D false; + uint16_t dev_no; + + /* + * We unconditionally enable mss support. In every sane configuration, + * this will succeed; and even if it doesn't, stsch_err() can deal + * with the consequences. + */ + enable_mss_facility(); + + if (store_iplb(&iplb)) { + IPL_assert(iplb.pbt =3D=3D S390_IPL_TYPE_CCW, "IPL_TYPE_CCW expect= ed"); + dev_no =3D iplb.ccw.devno; + debug_print_int("device no. ", dev_no); + net_schid.ssid =3D iplb.ccw.ssid & 0x3; + debug_print_int("ssid ", net_schid.ssid); + found =3D find_net_dev(&schib, dev_no); + } else { + for (ssid =3D 0; ssid < 0x3; ssid++) { + net_schid.ssid =3D ssid; + found =3D find_net_dev(&schib, -1); + if (found) { + break; + } + } + } + + IPL_assert(found, "No virtio net device found"); +} + +void main(void) +{ + sclp_setup(); + sclp_print("Network boot starting...\n"); + + virtio_setup(); + + panic("Failed to load OS from network\n"); +} --=20 1.8.3.1 From nobody Sun Apr 28 06:40:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499864089477707.1635190636667; Wed, 12 Jul 2017 05:54:49 -0700 (PDT) Received: from localhost ([::1]:52589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHAE-0003Mc-R0 for importer@patchew.org; Wed, 12 Jul 2017 08:54:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVH6l-0000Zu-2o for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:51:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVH6i-0005Af-0d for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:51:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39765) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVH6h-0005A7-Ny for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:51:07 -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 8BD4F30EF6A; Wed, 12 Jul 2017 12:51:06 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A1BD5D9C8; Wed, 12 Jul 2017 12:51:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8BD4F30EF6A Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8BD4F30EF6A From: Thomas Huth To: qemu-devel@nongnu.org, Christian Borntraeger , Cornelia Huck Date: Wed, 12 Jul 2017 14:49:52 +0200 Message-Id: <1499863793-18627-11-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.29]); Wed, 12 Jul 2017 12:51:06 +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 10/11] pc-bios/s390-ccw: Add virtio-net driver code 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The driver provides the recv() and send() functions which will be required by SLOF's libnet code for receiving and sending packets. Reviewed-by: Cornelia Huck Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/netboot.mak | 2 +- pc-bios/s390-ccw/virtio-net.c | 135 ++++++++++++++++++++++++++++++++++++++= ++++ pc-bios/s390-ccw/virtio.c | 5 ++ pc-bios/s390-ccw/virtio.h | 12 +++- 4 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 pc-bios/s390-ccw/virtio-net.c diff --git a/pc-bios/s390-ccw/netboot.mak b/pc-bios/s390-ccw/netboot.mak index 44b7645..eb70430 100644 --- a/pc-bios/s390-ccw/netboot.mak +++ b/pc-bios/s390-ccw/netboot.mak @@ -1,7 +1,7 @@ =20 SLOF_DIR :=3D $(SRC_PATH)/roms/SLOF =20 -NETOBJS :=3D start.o sclp.o virtio.o netmain.o libc.a +NETOBJS :=3D start.o sclp.o virtio.o virtio-net.o netmain.o libc.a =20 LIBC_INC :=3D -nostdinc -I$(SLOF_DIR)/lib/libc/include LIBNET_INC :=3D -I$(SLOF_DIR)/lib/libnet diff --git a/pc-bios/s390-ccw/virtio-net.c b/pc-bios/s390-ccw/virtio-net.c new file mode 100644 index 0000000..ff7f4da --- /dev/null +++ b/pc-bios/s390-ccw/virtio-net.c @@ -0,0 +1,135 @@ +/* + * Virtio-net driver for the s390-ccw firmware + * + * Copyright 2017 Thomas Huth, Red Hat Inc. + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "s390-ccw.h" +#include "virtio.h" + +#ifndef DEBUG_VIRTIO_NET +#define DEBUG_VIRTIO_NET 0 +#endif + +#define VIRTIO_NET_F_MAC_BIT (1 << 5) + +#define VQ_RX 0 /* Receive queue */ +#define VQ_TX 1 /* Transmit queue */ + +struct VirtioNetHdr { + uint8_t flags; + uint8_t gso_type; + uint16_t hdr_len; + uint16_t gso_size; + uint16_t csum_start; + uint16_t csum_offset; + /*uint16_t num_buffers;*/ /* Only with VIRTIO_NET_F_MRG_RXBUF or VIRTI= O1 */ +}; +typedef struct VirtioNetHdr VirtioNetHdr; + +static uint16_t rx_last_idx; /* Last index in receive queue "used" ring */ + +int virtio_net_init(void *mac_addr) +{ + VDev *vdev =3D virtio_get_device(); + VRing *rxvq =3D &vdev->vrings[VQ_RX]; + void *buf; + int i; + + vdev->guest_features[0] =3D VIRTIO_NET_F_MAC_BIT; + virtio_setup_ccw(vdev); + + IPL_assert(vdev->guest_features[0] & VIRTIO_NET_F_MAC_BIT, + "virtio-net device does not support the MAC address feature= "); + memcpy(mac_addr, vdev->config.net.mac, ETH_ALEN); + + for (i =3D 0; i < 64; i++) { + buf =3D malloc(ETH_MTU_SIZE + sizeof(VirtioNetHdr)); + IPL_assert(buf !=3D NULL, "Can not allocate memory for receive buf= fers"); + vring_send_buf(rxvq, buf, ETH_MTU_SIZE + sizeof(VirtioNetHdr), + VRING_DESC_F_WRITE); + } + vring_notify(rxvq); + + return 0; +} + +int send(int fd, const void *buf, int len, int flags) +{ + VirtioNetHdr tx_hdr; + VDev *vdev =3D virtio_get_device(); + VRing *txvq =3D &vdev->vrings[VQ_TX]; + + /* Set up header - we do not use anything special, so simply clear it = */ + memset(&tx_hdr, 0, sizeof(tx_hdr)); + + vring_send_buf(txvq, &tx_hdr, sizeof(tx_hdr), VRING_DESC_F_NEXT); + vring_send_buf(txvq, (void *)buf, len, VRING_HIDDEN_IS_CHAIN); + while (!vr_poll(txvq)) { + yield(); + } + if (drain_irqs(txvq->schid)) { + puts("send: drain irqs failed"); + return -1; + } + + return len; +} + +int recv(int fd, void *buf, int maxlen, int flags) +{ + VDev *vdev =3D virtio_get_device(); + VRing *rxvq =3D &vdev->vrings[VQ_RX]; + int len, id; + uint8_t *pkt; + + if (rx_last_idx =3D=3D rxvq->used->idx) { + return 0; + } + + len =3D rxvq->used->ring[rx_last_idx % rxvq->num].len - sizeof(VirtioN= etHdr); + if (len > maxlen) { + puts("virtio-net: Receive buffer too small"); + len =3D maxlen; + } + id =3D rxvq->used->ring[rx_last_idx % rxvq->num].id % rxvq->num; + pkt =3D (uint8_t *)(rxvq->desc[id].addr + sizeof(VirtioNetHdr)); + +#if DEBUG_VIRTIO_NET /* Dump packet */ + int i; + printf("\nbuf %p: len=3D%i\n", (void *)rxvq->desc[id].addr, len); + for (i =3D 0; i < 64; i++) { + printf(" %02x", pkt[i]); + if ((i % 16) =3D=3D 15) { + printf("\n"); + } + } + printf("\n"); +#endif + + /* Copy data to destination buffer */ + memcpy(buf, pkt, len); + + /* Mark buffer as available to the host again */ + rxvq->avail->ring[rxvq->avail->idx % rxvq->num] =3D id; + rxvq->avail->idx =3D rxvq->avail->idx + 1; + vring_notify(rxvq); + + /* Move index to next entry */ + rx_last_idx =3D rx_last_idx + 1; + + return len; +} diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c index 18fc5d1..c890a03 100644 --- a/pc-bios/s390-ccw/virtio.c +++ b/pc-bios/s390-ccw/virtio.c @@ -266,6 +266,11 @@ void virtio_setup_ccw(VDev *vdev) run_ccw(vdev, CCW_CMD_VDEV_RESET, NULL, 0); =20 switch (vdev->senseid.cu_model) { + case VIRTIO_ID_NET: + vdev->nr_vqs =3D 2; + vdev->cmd_vr_idx =3D 0; + cfg_size =3D sizeof(vdev->config.net); + break; case VIRTIO_ID_BLOCK: vdev->nr_vqs =3D 1; vdev->cmd_vr_idx =3D 0; diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h index a00a320..19fceb6 100644 --- a/pc-bios/s390-ccw/virtio.h +++ b/pc-bios/s390-ccw/virtio.h @@ -11,8 +11,6 @@ #ifndef VIRTIO_H #define VIRTIO_H =20 -#include "s390-ccw.h" - /* Status byte for guest to report progress, and synchronize features. */ /* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTI= O) */ #define VIRTIO_CONFIG_S_ACKNOWLEDGE 1 @@ -227,6 +225,13 @@ struct ScsiDevice { }; typedef struct ScsiDevice ScsiDevice; =20 +struct VirtioNetConfig { + uint8_t mac[6]; + /* uint16_t status; */ /* Only with VIRTIO_NET_F_STATUS = */ + /* uint16_t max_virtqueue_pairs; */ /* Only with VIRTIO_NET_F_MQ */ +}; +typedef struct VirtioNetConfig VirtioNetConfig; + struct VDev { int nr_vqs; VRing *vrings; @@ -239,6 +244,7 @@ struct VDev { union { VirtioBlkConfig blk; VirtioScsiConfig scsi; + VirtioNetConfig net; } config; ScsiDevice *scsi_device; bool is_cdrom; @@ -273,4 +279,6 @@ int vring_wait_reply(void); int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd); void virtio_setup_ccw(VDev *vdev); =20 +int virtio_net_init(void *mac_addr); + #endif /* VIRTIO_H */ --=20 1.8.3.1 From nobody Sun Apr 28 06:40:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499864644986587.0345189763868; Wed, 12 Jul 2017 06:04:04 -0700 (PDT) Received: from localhost ([::1]:52639 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHJ8-00033f-Kg for importer@patchew.org; Wed, 12 Jul 2017 09:03:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVH6p-0000eE-2v for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:51:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVH6n-0005DW-CP for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:51:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47206) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVH6n-0005D2-2I for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:51:13 -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 DC3D580F6C; Wed, 12 Jul 2017 12:51:11 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 274765D9CB; Wed, 12 Jul 2017 12:51:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DC3D580F6C Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DC3D580F6C From: Thomas Huth To: qemu-devel@nongnu.org, Christian Borntraeger , Cornelia Huck Date: Wed, 12 Jul 2017 14:49:53 +0200 Message-Id: <1499863793-18627-12-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.27]); Wed, 12 Jul 2017 12:51:12 +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 11/11] pc-bios/s390-ccw: Link libnet into the netboot image and do the TFTP load 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Most of the code has been taken from SLOF's netload.c file. Now we can finally load an image via TFTP and execute the downloaded kernel. Acked-by: Cornelia Huck Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/netboot.mak | 14 ++- pc-bios/s390-ccw/netmain.c | 225 +++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 238 insertions(+), 1 deletion(-) diff --git a/pc-bios/s390-ccw/netboot.mak b/pc-bios/s390-ccw/netboot.mak index eb70430..a9e1374 100644 --- a/pc-bios/s390-ccw/netboot.mak +++ b/pc-bios/s390-ccw/netboot.mak @@ -1,7 +1,7 @@ =20 SLOF_DIR :=3D $(SRC_PATH)/roms/SLOF =20 -NETOBJS :=3D start.o sclp.o virtio.o virtio-net.o netmain.o libc.a +NETOBJS :=3D start.o sclp.o virtio.o virtio-net.o netmain.o libnet.a libc.a =20 LIBC_INC :=3D -nostdinc -I$(SLOF_DIR)/lib/libc/include LIBNET_INC :=3D -I$(SLOF_DIR)/lib/libnet @@ -45,3 +45,15 @@ LIBCOBJS :=3D $(STRING_OBJS) $(CTYPE_OBJS) $(STDLIB_OBJS= ) $(STDIO_OBJS) sbrk.o =20 libc.a: $(LIBCOBJS) $(call quiet-command,$(AR) -rc $@ $^,"AR","$(TARGET_DIR)$@") + +# libnet files: + +LIBNETOBJS :=3D args.o dhcp.o dns.o icmpv6.o ipv6.o tcp.o udp.o bootp.o \ + dhcpv6.o ethernet.o ipv4.o ndp.o tftp.o +LIBNETCFLAGS :=3D $(QEMU_CFLAGS) $(LIBC_INC) $(LIBNET_INC) + +%.o : $(SLOF_DIR)/lib/libnet/%.c + $(call quiet-command,$(CC) $(LIBNETCFLAGS) -c -o $@ $<,"CC","$(TARGET_DIR= )$@") + +libnet.a: $(LIBNETOBJS) + $(call quiet-command,$(AR) -rc $@ $^,"AR","$(TARGET_DIR)$@") diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c index a69b3dd..d86d46b 100644 --- a/pc-bios/s390-ccw/netmain.c +++ b/pc-bios/s390-ccw/netmain.c @@ -6,6 +6,9 @@ * Based on the S390 virtio-ccw loading program (main.c) * Copyright (c) 2013 Alexander Graf * + * And based on the network loading code from SLOF (netload.c) + * Copyright (c) 2004, 2008 IBM Corporation + * * 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 @@ -18,17 +21,29 @@ #include #include #include + +#include +#include +#include +#include +#include +#include +#include #include =20 #include "s390-ccw.h" #include "virtio.h" =20 +#define DEFAULT_BOOT_RETRIES 10 +#define DEFAULT_TFTP_RETRIES 20 + extern char _start[]; =20 char stack[PAGE_SIZE * 8] __attribute__((aligned(PAGE_SIZE))); IplParameterBlock iplb __attribute__((aligned(PAGE_SIZE))); =20 static SubChannelId net_schid =3D { .one =3D 1 }; +static int ip_version =3D 4; static uint64_t dest_timer; =20 static uint64_t get_timer_ms(void) @@ -56,6 +71,208 @@ int get_sec_ticks(void) return 1000; /* number of ticks in 1 second */ } =20 +/** + * Obtain IP and configuration info from DHCP server (either IPv4 or IPv6). + * @param fn_ip contains the following configuration information: + * client MAC, client IP, TFTP-server MAC, TFTP-server I= P, + * boot file name + * @param retries Number of DHCP attempts + * @return 0 : IP and configuration info obtained; + * non-0 : error condition occurred. + */ +static int dhcp(struct filename_ip *fn_ip, int retries) +{ + int i =3D retries + 1; + int rc =3D -1; + + printf(" Requesting information via DHCP: "); + + dhcpv4_generate_transaction_id(); + dhcpv6_generate_transaction_id(); + + do { + printf("\b\b\b%03d", i - 1); + if (!--i) { + printf("\nGiving up after %d DHCP requests\n", retries); + return -1; + } + ip_version =3D 4; + rc =3D dhcpv4(NULL, fn_ip); + if (rc =3D=3D -1) { + ip_version =3D 6; + set_ipv6_address(fn_ip->fd, 0); + rc =3D dhcpv6(NULL, fn_ip); + if (rc =3D=3D 0) { + memcpy(&fn_ip->own_ip6, get_ipv6_address(), 16); + break; + } + } + if (rc !=3D -1) { /* either success or non-dhcp failure */ + break; + } + } while (1); + printf("\b\b\b\bdone\n"); + + return rc; +} + +/** + * Seed the random number generator with our mac and current timestamp + */ +static void seed_rng(uint8_t mac[]) +{ + uint64_t seed; + + asm volatile(" stck %0 " : : "Q"(seed) : "memory"); + seed ^=3D (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5]; + srand(seed); +} + +static int tftp_load(filename_ip_t *fnip, void *buffer, int len, + unsigned int retries, int ip_vers) +{ + tftp_err_t tftp_err; + int rc; + + rc =3D tftp(fnip, buffer, len, retries, &tftp_err, 1, 1428, ip_vers); + + if (rc > 0) { + printf(" TFTP: Received %s (%d KBytes)\n", fnip->filename, + rc / 1024); + } else if (rc =3D=3D -1) { + puts("unknown TFTP error"); + } else if (rc =3D=3D -2) { + printf("TFTP buffer of %d bytes is too small for %s\n", + len, fnip->filename); + } else if (rc =3D=3D -3) { + printf("file not found: %s\n", fnip->filename); + } else if (rc =3D=3D -4) { + puts("TFTP access violation"); + } else if (rc =3D=3D -5) { + puts("illegal TFTP operation"); + } else if (rc =3D=3D -6) { + puts("unknown TFTP transfer ID"); + } else if (rc =3D=3D -7) { + puts("no such TFTP user"); + } else if (rc =3D=3D -8) { + puts("TFTP blocksize negotiation failed"); + } else if (rc =3D=3D -9) { + puts("file exceeds maximum TFTP transfer size"); + } else if (rc <=3D -10 && rc >=3D -15) { + const char *icmp_err_str; + switch (rc) { + case -ICMP_NET_UNREACHABLE - 10: + icmp_err_str =3D "net unreachable"; + break; + case -ICMP_HOST_UNREACHABLE - 10: + icmp_err_str =3D "host unreachable"; + break; + case -ICMP_PROTOCOL_UNREACHABLE - 10: + icmp_err_str =3D "protocol unreachable"; + break; + case -ICMP_PORT_UNREACHABLE - 10: + icmp_err_str =3D "port unreachable"; + break; + case -ICMP_FRAGMENTATION_NEEDED - 10: + icmp_err_str =3D "fragmentation needed and DF set"; + break; + case -ICMP_SOURCE_ROUTE_FAILED - 10: + icmp_err_str =3D "source route failed"; + break; + default: + icmp_err_str =3D " UNKNOWN"; + break; + } + printf("ICMP ERROR \"%s\"\n", icmp_err_str); + } else if (rc =3D=3D -40) { + printf("TFTP error occurred after %d bad packets received", + tftp_err.bad_tftp_packets); + } else if (rc =3D=3D -41) { + printf("TFTP error occurred after missing %d responses", + tftp_err.no_packets); + } else if (rc =3D=3D -42) { + printf("TFTP error missing block %d, expected block was %d", + tftp_err.blocks_missed, + tftp_err.blocks_received); + } + + return rc; +} + +static int net_load(char *buffer, int len) +{ + filename_ip_t fn_ip; + uint8_t mac[6]; + int rc; + + memset(&fn_ip, 0, sizeof(filename_ip_t)); + + rc =3D virtio_net_init(mac); + if (rc < 0) { + puts("Could not initialize network device"); + return -101; + } + fn_ip.fd =3D rc; + + printf(" Using MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + + set_mac_address(mac); /* init ethernet layer */ + seed_rng(mac); + + rc =3D dhcp(&fn_ip, DEFAULT_BOOT_RETRIES); + if (rc >=3D 0) { + if (ip_version =3D=3D 4) { + set_ipv4_address(fn_ip.own_ip); + } + } else { + puts("Could not get IP address"); + return -101; + } + + if (ip_version =3D=3D 4) { + printf(" Using IPv4 address: %d.%d.%d.%d\n", + (fn_ip.own_ip >> 24) & 0xFF, (fn_ip.own_ip >> 16) & 0xFF, + (fn_ip.own_ip >> 8) & 0xFF, fn_ip.own_ip & 0xFF); + } else if (ip_version =3D=3D 6) { + char ip6_str[40]; + ipv6_to_str(fn_ip.own_ip6.addr, ip6_str); + printf(" Using IPv6 address: %s\n", ip6_str); + } + + if (rc =3D=3D -2) { + printf("ARP request to TFTP server (%d.%d.%d.%d) failed\n", + (fn_ip.server_ip >> 24) & 0xFF, (fn_ip.server_ip >> 16) & 0= xFF, + (fn_ip.server_ip >> 8) & 0xFF, fn_ip.server_ip & 0xFF); + return -102; + } + if (rc =3D=3D -4 || rc =3D=3D -3) { + puts("Can't obtain TFTP server IP address"); + return -107; + } + + if (ip_version =3D=3D 4) { + printf(" Requesting file \"%s\" via TFTP from %d.%d.%d.%d\n", + fn_ip.filename, + (fn_ip.server_ip >> 24) & 0xFF, (fn_ip.server_ip >> 16) & 0= xFF, + (fn_ip.server_ip >> 8) & 0xFF, fn_ip.server_ip & 0xFF); + } else if (ip_version =3D=3D 6) { + char ip6_str[40]; + printf(" Requesting file \"%s\" via TFTP from ", fn_ip.filename); + ipv6_to_str(fn_ip.server_ip6.addr, ip6_str); + printf("%s\n", ip6_str); + } + + /* Do the TFTP load and print error message if necessary */ + rc =3D tftp_load(&fn_ip, buffer, len, DEFAULT_TFTP_RETRIES, ip_version= ); + + if (ip_version =3D=3D 4) { + dhcp_send_release(fn_ip.fd); + } + + return rc; +} + void panic(const char *string) { sclp_print(string); @@ -127,10 +344,18 @@ static void virtio_setup(void) =20 void main(void) { + int rc; + sclp_setup(); sclp_print("Network boot starting...\n"); =20 virtio_setup(); =20 + rc =3D net_load(NULL, (long)_start); + if (rc > 0) { + sclp_print("Network loading done, starting kernel...\n"); + asm volatile (" lpsw 0(%0) " : : "r"(0) : "memory"); + } + panic("Failed to load OS from network\n"); } --=20 1.8.3.1