void execute_kernel(struct multiboot_info* boot_info, struct kernel_info* k_info) { IMAGE_DOS_HEADER* pImage = (IMAGE_DOS_HEADER*)KERNEL_BASE_VIRT; IMAGE_NT_HEADERS* pHeaders = (IMAGE_NT_HEADERS*)(KERNEL_BASE_VIRT + pImage->e_lfanew); uint32 base = pHeaders->OptionalHeader.ImageBase; uint32 entryPoint = pHeaders->OptionalHeader.AddressOfEntryPoint; void(*entryFunction) (struct multiboot_info*, uint32) = (entryPoint + base); entryFunction(boot_info, k_info); }
LOCAL void threadStart(ThreadStartInfo *startInfo) { int niceLevel; void (*entryFunction)(void*); void *userData; assert(startInfo != NULL); niceLevel = startInfo->niceLevel; entryFunction = startInfo->entryFunction; userData = startInfo->userData; sem_post(&startInfo->lock); if (nice(niceLevel) == -1) { // ignore error } assert(entryFunction != NULL); entryFunction(userData); }