Debian Codegraph @

grub-core/boot/i386/qemu/boot.S

raw
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
4 *
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.
9 *
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.
14 *
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/>.
17 */
18
19 #include <config.h>
20 #include <grub/symbol.h>
21 #include <grub/machine/memory.h>
22 #include <grub/machine/boot.h>
23 #include <grub/machine/kernel.h>
24
25 .text
26 .code16
27 .globl _start
28 _start:
29 /* Disable interrupts. */
30 cli
31
32 jmp 1f
33
34 .org GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR
35 VARIABLE(grub_core_entry_addr)
36 .long 0
37 1:
38
39 /* Set up %ds, %ss, and %es. */
40 xorw %ax, %ax
41 movw %ax, %ds
42 movw %ax, %ss
43 movw %ax, %es
44
45 /* Set up the real mode stack. */
46 movl $GRUB_MEMORY_MACHINE_REAL_STACK, %esp
47
48 /* Transition to protected mode. We use pushl to force generation
49 of a flat return address. */
50 pushl $1f
51 jmp real_to_prot
52 .code32
53 1:
54 /* Ensure A20 is enabled. We're in qemu, so control port A works
55 and there is no need to wait since there is no real logic, it's
56 all emulated. */
57 inb $0x92
58 andb $(~0x03), %al
59 orb $0x02, %al
60 outb $0x92
61 movl EXT_C(grub_core_entry_addr), %edx
62 jmp *%edx
63
64 #include "../../../kern/i386/realmode.S"
65
66 /* Intel, in its infinite wisdom, decided to put the i8086 entry point
67 *right here* and this is why we need this kludge. */
68
69 .org GRUB_BOOT_MACHINE_SIZE - 16
70
71 .code16
72
73 jmp _start
74 .org GRUB_BOOT_MACHINE_SIZE