/* * kmain * * This is the first thing that executes when the kernel starts. Any * initialisation e.g. interrupt handlers must be done at the start of * the function. This function should never return. */ void kmain(multiboot * mb) { setup_segmentation(); setup_interrupts(); kmalloc_init(); /* * Clear the screen */ unsigned int x; unsigned int y; for (y = 0; y < SCREEN_HEIGHT; y++) for (x = 0; x < SCREEN_WIDTH; x++) screen[y * SCREEN_WIDTH + x].c = ' '; /* * Place the cursor on line 0 to start with */ move_cursor(xpos, ypos); kprintf("%s\n%s\n%s\n\n\n\n", VERSION, COPYRIGHT, DISCLAIMER); assert(1 == mb->mods_count); assert(mb->mods_addr[0].mod_end < 2 * MB); filesystem = (char *)mb->mods_addr[0].mod_start; /* * Check here for the size of the RAM disk. Because we use a * hard-coded value of 2MB for the start of the kernel's private * data area, we can't safely work with filesystems that extend * into this area. This is really just a hack to avoid the * additional complexity of computing the right place to start * the kernel and page memory regions, but suffices for our * purposes. */ if (mb->mods_addr[0].mod_end >= 2 * MB) assert (!"Filesystem goes beyond 2Mb limit. Please use smaller filesystem."); pid_t pid = start_process(launch_shell); input_pipe = processes[pid].filedesc[STDIN_FILENO]->p; /* * Go in to user mode and enable interrupts */ enter_user_mode(); /* * Loop indenitely... we should never return from this function */ /* * Pretty soon a context switch will occur, and the processor * will jump out of this loop and start executing the first * scheduled process */ while (1) ; }
* @brief kernel main * * @author * * * @date */ #include <kernel.h> #include <task.h> #include <sched.h> #include <device.h> #include <assert.h> uint32_t global_data; int kmain(int argc __attribute__((unused)), char** argv __attribute__((unused)), uint32_t table) { app_startup(); global_data = table; /* add your code up to assert statement */ int d; setup(); /* Call function at 0xA0000000 */ d = enter_user_mode(); //restore(); assert(0); /* should never get here */ }