misc.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2010 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef GRUB_EMU_MISC_H
  19. #define GRUB_EMU_MISC_H 1
  20. #include <config.h>
  21. #include <stdarg.h>
  22. #include <stdio.h>
  23. #include <grub/compiler.h>
  24. #include <grub/symbol.h>
  25. #include <grub/types.h>
  26. #include <grub/misc.h>
  27. #include <grub/util/misc.h>
  28. extern int verbosity;
  29. extern const char *EXPORT_VAR(program_name);
  30. void grub_init_all (void);
  31. void grub_fini_all (void);
  32. void grub_find_zpool_from_dir (const char *dir,
  33. char **poolname, char **poolfs);
  34. char *grub_make_system_path_relative_to_its_root (const char *path)
  35. WARN_UNUSED_RESULT;
  36. int
  37. grub_util_device_is_mapped (const char *dev);
  38. #define GRUB_HOST_PRIuLONG_LONG "llu"
  39. #define GRUB_HOST_PRIxLONG_LONG "llx"
  40. void * EXPORT_FUNC(xcalloc) (grub_size_t nmemb, grub_size_t size) WARN_UNUSED_RESULT;
  41. void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT;
  42. void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT;
  43. char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT;
  44. char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))) WARN_UNUSED_RESULT;
  45. void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2)));
  46. void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2)));
  47. void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2), noreturn));
  48. void EXPORT_FUNC(grub_util_set_kexecute) (void);
  49. int EXPORT_FUNC(grub_util_get_kexecute) (void) WARN_UNUSED_RESULT;
  50. grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void);
  51. #ifdef HAVE_DEVICE_MAPPER
  52. int grub_device_mapper_supported (void);
  53. #endif
  54. #ifdef GRUB_BUILD
  55. #define grub_util_fopen fopen
  56. #else
  57. FILE *
  58. grub_util_fopen (const char *path, const char *mode);
  59. #endif
  60. int grub_util_file_sync (FILE *f);
  61. grub_err_t grub_util_tpm_open (const char *tpm_dev);
  62. grub_err_t grub_util_tpm_close (void);
  63. grub_size_t EXPORT_FUNC(grub_util_tpm_read) (void *output, grub_size_t size);
  64. grub_size_t EXPORT_FUNC(grub_util_tpm_write) (const void *input, grub_size_t size);
  65. #endif /* GRUB_EMU_MISC_H */