Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [bits 16]
- [global ap_trampoline]
- [global ap_trampoline_data]
- [extern PML4]
- [extern default_gdt]
- %define to_target(addr) ((addr - ap_trampoline) + 0x8000)
- ap_trampoline:
- cli
- cld
- jmp 0:to_target(.start)
- .start:
- xor ax, ax
- mov ds, ax
- mov es, ax
- mov fs, ax
- mov ss, ax
- mov gs, ax
- mov sp, 0x7c00
- in al, 0x92
- or al, 2
- out 0x92, al
- mov eax, PML4
- mov cr3, eax
- mov eax, cr4
- or eax, (1 << 5)
- mov cr4, eax
- mov ecx, 0xC0000080 ; EFER Model Specific Register
- rdmsr
- or eax, 1 << 8
- wrmsr
- mov eax, 0x80000011
- mov cr0, eax
- mov eax, default_gdt
- lgdt [eax]
- jmp 0x8:to_target(ap_trampoline_long_mode)
- [bits 64]
- ap_trampoline_long_mode:
- mov ax, 0x10
- mov ds, ax
- mov es, ax
- mov fs, ax
- mov gs, ax
- mov ss, ax
- mov rsp, [to_target(ap_trampoline_data.stack_ptr)]
- mov [to_target(ap_trampoline_data.status)], byte 10
- jmp [to_target(ap_trampoline_data.entry)]
- jmp $
- ap_trampoline_data:
- .status: db 0
- .pagetable: dq 0
- .stack_ptr: dq 0
- .entry: dq 0
- times 4096 - ($ - $$) db 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement