efi_selftest.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * EFI application loader
  3. *
  4. * Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #ifndef _EFI_SELFTEST_H
  9. #define _EFI_SELFTEST_H
  10. #include <common.h>
  11. #include <efi.h>
  12. #include <efi_api.h>
  13. #include <linker_lists.h>
  14. /*
  15. * Prints an error message.
  16. *
  17. * @... format string followed by fields to print
  18. */
  19. #define efi_st_error(...) \
  20. efi_st_printf("%s(%u):\nERROR: ", __FILE__, __LINE__); \
  21. efi_st_printf(__VA_ARGS__) \
  22. /*
  23. * A test may be setup and executed at boottime,
  24. * it may be setup at boottime and executed at runtime,
  25. * or it may be setup and executed at runtime.
  26. */
  27. enum efi_test_phase {
  28. EFI_EXECUTE_BEFORE_BOOTTIME_EXIT = 1,
  29. EFI_SETUP_BEFORE_BOOTTIME_EXIT,
  30. EFI_SETUP_AFTER_BOOTTIME_EXIT,
  31. };
  32. extern struct efi_simple_text_output_protocol *con_out;
  33. extern struct efi_simple_input_interface *con_in;
  34. /*
  35. * Exit the boot services.
  36. *
  37. * The size of the memory map is determined.
  38. * Pool memory is allocated to copy the memory map.
  39. * The memory amp is copied and the map key is obtained.
  40. * The map key is used to exit the boot services.
  41. */
  42. void efi_st_exit_boot_services(void);
  43. /*
  44. * Print a pointer to an u16 string
  45. *
  46. * @pointer: pointer
  47. * @buf: pointer to buffer address
  48. * on return position of terminating zero word
  49. */
  50. void efi_st_printf(const char *fmt, ...)
  51. __attribute__ ((format (__printf__, 1, 2)));
  52. /*
  53. * Reads an Unicode character from the input device.
  54. *
  55. * @return: Unicode character
  56. */
  57. u16 efi_st_get_key(void);
  58. /**
  59. * struct efi_unit_test - EFI unit test
  60. *
  61. * An efi_unit_test provides a interface to an EFI unit test.
  62. *
  63. * @name: name of unit test
  64. * @phase: specifies when setup and execute are executed
  65. * @setup: set up the unit test
  66. * @teardown: tear down the unit test
  67. * @execute: execute the unit test
  68. */
  69. struct efi_unit_test {
  70. const char *name;
  71. const enum efi_test_phase phase;
  72. int (*setup)(const efi_handle_t handle,
  73. const struct efi_system_table *systable);
  74. int (*execute)(void);
  75. int (*teardown)(void);
  76. };
  77. /* Declare a new EFI unit test */
  78. #define EFI_UNIT_TEST(__name) \
  79. ll_entry_declare(struct efi_unit_test, __name, efi_unit_test)
  80. #endif /* _EFI_SELFTEST_H */