rulimine/stage23/lib/spinup.asm64

71 lines
854 B
Plaintext
Raw Normal View History

section .rodata
invalid_idt:
dq 0, 0
section .text
%macro push32 1
sub rsp, 4
mov dword [rsp], %1
%endmacro
extern gdt
global common_spinup
bits 64
common_spinup:
cli
lgdt [rel gdt]
lidt [rel invalid_idt]
mov rbp, rsp
cmp esi, 4
jle .no_stack_args
.push_stack_args:
dec esi
mov eax, [rbp + 8 + rsi*8]
push32 eax
test esi, esi
jnz .push_stack_args
.no_stack_args:
push32 r9d
push32 r8d
push32 ecx
push32 edx
lea rbx, [rel .go_32]
push 0x18
push rbx
retfq
bits 32
.go_32:
mov eax, 0x20
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
2021-07-06 03:13:25 +03:00
xor eax, eax
lldt ax
2021-05-20 02:16:39 +03:00
mov eax, 0x00000011
mov cr0, eax
mov ecx, 0xc0000080
2021-05-20 02:16:39 +03:00
xor eax, eax
xor edx, edx
wrmsr
2021-05-20 02:16:39 +03:00
xor eax, eax
mov cr4, eax
call edi