-#ifdef __i386__
-void
-cpu_IA32e_enable(cpu_data_t *cdp)
-{
- assert(!ml_get_interrupts_enabled());
-
- if (!cdp->cpu_is64bit ||
- (rdmsr64(MSR_IA32_EFER) & MSR_IA32_EFER_LMA) != 0)
- return;
-
- postcode(CPU_IA32_ENABLE_ENTRY);
-
- /*
- * The following steps are performed by inlines so that
- * we can be assured we don't use the stack or any other
- * non-identity mapped data while paging is turned off...
- */
- /* Turn paging off */
- asm volatile(
- "mov %%cr0, %%eax \n\t"
- "andl %0, %%eax \n\t"
- "mov %%eax, %%cr0 \n\t"
- :
- : "i" (~CR0_PG)
- : "eax" );
-
- /* Pop new top level phys pg addr into CR3 */
- asm volatile(
- "mov %%eax, %%cr3 \n\t"
- :
- : "a" ((uint32_t) kernel64_cr3));
-
- /* Turn on the 64-bit mode bit */
- asm volatile(
- "rdmsr \n\t"
- "orl %1, %%eax \n\t"
- "wrmsr \n\t"
- :
- : "c" (MSR_IA32_EFER), "i" (MSR_IA32_EFER_LME)
- : "eax", "edx");
-
- /* Turn paging on again */
- asm volatile(
- "mov %%cr0, %%eax \n\t"
- "orl %0, %%eax \n\t"
- "mov %%eax, %%cr0 \n\t"
- :
- : "i" (CR0_PG)
- : "eax" );
-
-#if ONLY_SAFE_FOR_LINDA_SERIAL
- kprintf("cpu_IA32e_enable(%p)\n", cdp);
-#endif
-
- if ((rdmsr64(MSR_IA32_EFER) & MSR_IA32_EFER_LMA) == 0)
- panic("cpu_IA32e_enable() MSR_IA32_EFER_LMA not asserted");
-
- cdp->cpu_kernel_cr3 = kernel64_cr3;
-
- postcode(CPU_IA32_ENABLE_EXIT);
-}
-
-void
-cpu_IA32e_disable(cpu_data_t *cdp)
-{
- assert(!ml_get_interrupts_enabled());
-
- postcode(CPU_IA32_DISABLE_ENTRY);
-
- if (!cdp->cpu_is64bit ||
- (rdmsr64(MSR_IA32_EFER) & MSR_IA32_EFER_LMA) == 0)
- return;
-
- /*
- * The following steps are performed by inlines so that
- * we can be assured we don't use the stack or any other
- * non-identity mapped data while paging is turned off...
- */
- /* Turn paging off */
- asm volatile(
- "mov %%cr0, %%eax \n\t"
- "andl %0, %%eax \n\t"
- "mov %%eax, %%cr0 \n\t"
- :
- : "i" (~CR0_PG)
- : "eax" );
-
- /* Pop legacy top level phys pg addr into CR3 */
- asm volatile(
- "mov %%eax, %%cr3 \n\t"
- :
- : "a" ((uint32_t) lo_kernel_cr3));
-
- /* Turn off the 64-bit mode bit */
- asm volatile(
- "rdmsr \n\t"
- "andl %1, %%eax \n\t"
- "wrmsr \n\t"
- :
- : "c" (MSR_IA32_EFER), "i" (~MSR_IA32_EFER_LME)
- : "eax", "edx");
-
- /* Turn paging on again */
- asm volatile(
- "mov %%cr0, %%eax \n\t"
- "orl %0, %%eax \n\t"
- "mov %%eax, %%cr0 \n\t"
- :
- : "i" (CR0_PG)
- : "eax" );
-
- kprintf("cpu_IA32e_disable(%p)\n", cdp);
-
- if ((rdmsr64(MSR_IA32_EFER) & MSR_IA32_EFER_LMA) != 0)
- panic("cpu_IA32e_disable() MSR_IA32_EFER_LMA not cleared");
-
- cdp->cpu_kernel_cr3 = 0ULL;
-
- postcode(CPU_IA32_DISABLE_EXIT);
-}
-#endif
-