loader.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* loader.h - OS loaders */
  2. /*
  3. * GRUB -- GRand Unified Bootloader
  4. * Copyright (C) 2002,2003,2004,2006,2007,2009 Free Software Foundation, Inc.
  5. *
  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.
  10. *
  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.
  15. *
  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/>.
  18. */
  19. #ifndef GRUB_LOADER_HEADER
  20. #define GRUB_LOADER_HEADER 1
  21. #include <grub/file.h>
  22. #include <grub/symbol.h>
  23. #include <grub/err.h>
  24. #include <grub/types.h>
  25. /* Check if a loader is loaded. */
  26. int EXPORT_FUNC (grub_loader_is_loaded) (void);
  27. /* Set loader functions. */
  28. enum
  29. {
  30. GRUB_LOADER_FLAG_NORETURN = 1,
  31. GRUB_LOADER_FLAG_PXE_NOT_UNLOAD = 2,
  32. GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY = 4,
  33. };
  34. void EXPORT_FUNC (grub_loader_set) (grub_err_t (*boot) (void),
  35. grub_err_t (*unload) (void),
  36. int flags);
  37. void EXPORT_FUNC (grub_loader_set_ex) (grub_err_t (*boot) (void *context),
  38. grub_err_t (*unload) (void *context),
  39. void *context,
  40. int flags);
  41. /* Unset current loader, if any. */
  42. void EXPORT_FUNC (grub_loader_unset) (void);
  43. /* Call the boot hook in current loader. This may or may not return,
  44. depending on the setting by grub_loader_set. */
  45. grub_err_t grub_loader_boot (void);
  46. /* The space between numbers is intentional for the simplicity of adding new
  47. values even if external modules use them. */
  48. typedef enum {
  49. /* A preboot hook which can use everything and turns nothing off. */
  50. GRUB_LOADER_PREBOOT_HOOK_PRIO_NORMAL = 400,
  51. /* A preboot hook which can't use disks and may stop disks. */
  52. GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK = 300,
  53. /* A preboot hook which can't use disks or console and may stop console. */
  54. GRUB_LOADER_PREBOOT_HOOK_PRIO_CONSOLE = 200,
  55. /* A preboot hook which can't use disks or console, can't modify memory map
  56. and may stop memory services or finalize memory map. */
  57. GRUB_LOADER_PREBOOT_HOOK_PRIO_MEMORY = 100,
  58. } grub_loader_preboot_hook_prio_t;
  59. /* Register a preboot hook. */
  60. struct grub_preboot;
  61. struct grub_preboot *EXPORT_FUNC(grub_loader_register_preboot_hook) (grub_err_t (*preboot_func) (int noret),
  62. grub_err_t (*preboot_rest_func) (void),
  63. grub_loader_preboot_hook_prio_t prio);
  64. /* Unregister given preboot hook. */
  65. void EXPORT_FUNC (grub_loader_unregister_preboot_hook) (struct grub_preboot *hnd);
  66. #ifndef GRUB_MACHINE_EMU
  67. void grub_boot_init (void);
  68. void grub_boot_fini (void);
  69. #endif
  70. #endif /* ! GRUB_LOADER_HEADER */