On 10.01.19 13:39, David Hildenbrand wrote: > On 10.01.19 13:34, Janosch Frank wrote: >> On 10.01.19 13:23, David Hildenbrand wrote: >>> On 03.01.19 11:08, Janosch Frank wrote: >>>> z/VM isn't fond of vt220, so we need line mode when running under z/VM. >>>> >>>> Signed-off-by: Janosch Frank <frankja@xxxxxxxxxxxxx> >>>> --- >>>> lib/s390x/sclp-console.c | 178 ++++++++++++++++++++++++++++++++++++++++++----- >>>> lib/s390x/sclp.h | 67 ++++++++++++++++++ >>>> 2 files changed, 228 insertions(+), 17 deletions(-) >>>> >>>> diff --git a/lib/s390x/sclp-console.c b/lib/s390x/sclp-console.c >>>> index a5ef45f..6b30fab 100644 >>>> --- a/lib/s390x/sclp-console.c >>>> +++ b/lib/s390x/sclp-console.c >>>> @@ -11,21 +11,167 @@ >>>> #include <libcflat.h> >>>> #include <string.h> >>>> #include <asm/page.h> >>>> +#include <asm/arch_def.h> >>>> +#include <asm/io.h> >>>> #include "sclp.h" >>>> >> [...] >>>> + >>>> +static void sclp_print_ascii(const char *str) >>>> +{ >>>> + int len = strlen(str); >>>> + WriteEventData *sccb = (void *)_sccb; >>>> + >>>> + sclp_mark_busy(); >>>> + memset(sccb, 0, sizeof(*sccb)); >>>> + 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; >>>> + memcpy(sccb->data, str, len); >>> >>> Soooo ... what would happen when printing more than 4000 + something >>> characters? (same applies to lm below) >> >> I wouldn't advise on that, because you'll overwrite memory and sclp >> might have a length limit. But that wasn't a problem before, was it? >> >> Do you plan on printing the memory in one go? :-) > > Won't say it won't happen when somebody debugs/develops tests and gets > strange side effects from printing. Wonder if we should simply cut it > off to the supported size. > > (And yes, this is already in existing code) As the print functions have different max lengths for user data I'd print a warning and return after 2KB in sclp_print. Anything against that? It's simple and 2KB ought to be enough for everyone (TM) and nobody keeps you from calling print multiple times instead. if (strlen(str) > (1 << 11)) { sclp_print_ascii("Warning: Printing is limited to 2KB of data."); sclp_print_lm("Warning: Printing is limited to 2KB of data."); return; } > >>> >>>> + mto->length = count; >>>> + mto->type = 4; >>>> + mto->line_type_flags = LNTPFLGS_ENDTEXT; >>>> + ptr += count; >>>> + } while (offset < len && ptr + sizeof(*mto) <= end); >>>> + len = ptr - (unsigned char *) sccb; >>>> + sccb->header.length = len - offsetof(struct write_sccb, header); >>>> + msg = &sccb->msg; >>>> + msg->header.type = EVTYP_MSG; >>>> + msg->header.length = len - offsetof(struct write_sccb, msg.header); >>>> + mdb = &msg->mdb; >>>> + mdb->header.type = 1; >>>> + mdb->header.tag = 0xD4C4C240; >>>> + mdb->header.revision_code = 1; >>>> + mdb->header.length = len - offsetof(struct write_sccb, msg.mdb.header); >>>> + go = &mdb->go; >>>> + go->length = sizeof(*go); >>>> + go->type = 1; >>>> + sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb); >>>> +} >>>> + >>>> +/* >>>> + * 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 void sclp_set_write_mask(void) >>>> { >>>> WriteEventMask *sccb = (void *)_sccb; >>>> >>>> sclp_mark_busy(); >>>> + memset(_sccb, 0, sizeof(*sccb)); >>>> sccb->h.length = sizeof(WriteEventMask); >>>> - sccb->mask_length = sizeof(unsigned int); >>>> - sccb->receive_mask = SCLP_EVENT_MASK_MSG_ASCII; >>>> - sccb->cp_receive_mask = SCLP_EVENT_MASK_MSG_ASCII; >>>> - sccb->send_mask = SCLP_EVENT_MASK_MSG_ASCII; >>>> - sccb->cp_send_mask = SCLP_EVENT_MASK_MSG_ASCII; >>>> + sccb->h.function_code = 0; >>> >>> Already 0'ed out. >> >> Yes, this one is here to make absolutely clear which function we execute. > > Wondering if this should be SCLP_FC_NORMAL_WRITE, too? Yes I'll also be able to remove msg_buf and write_sccb structs as they are already defined in WriteEventData. That that has to wait until a proper level of caffeine is reached to adapt the offset calculations. > >> >>> >>>> + sccb->mask_length = sizeof(sccb_mask_t); >>>> + >>>> + /* For now we don't process sclp input. */ >>>> + sccb->cp_receive_mask = 0; >>> >>> dito >> >> Same >> If you want, I'll add a comment instead. > > Whatever you prefer, I guess a comment is enough. So this one has a comment. I changed the above one to the constant, so both should be fine. > >
Attachment:
signature.asc
Description: OpenPGP digital signature