]>
Commit | Line | Data |
---|---|---|
c9093a06 | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | UnixUgaDriver.c\r | |
15 | \r | |
16 | Abstract:\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 | |
30 | EFI_DRIVER_BINDING_PROTOCOL gUnixUgaDriverBinding = {\r | |
31 | UnixUgaDriverBindingSupported,\r | |
32 | UnixUgaDriverBindingStart,\r | |
33 | UnixUgaDriverBindingStop,\r | |
caea5554 | 34 | 0xa,\r |
c9093a06 | 35 | NULL,\r |
36 | NULL\r | |
37 | };\r | |
38 | \r | |
39 | \r | |
40 | EFI_STATUS\r | |
41 | EFIAPI\r | |
42 | UnixUgaDriverBindingSupported (\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 | |
49 | Routine Description:\r | |
50 | \r | |
51 | Arguments:\r | |
52 | \r | |
53 | Returns:\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 | |
95 | EFI_STATUS\r | |
96 | EFIAPI\r | |
97 | UnixUgaDriverBindingStart (\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 | |
104 | Routine Description:\r | |
105 | \r | |
106 | Arguments:\r | |
107 | \r | |
108 | Returns:\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 | |
180 | NULL\r | |
181 | );\r | |
182 | \r | |
183 | Done:\r | |
184 | if (EFI_ERROR (Status)) {\r | |
185 | \r | |
186 | gBS->CloseProtocol (\r | |
187 | Handle,\r | |
188 | &gEfiUnixIoProtocolGuid,\r | |
189 | This->DriverBindingHandle,\r | |
190 | Handle\r | |
191 | );\r | |
192 | \r | |
193 | if (Private != NULL) {\r | |
194 | //\r | |
195 | // On Error Free back private data\r | |
196 | //\r | |
197 | if (Private->ControllerNameTable != NULL) {\r | |
198 | FreeUnicodeStringTable (Private->ControllerNameTable);\r | |
199 | }\r | |
200 | \r | |
201 | gBS->FreePool (Private);\r | |
202 | }\r | |
203 | }\r | |
204 | \r | |
205 | return Status;\r | |
206 | }\r | |
207 | \r | |
208 | EFI_STATUS\r | |
209 | EFIAPI\r | |
210 | UnixUgaDriverBindingStop (\r | |
211 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
212 | IN EFI_HANDLE Handle,\r | |
213 | IN UINTN NumberOfChildren,\r | |
214 | IN EFI_HANDLE *ChildHandleBuffer\r | |
215 | )\r | |
216 | /*++\r | |
217 | \r | |
218 | Routine Description:\r | |
219 | \r | |
220 | Arguments:\r | |
221 | \r | |
222 | Returns:\r | |
223 | \r | |
224 | None\r | |
225 | \r | |
226 | --*/\r | |
227 | // TODO: This - add argument and description to function comment\r | |
228 | // TODO: Handle - add argument and description to function comment\r | |
229 | // TODO: NumberOfChildren - add argument and description to function comment\r | |
230 | // TODO: ChildHandleBuffer - add argument and description to function comment\r | |
231 | // TODO: EFI_NOT_STARTED - add return value to function comment\r | |
232 | // TODO: EFI_DEVICE_ERROR - add return value to function comment\r | |
233 | {\r | |
234 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
235 | EFI_STATUS Status;\r | |
236 | UGA_PRIVATE_DATA *Private;\r | |
237 | \r | |
238 | Status = gBS->OpenProtocol (\r | |
239 | Handle,\r | |
240 | &gEfiUgaDrawProtocolGuid,\r | |
241 | (VOID **)&UgaDraw,\r | |
242 | This->DriverBindingHandle,\r | |
243 | Handle,\r | |
244 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
245 | );\r | |
246 | if (EFI_ERROR (Status)) {\r | |
247 | //\r | |
248 | // If the UGA interface does not exist the driver is not started\r | |
249 | //\r | |
250 | return EFI_NOT_STARTED;\r | |
251 | }\r | |
252 | \r | |
253 | //\r | |
254 | // Get our private context information\r | |
255 | //\r | |
256 | Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (UgaDraw);\r | |
257 | \r | |
258 | //\r | |
259 | // Remove the SGO interface from the system\r | |
260 | //\r | |
261 | Status = gBS->UninstallMultipleProtocolInterfaces (\r | |
262 | Private->Handle,\r | |
263 | &gEfiUgaDrawProtocolGuid,\r | |
264 | &Private->UgaDraw,\r | |
265 | &gEfiSimpleTextInProtocolGuid,\r | |
266 | &Private->SimpleTextIn,\r | |
267 | NULL\r | |
268 | );\r | |
269 | if (!EFI_ERROR (Status)) {\r | |
270 | //\r | |
271 | // Shutdown the hardware\r | |
272 | //\r | |
273 | Status = UnixUgaDestructor (Private);\r | |
274 | if (EFI_ERROR (Status)) {\r | |
275 | return EFI_DEVICE_ERROR;\r | |
276 | }\r | |
277 | \r | |
278 | gBS->CloseProtocol (\r | |
279 | Handle,\r | |
280 | &gEfiUnixIoProtocolGuid,\r | |
281 | This->DriverBindingHandle,\r | |
282 | Handle\r | |
283 | );\r | |
284 | \r | |
285 | //\r | |
286 | // Free our instance data\r | |
287 | //\r | |
288 | FreeUnicodeStringTable (Private->ControllerNameTable);\r | |
289 | \r | |
290 | gBS->FreePool (Private);\r | |
291 | \r | |
292 | }\r | |
293 | \r | |
294 | return Status;\r | |
295 | }\r | |
296 | \r |