]>
Commit | Line | Data |
---|---|---|
95276127 | 1 | /**@file\r |
2 | This is the main routine for initializing the Graphics Console support routines.\r | |
3 | Remaining Tasks\r | |
8a7d75b0 | 4 | Add all standard Glyphs from UEFI 2.0 Specification\r |
95276127 | 5 | Implement optimal automatic Mode creation algorithm\r |
6 | Solve palette issues for mixed graphics and text\r | |
7 | When does this protocol reset the palette?\r | |
8 | \r | |
9 | Copyright (c) 2006 - 2007 Intel Corporation. <BR>\r | |
10 | All rights reserved. This program and the accompanying materials \r | |
11 | are licensed and made available under the terms and conditions of the BSD License \r | |
12 | which accompanies this distribution. The full text of the license may be found at \r | |
13 | http://opensource.org/licenses/bsd-license.php \r | |
14 | \r | |
15 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
16 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
17 | \r | |
18 | **/\r | |
19 | \r | |
95276127 | 20 | #include "GraphicsConsole.h"\r |
21 | \r | |
22 | STATIC\r | |
23 | EFI_STATUS\r | |
24 | GetTextColors (\r | |
25 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
26 | OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,\r | |
27 | OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background\r | |
28 | );\r | |
29 | \r | |
30 | STATIC\r | |
31 | EFI_STATUS\r | |
32 | DrawUnicodeWeightAtCursorN (\r | |
33 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
34 | IN CHAR16 *UnicodeWeight,\r | |
35 | IN UINTN Count\r | |
36 | );\r | |
37 | \r | |
38 | STATIC\r | |
39 | EFI_STATUS\r | |
40 | EraseCursor (\r | |
41 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r | |
42 | );\r | |
43 | \r | |
3012ce5c | 44 | EFI_STATUS\r |
45 | CheckModeSupported (\r | |
46 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r | |
47 | IN UINT32 HorizontalResolution,\r | |
48 | IN UINT32 VerticalResolution,\r | |
49 | OUT UINT32 *CurrentModeNumber\r | |
50 | );\r | |
51 | \r | |
95276127 | 52 | //\r |
53 | // Globals\r | |
54 | //\r | |
55 | GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate = {\r | |
56 | GRAPHICS_CONSOLE_DEV_SIGNATURE,\r | |
57 | (EFI_GRAPHICS_OUTPUT_PROTOCOL *) NULL,\r | |
58 | (EFI_UGA_DRAW_PROTOCOL *) NULL,\r | |
59 | {\r | |
60 | GraphicsConsoleConOutReset,\r | |
61 | GraphicsConsoleConOutOutputString,\r | |
62 | GraphicsConsoleConOutTestString,\r | |
63 | GraphicsConsoleConOutQueryMode,\r | |
64 | GraphicsConsoleConOutSetMode,\r | |
65 | GraphicsConsoleConOutSetAttribute,\r | |
66 | GraphicsConsoleConOutClearScreen,\r | |
67 | GraphicsConsoleConOutSetCursorPosition,\r | |
68 | GraphicsConsoleConOutEnableCursor,\r | |
69 | (EFI_SIMPLE_TEXT_OUTPUT_MODE *) NULL\r | |
70 | },\r | |
71 | {\r | |
72 | 0,\r | |
73 | 0,\r | |
74 | EFI_TEXT_ATTR(EFI_LIGHTGRAY, EFI_BLACK),\r | |
75 | 0,\r | |
76 | 0,\r | |
77 | TRUE\r | |
78 | },\r | |
79 | {\r | |
80 | { 80, 25, 0, 0, 0, 0 }, // Mode 0\r | |
3012ce5c | 81 | { 80, 50, 0, 0, 0, 0 }, // Mode 1\r |
82 | { 100,31, 0, 0, 0, 0 }, // Mode 2\r | |
83 | { 0, 0, 0, 0, 0, 0 } // Mode 3\r | |
95276127 | 84 | },\r |
85 | (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL,\r | |
86 | (EFI_HII_HANDLE) 0\r | |
87 | };\r | |
88 | \r | |
89 | EFI_HII_PROTOCOL *mHii;\r | |
90 | \r | |
91 | static CHAR16 mCrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };\r | |
92 | \r | |
93 | static EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {\r | |
94 | //\r | |
95 | // B G R\r | |
96 | //\r | |
97 | {0x00, 0x00, 0x00, 0x00}, // BLACK\r | |
98 | {0x98, 0x00, 0x00, 0x00}, // BLUE\r | |
99 | {0x00, 0x98, 0x00, 0x00}, // GREEN\r | |
100 | {0x98, 0x98, 0x00, 0x00}, // CYAN\r | |
101 | {0x00, 0x00, 0x98, 0x00}, // RED\r | |
102 | {0x98, 0x00, 0x98, 0x00}, // MAGENTA\r | |
103 | {0x00, 0x98, 0x98, 0x00}, // BROWN\r | |
104 | {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY\r | |
105 | {0x30, 0x30, 0x30, 0x00}, // DARKGRAY - BRIGHT BLACK\r | |
106 | {0xff, 0x00, 0x00, 0x00}, // LIGHTBLUE - ?\r | |
107 | {0x00, 0xff, 0x00, 0x00}, // LIGHTGREEN - ?\r | |
108 | {0xff, 0xff, 0x00, 0x00}, // LIGHTCYAN\r | |
109 | {0x00, 0x00, 0xff, 0x00}, // LIGHTRED\r | |
110 | {0xff, 0x00, 0xff, 0x00}, // LIGHTMAGENTA\r | |
111 | {0x00, 0xff, 0xff, 0x00}, // LIGHTBROWN\r | |
112 | {0xff, 0xff, 0xff, 0x00} // WHITE\r | |
113 | };\r | |
114 | \r | |
115 | static EFI_NARROW_GLYPH mCursorGlyph = {\r | |
116 | 0x0000,\r | |
117 | 0x00,\r | |
118 | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF }\r | |
119 | };\r | |
120 | \r | |
121 | EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding = {\r | |
122 | GraphicsConsoleControllerDriverSupported,\r | |
123 | GraphicsConsoleControllerDriverStart,\r | |
124 | GraphicsConsoleControllerDriverStop,\r | |
125 | 0xa,\r | |
126 | NULL,\r | |
127 | NULL\r | |
128 | };\r | |
129 | \r | |
130 | EFI_STATUS\r | |
131 | EFIAPI\r | |
132 | GraphicsConsoleControllerDriverSupported (\r | |
133 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
134 | IN EFI_HANDLE Controller,\r | |
135 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
136 | )\r | |
137 | {\r | |
138 | EFI_STATUS Status;\r | |
139 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r | |
140 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
141 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
142 | \r | |
143 | UgaDraw = NULL;\r | |
144 | //\r | |
145 | // Open the IO Abstraction(s) needed to perform the supported test\r | |
146 | //\r | |
147 | Status = gBS->OpenProtocol (\r | |
148 | Controller,\r | |
149 | &gEfiGraphicsOutputProtocolGuid,\r | |
150 | (VOID **) &GraphicsOutput,\r | |
151 | This->DriverBindingHandle,\r | |
152 | Controller,\r | |
153 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
154 | );\r | |
155 | \r | |
156 | if (EFI_ERROR (Status)) {\r | |
157 | GraphicsOutput = NULL;\r | |
158 | //\r | |
159 | // Open Graphics Output Protocol failed, try to open UGA Draw Protocol\r | |
160 | //\r | |
161 | Status = gBS->OpenProtocol (\r | |
162 | Controller,\r | |
163 | &gEfiUgaDrawProtocolGuid,\r | |
164 | (VOID **) &UgaDraw,\r | |
165 | This->DriverBindingHandle,\r | |
166 | Controller,\r | |
167 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
168 | );\r | |
169 | if (EFI_ERROR (Status)) {\r | |
170 | return Status;\r | |
171 | }\r | |
172 | }\r | |
173 | \r | |
174 | //\r | |
175 | // We need to ensure that we do not layer on top of a virtual handle.\r | |
176 | // We need to ensure that the handles produced by the conspliter do not\r | |
177 | // get used.\r | |
178 | //\r | |
179 | Status = gBS->OpenProtocol (\r | |
180 | Controller,\r | |
181 | &gEfiDevicePathProtocolGuid,\r | |
182 | (VOID **) &DevicePath,\r | |
183 | This->DriverBindingHandle,\r | |
184 | Controller,\r | |
185 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
186 | );\r | |
187 | if (!EFI_ERROR (Status)) {\r | |
188 | gBS->CloseProtocol (\r | |
189 | Controller,\r | |
190 | &gEfiDevicePathProtocolGuid,\r | |
191 | This->DriverBindingHandle,\r | |
192 | Controller\r | |
193 | );\r | |
194 | } else {\r | |
195 | goto Error;\r | |
196 | }\r | |
197 | //\r | |
198 | // Does Hii Exist? If not, we aren't ready to run\r | |
199 | //\r | |
200 | Status = EfiLocateHiiProtocol ();\r | |
201 | \r | |
202 | //\r | |
203 | // Close the I/O Abstraction(s) used to perform the supported test\r | |
204 | //\r | |
205 | Error:\r | |
206 | if (GraphicsOutput != NULL) {\r | |
207 | gBS->CloseProtocol (\r | |
208 | Controller,\r | |
209 | &gEfiGraphicsOutputProtocolGuid,\r | |
210 | This->DriverBindingHandle,\r | |
211 | Controller\r | |
212 | );\r | |
213 | } else {\r | |
214 | gBS->CloseProtocol (\r | |
215 | Controller,\r | |
216 | &gEfiUgaDrawProtocolGuid,\r | |
217 | This->DriverBindingHandle,\r | |
218 | Controller\r | |
219 | );\r | |
220 | }\r | |
221 | return Status;\r | |
222 | }\r | |
223 | \r | |
224 | EFI_STATUS\r | |
225 | EFIAPI\r | |
226 | GraphicsConsoleControllerDriverStart (\r | |
227 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
228 | IN EFI_HANDLE Controller,\r | |
229 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
230 | )\r | |
231 | /*++\r | |
232 | \r | |
233 | Routine Description:\r | |
234 | \r | |
235 | Start the controller.\r | |
236 | \r | |
237 | Arguments:\r | |
238 | \r | |
239 | This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
240 | Controller - The handle of the controller to start.\r | |
241 | RemainingDevicePath - A pointer to the remaining portion of a devcie path.\r | |
242 | \r | |
243 | Returns:\r | |
244 | \r | |
245 | EFI_SUCCESS - Return successfully.\r | |
246 | EFI_OUT_OF_RESOURCES - Out of resources.\r | |
247 | \r | |
248 | --*/\r | |
249 | {\r | |
3012ce5c | 250 | EFI_STATUS Status;\r |
251 | GRAPHICS_CONSOLE_DEV *Private;\r | |
95276127 | 252 | EFI_HII_PACKAGES *Package;\r |
253 | EFI_HII_FONT_PACK *FontPack;\r | |
3012ce5c | 254 | UINTN NarrowFontSize;\r |
255 | UINT32 HorizontalResolution;\r | |
256 | UINT32 VerticalResolution;\r | |
257 | UINT32 ColorDepth;\r | |
258 | UINT32 RefreshRate;\r | |
259 | UINTN MaxMode;\r | |
260 | UINTN Columns;\r | |
261 | UINTN Rows;\r | |
262 | UINT8 *Location;\r | |
95276127 | 263 | UINT32 ModeNumber;\r |
95276127 | 264 | \r |
265 | ModeNumber = 0;\r | |
266 | \r | |
267 | //\r | |
268 | // Initialize the Graphics Console device instance\r | |
269 | //\r | |
270 | Private = AllocateCopyPool (\r | |
271 | sizeof (GRAPHICS_CONSOLE_DEV),\r | |
272 | &mGraphicsConsoleDevTemplate\r | |
273 | );\r | |
274 | if (Private == NULL) {\r | |
275 | return EFI_OUT_OF_RESOURCES;\r | |
276 | }\r | |
277 | \r | |
278 | Private->SimpleTextOutput.Mode = &(Private->SimpleTextOutputMode);\r | |
279 | \r | |
280 | Status = gBS->OpenProtocol (\r | |
281 | Controller,\r | |
282 | &gEfiGraphicsOutputProtocolGuid,\r | |
283 | (VOID **) &Private->GraphicsOutput,\r | |
284 | This->DriverBindingHandle,\r | |
285 | Controller,\r | |
286 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
287 | );\r | |
288 | if (EFI_ERROR(Status)) {\r | |
289 | Private->GraphicsOutput = NULL;\r | |
290 | \r | |
291 | Status = gBS->OpenProtocol (\r | |
292 | Controller,\r | |
293 | &gEfiUgaDrawProtocolGuid,\r | |
294 | (VOID **) &Private->UgaDraw,\r | |
295 | This->DriverBindingHandle,\r | |
296 | Controller,\r | |
297 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
298 | );\r | |
299 | if (EFI_ERROR (Status)) {\r | |
300 | goto Error;\r | |
301 | }\r | |
302 | }\r | |
303 | \r | |
304 | //\r | |
305 | // Get the HII protocol. If Supported() succeeds, do we really\r | |
306 | // need to get HII protocol again?\r | |
307 | //\r | |
308 | Status = EfiLocateHiiProtocol ();\r | |
309 | if (EFI_ERROR (Status)) {\r | |
310 | goto Error;\r | |
311 | }\r | |
312 | \r | |
313 | NarrowFontSize = ReturnNarrowFontSize ();\r | |
314 | \r | |
315 | FontPack = AllocateZeroPool (sizeof (EFI_HII_FONT_PACK) + NarrowFontSize);\r | |
316 | ASSERT (FontPack);\r | |
317 | \r | |
318 | FontPack->Header.Length = (UINT32) (sizeof (EFI_HII_FONT_PACK) + NarrowFontSize);\r | |
319 | FontPack->Header.Type = EFI_HII_FONT;\r | |
320 | FontPack->NumberOfNarrowGlyphs = (UINT16) (NarrowFontSize / sizeof (EFI_NARROW_GLYPH));\r | |
321 | \r | |
322 | Location = (UINT8 *) (&FontPack->NumberOfWideGlyphs + sizeof (UINT8));\r | |
323 | CopyMem (Location, UsStdNarrowGlyphData, NarrowFontSize);\r | |
324 | \r | |
325 | //\r | |
326 | // Register our Fonts into the global database\r | |
327 | //\r | |
328 | Package = PreparePackages (1, NULL, FontPack);\r | |
329 | mHii->NewPack (mHii, Package, &(Private->HiiHandle));\r | |
330 | FreePool (Package);\r | |
331 | \r | |
332 | //\r | |
333 | // Free the font database\r | |
334 | //\r | |
335 | FreePool (FontPack);\r | |
336 | \r | |
337 | //\r | |
338 | // If the current mode information can not be retrieved, then attemp to set the default mode\r | |
339 | // of 800x600, 32 bit colot, 60 Hz refresh.\r | |
340 | //\r | |
341 | HorizontalResolution = 800;\r | |
342 | VerticalResolution = 600;\r | |
343 | \r | |
344 | if (Private->GraphicsOutput != NULL) {\r | |
345 | //\r | |
3012ce5c | 346 | // The console is build on top of Graphics Output Protocol, find the mode number \r |
347 | // for the user-defined mode; if there are multiple video devices,\r | |
348 | // graphic console driver will set all the video devices to the same mode.\r | |
95276127 | 349 | //\r |
3012ce5c | 350 | Status = CheckModeSupported (\r |
351 | Private->GraphicsOutput, \r | |
352 | CURRENT_HORIZONTAL_RESOLUTION, \r | |
353 | CURRENT_VERTICAL_RESOLUTION,\r | |
354 | &ModeNumber\r | |
355 | );\r | |
356 | if (!EFI_ERROR(Status)) {\r | |
357 | //\r | |
358 | // Update default mode to current mode\r | |
359 | //\r | |
360 | HorizontalResolution = CURRENT_HORIZONTAL_RESOLUTION;\r | |
361 | VerticalResolution = CURRENT_VERTICAL_RESOLUTION;\r | |
362 | } else {\r | |
363 | //\r | |
364 | // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec\r | |
365 | //\r | |
366 | Status = CheckModeSupported (\r | |
367 | Private->GraphicsOutput, \r | |
368 | 800, \r | |
369 | 600, \r | |
370 | &ModeNumber\r | |
371 | );\r | |
95276127 | 372 | }\r |
373 | \r | |
374 | if (EFI_ERROR (Status) || (ModeNumber == Private->GraphicsOutput->Mode->MaxMode)) {\r | |
375 | //\r | |
376 | // Set default mode failed or device don't support default mode, then get the current mode information\r | |
377 | //\r | |
378 | HorizontalResolution = Private->GraphicsOutput->Mode->Info->HorizontalResolution;\r | |
379 | VerticalResolution = Private->GraphicsOutput->Mode->Info->VerticalResolution;\r | |
380 | ModeNumber = Private->GraphicsOutput->Mode->Mode;\r | |
381 | }\r | |
382 | } else {\r | |
383 | //\r | |
3012ce5c | 384 | // At first try to set user-defined resolution\r |
95276127 | 385 | //\r |
386 | ColorDepth = 32;\r | |
387 | RefreshRate = 60;\r | |
388 | Status = Private->UgaDraw->SetMode (\r | |
389 | Private->UgaDraw,\r | |
3012ce5c | 390 | CURRENT_HORIZONTAL_RESOLUTION,\r |
391 | CURRENT_VERTICAL_RESOLUTION,\r | |
95276127 | 392 | ColorDepth,\r |
393 | RefreshRate\r | |
394 | );\r | |
3012ce5c | 395 | if (!EFI_ERROR (Status)) {\r |
396 | HorizontalResolution = CURRENT_HORIZONTAL_RESOLUTION;\r | |
397 | VerticalResolution = CURRENT_VERTICAL_RESOLUTION;\r | |
398 | } else {\r | |
95276127 | 399 | //\r |
3012ce5c | 400 | // Try to set 800*600 which is required by UEFI/EFI spec\r |
95276127 | 401 | //\r |
3012ce5c | 402 | Status = Private->UgaDraw->SetMode (\r |
95276127 | 403 | Private->UgaDraw,\r |
3012ce5c | 404 | HorizontalResolution,\r |
405 | VerticalResolution,\r | |
406 | ColorDepth,\r | |
407 | RefreshRate\r | |
95276127 | 408 | );\r |
409 | if (EFI_ERROR (Status)) {\r | |
3012ce5c | 410 | Status = Private->UgaDraw->GetMode (\r |
411 | Private->UgaDraw,\r | |
412 | &HorizontalResolution,\r | |
413 | &VerticalResolution,\r | |
414 | &ColorDepth,\r | |
415 | &RefreshRate\r | |
416 | );\r | |
417 | if (EFI_ERROR (Status)) {\r | |
418 | goto Error;\r | |
419 | }\r | |
95276127 | 420 | }\r |
421 | }\r | |
422 | }\r | |
423 | \r | |
424 | //\r | |
425 | // Compute the maximum number of text Rows and Columns that this current graphics mode can support\r | |
426 | //\r | |
427 | Columns = HorizontalResolution / GLYPH_WIDTH;\r | |
428 | Rows = VerticalResolution / GLYPH_HEIGHT;\r | |
429 | \r | |
430 | //\r | |
431 | // See if the mode is too small to support the required 80x25 text mode\r | |
432 | //\r | |
433 | if (Columns < 80 || Rows < 25) {\r | |
434 | goto Error;\r | |
435 | }\r | |
436 | //\r | |
437 | // Add Mode #0 that must be 80x25\r | |
438 | //\r | |
439 | MaxMode = 0;\r | |
440 | Private->ModeData[MaxMode].GopWidth = HorizontalResolution;\r | |
441 | Private->ModeData[MaxMode].GopHeight = VerticalResolution;\r | |
442 | Private->ModeData[MaxMode].GopModeNumber = ModeNumber;\r | |
443 | Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (80 * GLYPH_WIDTH)) >> 1;\r | |
444 | Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (25 * GLYPH_HEIGHT)) >> 1;\r | |
445 | MaxMode++;\r | |
446 | \r | |
447 | //\r | |
448 | // If it is possible to support Mode #1 - 80x50, than add it as an active mode\r | |
449 | //\r | |
450 | if (Rows >= 50) {\r | |
451 | Private->ModeData[MaxMode].GopWidth = HorizontalResolution;\r | |
452 | Private->ModeData[MaxMode].GopHeight = VerticalResolution;\r | |
453 | Private->ModeData[MaxMode].GopModeNumber = ModeNumber;\r | |
454 | Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (80 * GLYPH_WIDTH)) >> 1;\r | |
455 | Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (50 * GLYPH_HEIGHT)) >> 1;\r | |
456 | MaxMode++;\r | |
457 | }\r | |
3012ce5c | 458 | \r |
95276127 | 459 | //\r |
3012ce5c | 460 | // If it is not to support Mode #1 - 80x50, then skip it\r |
95276127 | 461 | //\r |
3012ce5c | 462 | if (MaxMode < 2) {\r |
463 | Private->ModeData[MaxMode].Columns = 0;\r | |
464 | Private->ModeData[MaxMode].Rows = 0;\r | |
465 | Private->ModeData[MaxMode].GopWidth = HorizontalResolution;\r | |
466 | Private->ModeData[MaxMode].GopHeight = VerticalResolution;\r | |
467 | Private->ModeData[MaxMode].GopModeNumber = ModeNumber;\r | |
468 | Private->ModeData[MaxMode].DeltaX = 0;\r | |
469 | Private->ModeData[MaxMode].DeltaY = 0;\r | |
470 | MaxMode++;\r | |
471 | }\r | |
472 | \r | |
473 | //\r | |
474 | // Add Mode #2 that must be 100x31 (graphic mode >= 800x600)\r | |
475 | //\r | |
476 | if (Columns >= 100 && Rows >= 31) { \r | |
477 | Private->ModeData[MaxMode].GopWidth = HorizontalResolution;\r | |
478 | Private->ModeData[MaxMode].GopHeight = VerticalResolution;\r | |
479 | Private->ModeData[MaxMode].GopModeNumber = ModeNumber;\r | |
480 | Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (100 * GLYPH_WIDTH)) >> 1;\r | |
481 | Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (31 * GLYPH_HEIGHT)) >> 1;\r | |
482 | MaxMode++;\r | |
483 | }\r | |
95276127 | 484 | \r |
3012ce5c | 485 | //\r |
486 | // Add Mode #3 that uses the entire display for user-defined mode\r | |
487 | //\r | |
488 | if (HorizontalResolution > 800 && VerticalResolution > 600) {\r | |
489 | Private->ModeData[MaxMode].Columns = HorizontalResolution/GLYPH_WIDTH;\r | |
490 | Private->ModeData[MaxMode].Rows = VerticalResolution/GLYPH_HEIGHT; \r | |
491 | Private->ModeData[MaxMode].GopWidth = HorizontalResolution;\r | |
492 | Private->ModeData[MaxMode].GopHeight = VerticalResolution;\r | |
95276127 | 493 | Private->ModeData[MaxMode].GopModeNumber = ModeNumber;\r |
3012ce5c | 494 | Private->ModeData[MaxMode].DeltaX = (HorizontalResolution % GLYPH_WIDTH) >> 1;\r |
495 | Private->ModeData[MaxMode].DeltaY = (VerticalResolution % GLYPH_HEIGHT) >> 1;\r | |
95276127 | 496 | MaxMode++;\r |
497 | }\r | |
3012ce5c | 498 | \r |
95276127 | 499 | //\r |
500 | // Update the maximum number of modes\r | |
501 | //\r | |
502 | Private->SimpleTextOutputMode.MaxMode = (INT32) MaxMode;\r | |
503 | \r | |
504 | //\r | |
505 | // Determine the number of text modes that this protocol can support\r | |
506 | //\r | |
507 | Status = GraphicsConsoleConOutSetMode (&Private->SimpleTextOutput, 0);\r | |
508 | if (EFI_ERROR (Status)) {\r | |
509 | goto Error;\r | |
510 | }\r | |
511 | \r | |
512 | DEBUG_CODE_BEGIN ();\r | |
513 | GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r");\r | |
514 | DEBUG_CODE_END ();\r | |
515 | \r | |
516 | //\r | |
517 | // Install protocol interfaces for the Graphics Console device.\r | |
518 | //\r | |
519 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
520 | &Controller,\r | |
521 | &gEfiSimpleTextOutProtocolGuid,\r | |
522 | &Private->SimpleTextOutput,\r | |
523 | NULL\r | |
524 | );\r | |
525 | \r | |
526 | Error:\r | |
527 | if (EFI_ERROR (Status)) {\r | |
528 | //\r | |
529 | // Close the GOP or UGA IO Protocol\r | |
530 | //\r | |
531 | if (Private->GraphicsOutput != NULL) {\r | |
532 | gBS->CloseProtocol (\r | |
533 | Controller,\r | |
534 | &gEfiGraphicsOutputProtocolGuid,\r | |
535 | This->DriverBindingHandle,\r | |
536 | Controller\r | |
537 | );\r | |
538 | } else {\r | |
539 | gBS->CloseProtocol (\r | |
540 | Controller,\r | |
541 | &gEfiUgaDrawProtocolGuid,\r | |
542 | This->DriverBindingHandle,\r | |
543 | Controller\r | |
544 | );\r | |
545 | }\r | |
546 | \r | |
547 | //\r | |
548 | // Free private data\r | |
549 | //\r | |
550 | if (Private != NULL) {\r | |
551 | if (Private->LineBuffer != NULL) {\r | |
552 | FreePool (Private->LineBuffer);\r | |
553 | }\r | |
554 | FreePool (Private);\r | |
555 | }\r | |
556 | }\r | |
557 | \r | |
558 | return Status;\r | |
559 | }\r | |
560 | \r | |
561 | EFI_STATUS\r | |
562 | EFIAPI\r | |
563 | GraphicsConsoleControllerDriverStop (\r | |
564 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
565 | IN EFI_HANDLE Controller,\r | |
566 | IN UINTN NumberOfChildren,\r | |
567 | IN EFI_HANDLE *ChildHandleBuffer\r | |
568 | )\r | |
569 | {\r | |
570 | EFI_STATUS Status;\r | |
571 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;\r | |
572 | GRAPHICS_CONSOLE_DEV *Private;\r | |
573 | \r | |
574 | Status = gBS->OpenProtocol (\r | |
575 | Controller,\r | |
576 | &gEfiSimpleTextOutProtocolGuid,\r | |
577 | (VOID **) &SimpleTextOutput,\r | |
578 | This->DriverBindingHandle,\r | |
579 | Controller,\r | |
580 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
581 | );\r | |
582 | if (EFI_ERROR (Status)) {\r | |
583 | return EFI_NOT_STARTED;\r | |
584 | }\r | |
585 | \r | |
586 | Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);\r | |
587 | \r | |
588 | Status = gBS->UninstallProtocolInterface (\r | |
589 | Controller,\r | |
590 | &gEfiSimpleTextOutProtocolGuid,\r | |
591 | &Private->SimpleTextOutput\r | |
592 | );\r | |
593 | \r | |
594 | if (!EFI_ERROR (Status)) {\r | |
595 | //\r | |
596 | // Close the GOP or UGA IO Protocol\r | |
597 | //\r | |
598 | if (Private->GraphicsOutput != NULL) {\r | |
599 | gBS->CloseProtocol (\r | |
600 | Controller,\r | |
601 | &gEfiGraphicsOutputProtocolGuid,\r | |
602 | This->DriverBindingHandle,\r | |
603 | Controller\r | |
604 | );\r | |
605 | } else {\r | |
606 | gBS->CloseProtocol (\r | |
607 | Controller,\r | |
608 | &gEfiUgaDrawProtocolGuid,\r | |
609 | This->DriverBindingHandle,\r | |
610 | Controller\r | |
611 | );\r | |
612 | }\r | |
613 | \r | |
614 | //\r | |
615 | // Remove the font pack\r | |
616 | //\r | |
617 | mHii->RemovePack (mHii, Private->HiiHandle);\r | |
618 | \r | |
619 | //\r | |
620 | // Free our instance data\r | |
621 | //\r | |
622 | if (Private != NULL) {\r | |
623 | FreePool (Private->LineBuffer);\r | |
624 | FreePool (Private);\r | |
625 | }\r | |
626 | }\r | |
627 | \r | |
628 | return Status;\r | |
629 | }\r | |
630 | \r | |
3012ce5c | 631 | EFI_STATUS\r |
632 | CheckModeSupported (\r | |
633 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r | |
634 | IN UINT32 HorizontalResolution,\r | |
635 | IN UINT32 VerticalResolution,\r | |
636 | OUT UINT32 *CurrentModeNumber\r | |
637 | )\r | |
638 | {\r | |
639 | UINT32 ModeNumber;\r | |
640 | EFI_STATUS Status;\r | |
641 | UINTN SizeOfInfo; \r | |
642 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r | |
643 | \r | |
644 | Status = EFI_SUCCESS;\r | |
645 | \r | |
646 | for (ModeNumber = 0; ModeNumber < GraphicsOutput->Mode->MaxMode; ModeNumber++) {\r | |
647 | Status = GraphicsOutput->QueryMode (\r | |
648 | GraphicsOutput,\r | |
649 | ModeNumber,\r | |
650 | &SizeOfInfo,\r | |
651 | &Info\r | |
652 | );\r | |
653 | if (!EFI_ERROR (Status)) {\r | |
654 | if ((Info->HorizontalResolution == HorizontalResolution) &&\r | |
655 | (Info->VerticalResolution == VerticalResolution)) {\r | |
656 | Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);\r | |
657 | if (!EFI_ERROR (Status)) {\r | |
658 | gBS->FreePool (Info);\r | |
659 | break;\r | |
660 | }\r | |
661 | }\r | |
662 | gBS->FreePool (Info);\r | |
663 | }\r | |
664 | }\r | |
665 | \r | |
666 | if (ModeNumber == GraphicsOutput->Mode->MaxMode) {\r | |
667 | Status = EFI_UNSUPPORTED;\r | |
668 | }\r | |
669 | \r | |
670 | *CurrentModeNumber = ModeNumber;\r | |
671 | return Status; \r | |
672 | }\r | |
673 | \r | |
95276127 | 674 | EFI_STATUS\r |
675 | EfiLocateHiiProtocol (\r | |
676 | VOID\r | |
677 | )\r | |
678 | /*++\r | |
679 | \r | |
680 | Routine Description:\r | |
681 | Find if the HII protocol is available. If yes, locate the HII protocol\r | |
682 | \r | |
683 | Arguments:\r | |
684 | \r | |
685 | Returns:\r | |
686 | \r | |
687 | --*/\r | |
688 | {\r | |
689 | EFI_HANDLE Handle;\r | |
690 | UINTN Size;\r | |
691 | EFI_STATUS Status;\r | |
692 | \r | |
693 | //\r | |
694 | // There should only be one - so buffer size is this\r | |
695 | //\r | |
696 | Size = sizeof (EFI_HANDLE);\r | |
697 | \r | |
698 | Status = gBS->LocateHandle (\r | |
699 | ByProtocol,\r | |
700 | &gEfiHiiProtocolGuid,\r | |
701 | NULL,\r | |
702 | &Size,\r | |
703 | &Handle\r | |
704 | );\r | |
705 | \r | |
706 | if (EFI_ERROR (Status)) {\r | |
707 | return Status;\r | |
708 | }\r | |
709 | \r | |
710 | Status = gBS->HandleProtocol (\r | |
711 | Handle,\r | |
712 | &gEfiHiiProtocolGuid,\r | |
713 | (VOID **)&mHii\r | |
714 | );\r | |
715 | \r | |
716 | return Status;\r | |
717 | }\r | |
718 | //\r | |
719 | // Body of the STO functions\r | |
720 | //\r | |
721 | EFI_STATUS\r | |
722 | EFIAPI\r | |
723 | GraphicsConsoleConOutReset (\r | |
724 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
725 | IN BOOLEAN ExtendedVerification\r | |
726 | )\r | |
727 | /*++\r | |
728 | Routine Description:\r | |
729 | \r | |
730 | Implements SIMPLE_TEXT_OUTPUT.Reset().\r | |
731 | If ExtendeVerification is TRUE, then perform dependent Graphics Console \r | |
732 | device reset, and set display mode to mode 0.\r | |
733 | If ExtendedVerification is FALSE, only set display mode to mode 0.\r | |
734 | \r | |
735 | Arguments:\r | |
736 | \r | |
737 | This - Indicates the calling context.\r | |
738 | \r | |
739 | ExtendedVerification - Indicates that the driver may perform a more exhaustive\r | |
740 | verification operation of the device during reset.\r | |
741 | \r | |
742 | Returns:\r | |
743 | \r | |
744 | EFI_SUCCESS\r | |
745 | The reset operation succeeds. \r | |
746 | \r | |
747 | EFI_DEVICE_ERROR\r | |
748 | The Graphics Console is not functioning correctly \r | |
749 | \r | |
750 | --*/\r | |
751 | {\r | |
752 | This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK));\r | |
753 | return This->SetMode (This, 0);\r | |
754 | }\r | |
755 | \r | |
756 | EFI_STATUS\r | |
757 | EFIAPI\r | |
758 | GraphicsConsoleConOutOutputString (\r | |
759 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
760 | IN CHAR16 *WString\r | |
761 | )\r | |
762 | /*++\r | |
763 | Routine Description:\r | |
764 | \r | |
765 | Implements SIMPLE_TEXT_OUTPUT.OutputString().\r | |
766 | The Unicode string will be converted to Glyphs and will be \r | |
767 | sent to the Graphics Console.\r | |
768 | \r | |
769 | \r | |
770 | Arguments:\r | |
771 | \r | |
772 | This - Indicates the calling context.\r | |
773 | \r | |
774 | WString - The Null-terminated Unicode string to be displayed on \r | |
775 | the Graphics Console.\r | |
776 | \r | |
777 | Returns:\r | |
778 | \r | |
779 | EFI_SUCCESS\r | |
780 | The string is output successfully. \r | |
781 | \r | |
782 | EFI_DEVICE_ERROR\r | |
783 | The Graphics Console failed to send the string out.\r | |
784 | \r | |
785 | EFI_WARN_UNKNOWN_GLYPH\r | |
786 | Indicates that some of the characters in the Unicode string could not \r | |
787 | be rendered and are skipped. \r | |
788 | \r | |
789 | --*/\r | |
790 | {\r | |
791 | GRAPHICS_CONSOLE_DEV *Private;\r | |
792 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r | |
793 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
794 | INTN Mode;\r | |
795 | UINTN MaxColumn;\r | |
796 | UINTN MaxRow;\r | |
797 | UINTN Width;\r | |
798 | UINTN Height;\r | |
799 | UINTN Delta;\r | |
800 | EFI_STATUS Status;\r | |
801 | BOOLEAN Warning;\r | |
802 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r | |
803 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r | |
804 | UINTN DeltaX;\r | |
805 | UINTN DeltaY;\r | |
806 | UINTN Count;\r | |
807 | UINTN Index;\r | |
808 | INT32 OriginAttribute;\r | |
809 | EFI_TPL OldTpl;\r | |
810 | CHAR16 SpaceStr[] = { NARROW_CHAR, ' ', 0 };\r | |
811 | \r | |
812 | Status = EFI_SUCCESS;\r | |
813 | \r | |
814 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
815 | //\r | |
816 | // Current mode\r | |
817 | //\r | |
818 | Mode = This->Mode->Mode;\r | |
819 | Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r | |
820 | GraphicsOutput = Private->GraphicsOutput;\r | |
821 | UgaDraw = Private->UgaDraw;\r | |
822 | \r | |
823 | MaxColumn = Private->ModeData[Mode].Columns;\r | |
824 | MaxRow = Private->ModeData[Mode].Rows;\r | |
825 | DeltaX = Private->ModeData[Mode].DeltaX;\r | |
826 | DeltaY = Private->ModeData[Mode].DeltaY;\r | |
827 | Width = MaxColumn * GLYPH_WIDTH;\r | |
828 | Height = (MaxRow - 1) * GLYPH_HEIGHT;\r | |
829 | Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r | |
830 | \r | |
831 | //\r | |
832 | // The Attributes won't change when during the time OutputString is called\r | |
833 | //\r | |
834 | GetTextColors (This, &Foreground, &Background);\r | |
835 | \r | |
836 | EraseCursor (This);\r | |
837 | \r | |
838 | Warning = FALSE;\r | |
839 | \r | |
840 | //\r | |
841 | // Backup attribute\r | |
842 | //\r | |
843 | OriginAttribute = This->Mode->Attribute;\r | |
844 | \r | |
845 | while (*WString) {\r | |
846 | \r | |
847 | if (*WString == CHAR_BACKSPACE) {\r | |
848 | //\r | |
849 | // If the cursor is at the left edge of the display, then move the cursor\r | |
850 | // one row up.\r | |
851 | //\r | |
852 | if (This->Mode->CursorColumn == 0 && This->Mode->CursorRow > 0) {\r | |
853 | This->Mode->CursorRow--;\r | |
854 | This->Mode->CursorColumn = (INT32) (MaxColumn - 1);\r | |
855 | This->OutputString (This, SpaceStr);\r | |
856 | EraseCursor (This);\r | |
857 | This->Mode->CursorRow--;\r | |
858 | This->Mode->CursorColumn = (INT32) (MaxColumn - 1);\r | |
859 | } else if (This->Mode->CursorColumn > 0) {\r | |
860 | //\r | |
861 | // If the cursor is not at the left edge of the display, then move the cursor\r | |
862 | // left one column.\r | |
863 | //\r | |
864 | This->Mode->CursorColumn--;\r | |
865 | This->OutputString (This, SpaceStr);\r | |
866 | EraseCursor (This);\r | |
867 | This->Mode->CursorColumn--;\r | |
868 | }\r | |
869 | \r | |
870 | WString++;\r | |
871 | \r | |
872 | } else if (*WString == CHAR_LINEFEED) {\r | |
873 | //\r | |
874 | // If the cursor is at the bottom of the display, then scroll the display one\r | |
875 | // row, and do not update the cursor position. Otherwise, move the cursor\r | |
876 | // down one row.\r | |
877 | //\r | |
878 | if (This->Mode->CursorRow == (INT32) (MaxRow - 1)) {\r | |
879 | if (GraphicsOutput != NULL) {\r | |
880 | //\r | |
881 | // Scroll Screen Up One Row\r | |
882 | //\r | |
883 | GraphicsOutput->Blt (\r | |
884 | GraphicsOutput,\r | |
885 | NULL,\r | |
886 | EfiBltVideoToVideo,\r | |
887 | DeltaX,\r | |
888 | DeltaY + GLYPH_HEIGHT,\r | |
889 | DeltaX,\r | |
890 | DeltaY,\r | |
891 | Width,\r | |
892 | Height,\r | |
893 | Delta\r | |
894 | );\r | |
895 | \r | |
896 | //\r | |
897 | // Print Blank Line at last line\r | |
898 | //\r | |
899 | GraphicsOutput->Blt (\r | |
900 | GraphicsOutput,\r | |
901 | &Background,\r | |
902 | EfiBltVideoFill,\r | |
903 | 0,\r | |
904 | 0,\r | |
905 | DeltaX,\r | |
906 | DeltaY + Height,\r | |
907 | Width,\r | |
908 | GLYPH_HEIGHT,\r | |
909 | Delta\r | |
910 | );\r | |
911 | } else {\r | |
912 | //\r | |
913 | // Scroll Screen Up One Row\r | |
914 | //\r | |
915 | UgaDraw->Blt (\r | |
916 | UgaDraw,\r | |
917 | NULL,\r | |
918 | EfiUgaVideoToVideo,\r | |
919 | DeltaX,\r | |
920 | DeltaY + GLYPH_HEIGHT,\r | |
921 | DeltaX,\r | |
922 | DeltaY,\r | |
923 | Width,\r | |
924 | Height,\r | |
925 | Delta\r | |
926 | );\r | |
927 | \r | |
928 | //\r | |
929 | // Print Blank Line at last line\r | |
930 | //\r | |
931 | UgaDraw->Blt (\r | |
932 | UgaDraw,\r | |
933 | (EFI_UGA_PIXEL *) (UINTN) &Background,\r | |
934 | EfiUgaVideoFill,\r | |
935 | 0,\r | |
936 | 0,\r | |
937 | DeltaX,\r | |
938 | DeltaY + Height,\r | |
939 | Width,\r | |
940 | GLYPH_HEIGHT,\r | |
941 | Delta\r | |
942 | );\r | |
943 | }\r | |
944 | } else {\r | |
945 | This->Mode->CursorRow++;\r | |
946 | }\r | |
947 | \r | |
948 | WString++;\r | |
949 | \r | |
950 | } else if (*WString == CHAR_CARRIAGE_RETURN) {\r | |
951 | //\r | |
952 | // Move the cursor to the beginning of the current row.\r | |
953 | //\r | |
954 | This->Mode->CursorColumn = 0;\r | |
955 | WString++;\r | |
956 | \r | |
957 | } else if (*WString == WIDE_CHAR) {\r | |
958 | \r | |
959 | This->Mode->Attribute |= EFI_WIDE_ATTRIBUTE;\r | |
960 | WString++;\r | |
961 | \r | |
962 | } else if (*WString == NARROW_CHAR) {\r | |
963 | \r | |
964 | This->Mode->Attribute &= (~ (UINT32) EFI_WIDE_ATTRIBUTE);\r | |
965 | WString++;\r | |
966 | \r | |
967 | } else {\r | |
968 | //\r | |
969 | // Print the character at the current cursor position and move the cursor\r | |
970 | // right one column. If this moves the cursor past the right edge of the\r | |
971 | // display, then the line should wrap to the beginning of the next line. This\r | |
972 | // is equivalent to inserting a CR and an LF. Note that if the cursor is at the\r | |
973 | // bottom of the display, and the line wraps, then the display will be scrolled\r | |
974 | // one line.\r | |
975 | // If wide char is going to be displayed, need to display one character at a time\r | |
976 | // Or, need to know the display length of a certain string.\r | |
977 | //\r | |
978 | // Index is used to determine how many character width units (wide = 2, narrow = 1)\r | |
979 | // Count is used to determine how many characters are used regardless of their attributes\r | |
980 | //\r | |
981 | for (Count = 0, Index = 0; (This->Mode->CursorColumn + Index) < MaxColumn; Count++, Index++) {\r | |
982 | if (WString[Count] == CHAR_NULL) {\r | |
983 | break;\r | |
984 | }\r | |
985 | \r | |
986 | if (WString[Count] == CHAR_BACKSPACE) {\r | |
987 | break;\r | |
988 | }\r | |
989 | \r | |
990 | if (WString[Count] == CHAR_LINEFEED) {\r | |
991 | break;\r | |
992 | }\r | |
993 | \r | |
994 | if (WString[Count] == CHAR_CARRIAGE_RETURN) {\r | |
995 | break;\r | |
996 | }\r | |
997 | \r | |
998 | if (WString[Count] == WIDE_CHAR) {\r | |
999 | break;\r | |
1000 | }\r | |
1001 | \r | |
1002 | if (WString[Count] == NARROW_CHAR) {\r | |
1003 | break;\r | |
1004 | }\r | |
1005 | //\r | |
1006 | // Is the wide attribute on?\r | |
1007 | //\r | |
1008 | if (This->Mode->Attribute & EFI_WIDE_ATTRIBUTE) {\r | |
1009 | //\r | |
1010 | // If wide, add one more width unit than normal since we are going to increment at the end of the for loop\r | |
1011 | //\r | |
1012 | Index++;\r | |
1013 | //\r | |
1014 | // This is the end-case where if we are at column 79 and about to print a wide character\r | |
1015 | // We should prevent this from happening because we will wrap inappropriately. We should\r | |
1016 | // not print this character until the next line.\r | |
1017 | //\r | |
1018 | if ((This->Mode->CursorColumn + Index + 1) > MaxColumn) {\r | |
1019 | Index++;\r | |
1020 | break;\r | |
1021 | }\r | |
1022 | }\r | |
1023 | }\r | |
1024 | \r | |
1025 | Status = DrawUnicodeWeightAtCursorN (This, WString, Count);\r | |
1026 | if (EFI_ERROR (Status)) {\r | |
1027 | Warning = TRUE;\r | |
1028 | }\r | |
1029 | //\r | |
1030 | // At the end of line, output carriage return and line feed\r | |
1031 | //\r | |
1032 | WString += Count;\r | |
1033 | This->Mode->CursorColumn += (INT32) Index;\r | |
1034 | if (This->Mode->CursorColumn > (INT32) MaxColumn) {\r | |
1035 | This->Mode->CursorColumn -= 2;\r | |
1036 | This->OutputString (This, SpaceStr);\r | |
1037 | }\r | |
1038 | \r | |
1039 | if (This->Mode->CursorColumn >= (INT32) MaxColumn) {\r | |
1040 | EraseCursor (This);\r | |
1041 | This->OutputString (This, mCrLfString);\r | |
1042 | EraseCursor (This);\r | |
1043 | }\r | |
1044 | }\r | |
1045 | }\r | |
1046 | \r | |
1047 | This->Mode->Attribute = OriginAttribute;\r | |
1048 | \r | |
1049 | EraseCursor (This);\r | |
1050 | \r | |
1051 | if (Warning) {\r | |
1052 | Status = EFI_WARN_UNKNOWN_GLYPH;\r | |
1053 | }\r | |
1054 | \r | |
1055 | gBS->RestoreTPL (OldTpl);\r | |
1056 | return Status;\r | |
1057 | \r | |
1058 | }\r | |
1059 | \r | |
1060 | EFI_STATUS\r | |
1061 | EFIAPI\r | |
1062 | GraphicsConsoleConOutTestString (\r | |
1063 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
1064 | IN CHAR16 *WString\r | |
1065 | )\r | |
1066 | /*++\r | |
1067 | Routine Description:\r | |
1068 | \r | |
1069 | Implements SIMPLE_TEXT_OUTPUT.TestString().\r | |
1070 | If one of the characters in the *Wstring is\r | |
1071 | neither valid valid Unicode drawing characters,\r | |
1072 | not ASCII code, then this function will return\r | |
1073 | EFI_UNSUPPORTED.\r | |
1074 | \r | |
1075 | \r | |
1076 | Arguments:\r | |
1077 | \r | |
1078 | This - Indicates the calling context.\r | |
1079 | \r | |
1080 | WString - The Null-terminated Unicode string to be tested.\r | |
1081 | \r | |
1082 | Returns:\r | |
1083 | \r | |
1084 | EFI_SUCCESS\r | |
1085 | The Graphics Console is capable of rendering the output string. \r | |
1086 | \r | |
1087 | EFI_UNSUPPORTED\r | |
1088 | Some of the characters in the Unicode string cannot be rendered. \r | |
1089 | \r | |
1090 | --*/\r | |
1091 | {\r | |
1092 | EFI_STATUS Status;\r | |
1093 | UINT16 GlyphWidth;\r | |
1094 | UINT32 GlyphStatus;\r | |
1095 | UINT16 Count;\r | |
1096 | GLYPH_UNION *Glyph;\r | |
1097 | \r | |
1098 | GlyphStatus = 0;\r | |
1099 | Count = 0;\r | |
1100 | \r | |
1101 | while (WString[Count]) {\r | |
1102 | Status = mHii->GetGlyph (\r | |
1103 | mHii,\r | |
1104 | WString,\r | |
1105 | &Count,\r | |
1106 | (UINT8 **) &Glyph,\r | |
1107 | &GlyphWidth,\r | |
1108 | &GlyphStatus\r | |
1109 | );\r | |
1110 | \r | |
1111 | if (EFI_ERROR (Status)) {\r | |
1112 | return EFI_UNSUPPORTED;\r | |
1113 | }\r | |
1114 | }\r | |
1115 | \r | |
1116 | return EFI_SUCCESS;\r | |
1117 | }\r | |
1118 | \r | |
1119 | EFI_STATUS\r | |
1120 | EFIAPI\r | |
1121 | GraphicsConsoleConOutQueryMode (\r | |
1122 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
1123 | IN UINTN ModeNumber,\r | |
1124 | OUT UINTN *Columns,\r | |
1125 | OUT UINTN *Rows\r | |
1126 | )\r | |
1127 | /*++\r | |
1128 | Routine Description:\r | |
1129 | \r | |
1130 | Implements SIMPLE_TEXT_OUTPUT.QueryMode().\r | |
1131 | It returnes information for an available text mode\r | |
1132 | that the Graphics Console supports.\r | |
1133 | In this driver,we only support text mode 80x25, which is\r | |
1134 | defined as mode 0.\r | |
1135 | \r | |
1136 | \r | |
1137 | Arguments:\r | |
1138 | \r | |
1139 | This - Indicates the calling context.\r | |
1140 | \r | |
1141 | ModeNumber - The mode number to return information on.\r | |
1142 | \r | |
1143 | Columns - The returned columns of the requested mode.\r | |
1144 | \r | |
1145 | Rows - The returned rows of the requested mode. \r | |
1146 | \r | |
1147 | Returns:\r | |
1148 | \r | |
1149 | EFI_SUCCESS\r | |
1150 | The requested mode information is returned. \r | |
1151 | \r | |
1152 | EFI_UNSUPPORTED\r | |
1153 | The mode number is not valid. \r | |
1154 | \r | |
1155 | --*/\r | |
1156 | {\r | |
1157 | GRAPHICS_CONSOLE_DEV *Private;\r | |
1158 | EFI_STATUS Status;\r | |
1159 | EFI_TPL OldTpl;\r | |
1160 | \r | |
1161 | if (ModeNumber >= (UINTN) This->Mode->MaxMode) {\r | |
1162 | return EFI_UNSUPPORTED;\r | |
1163 | }\r | |
1164 | \r | |
1165 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
1166 | Status = EFI_SUCCESS;\r | |
1167 | \r | |
1168 | Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r | |
1169 | \r | |
1170 | *Columns = Private->ModeData[ModeNumber].Columns;\r | |
1171 | *Rows = Private->ModeData[ModeNumber].Rows;\r | |
1172 | \r | |
1173 | if (*Columns <= 0 && *Rows <= 0) {\r | |
1174 | Status = EFI_UNSUPPORTED;\r | |
1175 | goto Done;\r | |
1176 | \r | |
1177 | }\r | |
1178 | \r | |
1179 | Done:\r | |
1180 | gBS->RestoreTPL (OldTpl);\r | |
1181 | return Status;\r | |
1182 | }\r | |
1183 | \r | |
1184 | EFI_STATUS\r | |
1185 | EFIAPI\r | |
1186 | GraphicsConsoleConOutSetMode (\r | |
1187 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
1188 | IN UINTN ModeNumber\r | |
1189 | )\r | |
1190 | /*++\r | |
1191 | Routine Description:\r | |
1192 | \r | |
1193 | Implements SIMPLE_TEXT_OUTPUT.SetMode().\r | |
1194 | Set the Graphics Console to a specified mode.\r | |
1195 | In this driver, we only support mode 0. \r | |
1196 | \r | |
1197 | Arguments:\r | |
1198 | \r | |
1199 | This - Indicates the calling context.\r | |
1200 | \r | |
1201 | ModeNumber - The text mode to set.\r | |
1202 | \r | |
1203 | Returns:\r | |
1204 | \r | |
1205 | EFI_SUCCESS\r | |
1206 | The requested text mode is set.\r | |
1207 | \r | |
1208 | EFI_DEVICE_ERROR\r | |
1209 | The requested text mode cannot be set because of Graphics Console device error.\r | |
1210 | \r | |
1211 | EFI_UNSUPPORTED\r | |
1212 | The text mode number is not valid. \r | |
1213 | \r | |
1214 | --*/\r | |
1215 | {\r | |
1216 | EFI_STATUS Status;\r | |
1217 | GRAPHICS_CONSOLE_DEV *Private;\r | |
1218 | GRAPHICS_CONSOLE_MODE_DATA *ModeData;\r | |
1219 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL *NewLineBuffer;\r | |
1220 | UINT32 HorizontalResolution;\r | |
1221 | UINT32 VerticalResolution;\r | |
1222 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r | |
1223 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
1224 | UINT32 ColorDepth;\r | |
1225 | UINT32 RefreshRate;\r | |
1226 | EFI_TPL OldTpl;\r | |
1227 | \r | |
1228 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
1229 | \r | |
1230 | Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r | |
1231 | GraphicsOutput = Private->GraphicsOutput;\r | |
1232 | UgaDraw = Private->UgaDraw;\r | |
1233 | ModeData = &(Private->ModeData[ModeNumber]);\r | |
1234 | \r | |
1235 | if (ModeData->Columns <= 0 && ModeData->Rows <= 0) {\r | |
1236 | Status = EFI_UNSUPPORTED;\r | |
1237 | goto Done;\r | |
1238 | }\r | |
1239 | \r | |
1240 | //\r | |
1241 | // Make sure the requested mode number is supported\r | |
1242 | //\r | |
1243 | if (ModeNumber >= (UINTN) This->Mode->MaxMode) {\r | |
1244 | Status = EFI_UNSUPPORTED;\r | |
1245 | goto Done;\r | |
1246 | }\r | |
1247 | \r | |
1248 | if (ModeData->Columns <= 0 && ModeData->Rows <= 0) {\r | |
1249 | Status = EFI_UNSUPPORTED;\r | |
1250 | goto Done;\r | |
1251 | }\r | |
1252 | //\r | |
1253 | // Attempt to allocate a line buffer for the requested mode number\r | |
1254 | //\r | |
1255 | NewLineBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * ModeData->Columns * GLYPH_WIDTH * GLYPH_HEIGHT);\r | |
1256 | \r | |
1257 | if (NewLineBuffer == NULL) {\r | |
1258 | //\r | |
1259 | // The new line buffer could not be allocated, so return an error.\r | |
1260 | // No changes to the state of the current console have been made, so the current console is still valid\r | |
1261 | //\r | |
1262 | Status = EFI_OUT_OF_RESOURCES;\r | |
1263 | goto Done;\r | |
1264 | }\r | |
1265 | //\r | |
1266 | // If the mode has been set at least one other time, then LineBuffer will not be NULL\r | |
1267 | //\r | |
1268 | if (Private->LineBuffer != NULL) {\r | |
1269 | //\r | |
1270 | // Clear the current text window on the current graphics console\r | |
1271 | //\r | |
1272 | This->ClearScreen (This);\r | |
1273 | \r | |
1274 | //\r | |
1275 | // If the new mode is the same as the old mode, then just return EFI_SUCCESS\r | |
1276 | //\r | |
1277 | if ((INT32) ModeNumber == This->Mode->Mode) {\r | |
1278 | FreePool (NewLineBuffer);\r | |
1279 | Status = EFI_SUCCESS;\r | |
1280 | goto Done;\r | |
1281 | }\r | |
1282 | //\r | |
1283 | // Otherwise, the size of the text console and/or the UGA mode will be changed,\r | |
1284 | // so turn off the cursor, and free the LineBuffer for the current mode\r | |
1285 | //\r | |
1286 | This->EnableCursor (This, FALSE);\r | |
1287 | \r | |
1288 | FreePool (Private->LineBuffer);\r | |
1289 | }\r | |
1290 | //\r | |
1291 | // Assign the current line buffer to the newly allocated line buffer\r | |
1292 | //\r | |
1293 | Private->LineBuffer = NewLineBuffer;\r | |
1294 | \r | |
1295 | if (GraphicsOutput != NULL) {\r | |
1296 | if (ModeData->GopModeNumber != GraphicsOutput->Mode->Mode) {\r | |
1297 | //\r | |
1298 | // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode\r | |
1299 | //\r | |
1300 | Status = GraphicsOutput->SetMode (GraphicsOutput, ModeData->GopModeNumber);\r | |
1301 | if (EFI_ERROR (Status)) {\r | |
1302 | //\r | |
1303 | // The mode set operation failed\r | |
1304 | //\r | |
1305 | goto Done;\r | |
1306 | }\r | |
1307 | } else {\r | |
1308 | //\r | |
1309 | // The current graphics mode is correct, so simply clear the entire display\r | |
1310 | //\r | |
1311 | Status = GraphicsOutput->Blt (\r | |
1312 | GraphicsOutput,\r | |
1313 | &mEfiColors[0],\r | |
1314 | EfiBltVideoFill,\r | |
1315 | 0,\r | |
1316 | 0,\r | |
1317 | 0,\r | |
1318 | 0,\r | |
1319 | ModeData->GopWidth,\r | |
1320 | ModeData->GopHeight,\r | |
1321 | 0\r | |
1322 | );\r | |
1323 | }\r | |
1324 | } else {\r | |
1325 | //\r | |
1326 | // Get the current UGA Draw mode information\r | |
1327 | //\r | |
1328 | Status = UgaDraw->GetMode (\r | |
1329 | UgaDraw,\r | |
1330 | &HorizontalResolution,\r | |
1331 | &VerticalResolution,\r | |
1332 | &ColorDepth,\r | |
1333 | &RefreshRate\r | |
1334 | );\r | |
1335 | if (EFI_ERROR (Status) || HorizontalResolution != ModeData->GopWidth || VerticalResolution != ModeData->GopHeight) {\r | |
1336 | //\r | |
1337 | // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode\r | |
1338 | //\r | |
1339 | Status = UgaDraw->SetMode (\r | |
1340 | UgaDraw,\r | |
1341 | ModeData->GopWidth,\r | |
1342 | ModeData->GopHeight,\r | |
1343 | 32,\r | |
1344 | 60\r | |
1345 | );\r | |
1346 | if (EFI_ERROR (Status)) {\r | |
1347 | //\r | |
1348 | // The mode set operation failed\r | |
1349 | //\r | |
1350 | goto Done;\r | |
1351 | }\r | |
1352 | } else {\r | |
1353 | //\r | |
1354 | // The current graphics mode is correct, so simply clear the entire display\r | |
1355 | //\r | |
1356 | Status = UgaDraw->Blt (\r | |
1357 | UgaDraw,\r | |
1358 | (EFI_UGA_PIXEL *) (UINTN) &mEfiColors[0],\r | |
1359 | EfiUgaVideoFill,\r | |
1360 | 0,\r | |
1361 | 0,\r | |
1362 | 0,\r | |
1363 | 0,\r | |
1364 | ModeData->GopWidth,\r | |
1365 | ModeData->GopHeight,\r | |
1366 | 0\r | |
1367 | );\r | |
1368 | }\r | |
1369 | }\r | |
1370 | \r | |
1371 | //\r | |
1372 | // The new mode is valid, so commit the mode change\r | |
1373 | //\r | |
1374 | This->Mode->Mode = (INT32) ModeNumber;\r | |
1375 | \r | |
1376 | //\r | |
1377 | // Move the text cursor to the upper left hand corner of the displat and enable it\r | |
1378 | //\r | |
1379 | This->SetCursorPosition (This, 0, 0);\r | |
1380 | This->EnableCursor (This, TRUE);\r | |
1381 | \r | |
1382 | Status = EFI_SUCCESS;\r | |
1383 | \r | |
1384 | Done:\r | |
1385 | gBS->RestoreTPL (OldTpl);\r | |
1386 | return Status;\r | |
1387 | }\r | |
1388 | \r | |
1389 | EFI_STATUS\r | |
1390 | EFIAPI\r | |
1391 | GraphicsConsoleConOutSetAttribute (\r | |
1392 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
1393 | IN UINTN Attribute\r | |
1394 | )\r | |
1395 | /*++\r | |
1396 | Routine Description:\r | |
1397 | \r | |
1398 | Implements SIMPLE_TEXT_OUTPUT.SetAttribute(). \r | |
1399 | \r | |
1400 | Arguments:\r | |
1401 | \r | |
1402 | This - Indicates the calling context.\r | |
1403 | \r | |
1404 | Attrubute - The attribute to set. Only bit0..6 are valid, all other bits\r | |
1405 | are undefined and must be zero.\r | |
1406 | \r | |
1407 | Returns:\r | |
1408 | \r | |
1409 | EFI_SUCCESS\r | |
1410 | The requested attribute is set. \r | |
1411 | \r | |
1412 | EFI_DEVICE_ERROR\r | |
1413 | The requested attribute cannot be set due to Graphics Console port error.\r | |
1414 | \r | |
1415 | EFI_UNSUPPORTED\r | |
1416 | The attribute requested is not defined by EFI spec. \r | |
1417 | \r | |
1418 | --*/\r | |
1419 | {\r | |
1420 | EFI_TPL OldTpl;\r | |
1421 | \r | |
1422 | if ((Attribute | 0xFF) != 0xFF) {\r | |
1423 | return EFI_UNSUPPORTED;\r | |
1424 | }\r | |
1425 | \r | |
1426 | if ((INT32) Attribute == This->Mode->Attribute) {\r | |
1427 | return EFI_SUCCESS;\r | |
1428 | }\r | |
1429 | \r | |
1430 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
1431 | \r | |
1432 | EraseCursor (This);\r | |
1433 | \r | |
1434 | This->Mode->Attribute = (INT32) Attribute;\r | |
1435 | \r | |
1436 | EraseCursor (This);\r | |
1437 | \r | |
1438 | gBS->RestoreTPL (OldTpl);\r | |
1439 | \r | |
1440 | return EFI_SUCCESS;\r | |
1441 | }\r | |
1442 | \r | |
1443 | EFI_STATUS\r | |
1444 | EFIAPI\r | |
1445 | GraphicsConsoleConOutClearScreen (\r | |
1446 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r | |
1447 | )\r | |
1448 | /*++\r | |
1449 | Routine Description:\r | |
1450 | \r | |
1451 | Implements SIMPLE_TEXT_OUTPUT.ClearScreen().\r | |
1452 | It clears the Graphics Console's display to the \r | |
1453 | currently selected background color.\r | |
1454 | \r | |
1455 | \r | |
1456 | Arguments:\r | |
1457 | \r | |
1458 | This - Indicates the calling context.\r | |
1459 | \r | |
1460 | Returns:\r | |
1461 | \r | |
1462 | EFI_SUCCESS\r | |
1463 | The operation completed successfully.\r | |
1464 | \r | |
1465 | EFI_DEVICE_ERROR\r | |
1466 | The Graphics Console cannot be cleared due to Graphics Console device error. \r | |
1467 | \r | |
1468 | EFI_UNSUPPORTED\r | |
1469 | The Graphics Console is not in a valid text mode. \r | |
1470 | \r | |
1471 | --*/\r | |
1472 | {\r | |
1473 | EFI_STATUS Status;\r | |
1474 | GRAPHICS_CONSOLE_DEV *Private;\r | |
1475 | GRAPHICS_CONSOLE_MODE_DATA *ModeData;\r | |
1476 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r | |
1477 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
1478 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r | |
1479 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r | |
1480 | EFI_TPL OldTpl;\r | |
1481 | \r | |
1482 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
1483 | \r | |
1484 | Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r | |
1485 | GraphicsOutput = Private->GraphicsOutput;\r | |
1486 | UgaDraw = Private->UgaDraw;\r | |
1487 | ModeData = &(Private->ModeData[This->Mode->Mode]);\r | |
1488 | \r | |
1489 | GetTextColors (This, &Foreground, &Background);\r | |
1490 | if (GraphicsOutput != NULL) {\r | |
1491 | Status = GraphicsOutput->Blt (\r | |
1492 | GraphicsOutput,\r | |
1493 | &Background,\r | |
1494 | EfiBltVideoFill,\r | |
1495 | 0,\r | |
1496 | 0,\r | |
1497 | 0,\r | |
1498 | 0,\r | |
1499 | ModeData->GopWidth,\r | |
1500 | ModeData->GopHeight,\r | |
1501 | 0\r | |
1502 | );\r | |
1503 | } else {\r | |
1504 | Status = UgaDraw->Blt (\r | |
1505 | UgaDraw,\r | |
1506 | (EFI_UGA_PIXEL *) (UINTN) &Background,\r | |
1507 | EfiUgaVideoFill,\r | |
1508 | 0,\r | |
1509 | 0,\r | |
1510 | 0,\r | |
1511 | 0,\r | |
1512 | ModeData->GopWidth,\r | |
1513 | ModeData->GopHeight,\r | |
1514 | 0\r | |
1515 | );\r | |
1516 | }\r | |
1517 | \r | |
1518 | This->Mode->CursorColumn = 0;\r | |
1519 | This->Mode->CursorRow = 0;\r | |
1520 | \r | |
1521 | EraseCursor (This);\r | |
1522 | \r | |
1523 | gBS->RestoreTPL (OldTpl);\r | |
1524 | \r | |
1525 | return Status;\r | |
1526 | }\r | |
1527 | \r | |
1528 | EFI_STATUS\r | |
1529 | EFIAPI\r | |
1530 | GraphicsConsoleConOutSetCursorPosition (\r | |
1531 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
1532 | IN UINTN Column,\r | |
1533 | IN UINTN Row\r | |
1534 | )\r | |
1535 | /*++\r | |
1536 | Routine Description:\r | |
1537 | \r | |
1538 | Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition(). \r | |
1539 | \r | |
1540 | Arguments:\r | |
1541 | \r | |
1542 | This - Indicates the calling context.\r | |
1543 | \r | |
1544 | Column - The row to set cursor to.\r | |
1545 | \r | |
1546 | Row - The column to set cursor to. \r | |
1547 | \r | |
1548 | Returns:\r | |
1549 | \r | |
1550 | EFI_SUCCESS\r | |
1551 | The operation completed successfully.\r | |
1552 | \r | |
1553 | EFI_DEVICE_ERROR\r | |
1554 | The request fails due to Graphics Console device error. \r | |
1555 | \r | |
1556 | EFI_UNSUPPORTED\r | |
1557 | The Graphics Console is not in a valid text mode, or the cursor position\r | |
1558 | is invalid for current mode. \r | |
1559 | \r | |
1560 | --*/\r | |
1561 | {\r | |
1562 | GRAPHICS_CONSOLE_DEV *Private;\r | |
1563 | GRAPHICS_CONSOLE_MODE_DATA *ModeData;\r | |
1564 | EFI_STATUS Status;\r | |
1565 | EFI_TPL OldTpl;\r | |
1566 | \r | |
1567 | Status = EFI_SUCCESS;\r | |
1568 | \r | |
1569 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
1570 | \r | |
1571 | Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r | |
1572 | ModeData = &(Private->ModeData[This->Mode->Mode]);\r | |
1573 | \r | |
1574 | if ((Column >= ModeData->Columns) || (Row >= ModeData->Rows)) {\r | |
1575 | Status = EFI_UNSUPPORTED;\r | |
1576 | goto Done;\r | |
1577 | }\r | |
1578 | \r | |
1579 | if (((INT32) Column == This->Mode->CursorColumn) && ((INT32) Row == This->Mode->CursorRow)) {\r | |
1580 | Status = EFI_SUCCESS;\r | |
1581 | goto Done;\r | |
1582 | }\r | |
1583 | \r | |
1584 | EraseCursor (This);\r | |
1585 | \r | |
1586 | This->Mode->CursorColumn = (INT32) Column;\r | |
1587 | This->Mode->CursorRow = (INT32) Row;\r | |
1588 | \r | |
1589 | EraseCursor (This);\r | |
1590 | \r | |
1591 | Done:\r | |
1592 | gBS->RestoreTPL (OldTpl);\r | |
1593 | \r | |
1594 | return Status;\r | |
1595 | }\r | |
1596 | \r | |
1597 | EFI_STATUS\r | |
1598 | EFIAPI\r | |
1599 | GraphicsConsoleConOutEnableCursor (\r | |
1600 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
1601 | IN BOOLEAN Visible\r | |
1602 | )\r | |
1603 | /*++\r | |
1604 | Routine Description:\r | |
1605 | \r | |
1606 | Implements SIMPLE_TEXT_OUTPUT.EnableCursor().\r | |
1607 | In this driver, the cursor cannot be hidden. \r | |
1608 | \r | |
1609 | Arguments:\r | |
1610 | \r | |
1611 | This - Indicates the calling context.\r | |
1612 | \r | |
1613 | Visible - If TRUE, the cursor is set to be visible,\r | |
1614 | If FALSE, the cursor is set to be invisible. \r | |
1615 | \r | |
1616 | Returns:\r | |
1617 | \r | |
1618 | EFI_SUCCESS\r | |
1619 | The request is valid.\r | |
1620 | \r | |
1621 | EFI_UNSUPPORTED\r | |
1622 | The Graphics Console does not support a hidden cursor. \r | |
1623 | \r | |
1624 | --*/\r | |
1625 | {\r | |
1626 | EFI_TPL OldTpl;\r | |
1627 | \r | |
1628 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
1629 | \r | |
1630 | EraseCursor (This);\r | |
1631 | \r | |
1632 | This->Mode->CursorVisible = Visible;\r | |
1633 | \r | |
1634 | EraseCursor (This);\r | |
1635 | \r | |
1636 | gBS->RestoreTPL (OldTpl);\r | |
1637 | return EFI_SUCCESS;\r | |
1638 | }\r | |
1639 | \r | |
1640 | STATIC\r | |
1641 | EFI_STATUS\r | |
1642 | GetTextColors (\r | |
1643 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
1644 | OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,\r | |
1645 | OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background\r | |
1646 | )\r | |
1647 | {\r | |
1648 | INTN Attribute;\r | |
1649 | \r | |
1650 | Attribute = This->Mode->Attribute & 0x7F;\r | |
1651 | \r | |
1652 | *Foreground = mEfiColors[Attribute & 0x0f];\r | |
1653 | *Background = mEfiColors[Attribute >> 4];\r | |
1654 | \r | |
1655 | return EFI_SUCCESS;\r | |
1656 | }\r | |
1657 | \r | |
1658 | STATIC\r | |
1659 | EFI_STATUS\r | |
1660 | DrawUnicodeWeightAtCursorN (\r | |
1661 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
1662 | IN CHAR16 *UnicodeWeight,\r | |
1663 | IN UINTN Count\r | |
1664 | )\r | |
1665 | {\r | |
1666 | GRAPHICS_CONSOLE_DEV *Private;\r | |
1667 | EFI_STATUS Status;\r | |
1668 | EFI_STATUS ReturnStatus;\r | |
1669 | GLYPH_UNION *Glyph;\r | |
1670 | GLYPH_UNION GlyphData;\r | |
1671 | INTN GlyphX;\r | |
1672 | INTN GlyphY;\r | |
1673 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r | |
1674 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
1675 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r | |
1676 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r | |
1677 | UINTN Index;\r | |
1678 | UINTN ArrayIndex;\r | |
1679 | UINTN Counts;\r | |
1680 | UINT16 GlyphWidth;\r | |
1681 | UINT32 GlyphStatus;\r | |
1682 | \r | |
1683 | Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r | |
1684 | \r | |
1685 | ReturnStatus = EFI_SUCCESS;\r | |
1686 | GlyphStatus = 0;\r | |
1687 | GlyphWidth = 0x08;\r | |
1688 | \r | |
1689 | GetTextColors (This, &Foreground, &Background);\r | |
1690 | \r | |
1691 | Index = 0;\r | |
1692 | ArrayIndex = 0;\r | |
1693 | while (Index < Count) {\r | |
1694 | if (This->Mode->Attribute & EFI_WIDE_ATTRIBUTE) {\r | |
1695 | GlyphStatus = WIDE_CHAR;\r | |
1696 | } else {\r | |
1697 | GlyphStatus = NARROW_CHAR;\r | |
1698 | }\r | |
1699 | \r | |
1700 | Status = mHii->GetGlyph (\r | |
1701 | mHii,\r | |
1702 | UnicodeWeight,\r | |
1703 | (UINT16 *) &Index,\r | |
1704 | (UINT8 **) &Glyph,\r | |
1705 | &GlyphWidth,\r | |
1706 | &GlyphStatus\r | |
1707 | );\r | |
1708 | if (EFI_ERROR (Status)) {\r | |
1709 | ReturnStatus = Status;\r | |
1710 | }\r | |
1711 | \r | |
1712 | Counts = 0;\r | |
1713 | \r | |
1714 | CopyMem (&GlyphData, Glyph, sizeof (GLYPH_UNION));\r | |
1715 | \r | |
1716 | do {\r | |
1717 | //\r | |
1718 | // We are creating the second half of the wide character's BLT buffer\r | |
1719 | //\r | |
1720 | if (GlyphWidth == 0x10 && Counts == 1) {\r | |
1721 | CopyMem (&GlyphData.NarrowGlyph.GlyphCol1, &Glyph->WideGlyph.GlyphCol2, sizeof (Glyph->WideGlyph.GlyphCol2));\r | |
1722 | }\r | |
1723 | \r | |
1724 | Counts++;\r | |
1725 | \r | |
1726 | if (GlyphWidth == 0x10) {\r | |
1727 | mHii->GlyphToBlt (\r | |
1728 | mHii,\r | |
1729 | (UINT8 *) &GlyphData,\r | |
1730 | Foreground,\r | |
1731 | Background,\r | |
1732 | Count * 2,\r | |
1733 | GLYPH_WIDTH,\r | |
1734 | GLYPH_HEIGHT,\r | |
1735 | &Private->LineBuffer[ArrayIndex * GLYPH_WIDTH]\r | |
1736 | );\r | |
1737 | } else {\r | |
1738 | mHii->GlyphToBlt (\r | |
1739 | mHii,\r | |
1740 | (UINT8 *) &GlyphData,\r | |
1741 | Foreground,\r | |
1742 | Background,\r | |
1743 | Count,\r | |
1744 | GLYPH_WIDTH,\r | |
1745 | GLYPH_HEIGHT,\r | |
1746 | &Private->LineBuffer[ArrayIndex * GLYPH_WIDTH]\r | |
1747 | );\r | |
1748 | }\r | |
1749 | \r | |
1750 | ArrayIndex++;\r | |
1751 | \r | |
1752 | } while (Counts < 2 && GlyphWidth == 0x10);\r | |
1753 | \r | |
1754 | }\r | |
1755 | //\r | |
1756 | // If we are printing Wide characters, treat the BLT as if it is twice as many characters\r | |
1757 | //\r | |
1758 | if (GlyphWidth == 0x10) {\r | |
1759 | Count = Count * 2;\r | |
1760 | }\r | |
1761 | //\r | |
1762 | // Blt a character to the screen\r | |
1763 | //\r | |
1764 | GlyphX = This->Mode->CursorColumn * GLYPH_WIDTH;\r | |
1765 | GlyphY = This->Mode->CursorRow * GLYPH_HEIGHT;\r | |
1766 | GraphicsOutput = Private->GraphicsOutput;\r | |
1767 | UgaDraw = Private->UgaDraw;\r | |
1768 | if (GraphicsOutput != NULL) {\r | |
1769 | GraphicsOutput->Blt (\r | |
1770 | GraphicsOutput,\r | |
1771 | Private->LineBuffer,\r | |
1772 | EfiBltBufferToVideo,\r | |
1773 | 0,\r | |
1774 | 0,\r | |
1775 | GlyphX + Private->ModeData[This->Mode->Mode].DeltaX,\r | |
1776 | GlyphY + Private->ModeData[This->Mode->Mode].DeltaY,\r | |
1777 | GLYPH_WIDTH * Count,\r | |
1778 | GLYPH_HEIGHT,\r | |
1779 | GLYPH_WIDTH * Count * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r | |
1780 | );\r | |
1781 | } else {\r | |
1782 | UgaDraw->Blt (\r | |
1783 | UgaDraw,\r | |
1784 | (EFI_UGA_PIXEL *) (UINTN) Private->LineBuffer,\r | |
1785 | EfiUgaBltBufferToVideo,\r | |
1786 | 0,\r | |
1787 | 0,\r | |
1788 | GlyphX + Private->ModeData[This->Mode->Mode].DeltaX,\r | |
1789 | GlyphY + Private->ModeData[This->Mode->Mode].DeltaY,\r | |
1790 | GLYPH_WIDTH * Count,\r | |
1791 | GLYPH_HEIGHT,\r | |
1792 | GLYPH_WIDTH * Count * sizeof (EFI_UGA_PIXEL)\r | |
1793 | );\r | |
1794 | }\r | |
1795 | \r | |
1796 | return ReturnStatus;\r | |
1797 | }\r | |
1798 | \r | |
1799 | STATIC\r | |
1800 | EFI_STATUS\r | |
1801 | EraseCursor (\r | |
1802 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r | |
1803 | )\r | |
1804 | {\r | |
1805 | GRAPHICS_CONSOLE_DEV *Private;\r | |
1806 | EFI_SIMPLE_TEXT_OUTPUT_MODE *CurrentMode;\r | |
1807 | INTN GlyphX;\r | |
1808 | INTN GlyphY;\r | |
1809 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r | |
1810 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
1811 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Foreground;\r | |
1812 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Background;\r | |
1813 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION BltChar[GLYPH_HEIGHT][GLYPH_WIDTH];\r | |
1814 | UINTN X;\r | |
1815 | UINTN Y;\r | |
1816 | \r | |
1817 | CurrentMode = This->Mode;\r | |
1818 | \r | |
1819 | if (!CurrentMode->CursorVisible) {\r | |
1820 | return EFI_SUCCESS;\r | |
1821 | }\r | |
1822 | \r | |
1823 | Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r | |
1824 | GraphicsOutput = Private->GraphicsOutput;\r | |
1825 | UgaDraw = Private->UgaDraw;\r | |
1826 | \r | |
1827 | //\r | |
1828 | // BUGBUG - we need to think about what to do with wide and narrow character deletions.\r | |
1829 | //\r | |
1830 | //\r | |
1831 | // Blt a character to the screen\r | |
1832 | //\r | |
1833 | GlyphX = (CurrentMode->CursorColumn * GLYPH_WIDTH) + Private->ModeData[CurrentMode->Mode].DeltaX;\r | |
1834 | GlyphY = (CurrentMode->CursorRow * GLYPH_HEIGHT) + Private->ModeData[CurrentMode->Mode].DeltaY;\r | |
1835 | if (GraphicsOutput != NULL) {\r | |
1836 | GraphicsOutput->Blt (\r | |
1837 | GraphicsOutput,\r | |
1838 | (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) BltChar,\r | |
1839 | EfiBltVideoToBltBuffer,\r | |
1840 | GlyphX,\r | |
1841 | GlyphY,\r | |
1842 | 0,\r | |
1843 | 0,\r | |
1844 | GLYPH_WIDTH,\r | |
1845 | GLYPH_HEIGHT,\r | |
1846 | GLYPH_WIDTH * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r | |
1847 | );\r | |
1848 | } else {\r | |
1849 | UgaDraw->Blt (\r | |
1850 | UgaDraw,\r | |
1851 | (EFI_UGA_PIXEL *) (UINTN) BltChar,\r | |
1852 | EfiUgaVideoToBltBuffer,\r | |
1853 | GlyphX,\r | |
1854 | GlyphY,\r | |
1855 | 0,\r | |
1856 | 0,\r | |
1857 | GLYPH_WIDTH,\r | |
1858 | GLYPH_HEIGHT,\r | |
1859 | GLYPH_WIDTH * sizeof (EFI_UGA_PIXEL)\r | |
1860 | );\r | |
1861 | }\r | |
1862 | \r | |
1863 | GetTextColors (This, &Foreground.Pixel, &Background.Pixel);\r | |
1864 | \r | |
1865 | //\r | |
1866 | // Convert Monochrome bitmap of the Glyph to BltBuffer structure\r | |
1867 | //\r | |
1868 | for (Y = 0; Y < GLYPH_HEIGHT; Y++) {\r | |
1869 | for (X = 0; X < GLYPH_WIDTH; X++) {\r | |
1870 | if ((mCursorGlyph.GlyphCol1[Y] & (1 << X)) != 0) {\r | |
1871 | BltChar[Y][GLYPH_WIDTH - X - 1].Raw ^= Foreground.Raw;\r | |
1872 | }\r | |
1873 | }\r | |
1874 | }\r | |
1875 | \r | |
1876 | if (GraphicsOutput != NULL) {\r | |
1877 | GraphicsOutput->Blt (\r | |
1878 | GraphicsOutput,\r | |
1879 | (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) BltChar,\r | |
1880 | EfiBltBufferToVideo,\r | |
1881 | 0,\r | |
1882 | 0,\r | |
1883 | GlyphX,\r | |
1884 | GlyphY,\r | |
1885 | GLYPH_WIDTH,\r | |
1886 | GLYPH_HEIGHT,\r | |
1887 | GLYPH_WIDTH * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r | |
1888 | );\r | |
1889 | } else {\r | |
1890 | UgaDraw->Blt (\r | |
1891 | UgaDraw,\r | |
1892 | (EFI_UGA_PIXEL *) (UINTN) BltChar,\r | |
1893 | EfiUgaBltBufferToVideo,\r | |
1894 | 0,\r | |
1895 | 0,\r | |
1896 | GlyphX,\r | |
1897 | GlyphY,\r | |
1898 | GLYPH_WIDTH,\r | |
1899 | GLYPH_HEIGHT,\r | |
1900 | GLYPH_WIDTH * sizeof (EFI_UGA_PIXEL)\r | |
1901 | );\r | |
1902 | }\r | |
1903 | \r | |
1904 | return EFI_SUCCESS;\r | |
1905 | }\r | |
97a079ed A |
1906 | \r |
1907 | /**\r | |
1908 | The user Entry Point for module GraphicsConsole. The user code starts with this function.\r | |
1909 | \r | |
1910 | @param[in] ImageHandle The firmware allocated handle for the EFI image. \r | |
1911 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
1912 | \r | |
1913 | @retval EFI_SUCCESS The entry point is executed successfully.\r | |
1914 | @retval other Some error occurs when executing this entry point.\r | |
1915 | \r | |
1916 | **/\r | |
1917 | EFI_STATUS\r | |
1918 | EFIAPI\r | |
1919 | InitializeGraphicsConsole (\r | |
1920 | IN EFI_HANDLE ImageHandle,\r | |
1921 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
1922 | )\r | |
1923 | {\r | |
1924 | EFI_STATUS Status;\r | |
1925 | \r | |
1926 | //\r | |
1927 | // Install driver model protocol(s).\r | |
1928 | //\r | |
5bca971e | 1929 | Status = EfiLibInstallDriverBindingComponentName2 (\r |
97a079ed A |
1930 | ImageHandle,\r |
1931 | SystemTable,\r | |
1932 | &gGraphicsConsoleDriverBinding,\r | |
1933 | ImageHandle,\r | |
1934 | &gGraphicsConsoleComponentName,\r | |
5bca971e | 1935 | &gGraphicsConsoleComponentName2\r |
97a079ed A |
1936 | );\r |
1937 | ASSERT_EFI_ERROR (Status);\r | |
1938 | \r | |
1939 | \r | |
1940 | return Status;\r | |
1941 | }\r | |
1942 | \r |