efi_selftest_reset.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * efi_selftest_reset
  4. *
  5. * Copyright (c) 2020 Heinrich Schuchardt <xypron.glpk@gmx.de>
  6. *
  7. * This test checks the following service at boot time or runtime:
  8. * ResetSystem()
  9. */
  10. #include <efi_selftest.h>
  11. static struct efi_runtime_services *runtime;
  12. /*
  13. * Setup unit test.
  14. *
  15. * @handle: handle of the loaded image
  16. * @systable: system table
  17. * @return: EFI_ST_SUCCESS for success
  18. */
  19. static int setup(const efi_handle_t handle,
  20. const struct efi_system_table *systable)
  21. {
  22. runtime = systable->runtime;
  23. return EFI_ST_SUCCESS;
  24. }
  25. /*
  26. * Execute unit test.
  27. *
  28. * @return: EFI_ST_SUCCESS for success
  29. */
  30. static int execute(void)
  31. {
  32. u16 reset_data[] = L"Reset by selftest";
  33. runtime->reset_system(EFI_RESET_COLD, EFI_SUCCESS,
  34. sizeof(reset_data), reset_data);
  35. efi_st_error("Reset failed.\n");
  36. return EFI_ST_FAILURE;
  37. }
  38. EFI_UNIT_TEST(reset) = {
  39. .name = "reset system",
  40. .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
  41. .setup = setup,
  42. .execute = execute,
  43. .on_request = true,
  44. };
  45. EFI_UNIT_TEST(resetrt) = {
  46. .name = "reset system runtime",
  47. .phase = EFI_SETUP_BEFORE_BOOTTIME_EXIT,
  48. .setup = setup,
  49. .execute = execute,
  50. .on_request = true,
  51. };