All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: kvm@vger.kernel.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	david@redhat.com,
	"Christian Borntraeger" <borntraeger@de.ibm.com>,
	"Cornelia Huck" <cornelia.huck@de.ibm.com>
Subject: [kvm-unit-tests PATCH v1 4/6] s390x: compile sclp-ascii.c
Date: Fri, 12 May 2017 12:58:28 +0200	[thread overview]
Message-ID: <20170512105830.10604-5-david@redhat.com> (raw)
In-Reply-To: <20170512105830.10604-1-david@redhat.com>

We can reuse strlen and memcpy. __pa(x) is already defined in page.h
We don't have (and need) defines for error values and consuming sclp
irqs is not required, as we won't be passing control to some other OS.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 lib/s390x/sclp-ascii.c | 28 +++++++---------------------
 lib/s390x/sclp.h       |  2 --
 s390x/Makefile         |  1 +
 3 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/lib/s390x/sclp-ascii.c b/lib/s390x/sclp-ascii.c
index dc1c3e4..dfb9e68 100644
--- a/lib/s390x/sclp-ascii.c
+++ b/lib/s390x/sclp-ascii.c
@@ -8,7 +8,9 @@
  * directory.
  */
 
-#include "s390-ccw.h"
+#include <libcflat.h>
+#include <string.h>
+#include <asm/page.h>
 #include "sclp.h"
 
 static char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096)));
@@ -24,11 +26,10 @@ static int sclp_service_call(unsigned int command, void *sccb)
                 "       srl     %0,28"
                 : "=&d" (cc) : "d" (command), "a" (__pa(sccb))
                 : "cc", "memory");
-        consume_sclp_int();
         if (cc == 3)
-                return -EIO;
+                return -1;
         if (cc == 2)
-                return -EBUSY;
+                return -1;
         return 0;
 }
 
@@ -51,24 +52,9 @@ void sclp_setup(void)
     sclp_set_write_mask();
 }
 
-static int _strlen(const char *str)
-{
-    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);
+    int len = strlen(str);
     WriteEventData *sccb = (void *)_sccb;
 
     sccb->h.length = sizeof(WriteEventData) + len;
@@ -76,7 +62,7 @@ void sclp_print(const char *str)
     sccb->ebh.length = sizeof(EventBufferHeader) + len;
     sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA;
     sccb->ebh.flags = 0;
-    _memcpy(sccb->data, str, len);
+    memcpy(sccb->data, str, len);
 
     sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);
 }
diff --git a/lib/s390x/sclp.h b/lib/s390x/sclp.h
index 3cbfb78..c48cc21 100644
--- a/lib/s390x/sclp.h
+++ b/lib/s390x/sclp.h
@@ -102,6 +102,4 @@ typedef struct ReadEventData {
     uint32_t mask;
 } __attribute__((packed)) ReadEventData;
 
-#define __pa(x) (x)
-
 #endif /* SCLP_H */
diff --git a/s390x/Makefile b/s390x/Makefile
index 549c1c0..0f72c9e 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -20,6 +20,7 @@ cflatobjs += lib/util.o
 cflatobjs += lib/alloc.o
 cflatobjs += lib/s390x/io.o
 cflatobjs += lib/s390x/stack.o
+cflatobjs += lib/s390x/sclp-ascii.o
 
 cstart.o = $(TEST_DIR)/cstart64.o
 
-- 
2.9.3

  parent reply	other threads:[~2017-05-12 10:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-12 10:58 [kvm-unit-tests PATCH v1 0/6] s390x: basic test infrastructure David Hildenbrand
2017-05-12 10:58 ` [kvm-unit-tests PATCH v1 1/6] s390x: initial infrastructure David Hildenbrand
2017-05-15  9:19   ` Christian Borntraeger
2017-05-16  7:54     ` David Hildenbrand
2017-05-16  7:58       ` Christian Borntraeger
2017-05-16  8:21         ` David Hildenbrand
2017-05-12 10:58 ` [kvm-unit-tests PATCH v1 2/6] s390x: basic self test David Hildenbrand
2017-05-16 13:35   ` Radim Krčmář
2017-05-16 19:16     ` David Hildenbrand
2017-05-17 13:12       ` Radim Krčmář
2017-05-17 16:50         ` David Hildenbrand
2017-05-12 10:58 ` [kvm-unit-tests PATCH v1 3/6] s390x: copy sclp.h and sclp-ascii.c from QEMU David Hildenbrand
2017-05-12 10:58 ` David Hildenbrand [this message]
2017-05-12 10:58 ` [kvm-unit-tests PATCH v1 5/6] s390x: wire up sclp console output David Hildenbrand
2017-05-12 10:58 ` [kvm-unit-tests PATCH v1 6/6] MAINTAINERS: add s390x maintainers David Hildenbrand

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=20170512105830.10604-5-david@redhat.com \
    --to=david@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=thuth@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.