/** Raise an internal error. * @param fmt Error format string. * @param ... Values to substitute into format. */ void __noreturn internal_error(const char *fmt, ...) { va_list args; printf("Internal Error: "); va_start(args, fmt); vprintf(fmt, args); va_end(args); printf("\n"); while (true) arch_pause(); }
void wait_for_APs_to_finish_booting(void) { unsigned n = 0; int i; /* check how many cpus are actually alive */ for (i = 0 ; i < ncpus ; i++) { if (cpu_test_flag(i, CPU_IS_READY)) n++; } if (n != ncpus) printf("WARNING only %d out of %d cpus booted\n", n, ncpus); /* we must let the other CPUs to run in kernel mode first */ BKL_UNLOCK(); while (ap_cpus_booted != (n - 1)) arch_pause(); /* now we have to take the lock again as we continue execution */ BKL_LOCK(); }
/** Entry point of the test kernel. * @param magic KBoot magic number. * @param tags Tag list pointer. */ void kmain(uint32_t magic, kboot_tag_t *tags) { debug_console_init(); if (magic != KBOOT_MAGIC) { printf("Incorrect magic number 0x%x\n", magic); while (true) arch_pause(); } mm_init(tags); primary_console_init(tags); printf("Test kernel loaded: magic: 0x%x, tags: %p\n", magic, tags); while (tags->type != KBOOT_TAG_NONE) { switch (tags->type) { case KBOOT_TAG_CORE: dump_core_tag((kboot_tag_core_t *)tags); break; case KBOOT_TAG_OPTION: dump_option_tag((kboot_tag_option_t *)tags); break; case KBOOT_TAG_MEMORY: dump_memory_tag((kboot_tag_memory_t *)tags); break; case KBOOT_TAG_VMEM: dump_vmem_tag((kboot_tag_vmem_t *)tags); break; case KBOOT_TAG_PAGETABLES: dump_pagetables_tag((kboot_tag_pagetables_t *)tags); break; case KBOOT_TAG_MODULE: dump_module_tag((kboot_tag_module_t *)tags); break; case KBOOT_TAG_VIDEO: dump_video_tag((kboot_tag_video_t *)tags); break; case KBOOT_TAG_BOOTDEV: dump_bootdev_tag((kboot_tag_bootdev_t *)tags); break; case KBOOT_TAG_LOG: dump_log_tag((kboot_tag_log_t *)tags); break; case KBOOT_TAG_SECTIONS: dump_sections_tag((kboot_tag_sections_t *)tags); break; case KBOOT_TAG_BIOS_E820: dump_bios_e820_tag((kboot_tag_bios_e820_t *)tags); break; case KBOOT_TAG_EFI: dump_efi_tag((kboot_tag_efi_t *)tags); break; } tags = (kboot_tag_t *)round_up((ptr_t)tags + tags->size, 8); } printf("Tag list dump complete\n"); #if defined(__i386__) || defined(__x86_64__) __asm__ volatile("wbinvd"); #endif while (true) arch_pause(); }