]>
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 | UnixUgaScreen.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | This file produces the graphics abstration of UGA. It is called by \r | |
19 | UnixUgaDriver.c file which deals with the EFI 1.1 driver model. \r | |
20 | This file just does graphics.\r | |
21 | \r | |
22 | --*/\r | |
23 | \r | |
24 | #include "UnixUga.h"\r | |
25 | \r | |
26 | EFI_UNIX_THUNK_PROTOCOL *mUnix;\r | |
27 | static EFI_EVENT mUgaScreenExitBootServicesEvent;\r | |
28 | \r | |
29 | STATIC | |
30 | EFI_STATUS\r | |
31 | UnixUgaStartWindow (\r | |
32 | IN UGA_PRIVATE_DATA *Private,\r | |
33 | IN UINT32 HorizontalResolution,\r | |
34 | IN UINT32 VerticalResolution,\r | |
35 | IN UINT32 ColorDepth,\r | |
36 | IN UINT32 RefreshRate\r | |
37 | );\r | |
38 | \r | |
39 | STATIC\r | |
40 | VOID\r | |
41 | EFIAPI\r | |
42 | KillNtUgaThread (\r | |
43 | IN EFI_EVENT Event,\r | |
44 | IN VOID *Context\r | |
45 | );\r | |
46 | \r | |
47 | //\r | |
48 | // UGA Protocol Member Functions\r | |
49 | //\r | |
50 | \r | |
51 | EFI_STATUS\r | |
52 | EFIAPI\r | |
53 | UnixUgaGetMode (\r | |
54 | EFI_UGA_DRAW_PROTOCOL *This,\r | |
55 | UINT32 *HorizontalResolution,\r | |
56 | UINT32 *VerticalResolution,\r | |
57 | UINT32 *ColorDepth,\r | |
58 | UINT32 *RefreshRate\r | |
59 | )\r | |
60 | /*++\r | |
61 | \r | |
62 | Routine Description:\r | |
63 | Return the current video mode information.\r | |
64 | \r | |
65 | Arguments:\r | |
66 | This - Protocol instance pointer.\r | |
67 | HorizontalResolution - Current video horizontal resolution in pixels\r | |
68 | VerticalResolution - Current video Vertical resolution in pixels\r | |
69 | ColorDepth - Current video color depth in bits per pixel\r | |
70 | RefreshRate - Current video refresh rate in Hz.\r | |
71 | \r | |
72 | Returns:\r | |
73 | EFI_SUCCESS - Mode information returned.\r | |
74 | EFI_NOT_STARTED - Video display is not initialized. Call SetMode () \r | |
75 | EFI_INVALID_PARAMETER - One of the input args was NULL.\r | |
76 | \r | |
77 | --*/\r | |
78 | // TODO: ADD IN/OUT description here\r | |
79 | {\r | |
80 | UGA_PRIVATE_DATA *Private;\r | |
81 | \r | |
82 | Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (This);\r | |
83 | \r | |
84 | if (Private->HardwareNeedsStarting) {\r | |
85 | return EFI_NOT_STARTED;\r | |
86 | }\r | |
87 | \r | |
88 | if ((HorizontalResolution == NULL) ||\r | |
89 | (VerticalResolution == NULL) ||\r | |
90 | (ColorDepth == NULL) ||\r | |
91 | (RefreshRate == NULL)) {\r | |
92 | return EFI_INVALID_PARAMETER;\r | |
93 | }\r | |
94 | \r | |
95 | *HorizontalResolution = Private->HorizontalResolution;\r | |
96 | *VerticalResolution = Private->VerticalResolution;\r | |
97 | *ColorDepth = Private->ColorDepth;\r | |
98 | *RefreshRate = Private->RefreshRate;\r | |
99 | return EFI_SUCCESS;\r | |
100 | }\r | |
101 | \r | |
102 | EFI_STATUS\r | |
103 | EFIAPI\r | |
104 | UnixUgaSetMode (\r | |
105 | EFI_UGA_DRAW_PROTOCOL *This,\r | |
106 | UINT32 HorizontalResolution,\r | |
107 | UINT32 VerticalResolution,\r | |
108 | UINT32 ColorDepth,\r | |
109 | UINT32 RefreshRate\r | |
110 | )\r | |
111 | /*++\r | |
112 | \r | |
113 | Routine Description:\r | |
114 | Return the current video mode information.\r | |
115 | \r | |
116 | Arguments:\r | |
117 | This - Protocol instance pointer.\r | |
118 | HorizontalResolution - Current video horizontal resolution in pixels\r | |
119 | VerticalResolution - Current video Vertical resolution in pixels\r | |
120 | ColorDepth - Current video color depth in bits per pixel\r | |
121 | RefreshRate - Current video refresh rate in Hz.\r | |
122 | \r | |
123 | Returns:\r | |
124 | EFI_SUCCESS - Mode information returned.\r | |
125 | EFI_NOT_STARTED - Video display is not initialized. Call SetMode () \r | |
126 | EFI_INVALID_PARAMETER - One of the input args was NULL.\r | |
127 | \r | |
128 | --*/\r | |
129 | // TODO: EFI_DEVICE_ERROR - add return value to function comment\r | |
130 | // TODO: EFI_DEVICE_ERROR - add return value to function comment\r | |
131 | // TODO: ADD IN/OUT description here\r | |
132 | {\r | |
133 | EFI_STATUS Status;\r | |
134 | UGA_PRIVATE_DATA *Private;\r | |
135 | EFI_UGA_PIXEL Fill;\r | |
136 | \r | |
137 | Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (This);\r | |
138 | \r | |
139 | if (Private->HardwareNeedsStarting) {\r | |
140 | Status = UnixUgaStartWindow (\r | |
141 | Private,\r | |
142 | HorizontalResolution,\r | |
143 | VerticalResolution,\r | |
144 | ColorDepth,\r | |
145 | RefreshRate\r | |
146 | );\r | |
147 | if (EFI_ERROR (Status)) {\r | |
148 | return EFI_DEVICE_ERROR;\r | |
149 | }\r | |
150 | \r | |
151 | Private->HardwareNeedsStarting = FALSE;\r | |
152 | } | |
153 | Status = Private->UgaIo->UgaSize(Private->UgaIo, | |
154 | HorizontalResolution, | |
155 | VerticalResolution); | |
156 | \r | |
157 | Private->HorizontalResolution = HorizontalResolution;\r | |
158 | Private->VerticalResolution = VerticalResolution;\r | |
159 | Private->ColorDepth = ColorDepth;\r | |
160 | Private->RefreshRate = RefreshRate;\r | |
161 | \r | |
162 | Fill.Red = 0x00;\r | |
163 | Fill.Green = 0x00;\r | |
164 | Fill.Blue = 0x00;\r | |
165 | This->Blt (\r | |
166 | This,\r | |
167 | &Fill,\r | |
168 | EfiUgaVideoFill,\r | |
169 | 0,\r | |
170 | 0,\r | |
171 | 0,\r | |
172 | 0,\r | |
173 | HorizontalResolution,\r | |
174 | VerticalResolution,\r | |
175 | HorizontalResolution * sizeof (EFI_UGA_PIXEL)\r | |
176 | );\r | |
177 | return EFI_SUCCESS;\r | |
178 | }\r | |
179 | \r | |
180 | EFI_STATUS\r | |
181 | EFIAPI\r | |
182 | UnixUgaBlt (\r | |
183 | IN EFI_UGA_DRAW_PROTOCOL *This,\r | |
184 | IN EFI_UGA_PIXEL *BltBuffer, OPTIONAL\r | |
185 | IN EFI_UGA_BLT_OPERATION BltOperation,\r | |
186 | IN UINTN SourceX,\r | |
187 | IN UINTN SourceY,\r | |
188 | IN UINTN DestinationX,\r | |
189 | IN UINTN DestinationY,\r | |
190 | IN UINTN Width,\r | |
191 | IN UINTN Height,\r | |
192 | IN UINTN Delta OPTIONAL\r | |
193 | )\r | |
194 | /*++\r | |
195 | \r | |
196 | Routine Description:\r | |
197 | Blt pixels from the rectangle (Width X Height) formed by the BltBuffer\r | |
198 | onto the graphics screen starting a location (X, Y). (0, 0) is defined as\r | |
199 | the upper left hand side of the screen. (X, Y) can be outside of the \r | |
200 | current screen geometry and the BltBuffer will be cliped when it is \r | |
201 | displayed. X and Y can be negative or positive. If Width or Height is \r | |
202 | bigger than the current video screen the image will be clipped.\r | |
203 | \r | |
204 | Arguments:\r | |
205 | This - Protocol instance pointer.\r | |
206 | X - X location on graphics screen. \r | |
207 | Y - Y location on the graphics screen.\r | |
208 | Width - Width of BltBuffer.\r | |
209 | Height - Hight of BltBuffer\r | |
210 | BltOperation - Operation to perform on BltBuffer and video memory\r | |
211 | BltBuffer - Buffer containing data to blt into video buffer. This \r | |
212 | buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)\r | |
213 | SourceX - If the BltOperation is a EfiCopyBlt this is the source\r | |
214 | of the copy. For other BLT operations this argument is not\r | |
215 | used.\r | |
216 | SourceX - If the BltOperation is a EfiCopyBlt this is the source\r | |
217 | of the copy. For other BLT operations this argument is not\r | |
218 | used.\r | |
219 | \r | |
220 | Returns:\r | |
221 | EFI_SUCCESS - The palette is updated with PaletteArray.\r | |
222 | EFI_INVALID_PARAMETER - BltOperation is not valid.\r | |
223 | EFI_DEVICE_ERROR - A hardware error occured writting to the video \r | |
224 | buffer.\r | |
225 | \r | |
226 | --*/\r | |
227 | // TODO: SourceY - add argument and description to function comment\r | |
228 | // TODO: DestinationX - add argument and description to function comment\r | |
229 | // TODO: DestinationY - add argument and description to function comment\r | |
230 | // TODO: Delta - add argument and description to function comment\r | |
231 | {\r | |
232 | UGA_PRIVATE_DATA *Private;\r | |
233 | EFI_TPL OriginalTPL;\r | |
234 | EFI_STATUS Status;\r | |
235 | \r | |
236 | Private = UGA_DRAW_PRIVATE_DATA_FROM_THIS (This);\r | |
237 | \r | |
238 | if ((BltOperation < 0) || (BltOperation >= EfiUgaBltMax)) {\r | |
239 | return EFI_INVALID_PARAMETER;\r | |
240 | }\r | |
241 | \r | |
242 | if (Width == 0 || Height == 0) {\r | |
243 | return EFI_INVALID_PARAMETER;\r | |
244 | }\r | |
245 | //\r | |
246 | // If Delta is zero, then the entire BltBuffer is being used, so Delta\r | |
247 | // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,\r | |
248 | // the number of bytes in each row can be computed.\r | |
249 | //\r | |
250 | if (Delta == 0) {\r | |
251 | Delta = Width * sizeof (EFI_UGA_PIXEL);\r | |
252 | }\r | |
253 | \r | |
254 | //\r | |
255 | // We have to raise to TPL Notify, so we make an atomic write the frame buffer.\r | |
256 | // We would not want a timer based event (Cursor, ...) to come in while we are\r | |
257 | // doing this operation.\r | |
258 | //\r | |
259 | OriginalTPL = gBS->RaiseTPL (EFI_TPL_NOTIFY);\r | |
260 | \r | |
261 | Status = Private->UgaIo->UgaBlt (Private->UgaIo, | |
262 | BltBuffer, | |
263 | BltOperation, | |
264 | SourceX, SourceY, | |
265 | DestinationX, DestinationY, | |
266 | Width, Height, | |
267 | Delta); | |
268 | \r | |
269 | gBS->RestoreTPL (OriginalTPL);\r | |
270 | \r | |
271 | return Status; | |
272 | }\r | |
273 | \r | |
274 | \r | |
275 | //\r | |
276 | // Construction and Destruction functions\r | |
277 | //\r | |
278 | \r | |
279 | EFI_STATUS\r | |
280 | UnixUgaSupported (\r | |
281 | IN EFI_UNIX_IO_PROTOCOL *UnixIo\r | |
282 | )\r | |
283 | /*++\r | |
284 | \r | |
285 | Routine Description:\r | |
286 | \r | |
287 | Arguments:\r | |
288 | \r | |
289 | Returns:\r | |
290 | \r | |
291 | None\r | |
292 | \r | |
293 | --*/\r | |
294 | // TODO: UnixIo - add argument and description to function comment\r | |
295 | // TODO: EFI_UNSUPPORTED - add return value to function comment\r | |
296 | // TODO: EFI_SUCCESS - add return value to function comment\r | |
297 | {\r | |
298 | //\r | |
299 | // Check to see if the IO abstraction represents a device type we support.\r | |
300 | //\r | |
301 | // This would be replaced a check of PCI subsystem ID, etc.\r | |
302 | //\r | |
303 | if (!CompareGuid (UnixIo->TypeGuid, &gEfiUnixUgaGuid)) {\r | |
304 | return EFI_UNSUPPORTED;\r | |
305 | }\r | |
306 | \r | |
307 | return EFI_SUCCESS;\r | |
308 | }\r | |
309 | \r | |
310 | \r | |
311 | STATIC | |
312 | EFI_STATUS\r | |
313 | UnixUgaStartWindow (\r | |
314 | IN UGA_PRIVATE_DATA *Private,\r | |
315 | IN UINT32 HorizontalResolution,\r | |
316 | IN UINT32 VerticalResolution,\r | |
317 | IN UINT32 ColorDepth,\r | |
318 | IN UINT32 RefreshRate\r | |
319 | )\r | |
320 | /*++\r | |
321 | \r | |
322 | Routine Description:\r | |
323 | \r | |
324 | TODO: Add function description\r | |
325 | \r | |
326 | Arguments:\r | |
327 | \r | |
328 | Private - TODO: add argument description\r | |
329 | HorizontalResolution - TODO: add argument description\r | |
330 | VerticalResolution - TODO: add argument description\r | |
331 | ColorDepth - TODO: add argument description\r | |
332 | RefreshRate - TODO: add argument description\r | |
333 | \r | |
334 | Returns:\r | |
335 | \r | |
336 | TODO: add return values\r | |
337 | \r | |
338 | --*/\r | |
339 | {\r | |
340 | EFI_STATUS Status;\r | |
341 | \r | |
342 | mUnix = Private->UnixThunk;\r | |
343 | \r | |
344 | Private->HorizontalResolution = HorizontalResolution;\r | |
345 | Private->VerticalResolution = VerticalResolution;\r | |
346 | \r | |
347 | //\r | |
348 | // Register to be notified on exit boot services so we can destroy the window.\r | |
349 | //\r | |
350 | Status = gBS->CreateEvent (\r | |
351 | EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,\r | |
352 | EFI_TPL_CALLBACK,\r | |
353 | KillNtUgaThread,\r | |
354 | Private,\r | |
355 | &mUgaScreenExitBootServicesEvent\r | |
356 | );\r | |
357 | \r | |
358 | Status = Private->UnixThunk->UgaCreate(&Private->UgaIo, Private->WindowName); | |
359 | return Status;\r | |
360 | }\r | |
361 | \r | |
362 | EFI_STATUS\r | |
363 | UnixUgaConstructor (\r | |
364 | UGA_PRIVATE_DATA *Private\r | |
365 | )\r | |
366 | /*++\r | |
367 | \r | |
368 | Routine Description:\r | |
369 | \r | |
370 | Arguments:\r | |
371 | \r | |
372 | Returns:\r | |
373 | \r | |
374 | None\r | |
375 | \r | |
376 | --*/\r | |
377 | // TODO: Private - add argument and description to function comment\r | |
378 | // TODO: EFI_SUCCESS - add return value to function comment\r | |
379 | {\r | |
380 | \r | |
381 | Private->UgaDraw.GetMode = UnixUgaGetMode;\r | |
382 | Private->UgaDraw.SetMode = UnixUgaSetMode;\r | |
383 | Private->UgaDraw.Blt = UnixUgaBlt;\r | |
384 | \r | |
385 | Private->HardwareNeedsStarting = TRUE;\r | |
386 | Private->UgaIo = NULL; | |
387 | \r | |
388 | UnixUgaInitializeSimpleTextInForWindow (Private);\r | |
389 | \r | |
390 | return EFI_SUCCESS;\r | |
391 | }\r | |
392 | \r | |
393 | EFI_STATUS\r | |
394 | UnixUgaDestructor (\r | |
395 | UGA_PRIVATE_DATA *Private\r | |
396 | )\r | |
397 | /*++\r | |
398 | \r | |
399 | Routine Description:\r | |
400 | \r | |
401 | Arguments:\r | |
402 | \r | |
403 | Returns:\r | |
404 | \r | |
405 | None\r | |
406 | \r | |
407 | --*/\r | |
408 | // TODO: Private - add argument and description to function comment\r | |
409 | // TODO: EFI_SUCCESS - add return value to function comment\r | |
410 | {\r | |
411 | if (!Private->HardwareNeedsStarting) {\r | |
412 | Private->UgaIo->UgaClose(Private->UgaIo); | |
413 | Private->UgaIo = NULL; | |
414 | }\r | |
415 | \r | |
416 | return EFI_SUCCESS;\r | |
417 | }\r | |
418 | \r | |
419 | STATIC\r | |
420 | VOID\r | |
421 | EFIAPI\r | |
422 | KillNtUgaThread (\r | |
423 | IN EFI_EVENT Event,\r | |
424 | IN VOID *Context\r | |
425 | )\r | |
426 | /*++\r | |
427 | \r | |
428 | Routine Description:\r | |
429 | \r | |
430 | This is the UGA screen's callback notification function for exit-boot-services. \r | |
431 | All we do here is call UnixUgaDestructor().\r | |
432 | \r | |
433 | Arguments:\r | |
434 | \r | |
435 | Event - not used\r | |
436 | Context - pointer to the Private structure.\r | |
437 | \r | |
438 | Returns:\r | |
439 | \r | |
440 | None.\r | |
441 | \r | |
442 | --*/\r | |
443 | {\r | |
444 | EFI_STATUS Status;\r | |
445 | Status = UnixUgaDestructor (Context);\r | |
446 | }\r |