diff options
author | Uwe Stuehler <uwe@cvs.openbsd.org> | 2005-05-12 05:10:31 +0000 |
---|---|---|
committer | Uwe Stuehler <uwe@cvs.openbsd.org> | 2005-05-12 05:10:31 +0000 |
commit | 50843c1d8d350cfe1eb0ee518d09db0ee81beeed (patch) | |
tree | 8359b61c3597293614e0885e37294fbd0e3b95b4 | |
parent | caf6105da4eb0486be4aa3847fade621ea80185c (diff) |
Minimal terminal line discipline support to stop the boot timeout
after the first keystroke, as on other platforms.
-rw-r--r-- | sys/arch/zaurus/stand/zboot/Makefile | 10 | ||||
-rw-r--r-- | sys/arch/zaurus/stand/zboot/compat_linux.h | 63 | ||||
-rw-r--r-- | sys/arch/zaurus/stand/zboot/devopen.c | 8 | ||||
-rw-r--r-- | sys/arch/zaurus/stand/zboot/exit.c | 7 | ||||
-rw-r--r-- | sys/arch/zaurus/stand/zboot/machdep.c | 11 | ||||
-rw-r--r-- | sys/arch/zaurus/stand/zboot/termios.c | 69 |
6 files changed, 135 insertions, 33 deletions
diff --git a/sys/arch/zaurus/stand/zboot/Makefile b/sys/arch/zaurus/stand/zboot/Makefile index 52557bfe3ee..f7f5c4015c9 100644 --- a/sys/arch/zaurus/stand/zboot/Makefile +++ b/sys/arch/zaurus/stand/zboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.4 2005/04/26 19:20:21 deraadt Exp $ +# $OpenBSD: Makefile,v 1.5 2005/05/12 05:10:30 uwe Exp $ MAN= boot.8 MANSUBDIR=zaurus @@ -21,7 +21,7 @@ CLEANFILES+= arm machine .endif # stand/boot -SRCS+= boot.c cmd.c vars.c bootarg.c conf.c +SRCS+= boot.c vars.c bootarg.c conf.c # libsa SRCS+= close.c closeall.c cons.c ctime.c disklabel.c dkcksum.c fstat.c \ @@ -32,9 +32,9 @@ SRCS+= close.c closeall.c cons.c ctime.c disklabel.c dkcksum.c fstat.c \ SRCS+= strcmp.c strlcpy.c strlen.c strncmp.c strncpy.c write.c \ ashrdi3.c divsi3.S -# local overrides for Linux/zaurus -SRCS+= alloc.c devopen.c exec.c exit.c loadfile.c machdep.c \ - unixdev.c unixsys.S +# local overrides and additions +SRCS+= alloc.c cmd.c devopen.c exec.c exit.c loadfile.c machdep.c \ + termios.c unixdev.c unixsys.S .PATH: ${S}/stand/boot .PATH: ${S}/lib/libsa diff --git a/sys/arch/zaurus/stand/zboot/compat_linux.h b/sys/arch/zaurus/stand/zboot/compat_linux.h index d983d460997..461ace4179a 100644 --- a/sys/arch/zaurus/stand/zboot/compat_linux.h +++ b/sys/arch/zaurus/stand/zboot/compat_linux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: compat_linux.h,v 1.5 2005/04/13 04:33:47 uwe Exp $ */ +/* $OpenBSD: compat_linux.h,v 1.6 2005/05/12 05:10:30 uwe Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de> @@ -16,14 +16,15 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef _TEST - /* This file must be included late, for redefinitions to take effect. */ #ifndef _LOCORE + #include <compat/linux/linux_types.h> #include <compat/linux/linux_fcntl.h> -#endif +#include <compat/linux/linux_termios.h> +struct proc; +#include <compat/linux/linux_ioctl.h> #define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1))) #define OFFSET_MAX INT_LIMIT(long long) @@ -41,6 +42,42 @@ #define EOVERFLOW 75 +#define termios linux_termios + +#define IMAXBEL LINUX_IMAXBEL +#define IGNBRK LINUX_IGNBRK +#define BRKINT LINUX_BRKINT +#define PARMRK LINUX_PARMRK +#define ISTRIP LINUX_ISTRIP +#define INLCR LINUX_INLCR +#define IGNCR LINUX_IGNCR +#define ICRNL LINUX_ICRNL +#define IXON LINUX_IXON +#define OPOST LINUX_OPOST +#define ECHO LINUX_ECHO +#define ECHONL LINUX_ECHONL +#define ICANON LINUX_ICANON +#define ISIG LINUX_ISIG +#define IEXTEN LINUX_IEXTEN +#define CSIZE LINUX_CSIZE +#define PARENB LINUX_PARENB +#define CS8 LINUX_CS8 + +#define TIOCGETA LINUX_TCGETS +#define TIOCSETA LINUX_TCGETS +#define TIOCSETAW LINUX_TCSETSW +#define TIOCSETAF LINUX_TCSETSF + +#define TCSANOW LINUX_TCSANOW +#define TCSADRAIN LINUX_TCSADRAIN +#define TCSAFLUSH LINUX_TCSAFLUSH + +void cfmakeraw(struct termios *); +int tcgetattr(int, struct termios *); +int tcsetattr(int, int, struct termios *); + +#endif /* !_LOCORE */ + /* linux/asm/unistd.h */ #define __NR_SYSCALL_BASE 0x900000 #define __NR_exit (__NR_SYSCALL_BASE+ 1) @@ -54,24 +91,6 @@ #define __NR__new_select (__NR_SYSCALL_BASE+142) #define __NR_select __NR__new_select /* XXX */ #define __NR_syscall (__NR_SYSCALL_BASE+113) -#define linux__sys2(x) #x -#define linux__sys1(x) linux__sys2(x) -#define linux__syscall(name) "swi\t" linux__sys1(__NR_##name) "\n\t" -#define linux__syscall_return(type, res) \ - do { \ - if ((unsigned long)(res) >= (unsigned long)(-125)) { \ - errno = -(res); \ - res = -1; \ - } \ - return (type) (res); \ - } while (0) #undef SYS_select #define SYS_select __NR__new_select - -#else - -#include <fcntl.h> -#include <unistd.h> - -#endif /* _TEST */ diff --git a/sys/arch/zaurus/stand/zboot/devopen.c b/sys/arch/zaurus/stand/zboot/devopen.c index 1acbb1a03cb..e5a81a880b1 100644 --- a/sys/arch/zaurus/stand/zboot/devopen.c +++ b/sys/arch/zaurus/stand/zboot/devopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: devopen.c,v 1.3 2005/05/11 16:42:15 deraadt Exp $ */ +/* $OpenBSD: devopen.c,v 1.4 2005/05/12 05:10:30 uwe Exp $ */ /* * Copyright (c) 1996-1999 Michael Shalayeff @@ -31,6 +31,8 @@ #include <sys/disklabel.h> #include <dev/cons.h> +#include <stand/boot/cmd.h> + extern int debug; /* XXX use slot for 'rd' for 'hd' pseudo-device */ @@ -177,7 +179,7 @@ devboot(dev_t bootdev, char *p) return; /* fall-back to the previous default device */ - strlcpy(p, "/dev/hda4", 16); + strlcpy(p, "/dev/hda4", sizeof cmd.bootdev); } int pch_pos = 0; @@ -222,7 +224,7 @@ getchar(void) if ((c < ' ' && c != '\n') || c == '\177') return c; -#if 0 +#ifndef _TEST putchar(c); #endif diff --git a/sys/arch/zaurus/stand/zboot/exit.c b/sys/arch/zaurus/stand/zboot/exit.c index 59db22983aa..4c6a29e9056 100644 --- a/sys/arch/zaurus/stand/zboot/exit.c +++ b/sys/arch/zaurus/stand/zboot/exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exit.c,v 1.2 2005/04/16 17:21:24 uwe Exp $ */ +/* $OpenBSD: exit.c,v 1.3 2005/05/12 05:10:30 uwe Exp $ */ /* $NetBSD: exit.c,v 1.11 1996/12/01 20:22:19 pk Exp $ */ /*- @@ -31,7 +31,7 @@ #include <sys/stdarg.h> -#include <lib/libsa/stand.h> +#include "libsa.h" __dead void panic(const char *fmt, ...) @@ -61,5 +61,8 @@ panic(const char *fmt, ...) void exit(void) { + extern struct termios otc; + + (void)tcsetattr(0, TCSADRAIN, &otc); uexit(0); } diff --git a/sys/arch/zaurus/stand/zboot/machdep.c b/sys/arch/zaurus/stand/zboot/machdep.c index 7e7501e6c61..1411b3f61bf 100644 --- a/sys/arch/zaurus/stand/zboot/machdep.c +++ b/sys/arch/zaurus/stand/zboot/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.2 2005/05/11 16:42:15 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.3 2005/05/12 05:10:30 uwe Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -29,6 +29,8 @@ #include "libsa.h" +struct termios otc; + char _alloc_heap[4 * 1024 * 1024]; int debug; @@ -38,6 +40,13 @@ machdep(void) { int i, j; struct zaurus_boot_probes *pr; + struct termios t; + + if (tcgetattr(0, &t) == 0) { + otc = t; + cfmakeraw(&t); + (void)tcsetattr(0, TCSAFLUSH, &t); + } /* * The list of probe routines is now in conf.c. diff --git a/sys/arch/zaurus/stand/zboot/termios.c b/sys/arch/zaurus/stand/zboot/termios.c new file mode 100644 index 00000000000..b7c883f6484 --- /dev/null +++ b/sys/arch/zaurus/stand/zboot/termios.c @@ -0,0 +1,69 @@ +/* $OpenBSD: termios.c,v 1.1 2005/05/12 05:10:30 uwe Exp $ */ + +/*- + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "libsa.h" + +void +cfmakeraw(struct termios *t) +{ + t->c_iflag &= ~(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); + t->c_oflag &= ~OPOST; + t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); + t->c_cflag &= ~(CSIZE|PARENB); + t->c_cflag |= CS8; +} + +int +tcgetattr(int fd, struct termios *t) +{ + return (uioctl(fd, TIOCGETA, t)); +} + +/* This function differs slightly from tcsetattr() in libc. */ +int +tcsetattr(int fd, int action, struct termios *t) +{ + switch (action) { + case TCSANOW: + action = TIOCSETA; + break; + case TCSADRAIN: + action = TIOCSETAW; + break; + case TCSAFLUSH: + action = TIOCSETAF; + break; + default: + errno = EINVAL; + return -1; + } + return (uioctl(fd, action, t)); +} |