2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2009 Free Software Foundation, Inc.
5 * GRUB 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, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #include <grub/symbol.h>
22 .p2align 4 /* force 16-byte alignment */
23 VARIABLE(grub_linux_trampoline_start)
25 /* %rdi contains protected memory start and %rsi
26 contains real memory start. */
35 lea (cont1 - base) (%esi, 1), %rax
36 mov %eax, (jump_vector - base) (%esi, 1)
38 lea (gdt - base) (%esi, 1), %rax
39 mov %rax, (gdtaddr - base) (%esi, 1)
41 /* Switch to compatibility mode. */
43 lidt (idtdesc - base) (%esi, 1)
44 lgdt (gdtdesc - base) (%esi, 1)
46 /* Update %cs. Thanks to David Miller for pointing this mistake out. */
47 ljmp *(jump_vector - base) (%esi, 1)
49 lea (cont1 - base) (%rsi, 1), %rax
50 mov %eax, (jump_vector - base) (%rsi, 1)
52 lea (gdt - base) (%rsi, 1), %rax
53 mov %rax, (gdtaddr - base) (%rsi, 1)
55 /* Switch to compatibility mode. */
57 lidt (idtdesc - base) (%rsi, 1)
58 lgdt (gdtdesc - base) (%rsi, 1)
60 /* Update %cs. Thanks to David Miller for pointing this mistake out. */
61 ljmp *(jump_vector - base) (%rsi, 1)
67 /* Update other registers. */
103 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
106 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
109 .byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00
112 .byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00
126 /* Jump location. Is filled by the code */
129 VARIABLE(grub_linux_trampoline_end)