MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / egInitScreen

Function egInitScreen

rEFIt_UEFI/libeg/libscreen.cpp:361–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361VOID egInitScreen(IN BOOLEAN SetMaxResolution)
362{
363 EFI_STATUS Status;
364 UINT32 Width, Height, Depth, RefreshRate;
365// CHAR16 *Resolution;
366
367 // get protocols
368 Status = EfiLibLocateProtocol(&ConsoleControlProtocolGuid, (VOID **) &ConsoleControl);
369 if (EFI_ERROR(Status))
370 ConsoleControl = NULL;
371
372 Status = EfiLibLocateProtocol(&UgaDrawProtocolGuid, (VOID **) &UgaDraw);
373 if (EFI_ERROR(Status))
374 UgaDraw = NULL;
375
376 Status = EfiLibLocateProtocol(&GraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);
377 if (EFI_ERROR(Status))
378 GraphicsOutput = NULL;
379
380 // Wrap GetMode and SetMode
381 if (ConsoleControl != NULL && (ConsoleControlGetMode == NULL || ConsoleControlSetMode == NULL)) {
382 ConsoleControlGetMode = ConsoleControl->GetMode;
383 ConsoleControlSetMode = ConsoleControl->SetMode;
384 ConsoleControl->GetMode = egConsoleControlGetMode;
385 ConsoleControl->SetMode = egConsoleControlSetMode;
386 }
387
388 // if it not the first run, just restore resolution
389 if (egScreenWidth != 0 && egScreenHeight != 0) {
390 XStringW Resolution = SWPrintf("%llux%llu", egScreenWidth, egScreenHeight);
391 Status = egSetScreenResolution(Resolution.wc_str());
392 if (!EFI_ERROR(Status)) {
393 return;
394 }
395 }
396
397 egDumpSetConsoleVideoModes();
398
399 // get screen size
400 egHasGraphics = FALSE;
401 if (GraphicsOutput != NULL) {
402 // egDumpGOPVideoModes();
403 if (GlobalConfig.ScreenResolution.notEmpty()) {
404 if (EFI_ERROR(egSetScreenResolution(GlobalConfig.ScreenResolution.wc_str()))) {
405 if (SetMaxResolution) {
406 egSetMaxResolution();
407 }
408 }
409 } else {
410 if (SetMaxResolution) {
411 egSetMaxResolution();
412 }
413 }
414 egScreenWidth = GraphicsOutput->Mode->Info->HorizontalResolution;
415 egScreenHeight = GraphicsOutput->Mode->Info->VerticalResolution;
416 egHasGraphics = TRUE;
417 }
418 //is there anybody ever see UGA protocol???

Callers 1

InitScreenFunction · 0.85

Calls 7

SWPrintfFunction · 0.85
egSetScreenResolutionFunction · 0.85
egSetMaxResolutionFunction · 0.85
EfiLibLocateProtocolFunction · 0.70
wc_strMethod · 0.45
notEmptyMethod · 0.45

Tested by

no test coverage detected