void base_cpu_init(void) { /* Detect the current processor. */ cpuid(&base_cpuid); /* Initialize the processor tables. */ base_trap_init(); base_irq_init(); base_gdt_init(); base_tss_init(); }
/* * This overrides the _exit() function in libc. * If the serial console (or remote GDB) is being used, it waits * until all the data has cleared out of the FIFOs; if the VGA * display is being used (normal console), then it waits for a keypress. * When it is done, it calls pc_reset() to reboot the computer. */ static void our_exit(int rc) { extern oskit_addr_t return_address; #if 0 printf("_exit(%d) called; %s...\r\n", rc, return_address ? "returning to netboot" : "rebooting"); #endif if (enable_gdb) { /* Detach from the remote GDB. */ gdb_serial_exit(rc); #ifdef HAVE_DEBUG_REGS /* Turn off the debug registers. */ set_dr7(get_dr7() & ~(DR7_G0 | DR7_G1 | DR7_G2 | DR7_G3)); #endif } /* flush and wait for `_exit called` message */ oskit_stream_release(console); if (!serial_console) { /* This is so that the user has a chance to SEE the output */ //~ printf("Press a key to reboot"); //~ printf("hit dat shit yo."); //~ getchar(); } if (return_address) { /* * The cleanup needs to be done here instead of in the * returned-to code because the return address may not * be accessible with our current paging and segment * state. * The order is important here: paging must be disabled * after we reload the gdt. */ cli(); clts(); phys_mem_va = 0; linear_base_va = 0; base_gdt_init(); /* Reload all since we changed linear_base_va. */ base_cpu_load(); paging_disable(); ((void (*)(void))return_address)(); } else pc_reset(); }
void base_cpu_init(void) { unsigned int efl, cr0; /* Initialize the processor tables. */ base_trap_init(); base_irq_init(); base_gdt_init(); base_tss_init(); /* * Setting these flags sets up alignment checking of * all memory accesses. */ efl = get_eflags(); efl |= EFL_AC; set_eflags( efl ); cr0 = get_cr0(); cr0 |= CR0_AM; set_cr0( cr0 ); }