1 /* multiboot2.c - boot a multiboot 2 OS image. */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2007 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #include <multiboot2.h>
21 #include <grub/multiboot2.h>
24 #include <grub/machine/loader.h>
28 grub_mb2_arch_elf32_hook (Elf32_Phdr
*phdr
, UNUSED grub_addr_t
*addr
)
30 Elf32_Addr paddr
= phdr
->p_paddr
;
32 if ((paddr
< grub_os_area_addr
)
33 || (paddr
+ phdr
->p_memsz
> grub_os_area_addr
+ grub_os_area_size
))
34 return grub_error(GRUB_ERR_OUT_OF_RANGE
,"Address 0x%x is out of range",
41 grub_mb2_arch_elf64_hook (Elf64_Phdr
*phdr
, UNUSED grub_addr_t
*addr
)
43 Elf64_Addr paddr
= phdr
->p_paddr
;
45 if ((paddr
< grub_os_area_addr
)
46 || (paddr
+ phdr
->p_memsz
> grub_os_area_addr
+ grub_os_area_size
))
47 return grub_error (GRUB_ERR_OUT_OF_RANGE
, "Address 0x%x is out of range",
54 grub_mb2_arch_module_alloc (grub_size_t size
, grub_addr_t
*addr
)
58 modaddr
= grub_memalign (MULTIBOOT2_MOD_ALIGN
, size
);
67 grub_mb2_arch_module_free (grub_addr_t addr
, UNUSED grub_size_t size
)
69 grub_free((void *) addr
);
74 grub_mb2_arch_boot (grub_addr_t entry
, void *tags
)
76 grub_multiboot2_real_boot (entry
, tags
);
80 grub_mb2_arch_unload (struct multiboot_tag_header
*tags
)
82 struct multiboot_tag_header
*tag
;
84 /* Free all module memory in the tag list. */
85 for_each_tag (tag
, tags
)
87 if (tag
->key
== MULTIBOOT2_TAG_MODULE
)
89 struct multiboot_tag_module
*module
=
90 (struct multiboot_tag_module
*) tag
;
91 grub_free((void *) module
->addr
);
97 grub_mb2_tags_arch_create (void)
99 /* XXX Create boot device et al. */
100 return GRUB_ERR_NONE
;