aboutsummaryrefslogtreecommitdiff
path: root/pc-bios/s390-ccw/sclp.c
diff options
context:
space:
mode:
authorCollin L. Walling <walling@linux.vnet.ibm.com>2018-02-23 10:43:16 -0500
committerThomas Huth <thuth@redhat.com>2018-02-26 07:56:55 +0100
commitff5dbf1bc3b81248f4f1c253b586491bc8daeda5 (patch)
tree4c98a2a5e9b2520462514da583775738effc50a2 /pc-bios/s390-ccw/sclp.c
parentf7178910845a73fcb69642476c3222af842e25e9 (diff)
downloadqemu-ff5dbf1bc3b81248f4f1c253b586491bc8daeda5.zip
qemu-ff5dbf1bc3b81248f4f1c253b586491bc8daeda5.tar.gz
qemu-ff5dbf1bc3b81248f4f1c253b586491bc8daeda5.tar.bz2
s390-ccw: read user input for boot index via the SCLP console
Implements an sclp_read function to capture input from the console and a wrapper function that handles parsing certain characters and adding input to a buffer. The input is checked for any erroneous values and is handled appropriately. A prompt will persist until input is entered or the timeout expires (if one was set). Example: Please choose (default will boot in 10 seconds): Correct input will boot the respective boot index. If the user's input is empty, 0, or if the timeout expires, then the default zipl entry will be chosen. If the input is within the range of available boot entries, then the selection will be booted. Any erroneous input will cancel the timeout and re-prompt the user. Signed-off-by: Collin L. Walling <walling@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'pc-bios/s390-ccw/sclp.c')
-rw-r--r--pc-bios/s390-ccw/sclp.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/pc-bios/s390-ccw/sclp.c b/pc-bios/s390-ccw/sclp.c
index e6a0898..a2f25eb 100644
--- a/pc-bios/s390-ccw/sclp.c
+++ b/pc-bios/s390-ccw/sclp.c
@@ -119,3 +119,22 @@ void sclp_get_loadparm_ascii(char *loadparm)
ebcdic_to_ascii((char *) sccb->loadparm, loadparm, 8);
}
}
+
+int sclp_read(char *str, size_t count)
+{
+ ReadEventData *sccb = (void *)_sccb;
+ char *buf = (char *)(&sccb->ebh) + 7;
+
+ /* If count exceeds max buffer size, then restrict it to the max size */
+ if (count > SCCB_SIZE - 8) {
+ count = SCCB_SIZE - 8;
+ }
+
+ sccb->h.length = SCCB_SIZE;
+ sccb->h.function_code = SCLP_UNCONDITIONAL_READ;
+
+ sclp_service_call(SCLP_CMD_READ_EVENT_DATA, sccb);
+ memcpy(str, buf, count);
+
+ return sccb->ebh.length - 7;
+}