3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 1999,2000,2001,2002,2005,2006,2007 Free Software Foundation, Inc.
6
* GRUB is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* GRUB is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20
#include <grub/boot.h>
21
#include <grub/machine/boot.h>
22
#include <grub/machine/kernel.h>
26
#define CODE_ADDR 0x6000
27
#define CODE_LENG (code_end - start)
28
#define DATA_ADDR ((GRUB_BOOT_MACHINE_KERNEL_ADDR) + 0x200)
30
#define BLCK_LENG 0x4000
49
leal 0x200 + data_start - data_next(%ebx,%eax), %eax
50
movzbl setup_sects - data_next(%bx), %ecx
53
movl %eax, code32_start - data_next(%bx)
57
. = data_start + 0x1F1
60
.byte (CODE_LENG >> 9)
81
.ascii "HdrS" // Header signature
82
.word 0x0203 // Header version number
85
.word 0, 0 // default_switch, SETUPSEG
87
.word 0x1000 // obsolete
89
.word 0 // version string ptr
91
.byte 0 // Filled in by boot loader
93
.byte 1 // Please load high
97
.long 0x100000 // 32-bit start address
99
.long 0 // Loaded ramdisk image address
101
.long 0 // Size of loaded ramdisk
109
.long 0 // Command line
111
.long 0xffffffff // Highest allowed ramdisk address
114
.long 0, 0, 0, 0 // Must be zero
115
.word 0xffff // 64 K segment size
117
.byte 0, 0 ,0 // Low 24 bits of source addy
118
.byte 0x93 // Access rights
119
.byte 0 // Extended access rights
121
.byte 0 // High 8 bits of source addy
122
.word 0xffff // 64 K segment size
124
.byte 0, 0, 0 // Low 24 bits of target addy
125
.byte 0x93 // Access rights
126
.byte 0 // Extended access rights
128
.byte 0 // High 8 bits of source addy
129
.long 0, 0, 0, 0 // More space for the BIOS
132
.byte 0x80,0,0xFF,0xFF
139
movw %cs:(reg_edx - start), %dx
147
subw $(normalize - start), %bx
152
pushw $(real_code - start)
153
lret // jump to real_code
158
movw (setup_sects - data_start), %cx
165
movw $(CODE_ADDR), %sp
170
// Move itself to 0:CODE_ADDR
175
movw $(CODE_ADDR >> 4), %ax
182
ljmp $(CODE_ADDR >> 4), $(real_code_2 - start)
189
movl (ramdisk_image - start), %esi
192
movl (code32_start - start), %esi
197
movl $DATA_ADDR, %edi
202
movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART)
204
movsbl (reg_edx + 2 - start), %eax
205
movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
207
movl %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE), %ecx
208
addl $(GRUB_KERNEL_MACHINE_RAW_SIZE - 0x200), %ecx
215
ljmp $(DATA_ADDR >> 4), $0
218
// esi: source address
219
// edi: target address
220
// ecx: number of bytes
229
cmpl $BLCK_LENG, %ecx
231
movl $BLCK_LENG, %ecx
236
movw %si, (gdt_src1 - start)
238
movb %al, (gdt_src1 + 2 - start)
239
movb %ah, (gdt_src2 - start)
242
movw %di, (gdt_dst1 - start)
244
movb %al, (gdt_dst1 + 2 - start)
245
movb %ah, (gdt_dst2 - start)
247
movw $(gdt - start), %si
259
movw $(err_int15_msg - start), %si
264
leal (%esi, %eax), %esi
265
leal (%edi, %eax), %edi
286
.ascii "move memory fails\0"
288
. = (. & (~0x1FF)) + 0x1FF