/** * This function is called from kmain, however it is not running in a * thread context yet. It should create the idle process which will * start executing idleproc_run() in a real thread context. To start * executing in the new process's context call context_make_active(), * passing in the appropriate context. This function should _NOT_ * return. * * Note: Don't forget to set curproc and curthr appropriately. * * @param arg1 the first argument (unused) * @param arg2 the second argument (unused) */ static void * bootstrap(int arg1, void *arg2) { /* necessary to finalize page table information */ dbg(DBG_INIT, "\nBOOTSTRAP: INSIDE BOOTSTRAP\n"); pt_template_init(); proc_t* process0=proc_create("Idle_Process"); kthread_t* thread0=kthread_create(process0,idleproc_run,1,(void*)1); curproc=process0; curthr=thread0; KASSERT(NULL != curproc); /* make sure that the "idle" process has been created successfully */ dbg(DBG_INIT,"(GRADING1 1.a) Idle Process Created Successfully\n"); KASSERT(PID_IDLE == curproc->p_pid); /* make sure that what has been created is the "idle" process */ dbg(DBG_INIT,"(GRADING1 1.a) Idle Process's pid assigned properly\n"); KASSERT(NULL != curthr); /* make sure that the thread for the "idle" process has been created successfully */ dbg(DBG_INIT,"(GRADING1 1.a) Thread for idle process created successfully\n"); /* dbg(DBG_INIT, "\nBOOTSTRAP: MOVING FROM BOOTSTRAP TO IDLEPROC_RUN\n");*/ /*sched_make_runnable(curthr); */ context_make_active(&thread0->kt_ctx); return 0; }
/** * This function is called from kmain, however it is not running in a * thread context yet. It should create the idle process which will * start executing idleproc_run() in a real thread context. To start * executing in the new process's context call context_make_active(), * passing in the appropriate context. This function should _NOT_ * return. * * Note: Don't forget to set curproc and curthr appropriately. * * @param arg1 the first argument (unused) * @param arg2 the second argument (unused) */ static void * bootstrap(int arg1, void *arg2) { dbg(DBG_PRINT,"*****************************************Entering bootstrap\n"); /* If the next line is removed/altered in your submission, 20 points will be deducted. */ dbgq(DBG_CORE, "SIGNATURE: 53616c7465645f5fd0f5f4e9adc70694ad12fcfaae6423bd5d01ca122cf44b611898d35ebf9b3fab4a0fbdefab9ecc12\n"); /* necessary to finalize page table information */ /*Cody Modifying*/ pt_template_init(); proc_t *p=proc_create("idle"); kthread_t *t=kthread_create(p,idleproc_run,NULL,NULL); curproc=p; curthr=t; KASSERT(NULL!=curproc); dbg(DBG_PRINT,"(GRADING1A 1.a)\n"); KASSERT(PID_IDLE == curproc->p_pid); dbg(DBG_PRINT,"(GRADING1A 1.a)\n"); KASSERT(NULL != curthr); dbg(DBG_PRINT,"(GRADING1A 1.a)\n"); context_make_active(&curthr->kt_ctx); /* NOT_YET_IMPLEMENTED("PROCS: bootstrap");*/ /*panic("weenix returned to bootstrap()!!! BAD!!!\n");*/ dbg(DBG_PRINT,"*****************************************Leaving bootstrap\n"); return NULL; }
/** * This is the first real C function ever called. It performs a lot of * hardware-specific initialization, then creates a pseudo-context to * execute the bootstrap function in. */ void kmain() { GDB_CALL_HOOK(boot); dbg_init(); dbgq(DBG_CORE, "Kernel binary:\n"); dbgq(DBG_CORE, " text: 0x%p-0x%p\n", &kernel_start_text, &kernel_end_text); dbgq(DBG_CORE, " data: 0x%p-0x%p\n", &kernel_start_data, &kernel_end_data); dbgq(DBG_CORE, " bss: 0x%p-0x%p\n", &kernel_start_bss, &kernel_end_bss); page_init(); pt_init(); slab_init(); pframe_init(); acpi_init(); apic_init(); pci_init(); intr_init(); gdt_init(); /* initialize slab allocators */ #ifdef __VM__ anon_init(); shadow_init(); #endif vmmap_init(); proc_init(); kthread_init(); #ifdef __DRIVERS__ bytedev_init(); blockdev_init(); #endif void *bstack = page_alloc(); pagedir_t *bpdir = pt_get(); KASSERT(NULL != bstack && "Ran out of memory while booting."); context_setup(&bootstrap_context, bootstrap, 0, NULL, bstack, PAGE_SIZE, bpdir); context_make_active(&bootstrap_context); panic("\nReturned to kmain()!!!\n"); }
/** * This function is called from kmain, however it is not running in a * thread context yet. It should create the idle process which will * start executing idleproc_run() in a real thread context. To start * executing in the new process's context call context_make_active(), * passing in the appropriate context. This function should _NOT_ * return. * * Note: Don't forget to set curproc and curthr appropriately. * * @param arg1 the first argument (unused) * @param arg2 the second argument (unused) */ static void *bootstrap(int arg1, void *arg2) { /* necessary to finalize page table information */ pt_template_init(); char name[]="IDLE"; curproc=proc_create(name); KASSERT(curproc != NULL && "Could not create Idle process"); /* make sure that the "idle" process has been created successfully */ KASSERT(curproc->p_pid == PID_IDLE); KASSERT(PID_IDLE == curproc->p_pid && "Process created is not Idle"); curthr=kthread_create(curproc,idleproc_run,arg1,arg2); KASSERT(curthr != NULL && "Could not create thread for Idle process"); context_make_active(&(curthr->kt_ctx)); NOT_YET_IMPLEMENTED("PROCS: bootstrap"); panic("weenix returned to bootstrap()!!! BAD!!!\n"); return NULL; }
/** * This function is called from kmain, however it is not running in a * thread context yet. It should create the idle process which will * start executing idleproc_run() in a real thread context. To start * executing in the new process's context call context_make_active(), * passing in the appropriate context. This function should _NOT_ * return. * * Note: Don't forget to set curproc and curthr appropriately. * * @param arg1 the first argument (unused) * @param arg2 the second argument (unused) */ static void * bootstrap(int arg1, void *arg2) { /* necessary to finalize page table information */ pt_template_init(); /* Create idle process and idle thread */ curproc = proc_create("idle"); curthr = kthread_create(curproc, (kthread_func_t) idleproc_run, NULL, NULL); dbg_print("Created idle proc and thread\n"); /* Make idle thread the active context */ context_make_active(&curthr->kt_ctx); /* NOT_YET_IMPLEMENTED("PROCS: bootstrap"); */ panic("weenix returned to bootstrap()!!! BAD!!!\n"); return NULL; }
/** * This function is called from kmain, however it is not running in a * thread context yet. It should create the idle process which will * start executing idleproc_run() in a real thread context. To start * executing in the new process's context call context_make_active(), * passing in the appropriate context. This function should _NOT_ * return. * * Note: Don't forget to set curproc and curthr appropriately. * * @param arg1 the first argument (unused) * @param arg2 the second argument (unused) */ static void * bootstrap(int arg1, void *arg2) { /* If the next line is removed/altered in your submission, 20 points will be deducted. */ dbgq(DBG_CORE, "SIGNATURE: 53616c7465645f5f75d4d6807cbe46557c5894883e55a7be357a5954568eccfc0c1d901bcc73a4409c500b4c2ad2554d\n"); /* necessary to finalize page table information */ pt_template_init(); curproc = proc_create("IDLE"); /* Creating idle process */ KASSERT(NULL != curproc); dbg(DBG_PRINT," (GRADING1A 1.a) successfully created IDLE process with process id %d\n",curproc->p_pid); KASSERT(PID_IDLE == curproc->p_pid); dbg(DBG_PRINT," (GRADING1A 1.a) PID_IDLE value is %d and it matches with the idle process id %d\n",PID_IDLE,curproc->p_pid); curthr = kthread_create(curproc,idleproc_run,0,NULL); /*running idleproc run*/ KASSERT(NULL != curthr); dbg(DBG_PRINT," (GRADING1A 1.a) thread for the idle process has been created successfully!!\n"); context_make_active(&curthr->kt_ctx); /*NOT_YET_IMPLEMENTED("PROCS: do_waitpid");*/ panic("weenix returned to bootstrap()!!! BAD!!!\n"); return NULL; }
/** * This function is called from kmain, however it is not running in a * thread context yet. It should create the idle process which will * start executing idleproc_run() in a real thread context. To start * executing in the new process's context call context_make_active(), * passing in the appropriate context. This function should _NOT_ * return. * * Note: Don't forget to set curproc and curthr appropriately. * * @param arg1 the first argument (unused) * @param arg2 the second argument (unused) */ static void * bootstrap(int arg1, void *arg2) { /* necessary to finalize page table information */ pt_template_init(); /* PROCS {{{ */ /* Set up our initial process and jump into it */ curproc = proc_create("idle"); KASSERT(NULL != curproc); KASSERT(PID_IDLE == curproc->p_pid); curthr = kthread_create(curproc, idleproc_run, 0, NULL); KASSERT(NULL != curthr); dbg(DBG_INIT, "Starting idle proc\n"); context_make_active(&curthr->kt_ctx); /* PROCS }}} */ panic("weenix returned to bootstrap()!!! BAD!!!\n"); return NULL; }
/** * This function is called from kmain, however it is not running in a * thread context yet. It should create the idle process which will * start executing idleproc_run() in a real thread context. To start * executing in the new process's context call context_make_active(), * passing in the appropriate context. This function should _NOT_ * return. * * Note: Don't forget to set curproc and curthr appropriately. * * @param arg1 the first argument (unused) * @param arg2 the second argument (unused) */ static void * bootstrap(int arg1, void *arg2) { dbg(DBG_CORE, "bootstrapping\n"); /* necessary to finalize page table information */ pt_template_init(); /* Create a process with pid 0 */ proc_t *p = proc_create("process 0"); kthread_t *kt = kthread_create(p, idleproc_run, arg1, arg2); KASSERT(p && (p->p_pid == 0)); KASSERT(kt); curproc = p; curthr = kt; context_make_active(&kt->kt_ctx); panic("weenix returned to bootstrap()!!! BAD!!!\n"); return NULL; }
/** * This function is called from kmain, however it is not running in a * thread context yet. It should create the idle process which will * start executing idleproc_run() in a real thread context. To start * executing in the new process's context call context_make_active(), * passing in the appropriate context. This function should _NOT_ * return. * * Note: Don't forget to set curproc and curthr appropriately. * * @param arg1 the first argument (unused) * @param arg2 the second argument (unused) */ static void * bootstrap(int arg1, void *arg2) { /* necessary to finalize page table information */ dbg(DBG_PROC, "Function: bootstrap\n"); pt_template_init(); /*NOT_YET_IMPLEMENTED("PROCS: bootstrap");*/ proc_t *p_idle=proc_create("Idle procss"); curproc=p_idle; KASSERT(NULL != curproc); dbg(DBG_PRINT,"GRADING1A 1.a-1\n"); KASSERT(PID_IDLE == curproc->p_pid); dbg(DBG_PRINT,"GRADING1A 1.a-2\n"); kthread_t *thr_idle=kthread_create(p_idle,idleproc_run,0,NULL); curthr=thr_idle; KASSERT(NULL != curthr); dbg(DBG_PRINT,"GRADING1A 1.a-3\n"); context_make_active(&curthr->kt_ctx); /*panic("weenix returned to bootstrap()!!! BAD!!!\n");*/ return NULL; }
/** * This function is called from kmain, however it is not running in a * thread context yet. It should create the idle process which will * start executing idleproc_run() in a real thread context. To start * executing in the new process's context call context_make_active(), * passing in the appropriate context. This function should _NOT_ * return. * * Note: Don't forget to set curproc and curthr appropriately. * * @param arg1 the first argument (unused) * @param arg2 the second argument (unused) */ static void * bootstrap(int arg1, void *arg2) { /* necessary to finalize page table information */ pt_template_init(); curproc = proc_create("idle"); KASSERT(NULL != curproc); /* make sure that the "idle" process has been created successfully */ dbg(DBG_PRINT, "(GRADING1A 1.a)\n"); KASSERT(PID_IDLE == curproc->p_pid); /* make sure that what has been created is the "idle" process */ dbg(DBG_PRINT, "(GRADING1A 1.a)\n"); curthr = kthread_create(curproc, idleproc_run, arg1, arg2); KASSERT(NULL != curthr); /* make sure that the thread for the "idle" process has been created successfully */ dbg(DBG_PRINT, "(GRADING1A 1.a)\n"); context_make_active(&curthr->kt_ctx); /* NOT_YET_IMPLEMENTED("PROCS: bootstrap"); */ panic("weenix returned to bootstrap()!!! BAD!!!\n"); return NULL; }
/** * This is the first real C function ever called. It performs a lot of * hardware-specific initialization, then creates a pseudo-context to * execute the bootstrap function in. */ void kmain() { GDB_CALL_HOOK(boot); dbg_init(); dbgq(DBG_CORE, "Kernel binary:\n"); dbgq(DBG_CORE, " text: 0x%p-0x%p\n", &kernel_start_text, &kernel_end_text); dbgq(DBG_CORE, " data: 0x%p-0x%p\n", &kernel_start_data, &kernel_end_data); dbgq(DBG_CORE, " bss: 0x%p-0x%p\n", &kernel_start_bss, &kernel_end_bss); page_init(); pt_init(); slab_init(); pframe_init(); acpi_init(); apic_init(); pci_init(); intr_init(); gdt_init(); /* initialize slab allocators */ #ifdef __VM__ anon_init(); shadow_init(); #endif vmmap_init(); proc_init(); kthread_init(); #ifdef __DRIVERS__ bytedev_init(); blockdev_init(); #endif void *bstack = page_alloc(); pagedir_t *bpdir = pt_get(); KASSERT(NULL != bstack && "Ran out of memory while booting."); /* This little loop gives gdb a place to synch up with weenix. In the * past the weenix command started qemu was started with -S which * allowed gdb to connect and start before the boot loader ran, but * since then a bug has appeared where breakpoints fail if gdb connects * before the boot loader runs. See * * https://bugs.launchpad.net/qemu/+bug/526653 * * This loop (along with an additional command in init.gdb setting * gdb_wait to 0) sticks weenix at a known place so gdb can join a * running weenix, set gdb_wait to zero and catch the breakpoint in * bootstrap below. See Config.mk for how to set GDBWAIT correctly. * * DANGER: if GDBWAIT != 0, and gdb is not running, this loop will never * exit and weenix will not run. Make SURE the GDBWAIT is set the way * you expect. */ while (gdb_wait) ; context_setup(&bootstrap_context, bootstrap, 0, NULL, bstack, PAGE_SIZE, bpdir); context_make_active(&bootstrap_context); panic("\nReturned to kmain()!!!\n"); }