1*433d6423SLionel Sambuc#include <machine/asm.h> 2*433d6423SLionel Sambuc#include <machine/vm.h> 3*433d6423SLionel Sambuc#include "archconst.h" 4*433d6423SLionel Sambuc 5*433d6423SLionel Sambuc.balign 4096 6*433d6423SLionel Sambuc.text 7*433d6423SLionel Sambuc.code16 8*433d6423SLionel SambucENTRY(trampoline) 9*433d6423SLionel Sambuc cli 10*433d6423SLionel Sambuc 11*433d6423SLionel Sambuc /* %cs has some value and we must use the same for data */ 12*433d6423SLionel Sambuc mov %cs, %ax 13*433d6423SLionel Sambuc mov %ax, %ds 14*433d6423SLionel Sambuc 15*433d6423SLionel Sambuc /* load gdt and idt prepared by bsp */ 16*433d6423SLionel Sambuc lgdtl _C_LABEL(__ap_gdt) - _C_LABEL(trampoline) 17*433d6423SLionel Sambuc lidtl _C_LABEL(__ap_idt) - _C_LABEL(trampoline) 18*433d6423SLionel Sambuc 19*433d6423SLionel Sambuc /* switch to protected mode */ 20*433d6423SLionel Sambuc mov %cr0, %eax 21*433d6423SLionel Sambuc orb $1, %al 22*433d6423SLionel Sambuc mov %eax, %cr0 23*433d6423SLionel Sambuc 24*433d6423SLionel Sambuc /* set page table feature flags: cr4.PSE on, cr4.PGE off */ 25*433d6423SLionel Sambuc movl %cr4, %eax 26*433d6423SLionel Sambuc orl $I386_CR4_PSE, %eax /* Turn on PSE */ 27*433d6423SLionel Sambuc andl $~I386_CR4_PGE, %eax /* Turn off PGE */ 28*433d6423SLionel Sambuc movl %eax, %cr4 29*433d6423SLionel Sambuc 30*433d6423SLionel Sambuc /* load boot cr3 and turn PG on so CPU can see all of memory */ 31*433d6423SLionel Sambuc movl _C_LABEL(__ap_pt) - _C_LABEL(trampoline), %eax 32*433d6423SLionel Sambuc movl %eax, %cr3 33*433d6423SLionel Sambuc movl %cr0, %ecx 34*433d6423SLionel Sambuc orl $I386_CR0_PG, %ecx 35*433d6423SLionel Sambuc movl %ecx, %cr0 36*433d6423SLionel Sambuc 37*433d6423SLionel Sambuc /* turn on cr4.PGE after cr0.PG is on */ 38*433d6423SLionel Sambuc movl %cr4, %eax 39*433d6423SLionel Sambuc orl $I386_CR4_PGE, %eax 40*433d6423SLionel Sambuc movl %eax, %cr4 41*433d6423SLionel Sambuc 42*433d6423SLionel Sambuc /* jump into regular highly mapped kernel */ 43*433d6423SLionel Sambuc ljmpl $KERN_CS_SELECTOR, $_C_LABEL(startup_ap_32) 44*433d6423SLionel Sambuc 45*433d6423SLionel Sambuc.balign 4 46*433d6423SLionel SambucLABEL(__ap_id) 47*433d6423SLionel Sambuc.space 4 48*433d6423SLionel SambucLABEL(__ap_pt) 49*433d6423SLionel Sambuc.space 4 50*433d6423SLionel SambucLABEL(__ap_gdt) 51*433d6423SLionel Sambuc.space 8 52*433d6423SLionel SambucLABEL(__ap_idt) 53*433d6423SLionel Sambuc.space 8 54*433d6423SLionel SambucLABEL(__ap_gdt_tab) 55*433d6423SLionel Sambuc.space GDT_SIZE*DESC_SIZE 56*433d6423SLionel SambucLABEL(__ap_idt_tab) 57*433d6423SLionel Sambuc.space IDT_SIZE*DESC_SIZE 58*433d6423SLionel SambucLABEL(__trampoline_end) 59