static void fix_processor_context(void) { int cpu = smp_processor_id(); struct tss_struct *t = &per_cpu(init_tss, cpu); set_tss_desc(cpu, t); /* * This just modifies memory; should not be * necessary. But... This is necessary, because * 386 hardware has concept of busy TSS or some * similar stupidity. */ load_TR_desc(); /* This does ltr */ load_LDT(¤t->active_mm->context); /* This does lldt */ /* * Now maybe reload the debug registers */ if (current->thread.debugreg7) { set_debugreg(current->thread.debugreg0, 0); set_debugreg(current->thread.debugreg1, 1); set_debugreg(current->thread.debugreg2, 2); set_debugreg(current->thread.debugreg3, 3); /* no 4 and 5 */ set_debugreg(current->thread.debugreg6, 6); set_debugreg(current->thread.debugreg7, 7); } }
__init void km_arch_trim() { unsigned long i; unsigned long *p = hal_x86_get_init_pgtable(); /* Kernel part in 4mb page; 1,低端。 2,高端 */ for(i = 0; i < HAL_GET_BASIC_KADDRESS(0) / 0x400000; i++) p[i] = 0; //Mask as invalid; for(i = (HAL_GET_BASIC_KADDRESS(0) + CONFIG_HAL_KERNEL_MEM_LEN) / 0x400000; i < 1024; i++) p[i] = 0; //Mask as invalid; write_cr3((unsigned long)hal_x86_get_init_pgtable() - HAL_GET_BASIC_KADDRESS(0)); /* load tr */ set_tss_desc(0, &init_tss); load_TR_desc(); /* 打开WP功能 */ do { unsigned long i = read_cr0(); //if(open) i |= 1 << 16; //else // i &= ~(1 << 16); write_cr0(i); } while (0); }