From c7e10205ae0d9e8e78a9f47b96bbb17ba568bab3 Mon Sep 17 00:00:00 2001 From: Maxim Sobolev Date: Fri, 25 Aug 2017 17:29:48 +0000 Subject: [PATCH] Make spinconsole platform independent and hook it up into EFI loader on i386 and amd64. Not enabled on ARMs, those are lacking timer routines. MFC after: 2 moths Sponsored by: Sippy Software, Inc. --- sys/boot/efi/loader/arch/amd64/Makefile.inc | 5 ++-- sys/boot/efi/loader/arch/i386/Makefile.inc | 5 ++-- sys/boot/efi/loader/conf.c | 2 ++ sys/boot/i386/libi386/spinconsole.c | 32 ++++++++++++--------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/sys/boot/efi/loader/arch/amd64/Makefile.inc b/sys/boot/efi/loader/arch/amd64/Makefile.inc index 5649c1271f18..071afa100611 100644 --- a/sys/boot/efi/loader/arch/amd64/Makefile.inc +++ b/sys/boot/efi/loader/arch/amd64/Makefile.inc @@ -9,7 +9,8 @@ SRCS+= amd64_tramp.S \ .PATH: ${.CURDIR}/../../i386/libi386 SRCS+= nullconsole.c \ - comconsole.c + comconsole.c \ + spinconsole.c -CFLAGS+= -fPIC +CFLAGS+= -fPIC -DTERM_EMU LDFLAGS+= -Wl,-znocombreloc diff --git a/sys/boot/efi/loader/arch/i386/Makefile.inc b/sys/boot/efi/loader/arch/i386/Makefile.inc index 4e08c5376336..a1af3cdd84c3 100644 --- a/sys/boot/efi/loader/arch/i386/Makefile.inc +++ b/sys/boot/efi/loader/arch/i386/Makefile.inc @@ -7,7 +7,8 @@ SRCS+= start.S \ .PATH: ${.CURDIR}/../../i386/libi386 SRCS+= nullconsole.c \ - comconsole.c + comconsole.c \ + spinconsole.c -CFLAGS+= -fPIC +CFLAGS+= -fPIC -DTERM_EMU LDFLAGS+= -Wl,-znocombreloc diff --git a/sys/boot/efi/loader/conf.c b/sys/boot/efi/loader/conf.c index a98d63f1b764..cea95b3db104 100644 --- a/sys/boot/efi/loader/conf.c +++ b/sys/boot/efi/loader/conf.c @@ -69,6 +69,7 @@ extern struct console efi_console; #if defined(__amd64__) || defined(__i386__) extern struct console comconsole; extern struct console nullconsole; +extern struct console spinconsole; #endif struct console *consoles[] = { @@ -76,6 +77,7 @@ struct console *consoles[] = { #if defined(__amd64__) || defined(__i386__) &comconsole, &nullconsole, + &spinconsole, #endif NULL }; diff --git a/sys/boot/i386/libi386/spinconsole.c b/sys/boot/i386/libi386/spinconsole.c index 161d81066b25..1daac3586939 100644 --- a/sys/boot/i386/libi386/spinconsole.c +++ b/sys/boot/i386/libi386/spinconsole.c @@ -41,16 +41,14 @@ __FBSDID("$FreeBSD$"); #include #include -extern void get_pos(int *x, int *y); -extern void curs_move(int *_x, int *_y, int x, int y); -extern void vidc_biosputchar(int c); - static void spinc_probe(struct console *cp); static int spinc_init(int arg); static void spinc_putchar(int c); static int spinc_getchar(void); static int spinc_ischar(void); +extern struct console *consoles[]; + struct console spinconsole = { "spinconsole", "spin port", @@ -62,47 +60,53 @@ struct console spinconsole = { spinc_ischar }; +static struct console *parent = NULL; + static void spinc_probe(struct console *cp) { - cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT); + + if (parent == NULL) + parent = consoles[0]; + parent->c_probe(cp); } static int spinc_init(int arg) { - return(0); + + return(parent->c_init(arg)); } static void spinc_putchar(int c) { - static int curx, cury; static unsigned tw_chars = 0x5C2D2F7C; /* "\-/|" */ - static time_t lasttime; + static time_t lasttime = 0; time_t now; - now = time(NULL); + now = time(0); if (now < (lasttime + 1)) return; - lasttime = now; #ifdef TERM_EMU - get_pos(&curx, &cury); - if (curx > 0) - curs_move(&curx, &cury, curx - 1, cury); + if (lasttime > 0) + parent->c_out('\b'); #endif - vidc_biosputchar((char)tw_chars); + lasttime = now; + parent->c_out((char)tw_chars); tw_chars = (tw_chars >> 8) | ((tw_chars & (unsigned long)0xFF) << 24); } static int spinc_getchar(void) { + return(-1); } static int spinc_ischar(void) { + return(0); }