diff options
-rw-r--r-- | com32/include/syslinux.h | 40 | ||||
-rw-r--r-- | com32/lib/Makefile | 2 | ||||
-rw-r--r-- | com32/lib/sys/idle.c | 49 | ||||
-rw-r--r-- | com32/lib/sys/line_input.c | 5 | ||||
-rw-r--r-- | com32/lib/sys/rawcon_read.c | 4 | ||||
-rw-r--r-- | com32/libutil/Makefile | 2 | ||||
-rw-r--r-- | com32/libutil/get_key.c | 3 | ||||
-rw-r--r-- | com32/libutil/idle.c | 53 | ||||
-rw-r--r-- | com32/libutil/include/libutil.h | 40 |
9 files changed, 193 insertions, 5 deletions
diff --git a/com32/include/syslinux.h b/com32/include/syslinux.h new file mode 100644 index 00000000..c7510076 --- /dev/null +++ b/com32/include/syslinux.h @@ -0,0 +1,40 @@ +#ident "$Id$" +/* ----------------------------------------------------------------------- * + * + * Copyright 2005 H. Peter Anvin - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * syslinux.h + * + * SYSLINUX-specific functions + */ + +#ifndef _SYSLINUX_H +#define _SYSLINUX_H + +void syslinux_idle(void); + +#endif diff --git a/com32/lib/Makefile b/com32/lib/Makefile index 29f0cecd..842f5f53 100644 --- a/com32/lib/Makefile +++ b/com32/lib/Makefile @@ -18,7 +18,7 @@ LIBOBJS = abort.o atexit.o atoi.o atol.o atoll.o calloc.o creat.o \ libgcc/__negdi2.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o \ libgcc/__muldi3.o libgcc/__udivmoddi4.o libgcc/__umoddi3.o \ libgcc/__divdi3.o libgcc/__moddi3.o \ - sys/entry.o sys/exit.o sys/argv.o sys/times.o \ + sys/entry.o sys/exit.o sys/argv.o sys/times.o sys/idle.o \ sys/fileinfo.o sys/opendev.o sys/read.o sys/write.o sys/ftell.o \ sys/close.o sys/open.o sys/fileread.o sys/fileclose.o \ sys/isatty.o sys/openconsole.o sys/line_input.o \ diff --git a/com32/lib/sys/idle.c b/com32/lib/sys/idle.c new file mode 100644 index 00000000..f2794b04 --- /dev/null +++ b/com32/lib/sys/idle.c @@ -0,0 +1,49 @@ +#ident "$Id$" +/* ----------------------------------------------------------------------- * + * + * Copyright 2005 H. Peter Anvin - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * idle.c + * + * What to do in a busy loop... + */ + +#include <syslinux.h> +#include <stddef.h> +#include <com32.h> + +void syslinux_idle(void) +{ + static com32sys_t sys_idle = { + .eax.l = 0x0013, + }; + + /* This call isn't supported on SYSLINUX < 3.08, but all it does + is return an error, so we don't care. */ + + __intcall(0x22, &sys_idle, NULL); +} diff --git a/com32/lib/sys/line_input.c b/com32/lib/sys/line_input.c index e0dd3997..a125ec8e 100644 --- a/com32/lib/sys/line_input.c +++ b/com32/lib/sys/line_input.c @@ -34,6 +34,7 @@ #include "file.h" #include <errno.h> +#include <syslinux.h> ssize_t __line_input(struct file_info *fp, char *buf, size_t bufsize, ssize_t (*get_char)(struct file_info *, void *, size_t)) @@ -47,8 +48,10 @@ ssize_t __line_input(struct file_info *fp, char *buf, size_t bufsize, for(;;) { rv = get_char(fp, &ch, 1); - if ( rv != 1 ) + if ( rv != 1 ) { + syslinux_idle(); continue; + } switch ( ch ) { case '\n': /* Ignore incoming linefeed */ diff --git a/com32/lib/sys/rawcon_read.c b/com32/lib/sys/rawcon_read.c index 483dbfa5..fb720ef8 100644 --- a/com32/lib/sys/rawcon_read.c +++ b/com32/lib/sys/rawcon_read.c @@ -29,8 +29,8 @@ /* * rawcon_read.c * - * Character-oriented reading from the console without echo, and with - * a timeout (50-100 ms). + * Character-oriented reading from the console without echo; + * this is a NONBLOCKING device. */ #include <errno.h> diff --git a/com32/libutil/Makefile b/com32/libutil/Makefile index c3cc4149..9003f986 100644 --- a/com32/libutil/Makefile +++ b/com32/libutil/Makefile @@ -47,7 +47,7 @@ LNXCFLAGS = -I./include -W -Wall -O -g LNXSFLAGS = -g LNXLDFLAGS = -g OBJCOPY = objcopy -LIBOBJS = ansiline.o ansiraw.o get_key.o +LIBOBJS = ansiline.o ansiraw.o get_key.o idle.o LNXLIBOBJS = $(patsubst %.o,%.lo,$(LIBOBJS)) .SUFFIXES: .lss .c .lo .o .elf .c32 .lnx diff --git a/com32/libutil/get_key.c b/com32/libutil/get_key.c index b7498a1e..e3b8f02b 100644 --- a/com32/libutil/get_key.c +++ b/com32/libutil/get_key.c @@ -41,6 +41,7 @@ #include <time.h> #include <sys/times.h> #include <getkey.h> +#include <libutil.h> struct keycode { int code; @@ -139,6 +140,8 @@ int get_key(FILE *f, clock_t timeout) else if ( !nc && timeout && lateness > timeout ) return KEY_NONE; /* timeout before sequence */ + do_idle(); + another = 1; continue; } diff --git a/com32/libutil/idle.c b/com32/libutil/idle.c new file mode 100644 index 00000000..7f724900 --- /dev/null +++ b/com32/libutil/idle.c @@ -0,0 +1,53 @@ +#ident "$Id$" +/* ----------------------------------------------------------------------- * + * + * Copyright 2005 H. Peter Anvin - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * idle.c + * + * What to do in a busy loop... + */ + +#ifdef __COM32__ + +#include <syslinux.h> + +void do_idle(void) +{ + syslinux_idle(); +} + +#else + +#include <sched.h> + +void do_idle(void) +{ + sched_yield(); /* As good as we can get... */ +} + +#endif diff --git a/com32/libutil/include/libutil.h b/com32/libutil/include/libutil.h new file mode 100644 index 00000000..9138b6db --- /dev/null +++ b/com32/libutil/include/libutil.h @@ -0,0 +1,40 @@ +#ident "$Id$" +/* ----------------------------------------------------------------------- * + * + * Copyright 2005 H. Peter Anvin - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * libutil.h + * + * Misc libutil functions + */ + +#ifndef LIBUTIL_LIBUTIL_H +#define LIBUTIL_LIBUTIL_H + +void do_idle(void); + +#endif |