1 /* dl.h - types and prototypes for loadable module support */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2002,2004,2005,2007,2008,2009 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/>.
23 #include <grub/symbol.h>
25 #include <grub/types.h>
28 #define GRUB_MOD_INIT(name) \
29 static void grub_mod_init (grub_dl_t mod __attribute__ ((unused))) __attribute__ ((used)); \
30 void grub_##name##_init (void); \
32 grub_##name##_init (void) { grub_mod_init (0); } \
34 grub_mod_init (grub_dl_t mod __attribute__ ((unused)))
36 #define GRUB_MOD_FINI(name) \
37 static void grub_mod_fini (void) __attribute__ ((used)); \
38 void grub_##name##_fini (void); \
40 grub_##name##_fini (void) { grub_mod_fini (); } \
45 #define GRUB_MOD_NAME(name) \
46 static char grub_modname[] __attribute__ ((section ("_modname, _modname"), used)) = #name;
48 #define GRUB_MOD_DEP(name) \
49 __asm__ (".section _moddeps, _moddeps\n.asciz \"" #name "\"\n")
51 #define GRUB_MOD_NAME(name) \
52 __asm__ (".section .modname\n.asciz \"" #name "\"\n")
54 #define GRUB_MOD_DEP(name) \
55 __asm__ (".section .moddeps\n.asciz \"" #name "\"\n")
58 struct grub_dl_segment
60 struct grub_dl_segment
*next
;
65 typedef struct grub_dl_segment
*grub_dl_segment_t
;
71 struct grub_dl_dep
*next
;
74 typedef struct grub_dl_dep
*grub_dl_dep_t
;
81 grub_dl_segment_t segment
;
83 void (*init
) (struct grub_dl
*mod
);
86 typedef struct grub_dl
*grub_dl_t
;
88 grub_dl_t
EXPORT_FUNC(grub_dl_load_file
) (const char *filename
);
89 grub_dl_t
EXPORT_FUNC(grub_dl_load
) (const char *name
);
90 grub_dl_t
grub_dl_load_core (void *addr
, grub_size_t size
);
91 int EXPORT_FUNC(grub_dl_unload
) (grub_dl_t mod
);
92 void grub_dl_unload_unneeded (void);
93 void grub_dl_unload_all (void);
96 grub_dl_ref (grub_dl_t mod
)
102 grub_dl_unref (grub_dl_t mod
)
108 int EXPORT_FUNC(grub_dl_ref
) (grub_dl_t mod
);
109 int EXPORT_FUNC(grub_dl_unref
) (grub_dl_t mod
);
111 void EXPORT_FUNC(grub_dl_iterate
) (int (*hook
) (grub_dl_t mod
));
112 grub_dl_t
EXPORT_FUNC(grub_dl_get
) (const char *name
);
113 grub_err_t
EXPORT_FUNC(grub_dl_register_symbol
) (const char *name
, void *addr
,
116 grub_err_t
grub_arch_dl_check_header (void *ehdr
);
117 grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod
, void *ehdr
);
119 #endif /* ! GRUB_DL_H */