Move serial console handling code out into its own file.
--- loader/Makefile.am | 2 +- loader/init.c | 208 +------------------------------------------------ loader/loader.c | 5 + loader/serial.c | 220 ++++++++++++++++++++++++++++++++++++++++++++++++++ ++ loader/serial.h | 9 ++ 5 files changed, 237 insertions(+), 207 deletions(-) create mode 100644 loader/serial.c create mode 100644 loader/serial.h diff --git a/loader/Makefile.am b/loader/Makefile.am index 02ab6cf..243817c 100644 --- a/loader/Makefile.am +++ b/loader/Makefile.am @@ -50,7 +50,7 @@ loader_SOURCES = loader.c copy.c moduleinfo.c loadermisc.c getparts.c dirbrowser.c fwloader.c ibft.c hardware.c method.c cdinstall.c hdinstall.c nfsinstall.c urlinstall.c net.c urls.c rpmextract.c readvars.c - unpack.c + serial.c unpack.c dirbrowser_CFLAGS = $(COMMON_CFLAGS) -DSTANDALONE dirbrowser_LDADD = $(NEWT_LIBS) diff --git a/loader/init.c b/loader/init.c index 429eada..d4f9c0d 100644 --- a/loader/init.c +++ b/loader/init.c @@ -83,71 +83,6 @@ static void fatal_error(int usePerror) { #endif } -static int setupTerminal(int fd) { - struct winsize winsize; - gpointer value = NULL; - - if (ioctl(fd, TIOCGWINSZ, &winsize)) { - printf("failed to get winsize"); - fatal_error(1); - } - - winsize.ws_row = 24; - winsize.ws_col = 80; - - if (ioctl(fd, TIOCSWINSZ, &winsize)) { - printf("failed to set winsize"); - fatal_error(1); - } - - if (!strcmp(ttyname(fd), "/dev/hvc0")) { - /* using an HMC on a POWER system, use vt320 */ - env[ENV_TERM] = "TERM=vt320"; - } else { - /* use the no-advanced-video vt100 definition */ - env[ENV_TERM] = "TERM=vt100-nav"; - - /* unless the user specifies that they want utf8 */ - if (g_hash_table_lookup_extended(cmdline, "utf8", NULL, &value)) { - env[ENV_TERM] = "TERM=vt100"; - } - } - - return 0; -} -#if defined(__sparc__) -static int termcmp(struct termios *a, struct termios *b) { - if (a->c_iflag != b->c_iflag || a->c_oflag != b->c_oflag || - a->c_cflag != b->c_cflag || a->c_lflag != b->c_lflag) - return 1; - return memcmp(a->c_cc, b->c_cc, sizeof(a->c_cc)); -} -#endif - -#if !defined(__s390__) && !defined(__s390x__) && !defined(__sparc__) -static int termcmp(struct termios *a, struct termios *b) { - if (a->c_iflag != b->c_iflag || a->c_oflag != b->c_oflag || - a->c_cflag != b->c_cflag || a->c_lflag != b->c_lflag || - a->c_ispeed != b->c_ispeed || a->c_ospeed != b->c_ospeed) - return 1; - return memcmp(a->c_cc, b->c_cc, sizeof(a->c_cc)); -} -#endif - -static void termReset(void) { - /* change to tty1 */ - ioctl(0, VT_ACTIVATE, 1); - /* reset terminal */ - tcsetattr(0, TCSANOW, &ts); - /* Shift in, default color, move down 100 lines */ - /* ^O ^[[0m ^[[100E */ - printf(" |