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/>.
19 #ifndef GRUB_RELOCATOR_PRIVATE_HEADER
20 #define GRUB_RELOCATOR_PRIVATE_HEADER 1
22 #include <grub/types.h>
24 #include <grub/mm_private.h>
26 extern grub_size_t grub_relocator_align
;
27 extern grub_size_t grub_relocator_forward_size
;
28 extern grub_size_t grub_relocator_backward_size
;
29 extern grub_size_t grub_relocator_jumper_size
;
32 grub_cpu_relocator_init (void);
34 grub_relocator_prepare_relocs (struct grub_relocator
*rel
,
36 void **relstart
, grub_size_t
*relsize
);
37 void grub_cpu_relocator_forward (void *rels
, void *src
, void *tgt
,
39 void grub_cpu_relocator_backward (void *rels
, void *src
, void *tgt
,
41 void grub_cpu_relocator_jumper (void *rels
, grub_addr_t addr
);
43 /* Remark: GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG = 1 or 2
45 #ifdef GRUB_MACHINE_IEEE1275
46 #define GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS 1
47 #define GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG 0
48 #elif defined (GRUB_MACHINE_EFI)
49 #define GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS 1
50 #define GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG 12
52 #define GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS 0
55 #if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS && GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG != 0
56 #define GRUB_RELOCATOR_HAVE_LEFTOVERS 1
58 #define GRUB_RELOCATOR_HAVE_LEFTOVERS 0
61 #if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
62 #define GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT (1 << GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG)
65 struct grub_relocator_mmap_event
71 REG_BEG_END
= REG_BEG_START
| 1,
72 #if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
73 REG_FIRMWARE_START
= 4,
74 REG_FIRMWARE_END
= REG_FIRMWARE_START
| 1,
75 /* To track the regions already in heap. */
76 FIRMWARE_BLOCK_START
= 6,
77 FIRMWARE_BLOCK_END
= FIRMWARE_BLOCK_START
| 1,
79 #if GRUB_RELOCATOR_HAVE_LEFTOVERS
80 REG_LEFTOVER_START
= 8,
81 REG_LEFTOVER_END
= REG_LEFTOVER_START
| 1,
84 COLLISION_END
= COLLISION_START
| 1
92 grub_mm_header_t hancestor
;
93 grub_mm_region_t
*regancestor
;
94 grub_mm_header_t head
;
96 #if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
97 struct grub_relocator_fw_leftover
*leftover
;
102 /* Return 0 on failure, 1 on success. The failure here
103 can be very time-expensive, so please make sure fill events is accurate. */
104 #if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
105 int grub_relocator_firmware_alloc_region (grub_phys_addr_t start
,
107 unsigned grub_relocator_firmware_fill_events (struct grub_relocator_mmap_event
*events
);
108 unsigned grub_relocator_firmware_get_max_events (void);
109 void grub_relocator_firmware_free_region (grub_phys_addr_t start
,