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