Fix cross compilation (e.g. on Darwin). Following changes to make.tmpl,
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / relocator_private.h
blob1c563cb64e40258733874374893e1eb9b7b388ec
1 /*
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>
23 #include <grub/err.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;
31 void
32 grub_cpu_relocator_init (void);
33 grub_err_t
34 grub_relocator_prepare_relocs (struct grub_relocator *rel,
35 grub_addr_t addr,
36 void **relstart, grub_size_t *relsize);
37 void grub_cpu_relocator_forward (void *rels, void *src, void *tgt,
38 grub_size_t size);
39 void grub_cpu_relocator_backward (void *rels, void *src, void *tgt,
40 grub_size_t size);
41 void grub_cpu_relocator_jumper (void *rels, grub_addr_t addr);
43 /* Remark: GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG = 1 or 2
44 aren't supported. */
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
51 #else
52 #define GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS 0
53 #endif
55 #if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS && GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG != 0
56 #define GRUB_RELOCATOR_HAVE_LEFTOVERS 1
57 #else
58 #define GRUB_RELOCATOR_HAVE_LEFTOVERS 0
59 #endif
61 #if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
62 #define GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT (1 << GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG)
63 #endif
65 struct grub_relocator_mmap_event
67 enum {
68 IN_REG_START = 0,
69 IN_REG_END = 1,
70 REG_BEG_START = 2,
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,
78 #endif
79 #if GRUB_RELOCATOR_HAVE_LEFTOVERS
80 REG_LEFTOVER_START = 8,
81 REG_LEFTOVER_END = REG_LEFTOVER_START | 1,
82 #endif
83 COLLISION_START = 10,
84 COLLISION_END = COLLISION_START | 1
85 } type;
86 grub_phys_addr_t pos;
87 union
89 struct
91 grub_mm_region_t reg;
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;
98 #endif
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,
106 grub_size_t size);
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,
110 grub_size_t size);
111 #endif
113 #endif