From 198d4f1deed6639600ac852bbec6958c9e0a04f9 Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Mon, 14 Oct 2024 18:16:03 -0600 Subject: [PATCH 1/4] [boot] Decrease boot time from 10 to 5 seconds --- elks/arch/i86/drivers/block/bios.c | 2 +- elks/include/linuxmt/trace.h | 2 +- image/Make.devices | 19 +++++++++---------- image/Make.image | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/elks/arch/i86/drivers/block/bios.c b/elks/arch/i86/drivers/block/bios.c index b2e211130..a00513004 100644 --- a/elks/arch/i86/drivers/block/bios.c +++ b/elks/arch/i86/drivers/block/bios.c @@ -18,7 +18,7 @@ #include "bioshd.h" #define RESET_DISK_CHG 1 /* =1 to reset BIOS on drive change fixes QEMU retry */ -#define IODELAY 0 /* emulate delay for floppy on QEMU */ +#define IODELAY 1 /* emulate delay for floppy on QEMU */ #define abs(v) (((int)(v) >= 0)? (v): -(v)) /* diff --git a/elks/include/linuxmt/trace.h b/elks/include/linuxmt/trace.h index 1742423b0..6975c8ce0 100644 --- a/elks/include/linuxmt/trace.h +++ b/elks/include/linuxmt/trace.h @@ -45,7 +45,7 @@ * TRACK_SPLIT_BLK - read extra sector on track split block (set in bioshd.c) * SPLIT_BLK - read extra sector on single split block (set in bioshd.c) * FULL_TRACK - read full track on cache refill (set in bioshd.c) - * SHOW_STARTUP - show startup time on boot (set in getty.c) + * BOOT_TIMER - show startup time on boot (set in getty.c) */ /* internal flags for kernel */ diff --git a/image/Make.devices b/image/Make.devices index 6346fb39b..bf72772ff 100755 --- a/image/Make.devices +++ b/image/Make.devices @@ -13,9 +13,13 @@ devices: -# $(MKDEV) /dev/console c 4 254 1 1 0600 -# $(MKDEV) /dev/tty1 c 4 0 -# $(MKDEV) /dev/ttyS0 c 4 64 +############################################################################## +# Create frequently accessed /dev files first + $(MKDEV) /dev/console c 4 254 1 1 0600 + $(MKDEV) /dev/tty1 c 4 0 + $(MKDEV) /dev/ttyS0 c 4 64 + $(MKDEV) /dev/fd0 b 3 32 + $(MKDEV) /dev/fd1 b 3 40 ############################################################################## # Create memory devices. @@ -92,6 +96,7 @@ devices: $(MKDEV) /dev/tty3 c 4 2 $(MKDEV) /dev/tty4 c 4 3 +############################################################################## # Pseudo-TTY slave devices. $(MKDEV) /dev/ttyp0 c 4 8 @@ -101,7 +106,7 @@ devices: # /dev/tty is minor 255, /dev/console minor 254 - $(MKDEV) /dev/tty c 4 255 1 1 0666 + $(MKDEV) /dev/tty c 4 255 1 1 0666 $(MKDEV) /dev/console c 4 254 1 1 0600 # Serial ports, as detected by the ROM BIOS. @@ -113,12 +118,6 @@ devices: $(MKDEV) /dev/lp c 6 0 # $(MKDEV) /dev/lp c 6 0 4 -# $MKSET 0 3 $(MKDEV) /dev/lp c 6 - -############################################################################## -# UDD user device driver, experimental - -# $(MKDEV) /dev/udd c 7 0 ############################################################################## # TCPDEV, used by ktcp diff --git a/image/Make.image b/image/Make.image index 72f3595fa..f16a957bd 100644 --- a/image/Make.image +++ b/image/Make.image @@ -78,7 +78,7 @@ endif minixfs: rm -f $(TARGET_FILE) mfs $(VERBOSE) $(TARGET_FILE) mkfs $(MINIX_MKFSOPTS) -# mfs -v $(VERBOSE) $(TARGET_FILE) addfs Image.all $(DESTDIR) + mfs -v $(VERBOSE) $(TARGET_FILE) addfs Image.all $(DESTDIR) # rm -f Filelist # for f in $$(cd $(DESTDIR); find * -name '*'); do \ # echo $$f >> FileList; \ From 30b4c5107dfcd7bf963f43515cbb4c76200acf2c Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Mon, 14 Oct 2024 18:16:46 -0600 Subject: [PATCH 2/4] Cleanup getty.c and make small by default --- elkscmd/sys_utils/getty.c | 77 +++++---------------------------------- 1 file changed, 10 insertions(+), 67 deletions(-) diff --git a/elkscmd/sys_utils/getty.c b/elkscmd/sys_utils/getty.c index 946a79fd8..713c0ea3d 100644 --- a/elkscmd/sys_utils/getty.c +++ b/elkscmd/sys_utils/getty.c @@ -33,7 +33,6 @@ * from the compile-time kernel rather than querying the current kernel. * These are all works in progress. */ -#include #include #include #include @@ -49,16 +48,10 @@ #include #include -#define DEBUG 0 /* set =1 for debug messages*/ -#define SHOW_STARTUP 0 /* set =1 to display system startup time */ - -/* debug messages go here*/ -#define CONSOLE _PATH_CONSOLE - -/* For those requiring a super-small getty, the following define cuts out - * all of the extra functionality regarding the /etc/issue code sequences. - */ -//#define SUPER_SMALL /* Disable for super-small binary */ +#define PARSE_ETC_ISSUE 0 /* set =1 to process /etc/issue @ sequences */ +#define BOOT_TIMER 1 /* set =1 to display system startup time */ +#define DEBUG 0 /* set =1 for debug messages */ +#define CONSOLE _PATH_CONSOLE /* debug messages go here */ #if DEBUG #define debug consolemsg @@ -89,32 +82,7 @@ void consolemsg(const char *str, ...) va_end(args); } - -#if UNUSED -char Host[256]; -void host(void) { - char *ptr; - int fp = open(_PATH_HOSTNAME,O_RDONLY), sz; - - if (fp) { - sz = read( fp, Host, 255); - if (sz >= 0) - Host[sz] = '\0'; - else - *Host = '\0'; - close(fp); - } - for (ptr = Host; isprint(*ptr); ptr++) - continue; - while (ptr >= &Host[1] && ptr[-1] == ' ') - ptr--; - *ptr = '\0'; - if (!*Host) - strcpy( Host, "LocalHost" ); -} -#endif - -#ifndef SUPER_SMALL +#if PARSE_ETC_ISSUE char *Date, *Time; /* Before = "Sun Dec 25 12:34:56 7890" @@ -191,24 +159,7 @@ static speed_t convert_baudrate(speed_t baudrate) case 38400: return B38400; case 57600: return B57600; case 115200: return B115200; -#ifdef B230400 case 230400: return B230400; -#endif -#ifdef B460800 - case 460800: return B460800; -#endif -#ifdef B500000 - case 500000: return B500000; -#endif -#ifdef B576000 - case 576000: return B576000; -#endif -#ifdef B921600 - case 921600: return B921600; -#endif -#ifdef B1000000 - case 1000000: return B1000000; -#endif } return 0; } @@ -232,7 +183,6 @@ void show_startup(void) int main(int argc, char **argv) { - char *ptr; int n, fd; speed_t baud = 0; struct termios termios; @@ -294,10 +244,11 @@ int main(int argc, char **argv) fd = open(_PATH_ISSUE, O_RDONLY); if (fd >= 0) { put('\n'); -#ifdef SUPER_SMALL +#if !PARSE_ETC_ISSUE while ((n=read(fd,Buffer,sizeof(Buffer))) > 0) write(1,Buffer,n); #else + char *ptr; when(); *Buffer = '\0'; while (read(fd,Buffer,1) > 0) { @@ -361,9 +312,9 @@ int main(int argc, char **argv) state(Date); break; case 'H': /* Host */ - if (!(ptr = getenv("HOSTNAME"))) - ptr = "LocalHost"; - state(ptr); + if (!(ptr = getenv("HOSTNAME"))) + ptr = "LocalHost"; + state(ptr); break; case 'L': /* Line used */ ptr = rindex(argv[1],'/'); @@ -377,16 +328,9 @@ int main(int argc, char **argv) case 'T': /* Time */ state(Time); break; -#if 0 - case 'U': /* Users */ - state("1 user"); - break; -#endif -#ifdef ELKS_VERSION case 'V': /* Version */ state(ELKS_VERSION); break; -#endif default: put('@'); put(ch); @@ -403,7 +347,6 @@ int main(int argc, char **argv) close(fd); } - show_startup(); for (;;) { state("login: "); From 30795e2278208470c0e515f1527e2e23c48fdfc6 Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Mon, 14 Oct 2024 18:20:16 -0600 Subject: [PATCH 3/4] Retab getty.c --- elkscmd/sys_utils/getty.c | 439 +++++++++++++++++++------------------- 1 file changed, 219 insertions(+), 220 deletions(-) diff --git a/elkscmd/sys_utils/getty.c b/elkscmd/sys_utils/getty.c index 713c0ea3d..b35e55e6d 100644 --- a/elkscmd/sys_utils/getty.c +++ b/elkscmd/sys_utils/getty.c @@ -19,15 +19,15 @@ * Support for \? and @? codes has been added in, supporting the following * codes: * - * \@ = @ @@ = @ - * \\ = \ @B = Baud Rate. - * \0 = ^@ @D = Date in dd-mmm-yyy format. - * \b = ^H @H = System hostname. - * \f = ^L @L = Line identifier. - * \n = ^J @S = System Identifier. - * \r = ^M @T = 24 hour time in HH:MM:SS format. - * \s = Space @U = Users connected. - * \t = 8-column tab @V = Kernel version. + * \@ = @ @@ = @ + * \\ = \ @B = Baud Rate. + * \0 = ^@ @D = Date in dd-mmm-yyy format. + * \b = ^H @H = System hostname. + * \f = ^L @L = Line identifier. + * \n = ^J @S = System Identifier. + * \r = ^M @T = 24 hour time in HH:MM:SS format. + * \s = Space @U = Users connected. + * \t = 8-column tab @V = Kernel version. * * Note that @U is not yet implemented, and @V returns a fixed string * from the compile-time kernel rather than querying the current kernel. @@ -49,79 +49,78 @@ #include #define PARSE_ETC_ISSUE 0 /* set =1 to process /etc/issue @ sequences */ -#define BOOT_TIMER 1 /* set =1 to display system startup time */ +#define BOOT_TIMER 0 /* set =1 to display system startup time */ #define DEBUG 0 /* set =1 for debug messages */ -#define CONSOLE _PATH_CONSOLE /* debug messages go here */ +#define CONSOLE _PATH_CONSOLE /* debug messages go here */ #if DEBUG -#define debug consolemsg +#define debug consolemsg #else #define debug(...) #endif #define _MK_FP(seg,off) ((void __far *)((((unsigned long)(seg)) << 16) | ((unsigned int)(off)))) -char * progname; -char Buffer[64]; -int ch, col; +char * progname; +char Buffer[64]; +int ch, col; void consolemsg(const char *str, ...) { - static int consolefd = -1; - char buf[80]; - - if (consolefd < 0) - consolefd = open(CONSOLE, O_RDWR); - - va_list args; - va_start(args, str); - sprintf(buf, "%s: ", progname); - write(consolefd, buf, strlen(buf)); - vsprintf(buf, str, args); - write(consolefd, buf, strlen(buf)); - va_end(args); + static int consolefd = -1; + char buf[80]; + + if (consolefd < 0) + consolefd = open(CONSOLE, O_RDWR); + + va_list args; + va_start(args, str); + sprintf(buf, "%s: ", progname); + write(consolefd, buf, strlen(buf)); + vsprintf(buf, str, args); + write(consolefd, buf, strlen(buf)); + va_end(args); } #if PARSE_ETC_ISSUE -char *Date, *Time; +char *Date, *Time; -/* Before = "Sun Dec 25 12:34:56 7890" - * Columns = "0....:....1....:....2..." - * After = "25-Dec-7890 12:34:56 " +/* Before = "Sun Dec 25 12:34:56 7890" + * Columns = "0....:....1....:....2..." + * After = "25-Dec-7890 12:34:56 " */ - void when(void) { char *Result; time_t now; int n; if (!Date) { - now = time(0); - Result = ctime(&now); + now = time(0); + Result = ctime(&now); - Result[0] = Result[8]; - Result[1] = Result[9]; + Result[0] = Result[8]; + Result[1] = Result[9]; - Result[3] = Result[4]; - Result[4] = Result[5]; - Result[5] = Result[6]; + Result[3] = Result[4]; + Result[4] = Result[5]; + Result[5] = Result[6]; - Result[7] = Result[20]; - Result[8] = Result[21]; - Result[9] = Result[22]; - Result[10] = Result[23]; + Result[7] = Result[20]; + Result[8] = Result[21]; + Result[9] = Result[22]; + Result[10] = Result[23]; - Result[2] = Result[6] = '-'; + Result[2] = Result[6] = '-'; - for (n=20; n>11; n--) - Result[n] = Result[n-1]; + for (n=20; n>11; n--) + Result[n] = Result[n-1]; - Result[11] = Result[20] = '\0'; + Result[11] = Result[20] = '\0'; - Date = Result; - if (*Date < '1') - Date++; - Time = Result + 12; + Date = Result; + if (*Date < '1') + Date++; + Time = Result + 12; } } #endif @@ -130,7 +129,7 @@ static void put(unsigned char ch) { col++; if (ch == '\r' || ch == '\n') - col = 0; + col = 0; write(STDOUT_FILENO, &ch, 1); } @@ -141,32 +140,32 @@ static void state(char *s) static speed_t convert_baudrate(speed_t baudrate) { - switch (baudrate) { - case 50: return B50; - case 75: return B75; - case 110: return B110; - case 134: return B134; - case 150: return B150; - case 200: return B200; - case 300: return B300; - case 600: return B600; - case 1200: return B1200; - case 1800: return B1800; - case 2400: return B2400; - case 4800: return B4800; - case 9600: return B9600; - case 19200: return B19200; - case 38400: return B38400; - case 57600: return B57600; - case 115200: return B115200; - case 230400: return B230400; - } - return 0; + switch (baudrate) { + case 50: return B50; + case 75: return B75; + case 110: return B110; + case 134: return B134; + case 150: return B150; + case 200: return B200; + case 300: return B300; + case 600: return B600; + case 1200: return B1200; + case 1800: return B1800; + case 2400: return B2400; + case 4800: return B4800; + case 9600: return B9600; + case 19200: return B19200; + case 38400: return B38400; + case 57600: return B57600; + case 115200: return B115200; + case 230400: return B230400; + } + return 0; } void show_startup(void) { -#if SHOW_STARTUP +#if BOOT_TIMER int fd; unsigned offset, kds; unsigned short __far *pjiffies; /* only access low order jiffies word */ @@ -188,35 +187,35 @@ int main(int argc, char **argv) struct termios termios; progname = argv[0]; - signal(SIGTSTP, SIG_IGN); /* ignore ^Z stop signal*/ + signal(SIGTSTP, SIG_IGN); /* ignore ^Z stop signal*/ if (argc < 2 || argc > 3) { - consolemsg("Usage: %s device [baudrate]\n", argv[0]); - exit(3); + consolemsg("Usage: %s device [baudrate]\n", argv[0]); + exit(3); } if (argc == 2) - debug("startup args '%s'\n", argv[1]); + debug("startup args '%s'\n", argv[1]); else if (argc == 3) { - baud = atol(argv[2]); - debug("startup args '%s' %ld\n", argv[1], baud); + baud = atol(argv[2]); + debug("startup args '%s' %ld\n", argv[1], baud); } /* allow execution outside of init*/ if (getppid() != 1) { - int tty = open(argv[1], O_RDWR); - if (tty < 0) { - consolemsg("cannot open terminal %s\n", argv[1]); - exit(4); - } - - debug("redirecting stdio to %s\n", argv[1]); - close(0); close(1); close(2); /* close inherited stdio */ - if (dup2(tty, 0) != 0 || dup2(tty, 1) != 1 || dup2(tty, 2) != 2) { - consolemsg("cannot redirect stdio (error %d)\n", errno); - exit(5); - } - close(tty); + int tty = open(argv[1], O_RDWR); + if (tty < 0) { + consolemsg("cannot open terminal %s\n", argv[1]); + exit(4); + } + + debug("redirecting stdio to %s\n", argv[1]); + close(0); close(1); close(2); /* close inherited stdio */ + if (dup2(tty, 0) != 0 || dup2(tty, 1) != 1 || dup2(tty, 2) != 2) { + consolemsg("cannot redirect stdio (error %d)\n", errno); + exit(5); + } + close(tty); } /* setup tty termios state*/ @@ -227,15 +226,15 @@ int main(int argc, char **argv) termios.c_lflag &= ~(IEXTEN | ECHOK | NOFLSH | ECHONL); termios.c_iflag |= BRKINT | ICRNL; termios.c_iflag &= ~(IGNBRK | IGNPAR | PARMRK | INPCK | ISTRIP | INLCR | IGNCR - | IXON | IXOFF | IXANY); + | IXON | IXOFF | IXANY); termios.c_oflag |= OPOST | ONLCR; termios.c_oflag &= ~XTABS; if (baud) termios.c_cflag = baud; termios.c_cflag &= ~PARENB; termios.c_cflag |= CS8 | CREAD | HUPCL; - termios.c_cflag |= CLOCAL; /* ignore modem control lines*/ - //termios.c_cflag |= CRTSCTS; /* hw flow control*/ + termios.c_cflag |= CLOCAL; /* ignore modem control lines*/ + //termios.c_cflag |= CRTSCTS; /* hw flow control*/ termios.c_cc[VMIN] = 1; termios.c_cc[VTIME] = 0; tcsetattr(STDIN_FILENO, TCSAFLUSH, &termios); @@ -243,135 +242,135 @@ int main(int argc, char **argv) fd = open(_PATH_ISSUE, O_RDONLY); if (fd >= 0) { - put('\n'); + put('\n'); #if !PARSE_ETC_ISSUE - while ((n=read(fd,Buffer,sizeof(Buffer))) > 0) - write(1,Buffer,n); + while ((n=read(fd,Buffer,sizeof(Buffer))) > 0) + write(1,Buffer,n); #else - char *ptr; - when(); - *Buffer = '\0'; - while (read(fd,Buffer,1) > 0) { - ch = *Buffer; - if (ch == '\\' || ch == '@') { - Buffer[1] = ch; - read(fd,Buffer+1,1); - } - switch (ch) { - case '\n': - put(ch); - break; - case '\\': - ch = Buffer[1]; - switch(ch) { - case '0': /* NUL */ - ch = 0; - case '\\': - case '@': - put(ch); - break; - case 'b': /* BS Backspace */ - put(8); - break; - case 'f': /* FF Formfeed */ - put(12); - break; - case 'n': /* LF Linefeed */ - put(10); - break; - case 's': /* SP Space */ - put(32); - break; - case 't': /* HT Tab */ - do { - put(' '); - } while (col & 7); - break; - case 'r': /* CR Return */ - ch=13; - default: /* Anything else */ - put('\\'); - put(ch); - break; - } - break; - case '@': - ch = Buffer[1]; - switch(ch) { - case '@': - put(ch); - break; - case 'B': /* Baud Rate */ - if (argc > 2) { - state(argv[2]); - state(" Baud"); - } else - state("Terminal"); - break; - case 'D': /* Date */ - state(Date); - break; - case 'H': /* Host */ - if (!(ptr = getenv("HOSTNAME"))) - ptr = "LocalHost"; - state(ptr); - break; - case 'L': /* Line used */ - ptr = rindex(argv[1],'/'); - if (ptr == NULL) - ptr = argv[1]; - state(ptr); - break; - case 'S': /* System */ - state("ELKS"); - break; - case 'T': /* Time */ - state(Time); - break; - case 'V': /* Version */ - state(ELKS_VERSION); - break; - default: - put('@'); - put(ch); - break; - } - break; - default: - put(ch); - break; - } - *Buffer = '\0'; - } + char *ptr; + when(); + *Buffer = '\0'; + while (read(fd,Buffer,1) > 0) { + ch = *Buffer; + if (ch == '\\' || ch == '@') { + Buffer[1] = ch; + read(fd,Buffer+1,1); + } + switch (ch) { + case '\n': + put(ch); + break; + case '\\': + ch = Buffer[1]; + switch(ch) { + case '0': /* NUL */ + ch = 0; + case '\\': + case '@': + put(ch); + break; + case 'b': /* BS Backspace */ + put(8); + break; + case 'f': /* FF Formfeed */ + put(12); + break; + case 'n': /* LF Linefeed */ + put(10); + break; + case 's': /* SP Space */ + put(32); + break; + case 't': /* HT Tab */ + do { + put(' '); + } while (col & 7); + break; + case 'r': /* CR Return */ + ch=13; + default: /* Anything else */ + put('\\'); + put(ch); + break; + } + break; + case '@': + ch = Buffer[1]; + switch(ch) { + case '@': + put(ch); + break; + case 'B': /* Baud Rate */ + if (argc > 2) { + state(argv[2]); + state(" Baud"); + } else + state("Terminal"); + break; + case 'D': /* Date */ + state(Date); + break; + case 'H': /* Host */ + if (!(ptr = getenv("HOSTNAME"))) + ptr = "LocalHost"; + state(ptr); + break; + case 'L': /* Line used */ + ptr = rindex(argv[1],'/'); + if (ptr == NULL) + ptr = argv[1]; + state(ptr); + break; + case 'S': /* System */ + state("ELKS"); + break; + case 'T': /* Time */ + state(Time); + break; + case 'V': /* Version */ + state(ELKS_VERSION); + break; + default: + put('@'); + put(ch); + break; + } + break; + default: + put(ch); + break; + } + *Buffer = '\0'; + } #endif - close(fd); + close(fd); } show_startup(); for (;;) { - state("login: "); - errno = 0; - n=read(STDIN_FILENO,Buffer,sizeof(Buffer)-1); - if (n < 1) { - debug("read fail on stdin, errno %d\n", errno); - if (errno == EINTR) - continue; - exit(1); - } - Buffer[n] = '\0'; - while (n > 0) - if (Buffer[--n] < ' ') - Buffer[n] = '\0'; - if (*Buffer) { - char *nargv[3]; - - debug("calling login: %s\n", Buffer); - nargv[0] = _PATH_LOGIN; - nargv[1] = Buffer; - nargv[2] = NULL; - execv(nargv[0], nargv); - debug("execv fail\n"); - exit(2); - } + state("login: "); + errno = 0; + n=read(STDIN_FILENO,Buffer,sizeof(Buffer)-1); + if (n < 1) { + debug("read fail on stdin, errno %d\n", errno); + if (errno == EINTR) + continue; + exit(1); + } + Buffer[n] = '\0'; + while (n > 0) + if (Buffer[--n] < ' ') + Buffer[n] = '\0'; + if (*Buffer) { + char *nargv[3]; + + debug("calling login: %s\n", Buffer); + nargv[0] = _PATH_LOGIN; + nargv[1] = Buffer; + nargv[2] = NULL; + execv(nargv[0], nargv); + debug("execv fail\n"); + exit(2); + } } } From 183cc6cff5d8f68ffe694d52919e060165c6b8e6 Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Mon, 14 Oct 2024 18:32:45 -0600 Subject: [PATCH 4/4] Turn off IODELAY --- elks/arch/i86/drivers/block/bios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elks/arch/i86/drivers/block/bios.c b/elks/arch/i86/drivers/block/bios.c index a00513004..b2e211130 100644 --- a/elks/arch/i86/drivers/block/bios.c +++ b/elks/arch/i86/drivers/block/bios.c @@ -18,7 +18,7 @@ #include "bioshd.h" #define RESET_DISK_CHG 1 /* =1 to reset BIOS on drive change fixes QEMU retry */ -#define IODELAY 1 /* emulate delay for floppy on QEMU */ +#define IODELAY 0 /* emulate delay for floppy on QEMU */ #define abs(v) (((int)(v) >= 0)? (v): -(v)) /*