~hamo/ubuntu/precise/grub2/grub2.hi_res

« back to all changes in this revision

Viewing changes to lib/i386/relocator_asm.S

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, Colin Watson, Robert Millan, Updated translations
  • Date: 2010-11-22 12:24:56 UTC
  • mfrom: (1.26.4 upstream) (17.3.36 sid)
  • mto: (17.3.43 sid)
  • mto: This revision was merged to the branch mainline in revision 89.
  • Revision ID: james.westby@ubuntu.com-20101122122456-y82z3sfb7k4zfdcc
Tags: 1.99~20101122-1
[ Colin Watson ]
* New Bazaar snapshot.  Too many changes to list in full, but some of the
  more user-visible ones are as follows:
  - GRUB script:
    + Function parameters, "break", "continue", "shift", "setparams",
      "return", and "!".
    + "export" command supports multiple variable names.
    + Multi-line quoted strings support.
    + Wildcard expansion.
  - sendkey support.
  - USB hotunplugging and USB serial support.
  - Rename CD-ROM to cd on BIOS.
  - Add new --boot-directory option to grub-install, grub-reboot, and
    grub-set-default; the old --root-directory option is still accepted
    but was often confusing.
  - Basic btrfs detection/UUID support (but no file reading yet).
  - bash-completion for utilities.
  - If a device is listed in device.map, always assume that it is
    BIOS-visible rather than using extra layers such as LVM or RAID.
  - Add grub-mknetdir script (closes: #550658).
  - Remove deprecated "root" command.
  - Handle RAID devices containing virtio components.
  - GRUB Legacy configuration file support (via grub-menulst2cfg).
  - Keyboard layout support (via grub-mklayout and grub-kbdcomp).
  - Check generated grub.cfg for syntax errors before saving.
  - Pause execution for at most ten seconds if any errors are displayed,
    so that the user has a chance to see them.
  - Support submenus.
  - Write embedding zone using Reed-Solomon, so that it's robust against
    being partially overwritten (closes: #550702, #591416, #593347).
  - GRUB_DISABLE_LINUX_RECOVERY and GRUB_DISABLE_NETBSD_RECOVERY merged
    into a single GRUB_DISABLE_RECOVERY variable.
  - Fix loader memory allocation failure (closes: #551627).
  - Don't call savedefault on recovery entries (closes: #589325).
  - Support triple-indirect blocks on ext2 (closes: #543924).
  - Recognise DDF1 fake RAID (closes: #603354).

[ Robert Millan ]
* Use dpkg architecture wildcards.

[ Updated translations ]
* Slovenian (Vanja Cvelbar).  Closes: #604003
* Dzongkha (dawa pemo via Tenzin Dendup).  Closes: #604102

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  GRUB  --  GRand Unified Bootloader
3
 
 *  Copyright (C) 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 <grub/symbol.h>
20
 
#include <grub/i386/memory.h>
21
 
 
22
 
#ifdef BACKWARD
23
 
#define RELOCATOR_VARIABLE(x) VARIABLE(grub_relocator32_backward_ ## x)
24
 
#else
25
 
#define RELOCATOR_VARIABLE(x) VARIABLE(grub_relocator32_forward_ ## x)
26
 
#endif
27
 
#ifdef __x86_64__
28
 
#define RAX %rax
29
 
#define RCX %rcx
30
 
#define RDI %rdi
31
 
#define RSI %rdi
32
 
#else
33
 
#define RAX %eax
34
 
#define RCX %ecx
35
 
#define RDI %edi
36
 
#define RSI %esi
37
 
#endif
38
 
 
39
 
/* The code segment of the protected mode.  */
40
 
#define CODE_SEGMENT    0x10
41
 
 
42
 
/* The data segment of the protected mode.  */
43
 
#define DATA_SEGMENT    0x18
44
 
 
45
 
        .p2align        4       /* force 16-byte alignment */
46
 
 
47
 
RELOCATOR_VARIABLE(start)
48
 
#ifdef BACKWARD
49
 
LOCAL(base):
50
 
#endif
51
 
        cli
52
 
 
53
 
#ifndef __x86_64__
54
 
        /* mov imm32, %eax */
55
 
        .byte   0xb8
56
 
RELOCATOR_VARIABLE(dest)
57
 
        .long   0
58
 
        movl    %eax, %edi
59
 
 
60
 
        /* mov imm32, %eax */
61
 
        .byte   0xb8
62
 
RELOCATOR_VARIABLE(src)
63
 
        .long   0
64
 
        movl    %eax, %esi
65
 
 
66
 
        /* mov imm32, %ecx */
67
 
        .byte   0xb9
68
 
RELOCATOR_VARIABLE(size)
69
 
        .long   0
70
 
#else
71
 
        xorq    %rax, %rax
72
 
 
73
 
        /* mov imm32, %eax */
74
 
        .byte   0xb8
75
 
RELOCATOR_VARIABLE(dest)
76
 
        .long   0
77
 
        movq    %rax, %rdi
78
 
 
79
 
        /* mov imm64, %rax */
80
 
        .byte   0x48
81
 
        .byte   0xb8
82
 
RELOCATOR_VARIABLE(src)
83
 
        .long   0, 0
84
 
        movq    %rax, %rsi
85
 
 
86
 
        xorq    %rcx, %rcx
87
 
        /* mov imm32, %ecx */
88
 
        .byte   0xb9
89
 
RELOCATOR_VARIABLE(size)
90
 
        .long   0
91
 
 
92
 
#endif
93
 
 
94
 
        mov     RDI, RAX
95
 
 
96
 
#ifdef BACKWARD
97
 
        add     RCX, RSI
98
 
        add     RCX, RDI
99
 
#endif
100
 
 
101
 
#ifndef BACKWARD
102
 
        add     RCX, RAX
103
 
#endif
104
 
        add     $0x3, RCX
105
 
        shr     $2, RCX
106
 
 
107
 
 
108
 
#ifdef BACKWARD
109
 
        /* Backward movsl is implicitly off-by-four.  compensate that.  */
110
 
        sub     $4,     RSI
111
 
        sub     $4,     RDI
112
 
 
113
 
        /* Backward copy.  */
114
 
        std
115
 
 
116
 
        rep
117
 
        movsl
118
 
 
119
 
#else
120
 
        /* Forward copy.  */
121
 
        cld
122
 
        rep
123
 
        movsl
124
 
#endif
125
 
 
126
 
        /* %rax contains now our new 'base'.  */
127
 
        mov     RAX, RSI
128
 
        add     $(LOCAL(cont0) - LOCAL(base)), RAX
129
 
        jmp     *RAX
130
 
LOCAL(cont0):
131
 
        lea     (LOCAL(cont1) - LOCAL(base)) (RSI, 1), RAX
132
 
        movl    %eax, (LOCAL(jump_vector) - LOCAL(base)) (RSI, 1)
133
 
 
134
 
        lea     (LOCAL(gdt) - LOCAL(base)) (RSI, 1), RAX
135
 
        mov     RAX, (LOCAL(gdt_addr) - LOCAL(base)) (RSI, 1)
136
 
 
137
 
        /* Switch to compatibility mode. */
138
 
 
139
 
        lgdt    (LOCAL(gdtdesc) - LOCAL(base)) (RSI, 1)
140
 
 
141
 
        /* Update %cs.  */
142
 
        ljmp    *(LOCAL(jump_vector) - LOCAL(base)) (RSI, 1)
143
 
 
144
 
LOCAL(cont1):
145
 
        .code32
146
 
 
147
 
        /* Update other registers. */
148
 
        movl    $DATA_SEGMENT, %eax
149
 
        movl    %eax, %ds
150
 
        movl    %eax, %es
151
 
        movl    %eax, %fs
152
 
        movl    %eax, %gs
153
 
        movl    %eax, %ss
154
 
 
155
 
        /* Disable paging. */
156
 
        movl    %cr0, %eax
157
 
        andl    $(~GRUB_MEMORY_CPU_CR0_PAGING_ON), %eax
158
 
        movl    %eax, %cr0
159
 
 
160
 
        /* Disable amd64. */
161
 
        movl    $GRUB_MEMORY_CPU_AMD64_MSR, %ecx
162
 
        rdmsr
163
 
        andl    $(~GRUB_MEMORY_CPU_AMD64_MSR_ON), %eax
164
 
        wrmsr
165
 
 
166
 
        /* Turn off PAE. */
167
 
        movl    %cr4, %eax
168
 
        andl    $GRUB_MEMORY_CPU_CR4_PAE_ON, %eax
169
 
        movl    %eax, %cr4
170
 
 
171
 
        jmp     LOCAL(cont2)
172
 
LOCAL(cont2):
173
 
        .code32
174
 
 
175
 
        /* mov imm32, %eax */
176
 
        .byte   0xb8
177
 
RELOCATOR_VARIABLE (esp)
178
 
        .long   0
179
 
 
180
 
        movl    %eax, %esp
181
 
 
182
 
        /* mov imm32, %eax */
183
 
        .byte   0xb8
184
 
RELOCATOR_VARIABLE (eax)
185
 
        .long   0
186
 
 
187
 
        /* mov imm32, %ebx */
188
 
        .byte   0xbb
189
 
RELOCATOR_VARIABLE (ebx)
190
 
        .long   0
191
 
 
192
 
        /* mov imm32, %ecx */
193
 
        .byte   0xb9
194
 
RELOCATOR_VARIABLE (ecx)
195
 
        .long   0
196
 
 
197
 
        /* mov imm32, %edx */
198
 
        .byte   0xba
199
 
RELOCATOR_VARIABLE (edx)
200
 
        .long   0
201
 
 
202
 
        /* Cleared direction flag is of no problem with any current
203
 
           payload and makes this implementation easier.  */
204
 
        cld
205
 
 
206
 
        .byte   0xea
207
 
RELOCATOR_VARIABLE (eip)
208
 
        .long   0
209
 
        .word   CODE_SEGMENT
210
 
 
211
 
        /* GDT. Copied from loader/i386/linux.c. */
212
 
        .p2align        4
213
 
LOCAL(gdt):
214
 
        /* NULL.  */
215
 
        .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
216
 
 
217
 
        /* Reserved.  */
218
 
        .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
219
 
 
220
 
        /* Code segment.  */
221
 
        .byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00
222
 
 
223
 
        /* Data segment.  */
224
 
        .byte 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00
225
 
 
226
 
        .p2align        4
227
 
LOCAL(gdtdesc):
228
 
        .word   0x27
229
 
LOCAL(gdt_addr):
230
 
#ifdef __x86_64__
231
 
        /* Filled by the code. */
232
 
        .quad   0
233
 
#else
234
 
        /* Filled by the code. */
235
 
        .long   0
236
 
#endif
237
 
 
238
 
        .p2align        4
239
 
LOCAL(jump_vector):
240
 
        /* Jump location. Is filled by the code */
241
 
        .long   0
242
 
        .long   CODE_SEGMENT
243
 
 
244
 
#ifndef BACKWARD
245
 
LOCAL(base):
246
 
#endif
247
 
 
248
 
RELOCATOR_VARIABLE(end)