summaryrefslogtreecommitdiff
path: root/include/efi_selftest.h
blob: 76304a2b2a7fc9b781a3122cf34c695cb50b46fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 *  EFI application loader
 *
 *  Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de>
 *
 *  SPDX-License-Identifier:     GPL-2.0+
 */

#ifndef _EFI_SELFTEST_H
#define _EFI_SELFTEST_H

#include <common.h>
#include <efi.h>
#include <efi_api.h>
#include <linker_lists.h>

/*
 * Prints an error message.
 *
 * @...	format string followed by fields to print
 */
#define efi_st_error(...) \
	efi_st_printf("%s(%u):\nERROR: ", __FILE__, __LINE__); \
	efi_st_printf(__VA_ARGS__) \

/*
 * A test may be setup and executed at boottime,
 * it may be setup at boottime and executed at runtime,
 * or it may be setup and executed at runtime.
 */
enum efi_test_phase {
	EFI_EXECUTE_BEFORE_BOOTTIME_EXIT = 1,
	EFI_SETUP_BEFORE_BOOTTIME_EXIT,
	EFI_SETUP_AFTER_BOOTTIME_EXIT,
};

extern struct efi_simple_text_output_protocol *con_out;
extern struct efi_simple_input_interface *con_in;

/*
 * Exit the boot services.
 *
 * The size of the memory map is determined.
 * Pool memory is allocated to copy the memory map.
 * The memory amp is copied and the map key is obtained.
 * The map key is used to exit the boot services.
 */
void efi_st_exit_boot_services(void);

/*
 * Print a pointer to an u16 string
 *
 * @pointer: pointer
 * @buf: pointer to buffer address
 * on return position of terminating zero word
 */
void efi_st_printf(const char *fmt, ...)
		 __attribute__ ((format (__printf__, 1, 2)));

/*
 * Reads an Unicode character from the input device.
 *
 * @return: Unicode character
 */
u16 efi_st_get_key(void);

/**
 * struct efi_unit_test - EFI unit test
 *
 * An efi_unit_test provides a interface to an EFI unit test.
 *
 * @name:	name of unit test
 * @phase:	specifies when setup and execute are executed
 * @setup:	set up the unit test
 * @teardown:	tear down the unit test
 * @execute:	execute the unit test
 */
struct efi_unit_test {
	const char *name;
	const enum efi_test_phase phase;
	int (*setup)(const efi_handle_t handle,
		     const struct efi_system_table *systable);
	int (*execute)(void);
	int (*teardown)(void);
};

/* Declare a new EFI unit test */
#define EFI_UNIT_TEST(__name)						\
	ll_entry_declare(struct efi_unit_test, __name, efi_unit_test)

#endif /* _EFI_SELFTEST_H */