2
* GRUB -- GRand Unified Bootloader
3
* Copyright (C) 2009 Free Software Foundation, Inc.
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.
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.
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/>.
20
#include <grub/misc.h>
22
#include <grub/types.h>
23
#include <grub/types.h>
26
#include <grub/i386/relocator.h>
28
extern grub_uint8_t grub_relocator32_forward_start;
29
extern grub_uint8_t grub_relocator32_forward_end;
30
extern grub_uint8_t grub_relocator32_backward_start;
31
extern grub_uint8_t grub_relocator32_backward_end;
33
extern grub_uint32_t grub_relocator32_backward_dest;
34
extern grub_uint32_t grub_relocator32_backward_size;
35
extern grub_addr_t grub_relocator32_backward_src;
37
extern grub_uint32_t grub_relocator32_forward_dest;
38
extern grub_uint32_t grub_relocator32_forward_size;
39
extern grub_addr_t grub_relocator32_forward_src;
41
extern grub_uint32_t grub_relocator32_forward_eax;
42
extern grub_uint32_t grub_relocator32_forward_ebx;
43
extern grub_uint32_t grub_relocator32_forward_ecx;
44
extern grub_uint32_t grub_relocator32_forward_edx;
45
extern grub_uint32_t grub_relocator32_forward_eip;
46
extern grub_uint32_t grub_relocator32_forward_esp;
48
extern grub_uint32_t grub_relocator32_backward_eax;
49
extern grub_uint32_t grub_relocator32_backward_ebx;
50
extern grub_uint32_t grub_relocator32_backward_ecx;
51
extern grub_uint32_t grub_relocator32_backward_edx;
52
extern grub_uint32_t grub_relocator32_backward_eip;
53
extern grub_uint32_t grub_relocator32_backward_esp;
55
#define RELOCATOR_SIZEOF(x) (&grub_relocator32_##x##_end - &grub_relocator32_##x##_start)
56
#define RELOCATOR_ALIGN 16
57
#define PREFIX(x) grub_relocator32_ ## x
60
write_call_relocator_bw (void *ptr, void *src, grub_uint32_t dest,
61
grub_size_t size, struct grub_relocator32_state state)
63
grub_relocator32_backward_dest = dest;
64
grub_relocator32_backward_src = PTR_TO_UINT64 (src);
65
grub_relocator32_backward_size = size;
67
grub_relocator32_backward_eax = state.eax;
68
grub_relocator32_backward_ebx = state.ebx;
69
grub_relocator32_backward_ecx = state.ecx;
70
grub_relocator32_backward_edx = state.edx;
71
grub_relocator32_backward_eip = state.eip;
72
grub_relocator32_backward_esp = state.esp;
75
&grub_relocator32_backward_start,
76
RELOCATOR_SIZEOF (backward));
77
((void (*) (void)) ptr) ();
81
write_call_relocator_fw (void *ptr, void *src, grub_uint32_t dest,
82
grub_size_t size, struct grub_relocator32_state state)
85
grub_relocator32_forward_dest = dest;
86
grub_relocator32_forward_src = PTR_TO_UINT64 (src);
87
grub_relocator32_forward_size = size;
89
grub_relocator32_forward_eax = state.eax;
90
grub_relocator32_forward_ebx = state.ebx;
91
grub_relocator32_forward_ecx = state.ecx;
92
grub_relocator32_forward_edx = state.edx;
93
grub_relocator32_forward_eip = state.eip;
94
grub_relocator32_forward_esp = state.esp;
97
&grub_relocator32_forward_start,
98
RELOCATOR_SIZEOF (forward));
99
((void (*) (void)) ptr) ();
102
#include "../relocator.c"