xref: /kvm-unit-tests/x86/efi/efistart64.S (revision 2c96b77ec9d3b1fcec7525174e23a6240ee05949)
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.data
8
9.align PAGE_SIZE
10.globl ptl2
11ptl2:
12	. = . + 4 * PAGE_SIZE
13.align PAGE_SIZE
14
15.globl ptl3
16ptl3:
17	. = . + PAGE_SIZE
18.align PAGE_SIZE
19
20.globl ptl4
21ptl4:
22	. = . + PAGE_SIZE
23.align PAGE_SIZE
24
25.section .init
26.code64
27.text
28
29.globl load_idt
30load_idt:
31	lidtq idt_descr(%rip)
32	retq
33
34.globl load_gdt_tss
35load_gdt_tss:
36	/* Load GDT */
37	lgdt gdt_descr(%rip)
38
39	/* Load TSS */
40	mov %rdi, %rax
41	ltr %ax
42
43	/* Update data segments */
44	mov $0x10, %ax /* 3rd entry in gdt64: 32/64-bit data segment */
45	mov %ax, %ds
46	mov %ax, %es
47	mov %ax, %fs
48	mov %ax, %gs
49	mov %ax, %ss
50
51	/*
52	 * Update the code segment by putting it on the stack before the return
53	 * address, then doing a far return: this will use the new code segment
54	 * along with the address.
55	 */
56	popq %rdi
57	pushq $0x08 /* 2nd entry in gdt64: 64-bit code segment */
58	pushq %rdi
59	lretq
60