]>
Commit | Line | Data |
---|---|---|
6a161fa9 | 1 | /* dl.h - types and prototypes for loadable module support */ |
2 | /* | |
4b13b216 | 3 | * GRUB -- GRand Unified Bootloader |
c642636f | 4 | * Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. |
6a161fa9 | 5 | * |
4b13b216 | 6 | * GRUB is free software; you can redistribute it and/or modify |
6a161fa9 | 7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program 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. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
4b13b216 | 17 | * along with GRUB; if not, write to the Free Software |
6a161fa9 | 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | |
20 | ||
4b13b216 | 21 | #ifndef GRUB_DL_H |
22 | #define GRUB_DL_H 1 | |
6a161fa9 | 23 | |
4b13b216 | 24 | #include <grub/symbol.h> |
25 | #include <grub/err.h> | |
26 | #include <grub/types.h> | |
6a161fa9 | 27 | |
6d099807 | 28 | #define GRUB_MOD_INIT(name) \ |
b38551da | 29 | static void grub_mod_init (grub_dl_t mod) __attribute__ ((used)); \ |
6d099807 | 30 | void grub_##name##_init (void); \ |
31 | void \ | |
32 | grub_##name##_init (void) { grub_mod_init (0); } \ | |
6a161fa9 | 33 | static void \ |
4b13b216 | 34 | grub_mod_init (grub_dl_t mod) |
6a161fa9 | 35 | |
6d099807 | 36 | #define GRUB_MOD_FINI(name) \ |
b38551da | 37 | static void grub_mod_fini (void) __attribute__ ((used)); \ |
6d099807 | 38 | void grub_##name##_fini (void); \ |
39 | void \ | |
40 | grub_##name##_fini (void) { grub_mod_fini (); } \ | |
6a161fa9 | 41 | static void \ |
4b13b216 | 42 | grub_mod_fini (void) |
6a161fa9 | 43 | |
4b13b216 | 44 | #define GRUB_MOD_NAME(name) \ |
6a161fa9 | 45 | __asm__ (".section .modname,\"S\"\n.string \"" #name "\"\n.previous") |
46 | ||
4b13b216 | 47 | #define GRUB_MOD_DEP(name) \ |
6a161fa9 | 48 | __asm__ (".section .moddeps,\"S\"\n.string \"" #name "\"\n.previous") |
49 | ||
4b13b216 | 50 | struct grub_dl_segment |
6a161fa9 | 51 | { |
4b13b216 | 52 | struct grub_dl_segment *next; |
6a161fa9 | 53 | void *addr; |
4b13b216 | 54 | grub_size_t size; |
6a161fa9 | 55 | unsigned section; |
56 | }; | |
4b13b216 | 57 | typedef struct grub_dl_segment *grub_dl_segment_t; |
6a161fa9 | 58 | |
4b13b216 | 59 | struct grub_dl; |
6a161fa9 | 60 | |
4b13b216 | 61 | struct grub_dl_dep |
6a161fa9 | 62 | { |
4b13b216 | 63 | struct grub_dl_dep *next; |
64 | struct grub_dl *mod; | |
6a161fa9 | 65 | }; |
4b13b216 | 66 | typedef struct grub_dl_dep *grub_dl_dep_t; |
6a161fa9 | 67 | |
4b13b216 | 68 | struct grub_dl |
6a161fa9 | 69 | { |
70 | char *name; | |
71 | int ref_count; | |
4b13b216 | 72 | grub_dl_dep_t dep; |
73 | grub_dl_segment_t segment; | |
74 | void (*init) (struct grub_dl *mod); | |
6a161fa9 | 75 | void (*fini) (void); |
76 | }; | |
4b13b216 | 77 | typedef struct grub_dl *grub_dl_t; |
6a161fa9 | 78 | |
c642636f | 79 | grub_err_t EXPORT_FUNC(grub_dl_check_header) (void *ehdr, grub_size_t size); |
4b13b216 | 80 | grub_dl_t EXPORT_FUNC(grub_dl_load_file) (const char *filename); |
81 | grub_dl_t EXPORT_FUNC(grub_dl_load) (const char *name); | |
82 | grub_dl_t grub_dl_load_core (void *addr, grub_size_t size); | |
83 | int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod); | |
84 | void grub_dl_unload_unneeded (void); | |
85 | void grub_dl_unload_all (void); | |
86 | int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod); | |
87 | int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod); | |
88 | void EXPORT_FUNC(grub_dl_iterate) (int (*hook) (grub_dl_t mod)); | |
89 | grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name); | |
90 | grub_err_t EXPORT_FUNC(grub_dl_register_symbol) (const char *name, void *addr, | |
91 | grub_dl_t mod); | |
92 | void *EXPORT_FUNC(grub_dl_resolve_symbol) (const char *name); | |
6a161fa9 | 93 | |
c642636f | 94 | grub_err_t grub_arch_dl_check_header (void *ehdr); |
4b13b216 | 95 | grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr); |
6a161fa9 | 96 | |
4b13b216 | 97 | #endif /* ! GRUB_DL_H */ |