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;
#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
/* 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++;
}
}
/* 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;
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 */