1/* Startup code and pre-defined data structures */ 2 3#include "apic-defs.h" 4#include "asm-generic/page.h" 5#include "crt0-efi-x86_64.S" 6 7.section .init 8.code64 9.text 10 11.globl load_idt 12load_idt: 13 lidtq idt_descr(%rip) 14 retq 15 16.globl load_gdt_tss 17load_gdt_tss: 18 /* Load GDT */ 19 lgdt gdt_descr(%rip) 20 21 /* Load TSS */ 22 mov %rdi, %rax 23 ltr %ax 24 25 /* Update data segments */ 26 mov $0x10, %ax /* 3rd entry in gdt64: 32/64-bit data segment */ 27 mov %ax, %ds 28 mov %ax, %es 29 mov %ax, %fs 30 mov %ax, %gs 31 mov %ax, %ss 32 33 /* 34 * Update the code segment by putting it on the stack before the return 35 * address, then doing a far return: this will use the new code segment 36 * along with the address. 37 */ 38 popq %rdi 39 pushq $0x08 /* 2nd entry in gdt64: 64-bit code segment */ 40 pushq %rdi 41 lretq 42