]> git.proxmox.com Git - mirror_edk2.git/blobdiff - DuetPkg/BiosVideoThunkDxe/BiosVideo.c
ArmPkg/CompilerIntrinsincsLib: Add div and mullu functions to ARMGCC
[mirror_edk2.git] / DuetPkg / BiosVideoThunkDxe / BiosVideo.c
index 1b471d9efc3942fb5be0834099041309ff81c917..da2c877d3553d10e4c33c3f78f86d404bfee264e 100644 (file)
@@ -2,8 +2,8 @@
 \r
   BiosVideo driver produce EFI_GRAPHIC_OUTPUT_PROTOCOL via LegacyBios Video rom.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -426,7 +426,7 @@ BiosVideoChildHandleInstall (
   Status = gBS->AllocatePool (\r
                   EfiBootServicesData,\r
                   sizeof (BIOS_VIDEO_DEV),\r
-                  &BiosVideoPrivate\r
+                  (VOID**) &BiosVideoPrivate\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     goto Done;\r
@@ -599,7 +599,7 @@ BiosVideoChildHandleUninstall (
   )\r
 {\r
   EFI_STATUS                   Status;\r
-  EFI_IA32_REGISTER_SET        Regs;\r
+  IA32_REGISTER_SET        Regs;\r
   EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
   EFI_VGA_MINI_PORT_PROTOCOL   *VgaMiniPort;\r
   BIOS_VIDEO_DEV               *BiosVideoPrivate;\r
@@ -854,7 +854,7 @@ ParseEdidData (
   //\r
   CheckSum = 0;\r
   for (Index = 0; Index < VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE; Index ++) {\r
-    CheckSum = CheckSum + EdidBuffer[Index];\r
+    CheckSum = (UINT8)(CheckSum + EdidBuffer[Index]);\r
   }\r
   if (CheckSum != 0) {\r
     return FALSE;\r
@@ -890,26 +890,26 @@ ParseEdidData (
         //\r
         // A valid Standard Timing\r
         //\r
-        HorizontalResolution = BufferIndex[0] * 8 + 248;\r
-        AspectRatio = BufferIndex[1] >> 6;\r
+        HorizontalResolution = (UINT8) (BufferIndex[0] * 8 + 248);\r
+        AspectRatio = (UINT8) (BufferIndex[1] >> 6);\r
         switch (AspectRatio) {\r
           case 0:\r
-            VerticalResolution = HorizontalResolution / 16 * 10;\r
+            VerticalResolution = (UINT8) (HorizontalResolution / 16 * 10);\r
             break;\r
           case 1:\r
-            VerticalResolution = HorizontalResolution / 4 * 3;\r
+            VerticalResolution = (UINT8) (HorizontalResolution / 4 * 3);\r
             break;\r
           case 2:\r
-            VerticalResolution = HorizontalResolution / 5 * 4;\r
+            VerticalResolution = (UINT8) (HorizontalResolution / 5 * 4);\r
             break;\r
           case 3:\r
-            VerticalResolution = HorizontalResolution / 16 * 9;\r
+            VerticalResolution = (UINT8) (HorizontalResolution / 16 * 9);\r
             break;\r
           default:\r
-            VerticalResolution = HorizontalResolution / 4 * 3;\r
+            VerticalResolution = (UINT8) (HorizontalResolution / 4 * 3);\r
             break;\r
         }\r
-        RefreshRate = (BufferIndex[1] & 0x1f) + 60;\r
+        RefreshRate = (UINT8) ((BufferIndex[1] & 0x1f) + 60);\r
         TempTiming.HorizontalResolution = HorizontalResolution;\r
         TempTiming.VerticalResolution = VerticalResolution;\r
         TempTiming.RefreshRate = RefreshRate;\r
@@ -1031,7 +1031,7 @@ BiosVideoCheckForVbe (
   )\r
 {\r
   EFI_STATUS                             Status;\r
-  EFI_IA32_REGISTER_SET                  Regs;\r
+  IA32_REGISTER_SET                  Regs;\r
   UINT16                                 *ModeNumberPtr;\r
   BOOLEAN                                ModeFound;\r
   BOOLEAN                                EdidFound;\r
@@ -1088,15 +1088,30 @@ BiosVideoCheckForVbe (
   //\r
   // Test to see if the Video Adapter is compliant with VBE 3.0\r
   //\r
+  // INT 10 - VESA SuperVGA BIOS (VBE) - GET SuperVGA INFORMATION\r
+  //\r
+  //  AX = 4F00h\r
+  //  ES:DI -> buffer for SuperVGA information (see #00077)\r
+  // Return: AL = 4Fh if function supported\r
+  //  AH = status\r
+  //      00h successful\r
+  //    ES:DI buffer filled\r
+  //      01h failed\r
+  //      ---VBE v2.0---\r
+  //      02h function not supported by current hardware configuration\r
+  //      03h function invalid in current video mode\r
+  // Desc:  determine whether VESA BIOS extensions are present and the capabilities\r
+  //    supported by the display adapter\r
+  //\r
   gBS->SetMem (&Regs, sizeof (Regs), 0);\r
   Regs.X.AX = VESA_BIOS_EXTENSIONS_RETURN_CONTROLLER_INFORMATION;\r
   gBS->SetMem (BiosVideoPrivate->VbeInformationBlock, sizeof (VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK), 0);\r
   BiosVideoPrivate->VbeInformationBlock->VESASignature  = VESA_BIOS_EXTENSIONS_VBE2_SIGNATURE;\r
-  Regs.X.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeInformationBlock);\r
+  Regs.E.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeInformationBlock);\r
   Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeInformationBlock);\r
 \r
   LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
-  \r
+    \r
   Status = EFI_DEVICE_ERROR;\r
 \r
   //\r
@@ -1121,12 +1136,25 @@ BiosVideoCheckForVbe (
   //\r
   // Read EDID information\r
   //\r
+  // INT 10 - VESA VBE/DC (Display Data Channel) - READ EDID\r
+  //\r
+  //    AX = 4F15h\r
+  //    BL = 01h\r
+  //    CX = 0000h\r
+  //    DX = 0000h\r
+  //    ES:DI -> 128-byte buffer for EDID record (see #00127)\r
+  // Return: AL = 4Fh if function supported\r
+  //    AH = status\r
+  //        00h successful\r
+  //    ES:DI buffer filled\r
+  //    01h failed (e.g. non-DDC monitor)\r
+  //\r
   gBS->SetMem (&Regs, sizeof (Regs), 0);\r
   Regs.X.AX = VESA_BIOS_EXTENSIONS_EDID;\r
   Regs.X.BX = 1;\r
   Regs.X.CX = 0;\r
   Regs.X.DX = 0;\r
-  Regs.X.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeEdidDataBlock);\r
+  Regs.E.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeEdidDataBlock);\r
   Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeEdidDataBlock);\r
 \r
   LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
@@ -1146,7 +1174,7 @@ BiosVideoCheckForVbe (
       Status = gBS->AllocatePool (\r
                       EfiBootServicesData,\r
                       VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE,\r
-                      &BiosVideoPrivate->EdidDiscovered.Edid\r
+                      (VOID**) &BiosVideoPrivate->EdidDiscovered.Edid\r
                       );\r
       if (EFI_ERROR (Status)) {\r
         goto Done;\r
@@ -1161,7 +1189,7 @@ BiosVideoCheckForVbe (
       Status = gBS->AllocatePool (\r
                       EfiBootServicesData,\r
                       VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE,\r
-                      &BiosVideoPrivate->EdidActive.Edid\r
+                      (VOID**)&BiosVideoPrivate->EdidActive.Edid\r
                       );\r
       if (EFI_ERROR (Status)) {\r
         goto Done;\r
@@ -1202,11 +1230,23 @@ BiosVideoCheckForVbe (
     //\r
     // Get the information about the mode\r
     //\r
+    // INT 10 - VESA SuperVGA BIOS - GET SuperVGA MODE INFORMATION\r
+    //\r
+    //   AX = 4F01h\r
+    //   CX = SuperVGA video mode (see #04082 for bitfields)\r
+    //   ES:DI -> 256-byte buffer for mode information (see #00079)\r
+    // Return: AL = 4Fh if function supported\r
+    //   AH = status\r
+    //      00h successful\r
+    //    ES:DI buffer filled\r
+    //      01h failed\r
+    // Desc:  determine the attributes of the specified video mode\r
+    //\r
     gBS->SetMem (&Regs, sizeof (Regs), 0);\r
     Regs.X.AX = VESA_BIOS_EXTENSIONS_RETURN_MODE_INFORMATION;\r
     Regs.X.CX = *ModeNumberPtr;\r
     gBS->SetMem (BiosVideoPrivate->VbeModeInformationBlock, sizeof (VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK), 0);\r
-    Regs.X.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeModeInformationBlock);\r
+    Regs.E.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeModeInformationBlock);\r
     Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeModeInformationBlock);\r
 \r
     LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
@@ -1580,7 +1620,7 @@ BiosVideoGraphicsOutputQueryMode (
   Status = gBS->AllocatePool (\r
                   EfiBootServicesData,\r
                   sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),\r
-                  Info\r
+                  (VOID**) Info\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -1622,7 +1662,7 @@ BiosVideoGraphicsOutputSetMode (
 {\r
   EFI_STATUS              Status;\r
   BIOS_VIDEO_DEV          *BiosVideoPrivate;\r
-  EFI_IA32_REGISTER_SET   Regs;\r
+  IA32_REGISTER_SET   Regs;\r
   BIOS_VIDEO_MODE_DATA    *ModeData;\r
 \r
   BiosVideoPrivate = BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);\r
@@ -1635,10 +1675,6 @@ BiosVideoGraphicsOutputSetMode (
     return EFI_UNSUPPORTED;\r
   }\r
 \r
-  if (ModeNumber == This->Mode->Mode) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
   ModeData = &BiosVideoPrivate->ModeData[ModeNumber];\r
 \r
   if (BiosVideoPrivate->LineBuffer) {\r
@@ -1657,7 +1693,7 @@ BiosVideoGraphicsOutputSetMode (
   Status = gBS->AllocatePool (\r
                   EfiBootServicesData,\r
                   ModeData->BytesPerScanLine,\r
-                  &BiosVideoPrivate->LineBuffer\r
+                  (VOID**) &BiosVideoPrivate->LineBuffer\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -1675,7 +1711,7 @@ BiosVideoGraphicsOutputSetMode (
     Status = gBS->AllocatePool (\r
                     EfiBootServicesData,\r
                     4 * 480 * 80,\r
-                    &BiosVideoPrivate->VgaFrameBuffer\r
+                    (VOID**) &BiosVideoPrivate->VgaFrameBuffer\r
                     );\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
@@ -1694,7 +1730,7 @@ BiosVideoGraphicsOutputSetMode (
     Status = gBS->AllocatePool (\r
                     EfiBootServicesData,\r
                     ModeData->BytesPerScanLine * ModeData->VerticalResolution,\r
-                    &BiosVideoPrivate->VbeFrameBuffer\r
+                    (VOID**) &BiosVideoPrivate->VbeFrameBuffer\r
                     );\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
@@ -1705,8 +1741,9 @@ BiosVideoGraphicsOutputSetMode (
     Regs.X.AX = VESA_BIOS_EXTENSIONS_SET_MODE;\r
     Regs.X.BX = (UINT16) (ModeData->VbeModeNumber | VESA_BIOS_EXTENSIONS_MODE_NUMBER_LINEAR_FRAME_BUFFER);\r
     gBS->SetMem (BiosVideoPrivate->VbeCrtcInformationBlock, sizeof (VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK), 0);\r
-    Regs.X.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeCrtcInformationBlock);\r
+    Regs.E.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeCrtcInformationBlock);\r
     Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeCrtcInformationBlock);\r
+    \r
     LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);\r
     \r
     //\r
@@ -1743,7 +1780,7 @@ BiosVideoGraphicsOutputSetMode (
   //\r
   // Frame BufferSize remain unchanged\r
   //\r
-  This->Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) ModeData->LinearFrameBuffer;\r
+  This->Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS)(UINTN)ModeData->LinearFrameBuffer;\r
   This->Mode->FrameBufferSize = ModeData->FrameBufferSize;\r
 \r
   BiosVideoPrivate->HardwareNeedsStarting = FALSE;\r
@@ -2120,6 +2157,8 @@ BiosVideoGraphicsOutputVbeBlt (
         );\r
     }\r
     break;\r
+  default:\r
+    break;\r
   }\r
 \r
   gBS->RestoreTPL (OriginalTPL);\r
@@ -2216,8 +2255,8 @@ VgaReadBitPlanes (
       PciIo->Mem.Read (\r
                   PciIo,\r
                   EfiPciIoWidthUint8,\r
-                  EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                  (UINT64) Source,\r
+                  (UINT8) EFI_PCI_IO_PASS_THROUGH_BAR,\r
+                  (UINT64)(UINTN) Source,\r
                   WidthInBytes,\r
                   (VOID *) Destination\r
                   );\r
@@ -2326,7 +2365,7 @@ BiosVideoGraphicsOutputVgaBlt (
   EFI_TPL             OriginalTPL;\r
   UINT8               *MemAddress;\r
   UINTN               BytesPerScanLine;\r
-  UINTN               BytesPerBitPlane;\r
+  //UINTN               BytesPerBitPlane;\r
   UINTN               Bit;\r
   UINTN               Index;\r
   UINTN               Index1;\r
@@ -2358,7 +2397,7 @@ BiosVideoGraphicsOutputVgaBlt (
   PciIo             = BiosVideoPrivate->PciIo;\r
   MemAddress        = BiosVideoPrivate->ModeData[CurrentMode].LinearFrameBuffer;\r
   BytesPerScanLine  = BiosVideoPrivate->ModeData[CurrentMode].BytesPerScanLine >> 3;\r
-  BytesPerBitPlane  = BytesPerScanLine * BiosVideoPrivate->ModeData[CurrentMode].VerticalResolution;\r
+  //BytesPerBitPlane  = BytesPerScanLine * BiosVideoPrivate->ModeData[CurrentMode].VerticalResolution;\r
   VgaFrameBuffer    = BiosVideoPrivate->VgaFrameBuffer;\r
 \r
   if (This == NULL || ((UINTN) BltOperation) >= EfiGraphicsOutputBltOperationMax) {\r
@@ -2467,9 +2506,9 @@ BiosVideoGraphicsOutputVgaBlt (
                 PciIo,\r
                 EfiPciIoWidthUint8,\r
                 EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                (UINT64) (DestinationAddress + Offset),\r
+                (UINT64) ((UINTN)DestinationAddress + Offset),\r
                 EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                (UINT64) (SourceAddress + Offset),\r
+                (UINT64) ((UINTN)SourceAddress + Offset),\r
                 Bytes\r
                 );\r
       }\r
@@ -2497,7 +2536,7 @@ BiosVideoGraphicsOutputVgaBlt (
     LeftMask      = mVgaLeftMaskTable[DestinationX & 0x07];\r
     RightMask     = mVgaRightMaskTable[(DestinationX + Width - 1) & 0x07];\r
     if (Bytes == 0) {\r
-      LeftMask &= RightMask;\r
+      LeftMask = (UINT8) (LeftMask & RightMask);\r
       RightMask = 0;\r
     }\r
 \r
@@ -2673,7 +2712,7 @@ BiosVideoGraphicsOutputVgaBlt (
                       PciIo,\r
                       EfiPciIoWidthUint8,\r
                       EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                      (UINT64) Address1,\r
+                      (UINT64)(UINTN) Address1,\r
                       1,\r
                       &Data\r
                       );\r
@@ -2682,7 +2721,7 @@ BiosVideoGraphicsOutputVgaBlt (
                       PciIo,\r
                       EfiPciIoWidthUint8,\r
                       EFI_PCI_IO_PASS_THROUGH_BAR,\r
-                      (UINT64) Address1,\r
+                      (UINT64)(UINTN) Address1,\r
                       1,\r
                       &BiosVideoPrivate->LineBuffer[Index1]\r
                       );\r
@@ -2696,6 +2735,8 @@ BiosVideoGraphicsOutputVgaBlt (
       }\r
     }\r
 \r
+    break;\r
+  default:\r
     break;\r
   }\r
 \r
@@ -2724,7 +2765,7 @@ BiosVideoVgaMiniPortSetMode (
   )\r
 {\r
   BIOS_VIDEO_DEV        *BiosVideoPrivate;\r
-  EFI_IA32_REGISTER_SET Regs;\r
+  IA32_REGISTER_SET Regs;\r
 \r
   if (This == NULL) {\r
     return EFI_INVALID_PARAMETER;\r