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 */
24
VARIABLE(grub_xnu_launcher_start)
31
VARIABLE(grub_xnu_heap_will_be_at)
37
VARIABLE(grub_xnu_heap_start)
43
VARIABLE(grub_xnu_heap_size)
47
/* %rax now contains our starting position after relocation. */
48
/* One more page to copy: ourselves. */
58
add $(cont0-base), %eax
66
VARIABLE(grub_xnu_heap_will_be_at)
73
VARIABLE(grub_xnu_heap_start)
81
VARIABLE(grub_xnu_heap_size)
86
/* %rax now contains our starting position after relocation. */
87
/* One more page to copy: ourselves. */
98
add $(cont0-base), %eax
100
add $(cont0-base), %rax
106
lea (cont1 - base) (%esi, 1), %eax
107
mov %eax, (jump_vector - base) (%esi, 1)
109
lea (gdt - base) (%esi, 1), %eax
110
mov %eax, (gdt_addr - base) (%esi, 1)
112
/* Switch to compatibility mode. */
114
lgdt (gdtdesc - base) (%esi, 1)
116
/* Update %cs. Thanks to David Miller for pointing this mistake out. */
117
ljmp *(jump_vector - base) (%esi,1)
119
lea (cont1 - base) (%rsi, 1), %rax
120
mov %eax, (jump_vector - base) (%rsi, 1)
122
lea (gdt - base) (%rsi, 1), %rax
123
mov %rax, (gdt_addr - base) (%rsi, 1)
125
/* Switch to compatibility mode. */
127
lgdt (gdtdesc - base) (%rsi, 1)
129
/* Update %cs. Thanks to David Miller for pointing this mistake out. */
130
ljmp *(jump_vector - base) (%rsi, 1)
136
/* Update other registers. */
144
/* Disable paging. */
146
and $0x7fffffff, %eax
150
mov $0xc0000080, %ecx
152
and $0xfffffeff, %eax
157
and $0xffffffcf, %eax
165
/* Registers on XNU boot: eip, esp and eax. */
166
/* mov imm32, %ecx */
168
VARIABLE (grub_xnu_entry_point)
170
/* mov imm32, %eax */
172
VARIABLE (grub_xnu_arg1)
174
/* mov imm32, %ebx */
176
VARIABLE (grub_xnu_stack)
184
/* GDT. Copied from loader/i386/linux.c. */
188
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
191
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
194
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00
197
.byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00
202
/* Filled by the code. */
207
/* Jump location. Is filled by the code */
211
VARIABLE(grub_xnu_launcher_end)