]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OptionRomPkg/Application/BltLibSample/BltLibSample.c
edk2: Remove packages moved to edk2-platforms
[mirror_edk2.git] / OptionRomPkg / Application / BltLibSample / BltLibSample.c
diff --git a/OptionRomPkg/Application/BltLibSample/BltLibSample.c b/OptionRomPkg/Application/BltLibSample/BltLibSample.c
deleted file mode 100644 (file)
index 6f90138..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-/** @file\r
-  Example program using BltLib\r
-\r
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include <Uefi.h>\r
-#include <Library/BltLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiApplicationEntryPoint.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-\r
-UINT64\r
-ReadTimestamp (\r
-  VOID\r
-  )\r
-{\r
-#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
-  return AsmReadTsc ();\r
-#else\r
-#error ReadTimestamp not supported for this architecture!\r
-#endif\r
-}\r
-\r
-UINT32\r
-Rand32 (\r
-  VOID\r
-  )\r
-{\r
-  UINTN    Found;\r
-  INTN     Bits;\r
-  UINT64   Tsc1;\r
-  UINT64   Tsc2;\r
-  UINT64   TscBits;\r
-  UINT32   R32;\r
-\r
-  R32 = 0;\r
-  Found = 0;\r
-  Tsc1 = ReadTimestamp ();\r
-  Tsc2 = ReadTimestamp ();\r
-  do {\r
-    Tsc2 = ReadTimestamp ();\r
-    TscBits = Tsc2 ^ Tsc1;\r
-    Bits = HighBitSet64 (TscBits);\r
-    if (Bits > 0) {\r
-      Bits = Bits - 1;\r
-    }\r
-    R32 = (UINT32)((R32 << Bits) |\r
-                   RShiftU64 (LShiftU64 (TscBits, (UINTN) (64 - Bits)), (UINTN) (64 - Bits)));\r
-    Found = Found + Bits;\r
-  } while (Found < 32);\r
-\r
-  return R32;\r
-}\r
-\r
-\r
-VOID\r
-TestFills (\r
-  VOID\r
-  )\r
-{\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Color;\r
-  UINTN                          Loop;\r
-  UINTN                          X;\r
-  UINTN                          Y;\r
-  UINTN                          W;\r
-  UINTN                          H;\r
-  UINTN                          Width;\r
-  UINTN                          Height;\r
-\r
-  BltLibGetSizes (&Width, &Height);\r
-  for (Loop = 0; Loop < 10000; Loop++) {\r
-    W = Width - (Rand32 () % Width);\r
-    H = Height - (Rand32 () % Height);\r
-    if (W != Width) {\r
-      X = Rand32 () % (Width - W);\r
-    } else {\r
-      X = 0;\r
-    }\r
-    if (H != Height) {\r
-      Y = Rand32 () % (Height - H);\r
-    } else {\r
-      Y = 0;\r
-    }\r
-    *(UINT32*) (&Color) = Rand32 () & 0xffffff;\r
-    BltLibVideoFill (&Color, X, Y, W, H);\r
-  }\r
-}\r
-\r
-\r
-VOID\r
-TestColor1 (\r
-  VOID\r
-  )\r
-{\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Color;\r
-  UINTN                          X;\r
-  UINTN                          Y;\r
-  UINTN                          Width;\r
-  UINTN                          Height;\r
-\r
-  BltLibGetSizes (&Width, &Height);\r
-  *(UINT32*) (&Color) = 0;\r
-\r
-  for (Y = 0; Y < Height; Y++) {\r
-    for (X = 0; X < Width; X++) {\r
-      Color.Red =   (UINT8) ((X * 0x100) / Width);\r
-      Color.Green = (UINT8) ((Y * 0x100) / Height);\r
-      Color.Blue =  (UINT8) ((Y * 0x100) / Height);\r
-      BltLibVideoFill (&Color, X, Y, 1, 1);\r
-    }\r
-  }\r
-}\r
-\r
-\r
-UINT32\r
-Uint32SqRt (\r
-  IN  UINT32  Uint32\r
-  )\r
-{\r
-  UINT32 Mask;\r
-  UINT32 SqRt;\r
-  UINT32 SqRtMask;\r
-  UINT32 Squared;\r
-\r
-  if (Uint32 == 0) {\r
-    return 0;\r
-  }\r
-\r
-  for (SqRt = 0, Mask = (UINT32) (1 << (HighBitSet32 (Uint32) / 2));\r
-       Mask != 0;\r
-       Mask = Mask >> 1\r
-      ) {\r
-    SqRtMask = SqRt | Mask;\r
-    //DEBUG ((EFI_D_INFO, "Uint32=0x%x SqRtMask=0x%x\n", Uint32, SqRtMask));\r
-    Squared = (UINT32) (SqRtMask * SqRtMask);\r
-    if (Squared > Uint32) {\r
-      continue;\r
-    } else if (Squared < Uint32) {\r
-      SqRt = SqRtMask;\r
-    } else {\r
-      return SqRtMask;\r
-    }\r
-  }\r
-\r
-  return SqRt;\r
-}\r
-\r
-\r
-UINT32\r
-Uint32Dist (\r
-  IN UINTN X,\r
-  IN UINTN Y\r
-  )\r
-{\r
-  return Uint32SqRt ((UINT32) ((X * X) + (Y * Y)));\r
-}\r
-\r
-UINT8\r
-GetTriColor (\r
-  IN UINTN ColorDist,\r
-  IN UINTN TriWidth\r
-  )\r
-{\r
-  return (UINT8) (((TriWidth - ColorDist) * 0x100) / TriWidth);\r
-  //return (((TriWidth * TriWidth - ColorDist * ColorDist) * 0x100) / (TriWidth * TriWidth));\r
-}\r
-\r
-VOID\r
-TestColor (\r
-  VOID\r
-  )\r
-{\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Color;\r
-  UINTN                          X, Y;\r
-  UINTN                          X1, X2, X3;\r
-  UINTN                          Y1, Y2;\r
-  UINTN                          LineWidth, TriWidth, ScreenWidth;\r
-  UINTN                          TriHeight, ScreenHeight;\r
-  UINT32                         ColorDist;\r
-\r
-  BltLibGetSizes (&ScreenWidth, &ScreenHeight);\r
-  *(UINT32*) (&Color) = 0;\r
-  BltLibVideoFill (&Color, 0, 0, ScreenWidth, ScreenHeight);\r
-\r
-  TriWidth = (UINTN) DivU64x32 (\r
-                       MultU64x32 (11547005, (UINT32) ScreenHeight),\r
-                       10000000\r
-                       );\r
-  TriHeight = (UINTN) DivU64x32 (\r
-                        MultU64x32 (8660254, (UINT32) ScreenWidth),\r
-                        10000000\r
-                        );\r
-  if (TriWidth > ScreenWidth) {\r
-    DEBUG ((EFI_D_INFO, "TriWidth at %d was too big\n", TriWidth));\r
-    TriWidth = ScreenWidth;\r
-  } else if (TriHeight > ScreenHeight) {\r
-    DEBUG ((EFI_D_INFO, "TriHeight at %d was too big\n", TriHeight));\r
-    TriHeight = ScreenHeight;\r
-  }\r
-\r
-  DEBUG ((EFI_D_INFO, "Triangle Width: %d; Height: %d\n", TriWidth, TriHeight));\r
-\r
-  X1 = (ScreenWidth - TriWidth) / 2;\r
-  X3 = X1 + TriWidth - 1;\r
-  X2 = (X1 + X3) / 2;\r
-  Y2 = (ScreenHeight - TriHeight) / 2;\r
-  Y1 = Y2 + TriHeight - 1;\r
-\r
-  for (Y = Y2; Y <= Y1; Y++) {\r
-    LineWidth =\r
-      (UINTN) DivU64x32 (\r
-                MultU64x32 (11547005, (UINT32) (Y - Y2)),\r
-                20000000\r
-                );\r
-    for (X = X2 - LineWidth; X < (X2 + LineWidth); X++) {\r
-      ColorDist = Uint32Dist(X - X1, Y1 - Y);\r
-      Color.Red = GetTriColor (ColorDist, TriWidth);\r
-\r
-      ColorDist = Uint32Dist((X < X2) ? X2 - X : X - X2, Y - Y2);\r
-      Color.Green = GetTriColor (ColorDist, TriWidth);\r
-\r
-      ColorDist = Uint32Dist(X3 - X, Y1 - Y);\r
-      Color.Blue = GetTriColor (ColorDist, TriWidth);\r
-\r
-      BltLibVideoFill (&Color, X, Y, 1, 1);\r
-    }\r
-  }\r
-}\r
-\r
-\r
-/**\r
-  The user Entry Point for Application. The user code starts with this function\r
-  as the real entry point for the application.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UefiMain (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS                     Status;\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL   *Gop;\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  gST->ConsoleOutHandle,\r
-                  &gEfiGraphicsOutputProtocolGuid,\r
-                  (VOID **) &Gop\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = BltLibConfigure (\r
-             (VOID*)(UINTN) Gop->Mode->FrameBufferBase,\r
-             Gop->Mode->Info\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  TestFills ();\r
-\r
-  TestColor ();\r
-\r
-  return EFI_SUCCESS;\r
-}\r