]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
ArmPlatformPkg/LcdGraphicsOutputDxe: check PrimeCell ID before initializing
[mirror_edk2.git] / ArmPlatformPkg / Drivers / LcdGraphicsOutputDxe / LcdGraphicsOutputDxe.c
index 0091c7597c70b27684ed8dc1d737aa0ea653fbb4..b721061fc1df5695092e8c71da97ae0b9af46b3f 100644 (file)
@@ -156,57 +156,62 @@ LcdGraphicsOutputDxeInitialize (
   EFI_STATUS  Status = EFI_SUCCESS;\r
   LCD_INSTANCE* Instance;\r
 \r
+  Status = LcdIdentify ();\r
+  if (EFI_ERROR(Status)) {\r
+    goto EXIT;\r
+  }\r
+\r
   Status = LcdInstanceContructor (&Instance);\r
   if (EFI_ERROR(Status)) {\r
     goto EXIT;\r
   }\r
 \r
-       // Install the Graphics Output Protocol and the Device Path\r
-       Status = gBS->InstallMultipleProtocolInterfaces(\r
-                       &Instance->Handle,\r
-                       &gEfiGraphicsOutputProtocolGuid, &Instance->Gop,\r
-                       &gEfiDevicePathProtocolGuid,     &Instance->DevicePath,\r
-                       NULL\r
-          );\r
-\r
-       if (EFI_ERROR(Status)) {\r
-         DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the protocol. Exit Status=%r\n", Status));\r
-               goto EXIT;\r
-       }\r
-\r
-       // Register for an ExitBootServicesEvent\r
-       // When ExitBootServices starts, this function here will make sure that the graphics driver will shut down properly,\r
-       // i.e. it will free up all allocated memory and perform any necessary hardware re-configuration.\r
-       Status = gBS->CreateEvent (\r
-           EVT_SIGNAL_EXIT_BOOT_SERVICES,\r
-           TPL_NOTIFY,\r
-           LcdGraphicsExitBootServicesEvent, NULL,\r
-                       &Instance->ExitBootServicesEvent\r
-                       );\r
-\r
-       if (EFI_ERROR(Status)) {\r
-         DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the ExitBootServicesEvent handler. Exit Status=%r\n", Status));\r
-               goto EXIT_ERROR_UNINSTALL_PROTOCOL;\r
-       }\r
-\r
-       // To get here, everything must be fine, so just exit\r
-       goto EXIT;\r
+  // Install the Graphics Output Protocol and the Device Path\r
+  Status = gBS->InstallMultipleProtocolInterfaces(\r
+            &Instance->Handle,\r
+            &gEfiGraphicsOutputProtocolGuid, &Instance->Gop,\r
+            &gEfiDevicePathProtocolGuid,     &Instance->DevicePath,\r
+            NULL\r
+            );\r
+\r
+  if (EFI_ERROR(Status)) {\r
+    DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the protocol. Exit Status=%r\n", Status));\r
+    goto EXIT;\r
+  }\r
+\r
+  // Register for an ExitBootServicesEvent\r
+  // When ExitBootServices starts, this function here will make sure that the graphics driver will shut down properly,\r
+  // i.e. it will free up all allocated memory and perform any necessary hardware re-configuration.\r
+  Status = gBS->CreateEvent (\r
+            EVT_SIGNAL_EXIT_BOOT_SERVICES,\r
+            TPL_NOTIFY,\r
+            LcdGraphicsExitBootServicesEvent, NULL,\r
+            &Instance->ExitBootServicesEvent\r
+            );\r
+\r
+  if (EFI_ERROR(Status)) {\r
+    DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the ExitBootServicesEvent handler. Exit Status=%r\n", Status));\r
+    goto EXIT_ERROR_UNINSTALL_PROTOCOL;\r
+  }\r
+\r
+  // To get here, everything must be fine, so just exit\r
+  goto EXIT;\r
 \r
 EXIT_ERROR_UNINSTALL_PROTOCOL:\r
-       /* The following function could return an error message,\r
-        * however, to get here something must have gone wrong already,\r
-        * so preserve the original error, i.e. don't change\r
-        * the Status variable, even it fails to uninstall the protocol.\r
-        */\r
-       gBS->UninstallMultipleProtocolInterfaces (\r
-           Instance->Handle,\r
-           &gEfiGraphicsOutputProtocolGuid, &Instance->Gop, // Uninstall Graphics Output protocol\r
-           &gEfiDevicePathProtocolGuid,     &Instance->DevicePath,     // Uninstall device path\r
-           NULL\r
-           );\r
+  /* The following function could return an error message,\r
+   * however, to get here something must have gone wrong already,\r
+   * so preserve the original error, i.e. don't change\r
+   * the Status variable, even it fails to uninstall the protocol.\r
+   */\r
+  gBS->UninstallMultipleProtocolInterfaces (\r
+    Instance->Handle,\r
+    &gEfiGraphicsOutputProtocolGuid, &Instance->Gop, // Uninstall Graphics Output protocol\r
+    &gEfiDevicePathProtocolGuid,     &Instance->DevicePath,     // Uninstall device path\r
+    NULL\r
+    );\r
 \r
 EXIT:\r
-       return Status;\r
+  return Status;\r
 \r
 }\r
 \r
@@ -239,15 +244,15 @@ EFI_STATUS
 EFIAPI\r
 LcdGraphicsQueryMode (\r
   IN EFI_GRAPHICS_OUTPUT_PROTOCOL            *This,\r
-       IN UINT32                                  ModeNumber,\r
-       OUT UINTN                                  *SizeOfInfo,\r
-       OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION   **Info\r
-       )\r
+  IN UINT32                                  ModeNumber,\r
+  OUT UINTN                                  *SizeOfInfo,\r
+  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION   **Info\r
+  )\r
 {\r
-       EFI_STATUS Status = EFI_SUCCESS;\r
-       LCD_INSTANCE *Instance;\r
+  EFI_STATUS Status = EFI_SUCCESS;\r
+  LCD_INSTANCE *Instance;\r
 \r
-       Instance = LCD_INSTANCE_FROM_GOP_THIS(This);\r
+  Instance = LCD_INSTANCE_FROM_GOP_THIS(This);\r
 \r
   // Setup the hardware if not already done\r
   if( !mDisplayInitialized ) {\r
@@ -257,14 +262,14 @@ LcdGraphicsQueryMode (
     }\r
   }\r
 \r
-       // Error checking\r
-       if ( (This == NULL) || (Info == NULL) || (SizeOfInfo == NULL) || (ModeNumber >= This->Mode->MaxMode) ) {\r
-         DEBUG((DEBUG_ERROR, "LcdGraphicsQueryMode: ERROR - For mode number %d : Invalid Parameter.\n", ModeNumber ));\r
-               Status = EFI_INVALID_PARAMETER;\r
-               goto EXIT;\r
-       }\r
+  // Error checking\r
+  if ( (This == NULL) || (Info == NULL) || (SizeOfInfo == NULL) || (ModeNumber >= This->Mode->MaxMode) ) {\r
+    DEBUG((DEBUG_ERROR, "LcdGraphicsQueryMode: ERROR - For mode number %d : Invalid Parameter.\n", ModeNumber ));\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto EXIT;\r
+  }\r
 \r
-       *Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r
+  *Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r
   if (*Info == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto EXIT;\r
@@ -278,7 +283,7 @@ LcdGraphicsQueryMode (
   }\r
 \r
 EXIT:\r
-       return Status;\r
+  return Status;\r
 }\r
 \r
 /***************************************\r
@@ -289,15 +294,15 @@ EFI_STATUS
 EFIAPI\r
 LcdGraphicsSetMode (\r
   IN EFI_GRAPHICS_OUTPUT_PROTOCOL   *This,\r
-       IN UINT32                         ModeNumber\r
-       )\r
+  IN UINT32                         ModeNumber\r
+  )\r
 {\r
-       EFI_STATUS                      Status               = EFI_SUCCESS;\r
-       EFI_GRAPHICS_OUTPUT_BLT_PIXEL   FillColour;\r
-       LCD_INSTANCE*                   Instance;\r
-       LCD_BPP                         Bpp;\r
+  EFI_STATUS                      Status = EFI_SUCCESS;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL   FillColour;\r
+  LCD_INSTANCE*                   Instance;\r
+  LCD_BPP                         Bpp;\r
 \r
-       Instance = LCD_INSTANCE_FROM_GOP_THIS (This);\r
+  Instance = LCD_INSTANCE_FROM_GOP_THIS (This);\r
 \r
   // Setup the hardware if not already done\r
   if(!mDisplayInitialized) {\r
@@ -314,33 +319,33 @@ LcdGraphicsSetMode (
     goto EXIT;\r
   }\r
 \r
-       // Set the oscillator frequency to support the new mode\r
+  // Set the oscillator frequency to support the new mode\r
   Status = LcdPlatformSetMode (ModeNumber);\r
   if (EFI_ERROR(Status)) {\r
     Status = EFI_DEVICE_ERROR;\r
     goto EXIT;\r
   }\r
 \r
-       // Update the UEFI mode information\r
-       This->Mode->Mode = ModeNumber;\r
-       LcdPlatformQueryMode (ModeNumber,&Instance->ModeInfo);\r
-       Status = LcdPlatformGetBpp(ModeNumber, &Bpp);\r
-       if (EFI_ERROR(Status)) {\r
-         DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Couldn't get bytes per pixel, status: %r\n", Status));\r
-         goto EXIT;\r
-       }\r
-       This->Mode->FrameBufferSize =  Instance->ModeInfo.VerticalResolution\r
-                                    * Instance->ModeInfo.PixelsPerScanLine\r
-                                    * GetBytesPerPixel(Bpp);\r
+  // Update the UEFI mode information\r
+  This->Mode->Mode = ModeNumber;\r
+  LcdPlatformQueryMode (ModeNumber,&Instance->ModeInfo);\r
+  Status = LcdPlatformGetBpp(ModeNumber, &Bpp);\r
+  if (EFI_ERROR(Status)) {\r
+    DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Couldn't get bytes per pixel, status: %r\n", Status));\r
+    goto EXIT;\r
+  }\r
+  This->Mode->FrameBufferSize =  Instance->ModeInfo.VerticalResolution\r
+                               * Instance->ModeInfo.PixelsPerScanLine\r
+                               * GetBytesPerPixel(Bpp);\r
 \r
   // Set the hardware to the new mode\r
-       Status = LcdSetMode (ModeNumber);\r
+  Status = LcdSetMode (ModeNumber);\r
   if (EFI_ERROR(Status)) {\r
     Status = EFI_DEVICE_ERROR;\r
     goto EXIT;\r
   }\r
 \r
-       // The UEFI spec requires that we now clear the visible portions of the output display to black.\r
+  // The UEFI spec requires that we now clear the visible portions of the output display to black.\r
 \r
   // Set the fill colour to black\r
   SetMem (&FillColour, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
@@ -359,7 +364,7 @@ LcdGraphicsSetMode (
       0);\r
 \r
 EXIT:\r
-       return Status;\r
+  return Status;\r
 }\r
 \r
 UINTN\r