]> git.proxmox.com Git - grub2.git/blame - include/grub/dl.h
2005-11-13 Marco Gerards <mgerards@xs4all.nl>
[grub2.git] / include / grub / dl.h
CommitLineData
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 29static void grub_mod_init (grub_dl_t mod) __attribute__ ((used)); \
6d099807 30void grub_##name##_init (void); \
31void \
32grub_##name##_init (void) { grub_mod_init (0); } \
6a161fa9 33static void \
4b13b216 34grub_mod_init (grub_dl_t mod)
6a161fa9 35
6d099807 36#define GRUB_MOD_FINI(name) \
b38551da 37static void grub_mod_fini (void) __attribute__ ((used)); \
6d099807 38void grub_##name##_fini (void); \
39void \
40grub_##name##_fini (void) { grub_mod_fini (); } \
6a161fa9 41static void \
4b13b216 42grub_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 50struct 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 57typedef struct grub_dl_segment *grub_dl_segment_t;
6a161fa9 58
4b13b216 59struct grub_dl;
6a161fa9 60
4b13b216 61struct grub_dl_dep
6a161fa9 62{
4b13b216 63 struct grub_dl_dep *next;
64 struct grub_dl *mod;
6a161fa9 65};
4b13b216 66typedef struct grub_dl_dep *grub_dl_dep_t;
6a161fa9 67
4b13b216 68struct 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 77typedef struct grub_dl *grub_dl_t;
6a161fa9 78
c642636f 79grub_err_t EXPORT_FUNC(grub_dl_check_header) (void *ehdr, grub_size_t size);
4b13b216 80grub_dl_t EXPORT_FUNC(grub_dl_load_file) (const char *filename);
81grub_dl_t EXPORT_FUNC(grub_dl_load) (const char *name);
82grub_dl_t grub_dl_load_core (void *addr, grub_size_t size);
83int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
84void grub_dl_unload_unneeded (void);
85void grub_dl_unload_all (void);
86int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
87int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
88void EXPORT_FUNC(grub_dl_iterate) (int (*hook) (grub_dl_t mod));
89grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name);
90grub_err_t EXPORT_FUNC(grub_dl_register_symbol) (const char *name, void *addr,
91 grub_dl_t mod);
92void *EXPORT_FUNC(grub_dl_resolve_symbol) (const char *name);
6a161fa9 93
c642636f 94grub_err_t grub_arch_dl_check_header (void *ehdr);
4b13b216 95grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
6a161fa9 96
4b13b216 97#endif /* ! GRUB_DL_H */