3 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
4 Portions copyright (c) 2010,Apple Inc. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #include <Protocol/GraphicsOutput.h>
21 #include <Protocol/SimpleTextIn.h>
22 #include <Protocol/SimpleTextInEx.h>
23 #include <Protocol/SimplePointer.h>
24 #include <Protocol/EmuIoThunk.h>
25 #include <Protocol/EmuGraphicsWindow.h>
27 #include <Guid/EventGroup.h>
29 #include <Library/DebugLib.h>
30 #include <Library/BaseLib.h>
31 #include <Library/UefiDriverEntryPoint.h>
32 #include <Library/UefiLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/MemoryAllocationLib.h>
35 #include <Library/UefiBootServicesTableLib.h>
36 #include <Library/KeyMapLib.h>
45 EFI_INPUT_KEY Q
[MAX_Q
];
48 #define EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('U', 'g', 'S', 'n')
49 typedef struct _EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY
{
51 EFI_HANDLE NotifyHandle
;
53 EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn
;
55 LIST_ENTRY NotifyEntry
;
56 } EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY
;
58 #define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
61 UINT32 HorizontalResolution
;
62 UINT32 VerticalResolution
;
69 extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding
;
70 extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName
;
72 #define EMU_UGA_CLASS_NAME L"EmuGopWindow"
74 #define GOP_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('G', 'o', 'p', 'N')
79 EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput
;
80 EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn
;
81 EFI_SIMPLE_POINTER_PROTOCOL SimplePointer
;
83 EMU_IO_THUNK_PROTOCOL
*EmuIoThunk
;
84 EMU_GRAPHICS_WINDOW_PROTOCOL
*EmuGraphicsWindow
;
86 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
88 EFI_SIMPLE_POINTER_MODE PointerMode
;
90 // GOP Private Data for QueryMode ()
92 GOP_MODE_DATA
*ModeData
;
96 // UGA Private Data knowing when to start hardware
98 BOOLEAN HardwareNeedsStarting
;
102 GOP_QUEUE_FIXED Queue
;
104 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInEx
;
105 EFI_KEY_STATE KeyState
;
106 LIST_ENTRY NotifyList
;
110 #define GOP_PRIVATE_DATA_FROM_THIS(a) \
111 CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE)
113 #define GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS(a) \
114 CR(a, GOP_PRIVATE_DATA, SimpleTextIn, GOP_PRIVATE_DATA_SIGNATURE)
116 #define GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS(a) \
117 CR(a, GOP_PRIVATE_DATA, SimpleTextInEx, GOP_PRIVATE_DATA_SIGNATURE)
119 #define GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS(a) \
120 CR(a, GOP_PRIVATE_DATA, SimplePointer, GOP_PRIVATE_DATA_SIGNATURE)
124 // Global Protocol Variables
126 extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding
;
127 extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName
;
128 extern EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2
;
131 // Gop Hardware abstraction internal worker functions
135 IN EMU_IO_THUNK_PROTOCOL
*EmuIoThunk
140 IN GOP_PRIVATE_DATA
*Private
145 IN GOP_PRIVATE_DATA
*Private
151 IN GOP_PRIVATE_DATA
*Private
,
156 EmuGopInitializeSimpleTextInForWindow (
157 IN GOP_PRIVATE_DATA
*Private
161 EmuGopInitializeSimplePointerForWindow (
162 IN GOP_PRIVATE_DATA
*Private
167 IN GOP_PRIVATE_DATA
*Private
,
168 IN UINT32 HorizontalResolution
,
169 IN UINT32 VerticalResolution
,
170 IN UINT32 ColorDepth
,
171 IN UINT32 RefreshRate
183 GopPrivateMakeCallbackFunction (
185 IN EFI_KEY_DATA
*KeyData
190 GopPrivateBreakCallbackFunction (
192 IN EFI_KEY_DATA
*KeyData