]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/WinNtGopDxe/WinNtGopDriver.c
removed gEfiWinNtCPUSpeedGuid, gEfiWinNtCPUModelGuid, and gEfiWinNtMemoryGuid. Replac...
[mirror_edk2.git] / Nt32Pkg / WinNtGopDxe / WinNtGopDriver.c
CommitLineData
c9fc89a3 1/** @file\r
2\r
3Copyright (c) 2006 - 2007, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 WinNtGopDriver.c\r
15\r
16Abstract:\r
17\r
18 This file implements the UEFI Device Driver model requirements for GOP\r
19\r
20 GOP is short hand for Graphics Output Protocol.\r
21\r
22\r
23**/\r
24\r
25//\r
26// The package level header files this module uses\r
27//\r
28#include <Uefi.h>\r
29#include <WinNtDxe.h>\r
30//\r
31// The protocols, PPI and GUID defintions for this module\r
32//\r
33#include <Guid/EventGroup.h>\r
34#include <Protocol/WinNtIo.h>\r
35#include <Protocol/ComponentName.h>\r
36#include <Protocol/SimpleTextIn.h>\r
37#include <Protocol/DriverBinding.h>\r
38#include <Protocol/GraphicsOutput.h>\r
39//\r
40// The Library classes this module consumes\r
41//\r
42#include <Library/DebugLib.h>\r
43#include <Library/BaseLib.h>\r
44#include <Library/UefiDriverEntryPoint.h>\r
45#include <Library/UefiLib.h>\r
46#include <Library/BaseMemoryLib.h>\r
47#include <Library/UefiBootServicesTableLib.h>\r
48#include <Library/MemoryAllocationLib.h>\r
49\r
50#include "WinNtGop.h"\r
51\r
52EFI_DRIVER_BINDING_PROTOCOL gWinNtGopDriverBinding = {\r
53 WinNtGopDriverBindingSupported,\r
54 WinNtGopDriverBindingStart,\r
55 WinNtGopDriverBindingStop,\r
56 0xa,\r
57 NULL,\r
58 NULL\r
59};\r
60\r
61/**\r
62 The user Entry Point for module WinNtGop. The user code starts with this function.\r
63\r
64 @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
65 @param[in] SystemTable A pointer to the EFI System Table.\r
66 \r
67 @retval EFI_SUCCESS The entry point is executed successfully.\r
68 @retval other Some error occurs when executing this entry point.\r
69\r
70**/\r
71EFI_STATUS\r
72EFIAPI\r
73InitializeWinNtGop(\r
74 IN EFI_HANDLE ImageHandle,\r
75 IN EFI_SYSTEM_TABLE *SystemTable\r
76 )\r
77{\r
78 EFI_STATUS Status;\r
79\r
80 //\r
81 // Install driver model protocol(s).\r
82 //\r
83 Status = EfiLibInstallAllDriverProtocols (\r
84 ImageHandle,\r
85 SystemTable,\r
86 &gWinNtGopDriverBinding,\r
87 ImageHandle,\r
88 &gWinNtGopComponentName,\r
89 NULL,\r
90 NULL\r
91 );\r
92 ASSERT_EFI_ERROR (Status);\r
93\r
94\r
95 return Status;\r
96}\r
97\r
98/**\r
99\r
100\r
101 @return None\r
102\r
103**/\r
104// TODO: This - add argument and description to function comment\r
105// TODO: Handle - add argument and description to function comment\r
106// TODO: RemainingDevicePath - add argument and description to function comment\r
107EFI_STATUS\r
108EFIAPI\r
109WinNtGopDriverBindingSupported (\r
110 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
111 IN EFI_HANDLE Handle,\r
112 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
113 )\r
114{\r
115 EFI_STATUS Status;\r
116 EFI_WIN_NT_IO_PROTOCOL *WinNtIo;\r
117\r
118 //\r
119 // Open the IO Abstraction(s) needed to perform the supported test\r
120 //\r
121 Status = gBS->OpenProtocol (\r
122 Handle,\r
123 &gEfiWinNtIoProtocolGuid,\r
124 &WinNtIo,\r
125 This->DriverBindingHandle,\r
126 Handle,\r
127 EFI_OPEN_PROTOCOL_BY_DRIVER\r
128 );\r
129 if (EFI_ERROR (Status)) {\r
130 return Status;\r
131 }\r
132\r
133 Status = WinNtGopSupported (WinNtIo);\r
134\r
135 //\r
136 // Close the I/O Abstraction(s) used to perform the supported test\r
137 //\r
138 gBS->CloseProtocol (\r
139 Handle,\r
140 &gEfiWinNtIoProtocolGuid,\r
141 This->DriverBindingHandle,\r
142 Handle\r
143 );\r
144\r
145 return Status;\r
146}\r
147\r
148\r
149/**\r
150\r
151\r
152 @return None\r
153\r
154**/\r
155// TODO: This - add argument and description to function comment\r
156// TODO: Handle - add argument and description to function comment\r
157// TODO: RemainingDevicePath - add argument and description to function comment\r
158// TODO: EFI_UNSUPPORTED - add return value to function comment\r
159EFI_STATUS\r
160EFIAPI\r
161WinNtGopDriverBindingStart (\r
162 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
163 IN EFI_HANDLE Handle,\r
164 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
165 )\r
166{\r
167 EFI_WIN_NT_IO_PROTOCOL *WinNtIo;\r
168 EFI_STATUS Status;\r
169 GOP_PRIVATE_DATA *Private;\r
170\r
171 //\r
172 // Grab the protocols we need\r
173 //\r
174 Status = gBS->OpenProtocol (\r
175 Handle,\r
176 &gEfiWinNtIoProtocolGuid,\r
177 &WinNtIo,\r
178 This->DriverBindingHandle,\r
179 Handle,\r
180 EFI_OPEN_PROTOCOL_BY_DRIVER\r
181 );\r
182 if (EFI_ERROR (Status)) {\r
183 return EFI_UNSUPPORTED;\r
184 }\r
185\r
186 //\r
187 // Allocate Private context data for SGO inteface.\r
188 //\r
189 Private = NULL;\r
190 Private = AllocatePool (sizeof (GOP_PRIVATE_DATA));\r
191 if (Private == NULL) {\r
192 goto Done;\r
193 }\r
194 //\r
195 // Set up context record\r
196 //\r
197 Private->Signature = GOP_PRIVATE_DATA_SIGNATURE;\r
198 Private->Handle = Handle;\r
199 Private->WinNtThunk = WinNtIo->WinNtThunk;\r
200\r
201 Private->ControllerNameTable = NULL;\r
202\r
203 AddUnicodeString (\r
204 "eng",\r
205 gWinNtGopComponentName.SupportedLanguages,\r
206 &Private->ControllerNameTable,\r
207 WinNtIo->EnvString\r
208 );\r
209\r
210 Private->WindowName = WinNtIo->EnvString;\r
211\r
212 Status = WinNtGopConstructor (Private);\r
213 if (EFI_ERROR (Status)) {\r
214 goto Done;\r
215 }\r
216 //\r
217 // Publish the Gop interface to the world\r
218 //\r
219 Status = gBS->InstallMultipleProtocolInterfaces (\r
220 &Private->Handle,\r
221 &gEfiGraphicsOutputProtocolGuid,\r
222 &Private->GraphicsOutput,\r
223 &gEfiSimpleTextInProtocolGuid,\r
224 &Private->SimpleTextIn,\r
225 NULL\r
226 );\r
227\r
228Done:\r
229 if (EFI_ERROR (Status)) {\r
230\r
231 gBS->CloseProtocol (\r
232 Handle,\r
233 &gEfiWinNtIoProtocolGuid,\r
234 This->DriverBindingHandle,\r
235 Handle\r
236 );\r
237\r
238 if (Private != NULL) {\r
239 //\r
240 // On Error Free back private data\r
241 //\r
242 if (Private->ControllerNameTable != NULL) {\r
243 FreeUnicodeStringTable (Private->ControllerNameTable);\r
244 }\r
245\r
246 FreePool (Private);\r
247 }\r
248 }\r
249\r
250 return Status;\r
251}\r
252\r
253\r
254/**\r
255\r
256\r
257 @return None\r
258\r
259**/\r
260// TODO: This - add argument and description to function comment\r
261// TODO: Handle - add argument and description to function comment\r
262// TODO: NumberOfChildren - add argument and description to function comment\r
263// TODO: ChildHandleBuffer - add argument and description to function comment\r
264// TODO: EFI_NOT_STARTED - add return value to function comment\r
265// TODO: EFI_DEVICE_ERROR - add return value to function comment\r
266EFI_STATUS\r
267EFIAPI\r
268WinNtGopDriverBindingStop (\r
269 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
270 IN EFI_HANDLE Handle,\r
271 IN UINTN NumberOfChildren,\r
272 IN EFI_HANDLE *ChildHandleBuffer\r
273 )\r
274{\r
275 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
276 EFI_STATUS Status;\r
277 GOP_PRIVATE_DATA *Private;\r
278\r
279 Status = gBS->OpenProtocol (\r
280 Handle,\r
281 &gEfiGraphicsOutputProtocolGuid,\r
282 &GraphicsOutput,\r
283 This->DriverBindingHandle,\r
284 Handle,\r
285 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
286 );\r
287 if (EFI_ERROR (Status)) {\r
288 //\r
289 // If the GOP interface does not exist the driver is not started\r
290 //\r
291 return EFI_NOT_STARTED;\r
292 }\r
293\r
294 //\r
295 // Get our private context information\r
296 //\r
297 Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);\r
298\r
299 //\r
300 // Remove the SGO interface from the system\r
301 //\r
302 Status = gBS->UninstallMultipleProtocolInterfaces (\r
303 Private->Handle,\r
304 &gEfiGraphicsOutputProtocolGuid,\r
305 &Private->GraphicsOutput,\r
306 &gEfiSimpleTextInProtocolGuid,\r
307 &Private->SimpleTextIn,\r
308 NULL\r
309 );\r
310 if (!EFI_ERROR (Status)) {\r
311 //\r
312 // Shutdown the hardware\r
313 //\r
314 Status = WinNtGopDestructor (Private);\r
315 if (EFI_ERROR (Status)) {\r
316 return EFI_DEVICE_ERROR;\r
317 }\r
318\r
319 gBS->CloseProtocol (\r
320 Handle,\r
321 &gEfiWinNtIoProtocolGuid,\r
322 This->DriverBindingHandle,\r
323 Handle\r
324 );\r
325\r
326 //\r
327 // Free our instance data\r
328 //\r
329 FreeUnicodeStringTable (Private->ControllerNameTable);\r
330\r
331 FreePool (Private);\r
332\r
333 }\r
334\r
335 return Status;\r
336}\r
337\r