Kernel: Minor improvements to prompting for boot device number, no
authorWill Sowerbutts <will@sowerbutts.com>
Mon, 29 Dec 2014 21:43:11 +0000 (21:43 +0000)
committerWill Sowerbutts <will@sowerbutts.com>
Mon, 29 Dec 2014 21:44:22 +0000 (21:44 +0000)
longer tries to parse junk left in the command line buffer at 0x0081.

Kernel/include/kernel.h
Kernel/kdata.c
Kernel/start.c

index 3e59bd1..47dbf87 100644 (file)
@@ -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
index 3621f70..c85cbc5 100644 (file)
@@ -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;
index f816cb3..3bda51d 100644 (file)
@@ -4,6 +4,8 @@
 #include <printf.h>
 #include <tty.h>
 
+#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 */