~ubuntu-branches/ubuntu/trusty/grub2/trusty-updates

« back to all changes in this revision

Viewing changes to grub-core/kern/i386/coreboot/startup.S

Tags: upstream-1.99~20101122
ImportĀ upstreamĀ versionĀ 1.99~20101122

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  GRUB  --  GRand Unified Bootloader
 
3
 *  Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008 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 <grub/symbol.h>
 
20
/* For stack parameters.  */
 
21
#include <grub/i386/pc/memory.h>
 
22
#include <grub/machine/memory.h>
 
23
#include <grub/cpu/linux.h>
 
24
#include <grub/offsets.h>
 
25
#include <multiboot.h>
 
26
#include <multiboot2.h>
 
27
 
 
28
/*
 
29
 * Note: GRUB is compiled with the options -mrtd and -mregparm=3.
 
30
 *       So the first three arguments are passed in %eax, %edx, and %ecx,
 
31
 *       respectively, and if a function has a fixed number of arguments
 
32
 *       and the number if greater than three, the function must return
 
33
 *       with "ret $N" where N is ((the number of arguments) - 3) * 4.
 
34
 */
 
35
 
 
36
        .file   "startup.S"
 
37
        .text
 
38
        .globl  start, _start
 
39
start:
 
40
_start:
 
41
        jmp codestart
 
42
 
 
43
        /*
 
44
         *  This is a special data area at a fixed offset from the beginning.
 
45
         */
 
46
 
 
47
        . = _start + GRUB_KERNEL_MACHINE_PREFIX
 
48
 
 
49
VARIABLE(grub_prefix)
 
50
        /* to be filled by grub-mkimage */
 
51
 
 
52
        /*
 
53
         *  Leave some breathing room for the prefix.
 
54
         */
 
55
 
 
56
        . = _start + GRUB_KERNEL_MACHINE_PREFIX_END
 
57
 
 
58
/*
 
59
 *  Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself).
 
60
 */
 
61
        .p2align        2       /* force 4-byte alignment */
 
62
multiboot_header:
 
63
        /* magic */
 
64
        .long   0x1BADB002
 
65
        /* flags */
 
66
        .long   MULTIBOOT_MEMORY_INFO
 
67
        /* checksum */
 
68
        .long   -0x1BADB002 - MULTIBOOT_MEMORY_INFO
 
69
 
 
70
codestart:
 
71
#ifdef GRUB_MACHINE_MULTIBOOT
 
72
        cmpl    $MULTIBOOT_BOOTLOADER_MAGIC, %eax
 
73
        jne 0f
 
74
        movl    %ebx, EXT_C(startup_multiboot_info)
 
75
0:
 
76
#endif
 
77
 
 
78
        /* initialize the stack */
 
79
        movl $GRUB_MEMORY_MACHINE_PROT_STACK, %esp
 
80
 
 
81
        /* jump to the main body of C code */
 
82
        jmp EXT_C(grub_main)
 
83
 
 
84
/*
 
85
 *  prot_to_real and associated structures (but NOT real_to_prot, that is
 
86
 *  only needed for BIOS gates).
 
87
 */
 
88
#include "../realmode.S"
 
89