orphan
[debian/elilo] / console.c
1 /* 
2  * console.c - Console screen handling functions
3  *
4  *  Copyright (C) 2006 Christoph Pfisterer
5  *
6  * This file is part of the ELILO, the EFI Linux boot loader.
7  *
8  *  ELILO is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2, or (at your option)
11  *  any later version.
12  *
13  *  ELILO is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with ELILO; see the file COPYING.  If not, write to the Free
20  *  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21  *  02111-1307, USA.
22  *
23  * Please check out the elilo.txt for complete documentation on how
24  * to use this program.
25  */
26
27 #include <efi.h>
28 #include <efilib.h>
29
30 #include "elilo.h"
31
32 #include <efiConsoleControl.h>
33
34 static EFI_GUID console_guid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
35
36 static BOOLEAN console_inited = FALSE;
37
38 static EFI_CONSOLE_CONTROL_PROTOCOL *console_control;
39
40 /*
41  * Initialize console functions
42  */
43 static VOID console_init(VOID)
44 {
45         EFI_STATUS status;
46
47         if (!console_inited) {
48                 console_inited = TRUE;
49
50                 status = LibLocateProtocol(&console_guid, (VOID **) &console_control);
51                 if (EFI_ERROR(status))
52                         console_control = NULL;
53         }
54 }
55
56 /*
57  * Switch the console to text mode
58  */
59
60 VOID console_textmode(VOID)
61 {
62         EFI_CONSOLE_CONTROL_SCREEN_MODE console_mode;
63
64         console_init();
65
66         if (console_control != NULL) {
67                 uefi_call_wrapper(console_control->GetMode, 4, console_control, &console_mode, NULL, NULL);
68                 if (console_mode == EfiConsoleControlScreenGraphics)
69                         uefi_call_wrapper(console_control->SetMode, 2, console_control, EfiConsoleControlScreenText);
70         }
71 }