:: limine / common / lib / spinup.asm_uefi_ia32 1.1 KB raw

1
extern _GLOBAL_OFFSET_TABLE_
2
3
extern gdt
4
5
section .text
6
7
extern flush_irqs
8
9
global common_spinup
10
bits 32
11
common_spinup:
12
    cli
13
14
    push 0
15
    push 0
16
    lidt [esp]
17
    add esp, 8
18
19
    call .get_got
20
  .get_got:
21
    pop ebx
22
    add ebx, _GLOBAL_OFFSET_TABLE_ + $$ - .get_got wrt ..gotpc
23
24
    lgdt [ebx + gdt wrt ..gotoff]
25
26
    push dword 0x18
27
    call .p1
28
  .p1:
29
    pop eax
30
    add eax, 6
31
    push eax
32
    retfd
33
34
  .flush_cs:
35
    mov eax, 0x20
36
    mov ds, eax
37
    mov es, eax
38
    mov fs, eax
39
    mov gs, eax
40
    mov ss, eax
41
42
    call flush_irqs
43
44
    xor eax, eax
45
    lldt ax
46
47
    ; We don't need the return address
48
    add esp, 4
49
50
    ; Get function address
51
    pop edi
52
53
    ; We don't need the argument count
54
    add esp, 4
55
56
    mov eax, 0x00000011
57
    mov cr0, eax
58
59
    xor eax, eax
60
    mov cr4, eax
61
    mov cr3, eax
62
63
    ; Clear TSS busy bit and load TR with base 0, limit 0
64
    sub esp, 8
65
    sgdt [esp]
66
    mov eax, [esp + 2]
67
    add esp, 8
68
    mov byte [eax + 0x3d], 0x89
69
    mov ax, 0x38
70
    ltr ax
71
72
    call edi
73
74
section .note.GNU-stack noalloc noexec nowrite progbits
tab: 248 wrap: offon