]> git.ipfire.org Git - people/ms/u-boot.git/blame - include/efi_selftest.h
mx53: Add Board support for GE PPD
[people/ms/u-boot.git] / include / efi_selftest.h
CommitLineData
623b3a57
HS
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
e67e7249
HS
17#define EFI_ST_SUCCESS 0
18#define EFI_ST_FAILURE 1
19
623b3a57
HS
20/*
21 * Prints an error message.
22 *
23 * @... format string followed by fields to print
24 */
25#define efi_st_error(...) \
9820c2f3
HS
26 (efi_st_printf("%s(%u):\nERROR: ", __FILE__, __LINE__), \
27 efi_st_printf(__VA_ARGS__)) \
623b3a57
HS
28
29/*
30 * A test may be setup and executed at boottime,
31 * it may be setup at boottime and executed at runtime,
32 * or it may be setup and executed at runtime.
33 */
34enum efi_test_phase {
35 EFI_EXECUTE_BEFORE_BOOTTIME_EXIT = 1,
36 EFI_SETUP_BEFORE_BOOTTIME_EXIT,
37 EFI_SETUP_AFTER_BOOTTIME_EXIT,
38};
39
40extern struct efi_simple_text_output_protocol *con_out;
41extern struct efi_simple_input_interface *con_in;
42
43/*
44 * Exit the boot services.
45 *
46 * The size of the memory map is determined.
47 * Pool memory is allocated to copy the memory map.
48 * The memory amp is copied and the map key is obtained.
49 * The map key is used to exit the boot services.
50 */
51void efi_st_exit_boot_services(void);
52
53/*
54 * Print a pointer to an u16 string
55 *
56 * @pointer: pointer
57 * @buf: pointer to buffer address
58 * on return position of terminating zero word
59 */
60void efi_st_printf(const char *fmt, ...)
61 __attribute__ ((format (__printf__, 1, 2)));
62
5ca23ed5
HS
63/*
64 * Compare memory.
65 * We cannot use lib/string.c due to different CFLAGS values.
66 *
67 * @buf1: first buffer
68 * @buf2: second buffer
69 * @length: number of bytes to compare
70 * @return: 0 if both buffers contain the same bytes
71 */
72int efi_st_memcmp(const void *buf1, const void *buf2, size_t length);
73
623b3a57
HS
74/*
75 * Reads an Unicode character from the input device.
76 *
77 * @return: Unicode character
78 */
79u16 efi_st_get_key(void);
80
81/**
82 * struct efi_unit_test - EFI unit test
83 *
84 * An efi_unit_test provides a interface to an EFI unit test.
85 *
86 * @name: name of unit test
87 * @phase: specifies when setup and execute are executed
88 * @setup: set up the unit test
89 * @teardown: tear down the unit test
90 * @execute: execute the unit test
91 */
92struct efi_unit_test {
93 const char *name;
94 const enum efi_test_phase phase;
95 int (*setup)(const efi_handle_t handle,
96 const struct efi_system_table *systable);
97 int (*execute)(void);
98 int (*teardown)(void);
99};
100
101/* Declare a new EFI unit test */
102#define EFI_UNIT_TEST(__name) \
103 ll_entry_declare(struct efi_unit_test, __name, efi_unit_test)
104
105#endif /* _EFI_SELFTEST_H */