1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * Copyright (C) 2012-2013 Kay Sievers <kay@vrfy.org>
15 * Copyright (C) 2012 Harald Hoyer <harald@redhat.com>
16 * Copyright (C) 2013 Intel Corporation
17 * Authored by Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
26 EFI_STATUS
graphics_mode(BOOLEAN on
) {
27 #define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \
28 { 0xf42f7782, 0x12e, 0x4c12, { 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21 } };
30 struct _EFI_CONSOLE_CONTROL_PROTOCOL
;
33 EfiConsoleControlScreenText
,
34 EfiConsoleControlScreenGraphics
,
35 EfiConsoleControlScreenMaxValue
,
36 } EFI_CONSOLE_CONTROL_SCREEN_MODE
;
38 typedef EFI_STATUS (EFIAPI
*EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE
)(
39 struct _EFI_CONSOLE_CONTROL_PROTOCOL
*This
,
40 EFI_CONSOLE_CONTROL_SCREEN_MODE
*Mode
,
45 typedef EFI_STATUS (EFIAPI
*EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE
)(
46 struct _EFI_CONSOLE_CONTROL_PROTOCOL
*This
,
47 EFI_CONSOLE_CONTROL_SCREEN_MODE Mode
50 typedef EFI_STATUS (EFIAPI
*EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN
)(
51 struct _EFI_CONSOLE_CONTROL_PROTOCOL
*This
,
55 typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL
{
56 EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE GetMode
;
57 EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE SetMode
;
58 EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN LockStdIn
;
59 } EFI_CONSOLE_CONTROL_PROTOCOL
;
61 EFI_GUID ConsoleControlProtocolGuid
= EFI_CONSOLE_CONTROL_PROTOCOL_GUID
;
62 EFI_CONSOLE_CONTROL_PROTOCOL
*ConsoleControl
= NULL
;
63 EFI_CONSOLE_CONTROL_SCREEN_MODE
new;
64 EFI_CONSOLE_CONTROL_SCREEN_MODE current
;
69 err
= LibLocateProtocol(&ConsoleControlProtocolGuid
, (VOID
**)&ConsoleControl
);
71 /* console control protocol is nonstandard and might not exist. */
72 return err
== EFI_NOT_FOUND
? EFI_SUCCESS
: err
;
74 /* check current mode */
75 err
= uefi_call_wrapper(ConsoleControl
->GetMode
, 4, ConsoleControl
, ¤t
, &uga_exists
, &stdin_locked
);
79 /* do not touch the mode */
80 new = on
? EfiConsoleControlScreenGraphics
: EfiConsoleControlScreenText
;
84 err
= uefi_call_wrapper(ConsoleControl
->SetMode
, 2, ConsoleControl
, new);
86 /* some firmware enables the cursor when switching modes */
87 uefi_call_wrapper(ST
->ConOut
->EnableCursor
, 2, ST
->ConOut
, FALSE
);