make the linux-ppc packags be in synch with other platforms
[tangerine.git] / arch / common / boot / grub2 / loader / i386 / pc / multiboot2.c
blob58afa239956c0a5dc580751cc5aeb2e2ef36eae4
1 /* multiboot2.c - boot a multiboot 2 OS image. */
2 /*
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>
22 #include <grub/elf.h>
23 #include <grub/err.h>
24 #include <grub/machine/loader.h>
25 #include <grub/mm.h>
27 grub_err_t
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",
35 paddr);
37 return GRUB_ERR_NONE;
40 grub_err_t
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",
48 paddr);
50 return GRUB_ERR_NONE;
53 grub_err_t
54 grub_mb2_arch_module_alloc (grub_size_t size, grub_addr_t *addr)
56 grub_addr_t modaddr;
58 modaddr = grub_memalign (MULTIBOOT2_MOD_ALIGN, size);
59 if (! modaddr)
60 return grub_errno;
62 *addr = modaddr;
63 return GRUB_ERR_NONE;
66 grub_err_t
67 grub_mb2_arch_module_free (grub_addr_t addr, UNUSED grub_size_t size)
69 grub_free((void *) addr);
70 return GRUB_ERR_NONE;
73 void
74 grub_mb2_arch_boot (grub_addr_t entry, void *tags)
76 grub_multiboot2_real_boot (entry, tags);
79 void
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);
96 grub_err_t
97 grub_mb2_tags_arch_create (void)
99 /* XXX Create boot device et al. */
100 return GRUB_ERR_NONE;