From: Janosch Frank <frankja@linux.ibm.com>
To: kvm@vger.kernel.org
Cc: imbrenda@linux.ibm.com, thuth@redhat.com, david@redhat.com,
nsg@linux.ibm.com, nrb@linux.ibm.com
Subject: [kvm-unit-tests PATCH 2/3] lib: s390x: sclp: Add compat handling for HMC ASCII consoles
Date: Tue, 10 Oct 2023 07:38:54 +0000 [thread overview]
Message-ID: <20231010073855.26319-3-frankja@linux.ibm.com> (raw)
In-Reply-To: <20231010073855.26319-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.
Additionally we add a console clear for the HMC ASCII console so that
old messages from a previously running operating system are not
polluting the console.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
lib/s390x/sclp-console.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/lib/s390x/sclp-console.c b/lib/s390x/sclp-console.c
index 19c74e46..313be1e4 100644
--- a/lib/s390x/sclp-console.c
+++ b/lib/s390x/sclp-console.c
@@ -11,6 +11,7 @@
#include <asm/arch_def.h>
#include <asm/io.h>
#include <asm/spinlock.h>
+#include "hardware.h"
#include "sclp.h"
/*
@@ -85,6 +86,8 @@ static uint8_t _ascebc[256] = {
0x90, 0x3F, 0x3F, 0x3F, 0x3F, 0xEA, 0x3F, 0xFF
};
+static bool lpar_ascii_compat;
+
static char lm_buff[120];
static unsigned char lm_buff_off;
static struct spinlock lm_buff_lock;
@@ -97,14 +100,27 @@ 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;
sclp_mark_busy();
memset(sccb, 0, sizeof(*sccb));
+
+ for (; i < len; i++) {
+ *str_dest = str[i];
+ str_dest++;
+ /* Add a \r to the \n for HMC ASCII console */
+ if (str[i] == '\n' && lpar_ascii_compat) {
+ *str_dest = '\r';
+ str_dest++;
+ }
+ }
+
+ len = (uintptr_t)str_dest - (uintptr_t)&sccb->msg;
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);
}
@@ -218,8 +234,13 @@ static void sclp_console_disable_read(void)
void sclp_console_setup(void)
{
+ lpar_ascii_compat = detect_host_early() == HOST_IS_LPAR;
+
/* We send ASCII and line mode. */
sclp_write_event_mask(0, SCLP_EVENT_MASK_MSG_ASCII | SCLP_EVENT_MASK_MSG);
+ /* Hard terminal reset to clear screen for HMC ASCII console */
+ if (lpar_ascii_compat)
+ sclp_print_ascii("\ec");
}
void sclp_print(const char *str)
--
2.34.1
next prev parent reply other threads:[~2023-10-10 7:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 7:38 [kvm-unit-tests PATCH 0/3] s390x: Improve console handling Janosch Frank
2023-10-10 7:38 ` [kvm-unit-tests PATCH 1/3] lib: s390x: hw: Provide early detect host Janosch Frank
2023-10-10 10:40 ` Claudio Imbrenda
2023-10-10 11:03 ` Janosch Frank
2023-10-10 11:42 ` Claudio Imbrenda
2023-10-12 11:13 ` Janosch Frank
2023-10-10 7:38 ` Janosch Frank [this message]
2023-10-10 8:35 ` [kvm-unit-tests PATCH 2/3] lib: s390x: sclp: Add compat handling for HMC ASCII consoles Nico Boehr
2023-10-10 8:57 ` Janosch Frank
2023-10-10 12:35 ` Nico Boehr
2023-10-10 7:38 ` [kvm-unit-tests PATCH 3/3] lib: s390x: sclp: Add line mode input handling Janosch Frank
2023-10-10 10:33 ` Claudio Imbrenda
2023-10-10 11:05 ` Janosch Frank
2023-10-10 11:44 ` Claudio Imbrenda
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=20231010073855.26319-3-frankja@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=david@redhat.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@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