uint16_t get_root_dev(void) { uint16_t rd = BAD_ROOT_DEV; if (cmdline && *cmdline) rd = bootdevice(cmdline); while(rd == BAD_ROOT_DEV){ kputs("bootdev: "); udata.u_base = (uint8_t *)bootline; udata.u_sysio = 1; udata.u_count = sizeof(bootline)-1; udata.u_euid = 0; /* Always begin as superuser */ cdread(TTYDEV, O_RDONLY); /* read root filesystem name from tty */ rd = bootdevice(bootline); } return rd; }
void fuzix_main(void) { /* setup state */ inint = false; udata.u_insys = true; ramtop = PROGTOP; tty_init(); if (d_open(TTYDEV, 0) != 0) panic("no tty"); /* Sign on messages (stashed in a buffer so we can bin them */ kprintf((char *)bufpool[0].bf_data, uname_str); #ifndef SWAPDEV #ifdef PROC_SIZE maxproc = procmem / PROC_SIZE; /* Check we don't exceed the process table size limit */ if (maxproc > PTABSIZE) { kprintf((char *)bufpool[1].bf_data, maxproc); maxproc = PTABSIZE; } #else maxproc = PTABSIZE; #endif #else maxproc = PTABSIZE; #endif /* Parameters message */ kprintf((char *)bufpool[2].bf_data, ramsize, procmem, maxproc); /* Now blow away the strings */ bufinit(); pagemap_init(); create_init(); kprintf("%x:%x\n", udata.u_page, udata.u_page2); kprintf("%x:%x\n", udata.u_ptab->p_page, udata.u_ptab->p_page2); kputs("Enabling interrupts ... "); ei(); kputs("ok.\n"); /* initialise hardware devices */ device_init(); root_dev = DEFAULT_ROOT; if (cmdline && *cmdline) { while (*cmdline == ' ') ++cmdline; root_dev = *cmdline - '0'; } else { kputs("bootdev: "); udata.u_base = bootline; udata.u_sysio = 1; udata.u_count = 2; udata.u_euid = 0; /* Always begin as superuser */ cdread(TTYDEV, O_RDONLY); /* read root filesystem name from tty */ if (*bootline >= '0') root_dev = *bootline - '0'; } /* Mount the root device */ kprintf("Mounting root fs (root_dev=%d): ", root_dev); if (fmount(root_dev, NULLINODE, 0)) panic("no filesys"); root = i_open(root_dev, ROOTINODE); if (!root) panic("no root"); kputs("OK\n"); i_ref(udata.u_cwd = root); i_ref(udata.u_root = root); rdtime32(&udata.u_time); exec_or_die(); }