32297d5ff7
* Makefile.util.def (libgrubmods.a): Add grub-core/kern/ia64/dl_helper.c * configure.ac: Add ia64-efi target. Probe for __ia64_trampoline, __udivsi3, __umoddi3, __udivdi3, __divsi3, __modsi3, __umodsi3, __moddi3 and __divdi3 symbols. * gentpl.py: Add ia64_efi platform. Rename x86_efi to efi and Add ia64-efi. All users updated. * grub-core/Makefile.am: Set KERNEL_HEADER_FILES for ia64-efi. * grub-core/Makefile.core.def (kernel.img): Add compile flags for ia64. Remove kern/generic/rtc_get_time_ms.c on EFI. Add kern/ia64/efi/startup.S, kern/ia64/efi/init.c, kern/ia64/dl.c, kern/ia64/dl_helper.c on ia64-efi. Add kern/emu/cache.c on emu. (linux): Use on loader/ia64/efi/linux.c on ia64. * grub-core/gensymlist.sh (grub_register_exported_symbols): Check whether symbol is a function. * grub-core/kern/dl.c [GRUB_MACHINE_EMU]: Include sys/mman.h. (grub_symbol): New field 'isfunc'. (grub_dl_resolve_symbol): Return whole symbol rather than just address. (grub_dl_register_symbol): New argument 'isfunc'. All users updated. (grub_dl_load_segments): Place all sections into the same region. [__ia64__]: Create trampolines and got. [GRUB_MACHINE_EMU]: Call mprotect. (grub_dl_resolve_symbols): Resolve symbol type as well. [__ia64__]: Create function descriptors. * grub-core/kern/efi/efi.c (grub_get_rtc): Renamed to ... (grub_rtc_get_time_ms): ... this. Expressions simplified. (grub_get_rtc): New function. * grub-core/kern/emu/cache.c [__ia64__]: New file. * grub-core/kern/emu/cache.S: Renamed to ... * grub-core/kern/emu/cache_s.S: ... this. [__ia64__]: Add a nop. * grub-core/kern/emu/full.c (grub_arch_dl_get_tramp_got_size) [__ia64__]: New function. * grub-core/kern/emu/lite.c [__ia64__]: Include ../ia64/dl.c. * grub-core/kern/ia64/dl.c: New file. * grub-core/kern/ia64/dl_helper.c: Likewise. * grub-core/kern/ia64/efi/init.c: New file. * grub-core/kern/ia64/efi/startup.S: Likewise. * grub-core/lib/efi/halt.c [__ia64__]: Don't try acpi. * grub-core/lib/ia64/longjmp.S: New file (from glibc). * grub-core/lib/ia64/setjmp.S: Likewise (from glibc). * grub-core/lib/setjmp.S [__ia64__]: Include ./ia64/setjmp.S. * grub-core/loader/ia64/efi/linux.c: New file. * include/grub/dl.h (GRUB_MOD_NAME): Redefined using C rather than asm. (GRUB_MOD_DEP): Likewise. (grub_dl) [__ia64__]: New fields got and tramp. (grub_dl): New field 'base'. (grub_dl_register_symbol): New argument isfunc. All users updated. (GRUB_IA64_DL_TRAMP_ALIGN): New definition. (GRUB_IA64_DL_TRAMP_SIZE): Likewise. (GRUB_IA64_DL_GOT_ALIGN): Likewise. (grub_ia64_dl_get_tramp_got_size): New proto. (GRUB_ARCH_DL_TRAMP_ALIGN) [__ia64__]: Likewise (GRUB_ARCH_DL_GOT_ALIGN) [__ia64__]: Likewise (grub_arch_dl_get_tramp_got_size) [__ia64__]: Likewise * include/grub/efi/api.h: Skip call wrappers on ia64. * include/grub/efi/pe32.h (GRUB_PE32_MACHINE_IA64): New definition. * include/grub/efi/time.h (GRUB_TICKS_PER_SECOND): Change to 1000. * include/grub/elf.h (ELF_ST_INFO): New definition. * include/grub/ia64/efi/kernel.h: New file. * include/grub/ia64/efi/memory.h: Likewise. * include/grub/ia64/efi/time.h: Likewise. * include/grub/ia64/kernel.h: Likewise. * include/grub/ia64/setjmp.h: Likewise (from glibc). * include/grub/ia64/time.h: New file. * include/grub/ia64/types.h: Likewise. * include/grub/libgcc.h (__udivsi3, __umodsi3, __umoddi3, __udivdi3, __moddi3, __divdi3, __divsi3, __modsi3, __ia64_trampoline): New protos. * include/grub/offsets.h (GRUB_KERNEL_IA64_EFI_PREFIX): New definition. (GRUB_KERNEL_IA64_EFI_PREFIX_END): Likewise. * include/grub/types.h (PRIxGRUB_ADDR): Likewise. * util/grub-mkimage.c (image_target_desc): New field pe_target. All users updated. (EFI64_HEADER_SIZE): New definition. All users updated. (image_targets): Add ia64-efi. * util/grub-mkimagexx.c (relocate_symbols): New arguments jumpers and jumpers_addr. All users updated. Create function descriptors. (count_funcs): New function. (unaligned_uint32): New struct. (MASK20): New definition. (MASK19): Likewise. (MASKF21): Likewise. (add_value_to_slot_20b): New function. (add_value_to_slot_21_real): Likewise. (add_value_to_slot_21): Likewise. (ia64_kernel_trampoline): New struct. (nopm): New variable. (jump): Likewise. (make_trampoline): New function. (relocate_addresses): Handle ia64. (make_reloc_section): Likewise. (load_image): Likewise. Also-By: Robert Millan <rmh.grub@aybabtu.com> Also-By: Vladimir Serbinenko <phcoder@gmail.com>
184 lines
5.1 KiB
C
184 lines
5.1 KiB
C
/* dl.h - types and prototypes for loadable module support */
|
|
/*
|
|
* GRUB -- GRand Unified Bootloader
|
|
* Copyright (C) 2002,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
|
|
*
|
|
* GRUB is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* GRUB is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef GRUB_DL_H
|
|
#define GRUB_DL_H 1
|
|
|
|
#include <grub/symbol.h>
|
|
#ifndef ASM_FILE
|
|
#include <grub/err.h>
|
|
#include <grub/types.h>
|
|
#include <grub/elf.h>
|
|
#endif
|
|
|
|
/*
|
|
* Macros GRUB_MOD_INIT and GRUB_MOD_FINI are also used by build rules
|
|
* to collect module names, so we define them only when they are not
|
|
* defined already.
|
|
*/
|
|
#ifndef ASM_FILE
|
|
|
|
#ifndef GRUB_MOD_INIT
|
|
#define GRUB_MOD_INIT(name) \
|
|
static void grub_mod_init (grub_dl_t mod __attribute__ ((unused))) __attribute__ ((used)); \
|
|
void grub_##name##_init (void); \
|
|
void \
|
|
grub_##name##_init (void) { grub_mod_init (0); } \
|
|
static void \
|
|
grub_mod_init (grub_dl_t mod __attribute__ ((unused)))
|
|
#endif
|
|
|
|
#ifndef GRUB_MOD_FINI
|
|
#define GRUB_MOD_FINI(name) \
|
|
static void grub_mod_fini (void) __attribute__ ((used)); \
|
|
void grub_##name##_fini (void); \
|
|
void \
|
|
grub_##name##_fini (void) { grub_mod_fini (); } \
|
|
static void \
|
|
grub_mod_fini (void)
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifndef ASM_FILE
|
|
#ifdef APPLE_CC
|
|
#define GRUB_MOD_SECTION(x) "_" #x ", _" #x ""
|
|
#else
|
|
#define GRUB_MOD_SECTION(x) "." #x
|
|
#endif
|
|
#else
|
|
#ifdef APPLE_CC
|
|
#define GRUB_MOD_SECTION(x) _ ## x , _ ##x
|
|
#else
|
|
#define GRUB_MOD_SECTION(x) . ## x
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef ASM_FILE
|
|
#define GRUB_MOD_DEP(name) \
|
|
static const char grub_module_depend_##name[] \
|
|
__attribute__((section(GRUB_MOD_SECTION(moddeps)), __used__)) = #name
|
|
#define GRUB_MOD_NAME(name) \
|
|
static const char grub_module_name_##name[] \
|
|
__attribute__((section(GRUB_MOD_SECTION(modname)), __used__)) = #name
|
|
#endif
|
|
|
|
/* Me, Vladimir Serbinenko, hereby I add this module check as per new
|
|
GNU module policy. Note that this license check is informative only.
|
|
Modules have to be licensed under GPLv3 or GPLv3+ (optionally
|
|
multi-licensed under other licences as well) independently of the
|
|
presence of this check and solely by linking (module loading in GRUB
|
|
constitutes linking) and GRUB core being licensed under GPLv3+.
|
|
Be sure to understand your license obligations.
|
|
*/
|
|
#ifndef ASM_FILE
|
|
#define GRUB_MOD_LICENSE(license) \
|
|
static char grub_module_license[] __attribute__ ((section (GRUB_MOD_SECTION (module_license)), used)) = "LICENSE=" license;
|
|
#else
|
|
#define GRUB_MOD_LICENSE(license) \
|
|
.section GRUB_MOD_SECTION(module_license), "a"; \
|
|
.ascii "LICENSE="; \
|
|
.ascii license; \
|
|
.byte 0
|
|
#endif
|
|
|
|
/* Under GPL license obligations you have to distribute your module
|
|
under GPLv3(+). However, you can also distribute the same code under
|
|
another license as long as GPLv3(+) version is provided.
|
|
*/
|
|
#define GRUB_MOD_DUAL_LICENSE(x)
|
|
|
|
#ifndef ASM_FILE
|
|
|
|
struct grub_dl_segment
|
|
{
|
|
struct grub_dl_segment *next;
|
|
void *addr;
|
|
grub_size_t size;
|
|
unsigned section;
|
|
};
|
|
typedef struct grub_dl_segment *grub_dl_segment_t;
|
|
|
|
struct grub_dl;
|
|
|
|
struct grub_dl_dep
|
|
{
|
|
struct grub_dl_dep *next;
|
|
struct grub_dl *mod;
|
|
};
|
|
typedef struct grub_dl_dep *grub_dl_dep_t;
|
|
|
|
struct grub_dl
|
|
{
|
|
char *name;
|
|
int ref_count;
|
|
grub_dl_dep_t dep;
|
|
grub_dl_segment_t segment;
|
|
Elf_Sym *symtab;
|
|
void (*init) (struct grub_dl *mod);
|
|
void (*fini) (void);
|
|
#ifdef __ia64__
|
|
void *got;
|
|
void *tramp;
|
|
#endif
|
|
void *base;
|
|
struct grub_dl *next;
|
|
};
|
|
typedef struct grub_dl *grub_dl_t;
|
|
|
|
grub_dl_t EXPORT_FUNC(grub_dl_load_file) (const char *filename);
|
|
grub_dl_t EXPORT_FUNC(grub_dl_load) (const char *name);
|
|
grub_dl_t grub_dl_load_core (void *addr, grub_size_t size);
|
|
int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
|
|
void grub_dl_unload_unneeded (void);
|
|
int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
|
|
int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
|
|
extern grub_dl_t EXPORT_VAR(grub_dl_head);
|
|
|
|
#define FOR_DL_MODULES(var) FOR_LIST_ELEMENTS ((var), (grub_dl_head))
|
|
|
|
grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name);
|
|
grub_err_t grub_dl_register_symbol (const char *name, void *addr,
|
|
int isfunc, grub_dl_t mod);
|
|
|
|
grub_err_t grub_arch_dl_check_header (void *ehdr);
|
|
grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
|
|
|
|
#if defined (_mips)
|
|
#define GRUB_LINKER_HAVE_INIT 1
|
|
void grub_arch_dl_init_linker (void);
|
|
#endif
|
|
|
|
#define GRUB_IA64_DL_TRAMP_ALIGN 16
|
|
#define GRUB_IA64_DL_TRAMP_SIZE 48
|
|
#define GRUB_IA64_DL_GOT_ALIGN 16
|
|
|
|
void
|
|
grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
|
grub_size_t *got);
|
|
|
|
#ifdef __ia64__
|
|
#define GRUB_ARCH_DL_TRAMP_ALIGN 16
|
|
#define GRUB_ARCH_DL_GOT_ALIGN 16
|
|
#define grub_arch_dl_get_tramp_got_size grub_ia64_dl_get_tramp_got_size
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif /* ! GRUB_DL_H */
|