]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/UnixUgaDxe/UnixUgaDriver.c
Update for NetworkPkg.
[mirror_edk2.git] / UnixPkg / UnixUgaDxe / UnixUgaDriver.c
CommitLineData
804405e7 1/*++\r
2\r
f9b8ab56
HT
3Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
804405e7 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 UnixUgaDriver.c\r
15\r
16Abstract:\r
17\r
18 This file implements the EFI 1.1 Device Driver model requirements for UGA\r
19\r
20 UGA is short hand for Universal Graphics Abstraction protocol.\r
21\r
22 This file is a verision of UgaIo the uses UnixThunk system calls as an IO \r
23 abstraction. For a PCI device UnixIo would be replaced with\r
24 a PCI IO abstraction that abstracted a specific PCI device. \r
25\r
26--*/\r
27\r
28#include "UnixUga.h"\r
29\r
30EFI_DRIVER_BINDING_PROTOCOL gUnixUgaDriverBinding = {\r
31 UnixUgaDriverBindingSupported,\r
32 UnixUgaDriverBindingStart,\r
33 UnixUgaDriverBindingStop,\r
34 0xa,\r
35 NULL,\r
36 NULL\r
37};\r
38\r
39\r
40EFI_STATUS\r
41EFIAPI\r
42UnixUgaDriverBindingSupported (\r
43 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
44 IN EFI_HANDLE Handle,\r
45 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
46 )\r
47/*++\r
48\r
49Routine Description:\r
50\r
51Arguments:\r
52\r
53Returns:\r
54\r
55 None\r
56\r
57--*/\r
58// TODO: This - add argument and description to function comment\r
59// TODO: Handle - add argument and description to function comment\r
60// TODO: RemainingDevicePath - add argument and description to function comment\r
61{\r
62 EFI_STATUS Status;\r
63 EFI_UNIX_IO_PROTOCOL *UnixIo;\r
64\r
65 //\r
66 // Open the IO Abstraction(s) needed to perform the supported test\r
67 //\r
68 Status = gBS->OpenProtocol (\r
69 Handle,\r
70 &gEfiUnixIoProtocolGuid,\r
71 (VOID **)&UnixIo,\r
72 This->DriverBindingHandle,\r
73 Handle,\r
74 EFI_OPEN_PROTOCOL_BY_DRIVER\r
75 );\r
76 if (EFI_ERROR (Status)) {\r
77 return Status;\r
78 }\r
79\r
80 Status = UnixUgaSupported (UnixIo);\r
81\r
82 //\r
83 // Close the I/O Abstraction(s) used to perform the supported test\r
84 //\r
85 gBS->CloseProtocol (\r
86 Handle,\r
87 &gEfiUnixIoProtocolGuid,\r
88 This->DriverBindingHandle,\r
89 Handle\r
90 );\r
91\r
92 return Status;\r
93}\r
94\r
95EFI_STATUS\r
96EFIAPI\r
97UnixUgaDriverBindingStart (\r
98 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
99 IN EFI_HANDLE Handle,\r
100 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
101 )\r
102/*++\r
103\r
104Routine Description:\r
105\r
106Arguments:\r
107\r
108Returns:\r
109\r
110 None\r
111\r
112--*/\r
113// TODO: This - add argument and description to function comment\r
114// TODO: Handle - add argument and description to function comment\r
115// TODO: RemainingDevicePath - add argument and description to function comment\r
116// TODO: EFI_UNSUPPORTED - add return value to function comment\r
117{\r
118 EFI_UNIX_IO_PROTOCOL *UnixIo;\r
119 EFI_STATUS Status;\r
120 UGA_PRIVATE_DATA *Private;\r
121\r
122 //\r
123 // Grab the protocols we need\r
124 //\r
125 Status = gBS->OpenProtocol (\r
126 Handle,\r
127 &gEfiUnixIoProtocolGuid,\r
128 (VOID **)&UnixIo,\r
129 This->DriverBindingHandle,\r
130 Handle,\r
131 EFI_OPEN_PROTOCOL_BY_DRIVER\r
132 );\r
133 if (EFI_ERROR (Status)) {\r
134 return EFI_UNSUPPORTED;\r
135 }\r
136\r
137 //\r
138 // Allocate Private context data for SGO inteface.\r
139 //\r
140 Private = NULL;\r
141 Status = gBS->AllocatePool (\r
142 EfiBootServicesData,\r
143 sizeof (UGA_PRIVATE_DATA),\r
144 (VOID **)&Private\r
145 );\r
146 if (EFI_ERROR (Status)) {\r
147 goto Done;\r
148 }\r
149 //\r
150 // Set up context record\r
151 //\r
152 Private->Signature = UGA_PRIVATE_DATA_SIGNATURE;\r
153 Private->Handle = Handle;\r
154 Private->UnixThunk = UnixIo->UnixThunk;\r
155\r
156 Private->ControllerNameTable = NULL;\r
157\r
158 AddUnicodeString (\r
159 "eng",\r
160 gUnixUgaComponentName.SupportedLanguages,\r
161 &Private->ControllerNameTable,\r
162 UnixIo->EnvString\r
163 );\r
164\r
165 Private->WindowName = UnixIo->EnvString;\r
166\r
167 Status = UnixUgaConstructor (Private);\r
168 if (EFI_ERROR (Status)) {\r
169 goto Done;\r
170 }\r
171 //\r
172 // Publish the Uga interface to the world\r
173 //\r
174 Status = gBS->InstallMultipleProtocolInterfaces (\r
175 &Private->Handle,\r
176 &gEfiUgaDrawProtocolGuid,\r
177 &Private->UgaDraw,\r
178 &gEfiSimpleTextInProtocolGuid,\r
179 &Private->SimpleTextIn,\r
2ff79f2e 180 &gEfiSimplePointerProtocolGuid,\r
181 &Private->SimplePointer,\r
804405e7 182 NULL\r
183 );\r
184\r
185Done:\r
186 if (EFI_ERROR (Status)) {\r
187\r
188 gBS->CloseProtocol (\r
189 Handle,\r
190 &gEfiUnixIoProtocolGuid,\r
191 This->DriverBindingHandle,\r
192 Handle\r
193 );\r
194\r
195 if (Private != NULL) {\r
196 //\r
197 // On Error Free back private data\r
198 //\r
199 if (Private->ControllerNameTable != NULL) {\r
200 FreeUnicodeStringTable (Private->ControllerNameTable);\r
201 }\r
202\r
203 gBS->FreePool (Private);\r
204 }\r
205 }\r
206\r
207 return Status;\r
208}\r
209\r
210EFI_STATUS\r
211EFIAPI\r
212UnixUgaDriverBindingStop (\r
213 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
214 IN EFI_HANDLE Handle,\r
215 IN UINTN NumberOfChildren,\r
216 IN EFI_HANDLE *ChildHandleBuffer\r
217 )\r
218/*++\r
219\r
220Routine Description:\r
221\r
222Arguments:\r
223\r
224Returns:\r
225\r
226 None\r
227\r
228--*/\r
229// TODO: This - add argument and description to function comment\r
230// TODO: Handle - add argument and description to function comment\r
231// TODO: NumberOfChildren - add argument and description to function comment\r
232// TODO: ChildHandleBuffer - add argument and description to function comment\r
233// TODO: EFI_NOT_STARTED - add return value to function comment\r
234// TODO: EFI_DEVICE_ERROR - add return value to function comment\r
235{\r
236 EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
237 EFI_STATUS Status;\r
238 UGA_PRIVATE_DATA *Private;\r
239\r
240 Status = gBS->OpenProtocol (\r
241 Handle,\r
242 &gEfiUgaDrawProtocolGuid,\r
243 (VOID **)&UgaDraw,\r
244 This->DriverBindingHandle,\r
245 Handle,\r
246 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
247 );\r
248 if (EFI_ERROR (Status)) {\r
249 //\r
250 // If the UGA interface does not exist the driver is not started\r
251 //\r
252 return EFI_NOT_STARTED;\r
253 }\r
254\r
255 //\r
256 // Get our private context information\r
257 //\r
258 Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (UgaDraw);\r
259\r
260 //\r
261 // Remove the SGO interface from the system\r
262 //\r
263 Status = gBS->UninstallMultipleProtocolInterfaces (\r
264 Private->Handle,\r
265 &gEfiUgaDrawProtocolGuid,\r
266 &Private->UgaDraw,\r
267 &gEfiSimpleTextInProtocolGuid,\r
268 &Private->SimpleTextIn,\r
2ff79f2e 269 &gEfiSimplePointerProtocolGuid,\r
270 &Private->SimplePointer,\r
804405e7 271 NULL\r
272 );\r
273 if (!EFI_ERROR (Status)) {\r
274 //\r
275 // Shutdown the hardware\r
276 //\r
277 Status = UnixUgaDestructor (Private);\r
278 if (EFI_ERROR (Status)) {\r
279 return EFI_DEVICE_ERROR;\r
280 }\r
281\r
282 gBS->CloseProtocol (\r
283 Handle,\r
284 &gEfiUnixIoProtocolGuid,\r
285 This->DriverBindingHandle,\r
286 Handle\r
287 );\r
288\r
289 //\r
290 // Free our instance data\r
291 //\r
292 FreeUnicodeStringTable (Private->ControllerNameTable);\r
293\r
294 gBS->FreePool (Private);\r
295\r
296 }\r
297\r
298 return Status;\r
299}\r
300\r