VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxConsoleDxe/VBoxConsole.c@ 26438

Last change on this file since 26438 was 26438, checked in by vboxsync, 15 years ago

EFI: more OSE fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/* $Id: VBoxConsole.c 26438 2010-02-11 15:38:00Z vboxsync $ */
2/** @file
3 * VBoxConsole.c - Helper driver waiting for Ready to Boot event to switch graphic mode into user-defined one.
4 */
5
6/*
7 * Copyright (C) 2009,2010 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31#include "VBoxConsole.h"
32
33/* @todo understand the reasons why TextOutputProtocol.SetMode isn't enough to switch mode. */
34#define VBOX_CONSOLE_VAR L"VBOX_CONSOLE_VAR"
35/*b53865fd-b76c-4433-9e85-c0cadf65aab8*/
36static EFI_GUID gVBoxConsoleVarGuid = { 0xb53865fd, 0xb76c, 0x4433, { 0x9e, 0x85, 0xc0, 0xca, 0xdf, 0x65, 0xaa, 0xb8}};
37
38static EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOutputProtocol;
39static EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
40static EFI_UGA_DRAW_PROTOCOL *Uga;
41
42static VOID
43EFIAPI
44ConsoleSwitchMode (
45 IN EFI_EVENT Event,
46 IN VOID *Context
47 )
48{
49 EFI_STATUS r = EFI_NOT_FOUND; /* Neither GOP nor UGA is found*/
50 EFI_TPL OldTpl;
51 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
52 DEBUG((DEBUG_INFO, "%a:%d - SwitchMode\n", __FILE__, __LINE__));
53 if (Gop)
54 r = Gop->SetMode(Gop, 2);
55 if (Uga)
56 r = Uga->SetMode(Uga, 1024, 768, 32, 60);
57 if(EFI_ERROR(r))
58 {
59 DEBUG((DEBUG_INFO, "%a:%d - %r\n", __FILE__, __LINE__, r));
60 goto done;
61 }
62 r = TextOutputProtocol->SetMode(TextOutputProtocol, TextOutputProtocol->Mode->MaxMode);
63 if(EFI_ERROR(r))
64 {
65 DEBUG((DEBUG_INFO, "%a:%d - %r\n", __FILE__, __LINE__, r));
66 goto done;
67 }
68 done:
69 gBS->RestoreTPL (OldTpl);
70 return;
71}
72
73EFI_STATUS
74EFIAPI
75VBoxConsoleInit(EFI_HANDLE hImage, EFI_SYSTEM_TABLE *pSysTable)
76{
77 EFI_STATUS r;
78 UINT32 val;
79 EFI_EVENT event;
80 UINTN size = sizeof(UINT32);
81 DEBUG((DEBUG_INFO, "%a:%d - STARTING\n", __FILE__, __LINE__));
82 r = gRT->GetVariable(VBOX_CONSOLE_VAR, &gVBoxConsoleVarGuid, NULL, &size, &val);
83 if ( EFI_ERROR(r)
84 && r == EFI_NOT_FOUND)
85 {
86 size = sizeof(UINT32);
87 val = 1;
88 r = gRT->SetVariable(VBOX_CONSOLE_VAR, &gVBoxConsoleVarGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, size, &val);
89 if (EFI_ERROR(r))
90 {
91 DEBUG((DEBUG_INFO, "%a:%d - %r\n", __FILE__, __LINE__, r));
92 return r;
93 }
94
95 r = gBS->LocateProtocol(&gEfiSimpleTextOutProtocolGuid, NULL, (VOID **)&TextOutputProtocol);
96 if(EFI_ERROR(r))
97 {
98 DEBUG((DEBUG_INFO, "%a:%d - %r\n", __FILE__, __LINE__, r));
99 }
100
101 r = gBS->LocateProtocol(&gEfiUgaDrawProtocolGuid, NULL, (VOID **)&Uga);
102 if(EFI_ERROR(r))
103 {
104 DEBUG((DEBUG_INFO, "%a:%d - %r\n", __FILE__, __LINE__, r));
105 }
106 r = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&Gop);
107 if(EFI_ERROR(r))
108 {
109 DEBUG((DEBUG_INFO, "%a:%d - %r\n", __FILE__, __LINE__, r));
110 }
111 ASSERT((Uga || Gop));
112 r = gBS->CreateEventEx(EVT_NOTIFY_SIGNAL, TPL_NOTIFY, ConsoleSwitchMode, NULL, &gEfiEventReadyToBootGuid, &event);
113 if (EFI_ERROR(r))
114 {
115 DEBUG((DEBUG_INFO, "%a:%d - %r\n", __FILE__, __LINE__, r));
116 return r;
117 }
118 return r;
119 }
120 if (!EFI_ERROR(r))
121 {
122 return EFI_ALREADY_STARTED;
123 }
124 return r;
125}
126
127EFI_STATUS
128EFIAPI
129VBoxConsoleFini(EFI_HANDLE hImage)
130{
131 return EFI_SUCCESS;
132}
133
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette