From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Alexander Graf <agraf@suse.de>,
Farhan Ali <alifm@linux.vnet.ibm.com>,
David Hildenbrand <david@redhat.com>,
Jens Freimann <jfreiman@redhat.com>,
Eric Farman <farman@linux.vnet.ibm.com>
Subject: [Qemu-devel] [RFC PATCH 03/14] pc-bios/s390-ccw: Add a write() function for stdio
Date: Tue, 27 Jun 2017 13:48:09 +0200 [thread overview]
Message-ID: <1498564100-10045-4-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1498564100-10045-1-git-send-email-thuth@redhat.com>
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().
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
pc-bios/s390-ccw/sclp.c | 32 ++++++++++++++------------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/pc-bios/s390-ccw/sclp.c b/pc-bios/s390-ccw/sclp.c
index a1639ba..a23bdd3 100644
--- a/pc-bios/s390-ccw/sclp.c
+++ b/pc-bios/s390-ccw/sclp.c
@@ -8,6 +8,7 @@
* directory.
*/
+#include <unistd.h>
#include "s390-ccw.h"
#include "sclp.h"
@@ -51,34 +52,29 @@ void sclp_setup(void)
sclp_set_write_mask();
}
-static int _strlen(const char *str)
+ssize_t write(int fd, const void *buf, size_t len)
{
- int i;
- for (i = 0; *str; i++)
- str++;
- return i;
-}
-
-static void _memcpy(char *dest, const char *src, int len)
-{
- int i;
- for (i = 0; i < len; i++)
- dest[i] = src[i];
-}
-
-void sclp_print(const char *str)
-{
- int len = _strlen(str);
WriteEventData *sccb = (void *)_sccb;
+ if (fd != 1 && fd != 2) {
+ return -EIO;
+ }
+
sccb->h.length = sizeof(WriteEventData) + len;
sccb->h.function_code = SCLP_FC_NORMAL_WRITE;
sccb->ebh.length = sizeof(EventBufferHeader) + len;
sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA;
sccb->ebh.flags = 0;
- _memcpy(sccb->data, str, len);
+ memcpy(sccb->data, buf, len);
sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);
+
+ return len;
+}
+
+void sclp_print(const char *str)
+{
+ write(1, str, strlen(str));
}
void sclp_get_loadparm_ascii(char *loadparm)
--
1.8.3.1
next prev parent reply other threads:[~2017-06-27 11:48 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-27 11:48 [Qemu-devel] [RFC PATCH 00/14] Implement network booting directly into the s390-ccw BIOS Thomas Huth
2017-06-27 11:48 ` [Qemu-devel] [RFC PATCH 01/14] pc-bios/s390-ccw: Add the libc from the SLOF firmware Thomas Huth
2017-06-27 15:32 ` David Hildenbrand
2017-06-27 22:14 ` Thomas Huth
2017-06-27 11:48 ` [Qemu-devel] [RFC PATCH 02/14] pc-bios/s390-ccw: Start using the libc from SLOF Thomas Huth
2017-06-27 11:48 ` Thomas Huth [this message]
2017-06-27 11:48 ` [Qemu-devel] [RFC PATCH 04/14] pc-bios/s390-ccw: Add implementation of sbrk() Thomas Huth
2017-06-27 11:48 ` [Qemu-devel] [RFC PATCH 05/14] pc-bios/s390-ccw: Add the TFTP network loading stack from SLOF Thomas Huth
2017-06-27 11:48 ` [Qemu-devel] [RFC PATCH 06/14] libnet: Remove remainders of netsave code Thomas Huth
2017-06-27 11:48 ` [Qemu-devel] [RFC PATCH 07/14] libnet: Rework error message printing Thomas Huth
2017-06-27 11:48 ` [Qemu-devel] [RFC PATCH 08/14] libnet: Refactor some code of netload() into a separate function Thomas Huth
2017-06-27 11:48 ` [Qemu-devel] [RFC PATCH 09/14] pc-bios/s390-ccw: Make the basic libnet code compilable Thomas Huth
2017-06-27 11:48 ` [Qemu-devel] [RFC PATCH 10/14] pc-bios/s390-ccw: Add timer code for the libnet Thomas Huth
2017-06-27 11:48 ` [Qemu-devel] [RFC PATCH 11/14] pc-bios/s390-ccw: Add virtio-net driver code Thomas Huth
2017-06-27 11:48 ` [Qemu-devel] [RFC PATCH 12/14] pc-bios/s390-ccw: Load file via an intermediate .INS file Thomas Huth
2017-06-27 11:48 ` [Qemu-devel] [RFC PATCH 13/14] pc-bios/s390-ccw: Allow loading to address 0 Thomas Huth
2017-06-27 11:48 ` [Qemu-devel] [RFC PATCH 14/14] pc-bios/s390-ccw: Wire up the netload code Thomas Huth
2017-06-27 15:41 ` [Qemu-devel] [RFC PATCH 00/14] Implement network booting directly into the s390-ccw BIOS David Hildenbrand
2017-06-27 15:50 ` Viktor Mihajlovski
2017-06-27 21:40 ` Thomas Huth
2017-06-28 7:28 ` Viktor Mihajlovski
2017-06-28 8:02 ` Thomas Huth
2017-06-28 10:56 ` Thomas Huth
2017-06-28 15:02 ` Viktor Mihajlovski
2017-06-29 7:58 ` Thomas Huth
2017-06-29 8:10 ` Viktor Mihajlovski
2017-06-27 16:50 ` Farhan Ali
2017-06-28 7:34 ` Thomas Huth
2017-06-27 21:15 ` Alexander Graf
2017-06-27 21:56 ` Thomas Huth
2017-06-28 8:06 ` Gerd Hoffmann
2017-06-28 7:43 ` Christian Borntraeger
2017-06-28 8:59 ` Thomas Huth
2017-06-29 8:17 ` Thomas Huth
2017-06-29 8:39 ` Christian Borntraeger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1498564100-10045-4-git-send-email-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=agraf@suse.de \
--cc=alifm@linux.vnet.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=david@redhat.com \
--cc=farman@linux.vnet.ibm.com \
--cc=jfreiman@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).