extlinux/main.c: space change
[syslinux.git] / efi / x86_64 / linux.S
blob29dde94a95fcb660287428fd4c66bf9f2ed457a6
1 /* ----------------------------------------------------------------------- *
2  *
3  *   Copyright 2013 Intel Corporation; author: Matt Fleming
4  *
5  *   This program is free software; you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
8  *   Boston MA 02110-1301, USA; either version 2 of the License, or
9  *   (at your option) any later version; incorporated herein by reference.
10  *
11  * ----------------------------------------------------------------------- */
13 #define CR0_PG_BIT    31
14 #define CR4_PAE_BIT   5
15 #define MSR_EFER      0xc0000080
17         .globl kernel_jump
18         .type kernel_jump,@function
19         .code64
20 kernel_jump:
21         cli
23         /* save the content of rsi (boot_param argument of kernel_jump function) */
24         mov %rsi, %rbx
26         call base_address
27 base_address:
28         pop %rsi
30         /* need to perform a long jump to update cs */
32         /* load absolute address of pm_code in jmp_address location */
33         lea (pm_code - base_address)(%rsi, 1), %rax
34         mov %eax, (jmp_address - base_address)(%rsi, 1)
36         ljmp *(jmp_address - base_address)(%rsi, 1)
38 jmp_address:
39         .long 0    /* address */
40         .word 0x10 /* segment */
42         .code32
43 pm_code:
45         /* cs segment has been updated, now update the rest */
46         mov $0x18, %eax
47         mov %eax, %ds
48         mov %eax, %es
49         mov %eax, %fs
50         mov %eax, %gs
51         mov %eax, %ss
53         /* disable paging. */
54         mov %cr0, %eax
55         btr $CR0_PG_BIT, %eax /* PG in CR0 */
56         mov %eax, %cr0
58         /* disable long mode. */
59         mov $MSR_EFER, %ecx
60         rdmsr
61         btr $8, %eax
62         wrmsr
64         /* kernel jump */
65         mov %ebx, %esi
66         jmp *%edi
68         .code64
69         .align 4
70         .globl efi_handover_32
71         .type  efi_handover_32,@function
72 efi_handover_32:
73         movl    $38, errno(%rip)        /* ENOSYS */
74         ret
76         .globl efi_handover_64
77         .globl efi_handover
78         .type  efi_handover_64,@function
79         .type  efi_handover,@function
80 efi_handover_64:
81 efi_handover:
82         add     $512, %rcx
83         cli
84         jmp     *%rcx