Exemple #1
0
/**
 * Once we're inside of idleproc_run(), we are executing in the context of the
 * first process-- a real context, so we can finally begin running
 * meaningful code.
 *
 * This is the body of process 0. It should initialize all that we didn't
 * already initialize in kmain(), launch the init process (initproc_run),
 * wait for the init process to exit, then halt the machine.
 *
 * @param arg1 the first argument (unused)
 * @param arg2 the second argument (unused)
 */
static void *
idleproc_run(int arg1, void *arg2)
{
        int status;
        pid_t child;

        /* create init proc */
        kthread_t *initthr = initproc_create();
        init_call_all();
        GDB_CALL_HOOK(initialized);

        /* Create other kernel threads (in order) */

#ifdef __VFS__
        /* Once you have VFS remember to set the current working directory
         * of the idle and init processes */
        NOT_YET_IMPLEMENTED("VFS: idleproc_run");

        /* Here you need to make the null, zero, and tty devices using mknod */
        /* You can't do this until you have VFS, check the include/drivers/dev.h
         * file for macros with the device ID's you will need to pass to mknod */
        NOT_YET_IMPLEMENTED("VFS: idleproc_run");
#endif

        /* Finally, enable interrupts (we want to make sure interrupts
         * are enabled AFTER all drivers are initialized) */
        intr_enable();

        /* Run initproc */
        sched_make_runnable(initthr);
        /* Now wait for it */
        child = do_waitpid(-1, 0, &status);
        KASSERT(PID_INIT == child);

#ifdef __MTP__
        kthread_reapd_shutdown();
#endif


#ifdef __SHADOWD__
        /* wait for shadowd to shutdown */
        shadowd_shutdown();
#endif

#ifdef __VFS__
        /* Shutdown the vfs: */
        dbg_print("weenix: vfs shutdown...\n");
        vput(curproc->p_cwd);
        if (vfs_shutdown())
                panic("vfs shutdown FAILED!!\n");

#endif

        /* Shutdown the pframe system */
#ifdef __S5FS__
        pframe_shutdown();
#endif

        dbg_print("\nweenix: halted cleanly!\n");
        GDB_CALL_HOOK(shutdown);
        hard_shutdown();
        return NULL;
}
Exemple #2
0
/**
 * Once we're inside of idleproc_run(), we are executing in the context of the
 * first process-- a real context, so we can finally begin running
 * meaningful code.
 *
 * This is the body of process 0. It should initialize all that we didn't
 * already initialize in kmain(), launch the init process (initproc_run),
 * wait for the init process to exit, then halt the machine.
 *
 * @param arg1 the first argument (unused)
 * @param arg2 the second argument (unused)
 */
static void *
idleproc_run(int arg1, void *arg2)
{
        int status;
        pid_t child;

        /* create init proc */
        kthread_t *initthr = initproc_create();
        init_call_all();
        GDB_CALL_HOOK(initialized);

        /* Create other kernel threads (in order) */
        /* PROCS BLANK {{{ */
#ifdef __SHADOWD__
        /* TODO port this - alvin */
#endif
        /* PROCS BLANK }}} */

#ifdef __VFS__
        /* Once you have VFS remember to set the current working directory
         * of the idle and init processes */
        /* PROCS BLANK {{{ */
        proc_t *idle = proc_lookup(PID_IDLE);
        proc_t *init = proc_lookup(PID_INIT);
        KASSERT(NULL != idle);
        KASSERT(NULL != init);
        idle->p_cwd = vfs_root_vn;
        init->p_cwd = vfs_root_vn;
        vref(vfs_root_vn);
        vref(vfs_root_vn);
        /* PROCS BLANK }}} */

        /* Here you need to make the null, zero, and tty devices using mknod */
        /* You can't do this until you have VFS, check the include/drivers/dev.h
         * file for macros with the device ID's you will need to pass to mknod */
        /* PROCS BLANK {{{ */
        int fd, ii;
        char path[32];

        struct stat statbuf;
        if (do_stat("/dev", &statbuf) < 0) {
                KASSERT(!(status = do_mkdir("/dev")));
        }
        if ((fd = do_open("/dev/null", O_RDONLY)) < 0) {
                KASSERT(!(status = do_mknod("/dev/null", S_IFCHR, MEM_NULL_DEVID)));
        } else {
                do_close(fd);
        }
        if ((fd = do_open("/dev/zero", O_RDONLY)) < 0) {
                KASSERT(!(status = do_mknod("/dev/zero", S_IFCHR, MEM_ZERO_DEVID)));
        } else {
                do_close(fd);
        }

        memset(path, '\0', 32);
        for (ii = 0; ii < __NTERMS__; ii++) {
                sprintf(path, "/dev/tty%d", ii);
                dbg(DBG_INIT, "Creating tty mknod with path %s\n", path);
                if ((fd = do_open(path, O_RDONLY)) < 0) {
                        KASSERT(!do_mknod(path, S_IFCHR, MKDEVID(2, ii)));
                } else {
                        do_close(fd);
                }
        }

        for (ii = 0; ii < __NDISKS__; ii++) {
                sprintf(path, "/dev/hda%d", ii);
                dbg(DBG_INIT, "Creating disk mknod with path %s\n", path);
                if ((fd = do_open(path, O_RDONLY)) < 0) {
                        KASSERT(!do_mknod(path, S_IFBLK, MKDEVID(1, ii)));
                } else {
                        do_close(fd);
                }
        }
        /* PROCS BLANK }}} */
#endif

        /* Finally, enable interrupts (we want to make sure interrupts
         * are enabled AFTER all drivers are initialized) */
        intr_enable();

        /* Run initproc */
        sched_make_runnable(initthr);
        /* Now wait for it */
        child = do_waitpid(-1, 0, &status);
        KASSERT(PID_INIT == child);

#ifdef __MTP__
        kthread_reapd_shutdown();
#endif


#ifdef __SHADOWD__
        /* wait for shadowd to shutdown */
        shadowd_shutdown();
#endif

#ifdef __VFS__
        /* Shutdown the vfs: */
        dbg_print("weenix: vfs shutdown...\n");
        vput(curproc->p_cwd);
        if (vfs_shutdown())
                panic("vfs shutdown FAILED!!\n");

#endif

        /* Shutdown the pframe system */
#ifdef __S5FS__
        pframe_shutdown();
#endif

        dbg_print("\nweenix: halted cleanly!\n");
        GDB_CALL_HOOK(shutdown);
        hard_shutdown();
        return NULL;
}