2009-07-20 Joe Auricchio <jauricchio@gmail.com>
[grub2/phcoder.git] / include / grub / loader.h
blob319f3c551fe58e85a38af62aef948122f2f906e7
1 /* loader.h - OS loaders */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2002,2003,2004,2006,2007,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/>.
20 #ifndef GRUB_LOADER_HEADER
21 #define GRUB_LOADER_HEADER 1
23 #include <grub/file.h>
24 #include <grub/symbol.h>
25 #include <grub/err.h>
26 #include <grub/types.h>
28 /* Check if a loader is loaded. */
29 int grub_loader_is_loaded (void);
31 /* Set loader functions. NORETURN must be set to true, if BOOT won't return
32 to the original state. */
33 void grub_loader_set (grub_err_t (*boot) (void),
34 grub_err_t (*unload) (void),
35 int noreturn);
37 /* Unset current loader, if any. */
38 void grub_loader_unset (void);
40 /* Call the boot hook in current loader. This may or may not return,
41 depending on the setting by grub_loader_set. */
42 grub_err_t grub_loader_boot (void);
44 /* The space between numbers is intentional for the simplicity of adding new
45 values even if external modules use them. */
46 typedef enum {
47 /* A preboot hook which can use everything and turns nothing off. */
48 GRUB_LOADER_PREBOOT_HOOK_PRIO_NORMAL = 400,
49 /* A preboot hook which can't use disks and may stop disks. */
50 GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK = 300,
51 /* A preboot hook which can't use disks or console and may stop console. */
52 GRUB_LOADER_PREBOOT_HOOK_PRIO_CONSOLE = 200,
53 /* A preboot hook which can't use disks or console, can't modify memory map
54 and may stop memory services or finalize memory map. */
55 GRUB_LOADER_PREBOOT_HOOK_PRIO_MEMORY = 100,
56 } grub_loader_preboot_hook_prio_t;
58 /* Register a preboot hook. */
59 void *grub_loader_register_preboot_hook (grub_err_t (*preboot_func) (int noret),
60 grub_err_t (*preboot_rest_func) (void),
61 grub_loader_preboot_hook_prio_t prio);
63 /* Unregister given preboot hook. */
64 void grub_loader_unregister_preboot_hook (void *hnd);
66 #endif /* ! GRUB_LOADER_HEADER */