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