On 23.01.2018 19:26, Collin L. Walling wrote: > 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 <wall...@linux.vnet.ibm.com> > --- > pc-bios/s390-ccw/menu.c | 152 > +++++++++++++++++++++++++++++++++++++++++++- > pc-bios/s390-ccw/s390-ccw.h | 2 + > pc-bios/s390-ccw/sclp.c | 20 ++++++ > pc-bios/s390-ccw/virtio.c | 2 +- > 4 files changed, 172 insertions(+), 4 deletions(-) [...] > +static int read_prompt(char *buf, size_t len) > +{ > + char inp[2] = {}; > + uint8_t idx = 0; > + uint64_t time; > + > + if (timeout) { > + time = get_clock() + (timeout * TOD_CLOCK_SECOND);
Nit: Parentheses around "timeout * TOD_CLOCK_SECOND" are not required. Apart from that, patch looks fine to me now. Reviewed-by: Thomas Huth <th...@redhat.com>