1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de>
7 * Test the graphical output protocol.
10 #include <efi_selftest.h>
12 static struct efi_boot_services
*boottime
;
13 static efi_guid_t efi_gop_guid
= EFI_GOP_GUID
;
14 static struct efi_gop
*gop
;
19 * @handle: handle of the loaded image
20 * @systable: system table
21 * @return: EFI_ST_SUCCESS for success
23 static int setup(const efi_handle_t handle
,
24 const struct efi_system_table
*systable
)
28 boottime
= systable
->boottime
;
30 ret
= boottime
->locate_protocol(&efi_gop_guid
, NULL
, (void **)&gop
);
31 if (ret
!= EFI_SUCCESS
) {
33 efi_st_printf("Graphical output protocol is not available.\n");
36 return EFI_ST_SUCCESS
;
40 * Tear down unit test.
42 * @return: EFI_ST_SUCCESS for success
44 static int teardown(void)
46 return EFI_ST_SUCCESS
;
52 * @return: EFI_ST_SUCCESS for success
54 static int execute(void)
59 struct efi_gop_mode_info
*info
;
62 return EFI_ST_SUCCESS
;
65 efi_st_error("EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE missing\n");
66 return EFI_ST_FAILURE
;
68 max_mode
= gop
->mode
->max_mode
;
70 efi_st_error("No graphical mode available\n");
71 return EFI_ST_FAILURE
;
73 efi_st_printf("Number of available modes: %u\n", max_mode
);
75 for (i
= 0; i
< max_mode
; ++i
) {
76 ret
= gop
->query_mode(gop
, i
, &size
, &info
);
77 if (ret
!= EFI_SUCCESS
) {
78 efi_st_printf("Could not query mode %u\n", i
);
79 return EFI_ST_FAILURE
;
81 efi_st_printf("Mode %u: %u x %u\n",
82 i
, info
->width
, info
->height
);
85 return EFI_ST_SUCCESS
;
88 EFI_UNIT_TEST(gop
) = {
89 .name
= "graphical output",
90 .phase
= EFI_EXECUTE_BEFORE_BOOTTIME_EXIT
,