BOOT_CODE bool_t init_cpu( bool_t mask_legacy_irqs ) { /* initialise CPU's descriptor table registers (GDTR, IDTR, LDTR, TR) */ init_dtrs(); /* initialise MSRs (needs an initialised TSS) */ init_sysenter_msrs(); /* setup additional PAT MSR */ if (!init_pat_msr()) { return false; } /* initialise floating-point unit */ Arch_initFpu(); /* initialise local APIC */ if (!apic_init(mask_legacy_irqs)) { return false; } #ifdef CONFIG_DEBUG_DISABLE_PREFETCHERS if (!disablePrefetchers()) { return false; } #endif return true; }
BOOT_CODE bool_t init_node_cpu( uint32_t apic_khz, bool_t mask_legacy_irqs ) { /* initialise CPU's descriptor table registers (GDTR, IDTR, LDTR, TR) */ init_dtrs(); /* initialise MSRs (needs an initialised TSS) */ init_sysenter_msrs(); /* setup additional PAT MSR */ if (!init_pat_msr()) { return false; } /* initialise floating-point unit */ Arch_initFpu(); /* initialise local APIC */ if (!apic_init(apic_khz, mask_legacy_irqs)) { return false; } return true; }
status_t arch_int_init_post_vm(kernel_args* args) { // Always init the local apic as it can be used for timers even if we // don't end up using the io apic apic_init(args); return B_OK; }
int __init arch_host_irq_init(void) { #if CONFIG_LOCAL_APIC apic_init(); #endif return VMM_OK; }
BOOT_CODE bool_t init_cpu( bool_t mask_legacy_irqs ) { /* initialise virtual-memory-related data structures */ if (!init_vm_state()) { return false; } /* initialise CPU's descriptor table registers (GDTR, IDTR, LDTR, TR) */ init_dtrs(); if (config_set(CONFIG_SYSENTER)) { /* initialise MSRs (needs an initialised TSS) */ init_sysenter_msrs(); } else if (config_set(CONFIG_SYSCALL)) { init_syscall_msrs(); } else { return false; } /* setup additional PAT MSR */ if (!init_pat_msr()) { return false; } #ifdef CONFIG_HARDWARE_DEBUG_API /* Initialize hardware breakpoints */ Arch_initHardwareBreakpoints(); #endif /* initialise floating-point unit */ if (!Arch_initFpu()) { return false; } /* initialise local APIC */ if (!apic_init(mask_legacy_irqs)) { return false; } #ifdef CONFIG_DEBUG_DISABLE_PREFETCHERS if (!disablePrefetchers()) { return false; } #endif #ifdef CONFIG_VTX /* initialise Intel VT-x extensions */ if (!vtx_init()) { return false; } #endif return true; }
void arch_init() { i8042_init(); if (apic_is_available()) { apic_init(); } else { // pic_init(); // pit_init(); } }
void interrupt_init() { int i; init_idt(); apic_init(); for (i = 0; i < IDT_MAX_DESCS; i++) { tw_memset(&(handlers[i]), 0, sizeof(intr_handler_s)); } }
void x86_init() { gdt_install(); idt_install(); isrs_install(); apic_init(); /* apic */ irq_install(); console_init(); timer_install(); init_keyboard(); }
int main(int argc, char **argv) { printf("%s: HelenOS APIC driver\n", NAME); if (!apic_init()) return -1; printf("%s: Accepting connections\n", NAME); task_retval(0); async_manager(); /* Never reached */ return 0; }
void kernel_entry (multiboot_info* bootinfo) { clear_screen(); puts("Kernel loaded.\n"); gdt_install(); puts("GDT initialised.\n"); idt_install(); puts("IDT initialised.\n"); memman_init(bootinfo); kheap_init(); fat32_init(); // TODO: figure out how to do it safely //acpi_init(); apic_init(); ioapic_init(); // keyboard only for now register_handler(0x21, keyboard_handler); register_handler(0xD, gpf_handler); syscalls_init(); // maybe syscalls_init() like acpi_init, apic_init, etc... there should be common naming timer_init(0x20, 0x002fffff, 0xB, 1); // vector, counter, divider, periodic -- check manual before using // sets up kernel task and registers handler for timer scheduler_init(); // registers locking sys monitor_init(); keyboard_init(); // testing scheduler if (fork_kernel() == 0) { if (!exec("SHELL")) { // something horrible happend // exit() } exit(); } else { for(;;) { asm volatile("hlt"); } } asm ("sti"); // release monsters, it can be set earlier, but fails horribly if set before acpi_init for(;;); }
static CPUState *pc_new_cpu(const char *cpu_model) { CPUState *env; env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find x86 CPU definition\n"); exit(1); } if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) { env->cpuid_apic_id = env->cpu_index; env->apic_state = apic_init(env, env->cpuid_apic_id); } qemu_register_reset(pc_cpu_reset, env); pc_cpu_reset(env); return env; }
/** * 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"); }
int start_main(void) { extern int main(int argc, char **argv); /* Gather system information. */ lib_get_sysinfo(); /* Optionally set up the consoles. */ #if !CONFIG(LP_SKIP_CONSOLE_INIT) console_init(); #endif exception_init(); if (CONFIG(LP_ENABLE_APIC)) { apic_init(); enable_interrupts(); } /* * Any other system init that has to happen before the * user gets control goes here. */ /* * Go to the entry point. * In the future we may care about the return value. */ /* * Returning from main() will go to the _leave function to return * us to the original context. */ return main(main_argc, (main_argc != 0) ? main_argv : NULL); }
/* * Bootstrap-CPU start; we came from head.S */ void __no_return kernel_start(void) { /* Before anything else, zero the bss section. As said by C99: * “All objects with static storage duration shall be inited * before program startup”, and that the implicit init is done * with zero. Kernel assembly code also assumes a zeroed BSS * space */ clear_bss(); /* * Very-early setup: Do not call any code that will use * printk(), `current', per-CPU vars, or a spin lock. */ setup_idt(); schedulify_this_code_path(BOOTSTRAP); /* * Memory Management init */ print_info(); /* First, don't override the ramdisk area (if any) */ ramdisk_init(); /* Then discover our physical memory map .. */ e820_init(); /* and tokenize the available memory into allocatable pages */ pagealloc_init(); /* With the page allocator in place, git rid of our temporary * early-boot page tables and setup dynamic permanent ones */ vm_init(); /* MM basics done, enable dynamic heap memory to kernel code * early on .. */ kmalloc_init(); /* * Secondary-CPUs startup */ /* Discover our secondary-CPUs and system IRQs layout before * initializing the local APICs */ mptables_init(); /* Remap and mask the PIC; it's just a disturbance */ serial_init(); pic_init(); /* Initialize the APICs (and map their MMIO regs) before enabling * IRQs, and before firing other cores using Inter-CPU Interrupts */ apic_init(); ioapic_init(); /* SMP infrastructure ready, fire the CPUs! */ smpboot_init(); keyboard_init(); /* Startup finished, roll-in the scheduler! */ sched_init(); local_irq_enable(); /* * Second part of kernel initialization (Scheduler is now on!) */ ext2_init(); // Signal the secondary cores to run their own test-cases code. // They've been waiting for us (thread 0) till all of kernel // subsystems has been properly initialized. Wait No More! smpboot_trigger_secondary_cores_testcases(); run_test_cases(); halt(); }
/** * 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"); }