| 1 | section .rodata |
| 2 | |
| 3 | invalid_idt: |
| 4 | dd 0, 0 |
| 5 | |
| 6 | section .text |
| 7 | |
| 8 | extern flush_irqs |
| 9 | |
| 10 | global common_spinup |
| 11 | bits 32 |
| 12 | common_spinup: |
| 13 | cli |
| 14 | |
| 15 | lidt [invalid_idt] |
| 16 | |
| 17 | call flush_irqs |
| 18 | |
| 19 | xor eax, eax |
| 20 | lldt ax |
| 21 | |
| 22 | ; We don't need the return address |
| 23 | add esp, 4 |
| 24 | |
| 25 | ; Get function address |
| 26 | pop edi |
| 27 | |
| 28 | ; We don't need the argument count |
| 29 | add esp, 4 |
| 30 | |
| 31 | mov eax, 0x00000011 |
| 32 | mov cr0, eax |
| 33 | |
| 34 | xor eax, eax |
| 35 | mov cr4, eax |
| 36 | mov cr3, eax |
| 37 | |
| 38 | ; Clear TSS busy bit and load TR with base 0, limit 0 |
| 39 | sub esp, 8 |
| 40 | sgdt [esp] |
| 41 | mov eax, [esp + 2] |
| 42 | add esp, 8 |
| 43 | mov byte [eax + 0x3d], 0x89 |
| 44 | mov ax, 0x38 |
| 45 | ltr ax |
| 46 | |
| 47 | call edi |
| 48 | |
| 49 | section .note.GNU-stack noalloc noexec nowrite progbits |
