4 * Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de>
6 * SPDX-License-Identifier: GPL-2.0+
8 * Test the graphical output protocol.
11 #include <efi_selftest.h>
13 static struct efi_boot_services
*boottime
;
14 static efi_guid_t efi_gop_guid
= EFI_GOP_GUID
;
15 static struct efi_gop
*gop
;
20 * @handle: handle of the loaded image
21 * @systable: system table
22 * @return: EFI_ST_SUCCESS for success
24 static int setup(const efi_handle_t handle
,
25 const struct efi_system_table
*systable
)
29 boottime
= systable
->boottime
;
31 ret
= boottime
->locate_protocol(&efi_gop_guid
, NULL
, (void **)&gop
);
32 if (ret
!= EFI_SUCCESS
) {
34 efi_st_printf("Graphical output protocol is not available.\n");
37 return EFI_ST_SUCCESS
;
41 * Tear down unit test.
43 * @return: EFI_ST_SUCCESS for success
45 static int teardown(void)
47 return EFI_ST_SUCCESS
;
53 * @return: EFI_ST_SUCCESS for success
55 static int execute(void)
60 struct efi_gop_mode_info
*info
;
63 return EFI_ST_SUCCESS
;
66 efi_st_error("EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE missing\n");
67 return EFI_ST_FAILURE
;
69 max_mode
= gop
->mode
->max_mode
;
71 efi_st_error("No graphical mode available\n");
72 return EFI_ST_FAILURE
;
74 efi_st_printf("Number of available modes: %u\n", max_mode
);
76 for (i
= 0; i
< max_mode
; ++i
) {
77 ret
= gop
->query_mode(gop
, i
, &size
, &info
);
78 if (ret
!= EFI_SUCCESS
) {
79 efi_st_printf("Could not query mode %u\n", i
);
80 return EFI_ST_FAILURE
;
82 efi_st_printf("Mode %u: %u x %u\n",
83 i
, info
->width
, info
->height
);
86 return EFI_ST_SUCCESS
;
89 EFI_UNIT_TEST(gop
) = {
90 .name
= "graphical output",
91 .phase
= EFI_EXECUTE_BEFORE_BOOTTIME_EXIT
,