From: Janosch Frank <frankja@linux.ibm.com>
To: kvm@vger.kernel.org
Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com,
thuth@redhat.com, david@redhat.com, nsg@linux.ibm.com,
nrb@linux.ibm.com
Subject: [kvm-unit-tests PATCH 1/2] lib: s390x: sclp: Add carriage return to line feed
Date: Fri, 7 Jul 2023 14:54:09 +0000 [thread overview]
Message-ID: <20230707145410.1679-2-frankja@linux.ibm.com> (raw)
In-Reply-To: <20230707145410.1679-1-frankja@linux.ibm.com>
Without the \r the output of the HMC ASCII console takes a lot of
additional effort to read in comparison to the line mode console.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
lib/s390x/sclp-console.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/lib/s390x/sclp-console.c b/lib/s390x/sclp-console.c
index 19c74e46..66572774 100644
--- a/lib/s390x/sclp-console.c
+++ b/lib/s390x/sclp-console.c
@@ -97,14 +97,31 @@ static void sclp_print_ascii(const char *str)
{
int len = strlen(str);
WriteEventData *sccb = (void *)_sccb;
+ char *str_dest = (char *)&sccb->msg;
+ int i = 0, j = 0;
sclp_mark_busy();
memset(sccb, 0, sizeof(*sccb));
+
+ /*
+ * Copy the string over and add a \r to all \n since the HMC
+ * ASCII console requires it.
+ */
+ for (; i < len && j < (PAGE_SIZE / 2); i++) {
+ if (str[i] == '\n') {
+ str_dest[j] = '\r';
+ j++;
+ }
+ str_dest[j] = str[i];
+ j++;
+ }
+
+ /* len has changed since we might have added \r */
+ len = j;
sccb->h.length = offsetof(WriteEventData, msg) + len;
sccb->h.function_code = SCLP_FC_NORMAL_WRITE;
sccb->ebh.length = sizeof(EventBufferHeader) + len;
sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA;
- memcpy(&sccb->msg, str, len);
sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);
}
--
2.34.1
next prev parent reply other threads:[~2023-07-07 14:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-07 14:54 [kvm-unit-tests PATCH 0/2] s390x: Improve console handling Janosch Frank
2023-07-07 14:54 ` Janosch Frank [this message]
2023-07-07 14:54 ` [kvm-unit-tests PATCH 2/2] lib: s390x: sclp: Add line mode input handling Janosch Frank
2023-07-10 9:33 ` Nico Boehr
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=20230707145410.1679-2-frankja@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=david@redhat.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=nrb@linux.ibm.com \
--cc=nsg@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox