From: Will Sowerbutts Date: Mon, 29 Dec 2014 21:43:11 +0000 (+0000) Subject: Kernel: Minor improvements to prompting for boot device number, no X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=a9f57dc8eabc9ce457c7e82b26e365fad94abfaa;p=FUZIX.git Kernel: Minor improvements to prompting for boot device number, no longer tries to parse junk left in the command line buffer at 0x0081. --- diff --git a/Kernel/include/kernel.h b/Kernel/include/kernel.h index 3e59bd19..47dbf871 100644 --- a/Kernel/include/kernel.h +++ b/Kernel/include/kernel.h @@ -15,10 +15,6 @@ From UZI by Doug Braun and UZI280 by Stefan Nitschke. #include "config.h" #include "cpu.h" -#ifndef DEFAULT_ROOT -#define DEFAULT_ROOT 0 -#endif - #ifndef NULL #define NULL (void *)0 #endif diff --git a/Kernel/kdata.c b/Kernel/kdata.c index 3621f70f..c85cbc5f 100644 --- a/Kernel/kdata.c +++ b/Kernel/kdata.c @@ -8,7 +8,7 @@ char bootline[BOOTLINE_LEN]; uint16_t ramsize, procmem, maxproc, nproc, nready; uint16_t runticks; bool inint; -uint16_t root_dev = DEFAULT_ROOT; +uint16_t root_dev; uint8_t ticks_this_dsecond; inoptr root; uint16_t waitno; diff --git a/Kernel/start.c b/Kernel/start.c index f816cb30..3bda51de 100644 --- a/Kernel/start.c +++ b/Kernel/start.c @@ -4,6 +4,8 @@ #include #include +#define BAD_ROOT_DEV 0xFFFF + /* * Put nothing here that cannot be discarded. We will eventually * make the entire of this disappear after the initial _execve @@ -73,19 +75,21 @@ void create_init(void) /* to sensibly parse device names this needs to be platform-specific, so for now it only parses device numbers */ -unsigned int bootdevice(char *s) +uint16_t bootdevice(char *s) { unsigned int r = 0; + /* skip spaces */ while(*s == ' ') s++; while(true){ if(*s >= '0' && *s <= '9'){ r = (r*10) + (*s - '0'); - }else{ + }else if(*s == '\r' || *s == '\n' || *s == 0){ return r; - } + }else + return BAD_ROOT_DEV; s++; } } @@ -142,10 +146,11 @@ void fuzix_main(void) /* initialise hardware devices */ device_init(); - root_dev = DEFAULT_ROOT; - if (cmdline && *cmdline) { + root_dev = BAD_ROOT_DEV; + if (cmdline && *cmdline) root_dev = bootdevice(cmdline); - } else { + + while(root_dev == BAD_ROOT_DEV){ kputs("bootdev: "); udata.u_base = bootline; udata.u_sysio = 1; @@ -154,7 +159,7 @@ void fuzix_main(void) memset(bootline, 0, BOOTLINE_LEN); cdread(TTYDEV, O_RDONLY); /* read root filesystem name from tty */ - root_dev = bootdevice(bootline); + root_dev = bootdevice(bootline); } /* Mount the root device */