104 |
|
|
105 |
. = EXT_C(start) + 0x50 |
. = EXT_C(start) + 0x50 |
106 |
|
|
107 |
|
/* |
108 |
|
* Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself). |
109 |
|
* This uses the a.out kludge to load raw binary to the area starting at 1MB, |
110 |
|
* and relocates itself after loaded. |
111 |
|
*/ |
112 |
|
multiboot_header: |
113 |
|
/* magic */ |
114 |
|
.long 0x1BADB002 |
115 |
|
/* flags */ |
116 |
|
.long (1 << 16) |
117 |
|
/* checksum */ |
118 |
|
.long -0x1BADB002 - (1 << 16) |
119 |
|
/* header addr */ |
120 |
|
.long multiboot_header - _start + 0x100000 + 0x200 |
121 |
|
/* load addr */ |
122 |
|
.long 0x100000 |
123 |
|
/* load end addr */ |
124 |
|
.long 0 |
125 |
|
/* bss end addr */ |
126 |
|
.long 0 |
127 |
|
/* entry addr */ |
128 |
|
.long multiboot_entry - _start + 0x100000 + 0x200 |
129 |
|
|
130 |
|
multiboot_entry: |
131 |
|
.code32 |
132 |
|
/* obtain the boot device */ |
133 |
|
movl 12(%ebx), %edx |
134 |
|
|
135 |
|
/* relocate the code */ |
136 |
|
movl $(GRUB_KERNEL_MACHINE_RAW_SIZE + 0x200), %ecx |
137 |
|
addl EXT_C(grub_compressed_size) - _start + 0x100000 + 0x200, %ecx |
138 |
|
movl $0x100000, %esi |
139 |
|
movl $GRUB_BOOT_MACHINE_KERNEL_ADDR, %edi |
140 |
|
cld |
141 |
|
rep |
142 |
|
movsb |
143 |
|
/* jump to the real address */ |
144 |
|
movl $multiboot_trampoline, %eax |
145 |
|
jmp *%eax |
146 |
|
|
147 |
|
multiboot_trampoline: |
148 |
|
/* fill the boot information */ |
149 |
|
movl %edx, %eax |
150 |
|
shrl $8, %eax |
151 |
|
xorl %ebx, %ebx |
152 |
|
cmpb $0xFF, %al |
153 |
|
je 1f |
154 |
|
movb %ah, %bl |
155 |
|
movl %ebx, EXT_C(grub_install_dos_part) |
156 |
|
1: |
157 |
|
cmpb $0xFF, %ah |
158 |
|
je 2f |
159 |
|
movb %al, %bl |
160 |
|
movl %ebx, EXT_C(grub_install_bsd_part) |
161 |
|
2: |
162 |
|
shrl $24, %edx |
163 |
|
/* enter the usual booting */ |
164 |
|
call prot_to_real |
165 |
|
.code16 |
166 |
|
|
167 |
/* the real mode code continues... */ |
/* the real mode code continues... */ |
168 |
codestart: |
codestart: |
169 |
cli /* we're not safe here! */ |
cli /* we're not safe here! */ |