]> code.delx.au - refind/blobdiff - libeg/screen.c
installation script improvements; 0.5.1 release
[refind] / libeg / screen.c
index fd441febe9e5821d439a9f473786b31c167b9694..f17f7f563e897178584fa04c319c258aa4672702 100644 (file)
 
 #include "libegint.h"
 #include "../refind/screen.h"
-#include "refit_call_wrapper.h"
+#include "../include/refit_call_wrapper.h"
 
 #include <efiUgaDraw.h>
 #include <efiConsoleControl.h>
 
+#ifndef __MAKEWITH_GNUEFI
+#define LibLocateProtocol EfiLibLocateProtocol
+#endif
+
 // Console defines and variables
 
 static EFI_GUID ConsoleControlProtocolGuid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
@@ -96,6 +100,17 @@ VOID egInitScreen(VOID)
     }
 }
 
+// // Returns current graphics mode number
+// UINT32 egGetGraphicsMode(VOID) {
+//    UINT32 retval = 0;
+// 
+//    if (GraphicsOutput != NULL) {
+//       retval = GraphicsOutput->Mode->Mode;
+//    }
+// 
+//    return retval;
+// } // UINT32 egGetGraphicsMode()
+
 // Sets the screen resolution to the specified value, if possible.
 // If the specified value is not valid, displays a warning with the valid
 // modes on UEFI systems, or silently fails on EFI 1.x systems. Note that
@@ -118,6 +133,8 @@ BOOLEAN egSetScreenSize(IN UINTN ScreenWidth, IN UINTN ScreenHeight) {
          if ((Status == EFI_SUCCESS) && (Size >= sizeof(*Info)) &&
              (Info->HorizontalResolution == ScreenWidth) && (Info->VerticalResolution == ScreenHeight)) {
             Status = refit_call2_wrapper(GraphicsOutput->SetMode, GraphicsOutput, ModeNum);
+//             if (Status == EFI_SUCCESS)
+//                Status = refit_call2_wrapper(ST->ConOut->SetMode, ST->ConOut, ModeNum);
             ModeSet = (Status == EFI_SUCCESS);
          } // if
          ModeNum++;
@@ -127,6 +144,7 @@ BOOLEAN egSetScreenSize(IN UINTN ScreenWidth, IN UINTN ScreenHeight) {
          egScreenWidth = ScreenWidth;
          egScreenHeight = ScreenHeight;
       } else {// If unsuccessful, display an error message for the user....
+         SwitchToText(FALSE);
          Print(L"Error setting mode %d x %d; using default mode!\nAvailable modes are:\n", ScreenWidth, ScreenHeight);
          ModeNum = 0;
          Status = EFI_SUCCESS;
@@ -138,6 +156,7 @@ BOOLEAN egSetScreenSize(IN UINTN ScreenWidth, IN UINTN ScreenHeight) {
             ModeNum++;
          } // while()
          PauseForKey();
+         SwitchToGraphics();
       } // if()
    } else if (UgaDraw != NULL) { // UGA mode (EFI 1.x)
       // Try to use current color depth & refresh rate for new mode. Maybe not the best choice
@@ -168,13 +187,17 @@ VOID egGetScreenSize(OUT UINTN *ScreenWidth, OUT UINTN *ScreenHeight)
 
 CHAR16 * egScreenDescription(VOID)
 {
+    CHAR16 *Temp;
+
     if (egHasGraphics) {
         if (GraphicsOutput != NULL) {
-            return PoolPrint(L"Graphics Output (UEFI), %dx%d",
-                             egScreenWidth, egScreenHeight);
+            Temp = AllocateZeroPool(256 * sizeof(CHAR16));
+            SPrint(Temp, 255, L"Graphics Output (UEFI), %dx%d", egScreenWidth, egScreenHeight);
+            return Temp;
         } else if (UgaDraw != NULL) {
-            return PoolPrint(L"UGA Draw (EFI 1.10), %dx%d",
-                             egScreenWidth, egScreenHeight);
+            Temp = AllocateZeroPool(256 * sizeof(CHAR16));
+            SPrint(Temp, 255, L"UGA Draw (EFI 1.10), %dx%d", egScreenWidth, egScreenHeight);
+            return Temp;
         } else {
             return L"Internal Error";
         }