/** * @fn kernel_main_loop * * @brief The heart of the RTOS, the main loop where the kernel is entered and exited. * * The complete function is: * * Loop *<ol><li>Select and dispatch a process to run</li> *<li>Exit the kernel (The loop is left and re-entered here.)</li> *<li>Handle the request from the process that was running.</li> *<li>End loop, go to 1.</li> *</ol> */ void kernel_main_loop(void) { for(;;) { kernel_dispatch(); exit_kernel(); /* if this task makes a system call, or is interrupted, * the thread of control will return to here. */ kernel_handle_request(); } }
void asmlinkage sysenter_handler_entry(struct context *context) { ulong num = context->esi; ulong param0 = context->edi; ulong param1 = context->eax; ulong param2 = context->edx; ulong ret_addr = 0; ulong ret_size = 0; int succeed = 0; int call_kernel = 1; if (num == SYSCALL_PING) { ret_addr = param0 + 1; succeed = 1; call_kernel = 0; } if (call_kernel) { struct kernel_dispatch_info kdispatch; kdispatch.context = context; kdispatch.dispatch_type = kdisp_syscall; kdispatch.syscall.num = num; kdispatch.syscall.param0 = param0; kdispatch.syscall.param1 = param1; kdispatch.syscall.param2 = param2; kernel_dispatch(&kdispatch); //kprintf("Syscall from user!\n"); } else { // Prepare return value context->eax = succeed; context->esi = ret_addr; context->edi = ret_size; } }