Skip to contentSkip to conversation

s390x: Add linemode console

PATCH Janosch Frank 1 participant 1 message Dec 7, 2018 1 message not in the archive s390

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --nZnnjAY2Ruk8eprPKjxzFQ9Bg0NBRYTVG
Content-Type: multipart/mixed; boundary="pi0qdAcqP7QyRLhFodt9KgPIzRqpOeZR3";
protected-headers="v1"
From: Janosch Frank <[email protected]>
To: David Hildenbrand <[email protected]>, [email protected]
Cc: [email protected], [email protected]
Message-ID: <[email protected]>
Subject: Re: [kvm-unit-tests PATCH v2 6/6] s390x: Add linemode console
References: <[email protected]>
<[email protected]> <[email protected]>
In-Reply-To: <[email protected]>

--pi0qdAcqP7QyRLhFodt9KgPIzRqpOeZR3
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

Quoted 2 lines · David Hildenbrand
Quoted 1 line · Janosch Frank

z/VM isn't fond of vt220, so we need line mode when running under z/VM=

=2E

Quoted 4 lines
Quoted 4 lines

---
lib/s390x/sclp-console.c | 199 ++++++++++++++++++++++++++++++++++++++=

++++-----

Quoted 8 lines
Quoted 8 lines
 lib/s390x/sclp.h         |  67 ++++++++++++++++
 2 files changed, 245 insertions(+), 21 deletions(-)
lib/s390x/sclp-console.c +0 -0
index 13ab03d..c31e178 100644
@@ -11,23 +11,183 @@

[...]

Quoted 4 lines

lib/s390x/sclp-console.c

Quoted 2 lines
lib/s390x/sclp-console.c +2 -0
+
+static bool initialized =3D false;

=20
false is the default after your BSS clearing patch.

Yes, already fixed

Quoted 12 lines

=20

Quoted 11 lines
lib/s390x/sclp-console.c +11 -0
+
+static void sclp_print_ascii(const char *str)
+{
+	int len =3D strlen(str);
+	WriteEventData *sccb =3D (void *)_sccb;
+
+	while (sclp_busy)
+		/* Wait for SCLP request to complete */;
+	sclp_busy =3D true;
+	memset(sccb, 0, sizeof(*sccb));
+	sccb->h.length =3D sizeof(WriteEventData) + len;
Quoted 8 lines

lib/s390x/sclp-console.c

Quoted 6 lines
lib/s390x/sclp-console.c +6 -0
+	sccb->h.function_code =3D SCLP_FC_NORMAL_WRITE;
+	sccb->ebh.length =3D sizeof(EventBufferHeader) + len;
+	sccb->ebh.type =3D SCLP_EVENT_ASCII_CONSOLE_DATA;
+	memcpy(sccb->data, str, len);
+
+	sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);

=20
Shouldn't we wait for a response? (see below)

Yes, already fixed

Quoted 33 lines

=20

Quoted 32 lines
lib/s390x/sclp-console.c +32 -0
+}
+
+static void sclp_print_lm(const char *str)
+{
+	unsigned char *ptr, *end, ch;
+	unsigned int count, offset, len;
+	struct write_sccb *sccb;
+	struct msg_buf *msg;
+	struct mdb *mdb;
+	struct mto *mto;
+	struct go *go;
+
+	while (sclp_busy)
+		/* Wait for SCLP request to complete */;
+	sclp_busy =3D true;
+	sccb =3D (struct write_sccb *) _sccb;
+	end =3D (unsigned char *) sccb + 4096 - 1;
+	memset(sccb, 0, sizeof(*sccb));
+	ptr =3D (unsigned char *) &sccb->msg.mdb.mto;
+	len =3D strlen(str);
+	offset =3D 0;
+	do {
+		for (count =3D sizeof(*mto); offset < len; count++) {
+			ch =3D str[offset++];
+			if ((ch =3D=3D 0x0a) || (ptr + count > end))
+				break;
+			ptr[count] =3D _ascebc[ch];
+		}
+		mto =3D (struct mto *) ptr;
+		memset(mto, 0, sizeof(*mto));
+		mto->length =3D count;
+		mto->type =3D 4;
Quoted 8 lines

lib/s390x/sclp-console.c

Quoted 8 lines
lib/s390x/sclp-console.c +8 -0
+		mto->line_type_flags =3D LNTPFLGS_ENDTEXT;
+		ptr +=3D count;
+	} while ((offset < len) && (ptr + sizeof(*mto) <=3D end));
+	len =3D ptr - (unsigned char *) sccb;
+	sccb->header.length =3D len - offsetof(struct write_sccb, header);
+	msg =3D &sccb->msg;
+	msg->header.type =3D EVTYP_MSG;
+	msg->header.length =3D len - offsetof(struct write_sccb, msg.header)=

;

Quoted 5 lines

lib/s390x/sclp-console.c

Quoted 5 lines
lib/s390x/sclp-console.c +5 -0
+	mdb =3D &msg->mdb;
+	mdb->header.type =3D 1;
+	mdb->header.tag =3D 0xD4C4C240;
+	mdb->header.revision_code =3D 1;
+	mdb->header.length =3D len - offsetof(struct write_sccb, msg.mdb.hea=

der);

Quoted 6 lines

lib/s390x/sclp-console.c

Quoted 4 lines
lib/s390x/sclp-console.c +4 -0
+	go =3D &mdb->go;
+	go->length =3D sizeof(*go);
+	go->type =3D 1;
+	sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);

=20
Shouldn't we wait for a response? (see below)

Yes, already fixed

Quoted 19 lines

=20

lib/s390x/sclp-console.c

Quoted 13 lines
lib/s390x/sclp-console.c +8 -0
+}
+
+/*
+ * SCLP needs to be initialized by setting a send and receive mask,
+ * indicating which messages the control program (we) want(s) to
+ * send/receive.
+ */
+static bool sclp_set_write_mask(void)
 {
 	WriteEventMask *sccb =3D (void *)_sccb;

=20

lib/s390x/sclp-console.c +0 -0
 	while (sclp_busy)
 		/* Wait for SCLP request to complete */;

=20
Can this actually happen?
=20
I'd say whoever issues a request has to wait for the response. Somebody=

Quoted 1 line

who didn't, doesn't have to wait.

We could put the sclp_wait_busy() at the end of the sclp call function and effectively make it synchronous by enforcing the wait. We don't really need the async performance gain.

Quoted 2 lines

=20
(for multiple CPUs later on that has to be guarded by a lock in additio=

n

Quoted 1 line

to the bool)

Yeah, smp is currently on another branch, so I might just start to add another patch and introduce locks. :-)

Quoted 16 lines

=20

Quoted 5 lines
lib/s390x/sclp-console.c +1 -2
 	sclp_busy =3D true;
+	memset(_sccb, 0, sizeof(*sccb));
 	sccb->h.length =3D sizeof(WriteEventMask);
-	sccb->mask_length =3D sizeof(unsigned int);
-	sccb->receive_mask =3D SCLP_EVENT_MASK_MSG_ASCII;

lib/s390x/sclp-console.c

Quoted 10 lines
lib/s390x/sclp-console.c +7 -3
-	sccb->cp_receive_mask =3D SCLP_EVENT_MASK_MSG_ASCII;
-	sccb->send_mask =3D SCLP_EVENT_MASK_MSG_ASCII;
-	sccb->cp_send_mask =3D SCLP_EVENT_MASK_MSG_ASCII;
+	sccb->h.function_code =3D 0;
+	sccb->mask_length =3D sizeof(sccb_mask_t);
+
+	/* For now we don't process sclp input. */
+	sccb->cp_receive_mask =3D 0;
+	/* We send ASCII and line mode. */
+	sccb->cp_send_mask =3D SCLP_EVENT_MASK_MSG_ASCII | SCLP_EVENT_MASK_M=

SG;

Quoted 9 lines

lib/s390x/sclp-console.c

Quoted 6 lines

=20

lib/s390x/sclp-console.c +4 -0
 	sclp_service_call(SCLP_CMD_WRITE_EVENT_MASK, sccb);
+	while (sclp_busy) {
+	}
+	if (sccb->h.response_code !=3D SCLP_RC_NORMAL_COMPLETION)
+		return false;

=20
Hmm, what do do in this case? I don't see that the caller is fixed up (you changed the return type from void to bool)

I don't know, there used to be a TODO there...
I thought about calling exit(1);

Quoted 3 lines

=20
I "initialized" actually worth keeping around? I'd say let's just continue as if it succeeded. (we cannot really do anything about it, ca=

n

Quoted 1 line

we?)

There is the problem of prints that come before the initialization. PGM interrupts while sclp_busy =3D=3D true is also fun if they want to pr= int.

--pi0qdAcqP7QyRLhFodt9KgPIzRqpOeZR3--

--nZnnjAY2Ruk8eprPKjxzFQ9Bg0NBRYTVG
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJcCqeiAAoJEONU5rjiOLn4tisP/RE45YP4HaMR30ONNUdTOPBq zOAc80X5j7ic0vjFM2zP09Z9sMOcF7o3syLfpQSkgFeegOPZIidVdGv3RpA1kH5z I2IjICkb4KV1O5FPNssopVwcAEix5ecUJNcs0jyPMoqEVomZpxor9KJeRk19VldV CGlz0pqD8Ux68tTIK3Bst9oj6SsL2rRwt2GsypdRTi0/K/sDjbyAlv/EPGy94Yx3 cIXpX2C2Iz4s5Y0llRcCeJmpjS8uTjT5ESWIAahMV+bya8SlzUGwoOZKcq6TfNiB l/YVqST+vJi1M3AEy5d33LJwNsXSSmZ/XZTMy3YMBVcOYNFzPX2KxHeEOKvdBhfT zCsv/tjmb89mK+kK3k+m6Hcr+6cfliDRD+pbuZbJYrJcvtTshFIJYAWrt6KVV1T0 wH2eyiprL9fIoR9B9n9l7vMTsfZ21ZUZuffqqdHPvQiBhvcLAopT1uz5kqczjZK7 47ZQgZh9cMQV5cLTziBBuFTYKFmhZ7VA3ELe7Hz/h7saAb5KqlJLZ3oJdYau1soZ 0/CsOmTJnGOp0EpHniqOs51tbk8xO/pHdktZ9yy0hHIeIkRS9ky8gaJMOZQSrRoi zP4sDeYnal7XONcRbz+9aw6Q5yfUuF4MBEawTKmIEhYI9YJCcV6EJLeaCmgpfIKq j/c849BteAq6bSdI0gKQ
=RGS3
-----END PGP SIGNATURE-----

--nZnnjAY2Ruk8eprPKjxzFQ9Bg0NBRYTVG--