public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH edk2-platforms v2 00/18] ARM: Update GOP
@ 2017-12-22 19:08 evan.lloyd
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 01/18] ARM/VExpressPkg: Fix MODULE_TYPE of HDLCD/PL111 platform libraries evan.lloyd
                   ` (18 more replies)
  0 siblings, 19 replies; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: EvanLloyd <evan.lloyd@arm.com>

This patch series addresses comments on the original
(https://lists.01.org/pipermail/edk2-devel/2017-September/015356.html)
reworking of the Graphics Output Protocol code in Platform/ARM.
It also contains updates for the new SCMI protocol (MTL Library).

After a number of format and quality modifications, several errors
are corrected and new functionality added for Mali DP.

The changes are tested on Juno, and FVP.

Code is available for examination at:
  https://github.com/EvanLloyd/edk2-platforms/tree/166_gop_v2

Ard Biesheuvel (1):
  ARM/VExpressPkg: Fix MODULE_TYPE of HDLCD/PL111 platform libraries

EvanLloyd (1):
  ARM/VExpressPkg: HdLcdArmVExpressLib: Remove redundant Bpp

Girish Pathak (16):
  ARM/VExpressPkg: Tidy HDLCD and PL11LCD platform Lib: Coding standard
  ARM/VExpressPkg: Tidy HdLcd/PL111Lcd code: Updated comments
  ARM/VExpressPkg: Remove unused PcdPL111LcdMaxMode from HDLCD inf
  ARM/VExpressPkg: PL111 and HDLCD: add const qualifier
  ARM/VExpressPkg: Add and update debug ASSERTS
  ARM/VExpressPkg: PL111LcdArmVExpressLib: Minor code cleanup
  ARM/VExpressPkg: PL111 and HDLCD: Use FixedPcdGet32
  ARM/VExpressPkg: PL11LcdArmVExpressLib: Improvement conditional
  ARM/VExpressPkg: HdLcdArmVExpressLib: Remove status check EFI_TIMEOUT
  ARM/VExpressPkg: Redefine LcdPlatformGetTimings function
  ARM/VExpressPkg: PL111 and HDLCD: Add PCD to select pixel format
  ARM/VExpressPkg: Reserving framebuffer at build
  ARM/VExpressPkg: New DP500/DP550/DP650 platform library.
  ARM/JunoPkg: Mapping Non-Trused SRAM as device memory
  ARM/JunoPkg: Adding SCMI MTL library
  ARM/JunoPkg: Add HDLCD platform library

 Platform/ARM/JunoPkg/ArmJuno.dec                                                   |  17 +-
 Platform/ARM/VExpressPkg/ArmVExpressPkg.dec                                        |   3 +-
 Platform/ARM/JunoPkg/ArmJuno.dsc                                                   |  32 ++
 Platform/ARM/JunoPkg/ArmJuno.fdf                                                   |  12 +-
 Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf                             |   5 +-
 Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf                                     |  39 ++
 Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf                   |  40 ++
 Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf                     |  45 ++
 Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf             |   7 +-
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf       |  13 +-
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf |   9 +-
 Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h                                |  94 ++++
 Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c                               |  24 +-
 Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c                                       | 195 +++++++
 Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c                        | 559 ++++++++++++++++++++
 Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c                       | 374 +++++++++++++
 Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c                      |  28 +-
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c            | 309 +++++++----
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c      | 425 +++++++++------
 19 files changed, 1920 insertions(+), 310 deletions(-)
 create mode 100644 Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
 create mode 100644 Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
 create mode 100644 Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
 create mode 100644 Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h
 create mode 100644 Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c
 create mode 100644 Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
 create mode 100644 Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c

-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 01/18] ARM/VExpressPkg: Fix MODULE_TYPE of HDLCD/PL111 platform libraries
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 02/18] ARM/VExpressPkg: Tidy HDLCD and PL11LCD platform Lib: Coding standard evan.lloyd
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

This change fixes incorrect MODULE_TYPE of HDLCD and PL111
LcdPlatformLibs. Currently set MODUL_TYPE DXE_DRIVER is incorrect
for these platform libraries. Hence set this to type BASE.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
---
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf       | 4 ++--
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
index fc51c781b45122eaf4f2269af61b44c8630cdfb8..18d210ce718db45e018681cd1ccdad48f4adc7f3 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
@@ -2,7 +2,7 @@
 #
 #  Component description file for HdLcdArmLib module
 #
-#  Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+#  Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -18,7 +18,7 @@ [Defines]
   INF_VERSION                    = 0x00010005
   BASE_NAME                      = HdLcdArmVExpress
   FILE_GUID                      = 535a720e-06c0-4bb9-b563-452216abbed4
-  MODULE_TYPE                    = DXE_DRIVER
+  MODULE_TYPE                    = BASE
   VERSION_STRING                 = 1.0
   LIBRARY_CLASS                  = LcdPlatformLib
 
diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
index fd83d2412d4fd2dfa59204f21626c62e377e3c55..335c84841a4ff4b57c0d495bc48e93579b5ce576 100644
--- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
+++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
@@ -2,7 +2,7 @@
 #
 #  Component description file for ArmVeGraphicsDxe module
 #
-#  Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+#  Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -18,7 +18,7 @@ [Defines]
   INF_VERSION                    = 0x00010005
   BASE_NAME                      = PL111LcdArmVExpressLib
   FILE_GUID                      = b7f06f20-496f-11e0-a8e8-0002a5d5c51b
-  MODULE_TYPE                    = DXE_DRIVER
+  MODULE_TYPE                    = BASE
   VERSION_STRING                 = 1.0
   LIBRARY_CLASS                  = LcdPlatformLib
 
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 02/18] ARM/VExpressPkg: Tidy HDLCD and PL11LCD platform Lib: Coding standard
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 01/18] ARM/VExpressPkg: Fix MODULE_TYPE of HDLCD/PL111 platform libraries evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 14:07   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 03/18] ARM/VExpressPkg: Tidy HdLcd/PL111Lcd code: Updated comments evan.lloyd
                   ` (16 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak at arm.com>

There is no functional modification in this change
As preparation for further work, the formatting is corrected to meet
the EDKII coding standard.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf  |   5 +-
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c       | 136 ++++++-----
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 238 +++++++++++---------
 3 files changed, 218 insertions(+), 161 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
index 18d210ce718db45e018681cd1ccdad48f4adc7f3..d44aa7776a4ac60d60f3b4386e67c53423287383 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
@@ -1,6 +1,6 @@
 #/** @file
 #
-#  Component description file for HdLcdArmLib module
+#  Component description file for HdLcdArmVExpress module
 #
 #  Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
 #
@@ -23,8 +23,7 @@ [Defines]
   LIBRARY_CLASS                  = LcdPlatformLib
 
 [Sources.common]
-
-HdLcdArmVExpress.c
+  HdLcdArmVExpress.c
 
 [Packages]
   ArmPlatformPkg/ArmPlatformPkg.dec
diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index b1106ee19b98cebac01820924514eac79b97d0d5..851ba83b79f0fea7019269c30e7add58f5ff9cb2 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -1,6 +1,6 @@
-/**
+/** @file
 
-  Copyright (c) 2012, ARM Ltd. All rights reserved.
+  Copyright (c) 2012-2017, ARM Ltd. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
@@ -44,35 +44,40 @@ typedef struct {
   UINT32                     VFrontPorch;
 } LCD_RESOLUTION;
 
-
 LCD_RESOLUTION mResolutions[] = {
   { // Mode 0 : VGA : 640 x 480 x 24 bpp
-    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, VGA_OSC_FREQUENCY,
+    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    VGA_OSC_FREQUENCY,
     VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
     VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
   },
   { // Mode 1 : SVGA : 800 x 600 x 24 bpp
-    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, SVGA_OSC_FREQUENCY,
+    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    SVGA_OSC_FREQUENCY,
     SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
     SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
   },
   { // Mode 2 : XGA : 1024 x 768 x 24 bpp
-    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, XGA_OSC_FREQUENCY,
+    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    XGA_OSC_FREQUENCY,
     XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
     XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
   },
   { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
-    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (SXGA_OSC_FREQUENCY/2),
+    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    (SXGA_OSC_FREQUENCY/2),
     SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
     SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
   },
   { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
-    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (UXGA_OSC_FREQUENCY/2),
+    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    (UXGA_OSC_FREQUENCY/2),
     UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
     UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
   },
   { // Mode 5 : HD : 1920 x 1080 x 24 bpp
-    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (HD_OSC_FREQUENCY/2),
+    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    (HD_OSC_FREQUENCY/2),
     HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
     HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
   }
@@ -95,19 +100,25 @@ LcdPlatformInitializeDisplay (
 {
   EFI_STATUS  Status;
 
-  // Set the FPGA multiplexer to select the video output from the motherboard or the daughterboard
-  Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, ARM_VE_DAUGHTERBOARD_1_SITE);
-  if (EFI_ERROR(Status)) {
+  // Set the FPGA multiplexer to select the video output from the
+  // motherboard or the daughterboard
+  Status = ArmPlatformSysConfigSet (
+             SYS_CFG_MUXFPGA,
+             ARM_VE_DAUGHTERBOARD_1_SITE
+             );
+  if (EFI_ERROR (Status)) {
     return Status;
   }
 
   // Install the EDID Protocols
   Status = gBS->InstallMultipleProtocolInterfaces (
-    &Handle,
-    &gEfiEdidDiscoveredProtocolGuid,  &mEdidDiscovered,
-    &gEfiEdidActiveProtocolGuid,      &mEdidActive,
-    NULL
-  );
+                  &Handle,
+                  &gEfiEdidDiscoveredProtocolGuid,
+                  &mEdidDiscovered,
+                  &gEfiEdidActiveProtocolGuid,
+                  &mEdidActive,
+                  NULL
+                  );
 
   return Status;
 }
@@ -132,16 +143,25 @@ LcdPlatformGetVram (
   } else {
     AllocationType = AllocateAddress;
   }
-  Status = gBS->AllocatePages (AllocationType, EfiBootServicesData, EFI_SIZE_TO_PAGES(((UINTN)LCD_VRAM_SIZE)), VramBaseAddress);
-  if (EFI_ERROR(Status)) {
+  Status = gBS->AllocatePages (
+                  AllocationType,
+                  EfiBootServicesData,
+                  EFI_SIZE_TO_PAGES (((UINTN)LCD_VRAM_SIZE)),
+                  VramBaseAddress
+                  );
+  if (EFI_ERROR (Status)) {
     return Status;
   }
 
-  // Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is cacheable.
-  Status = gDS->SetMemorySpaceAttributes (*VramBaseAddress, *VramSize,
-                  EFI_MEMORY_WC);
-  ASSERT_EFI_ERROR(Status);
-  if (EFI_ERROR(Status)) {
+  // Mark the VRAM as write-combining.
+  // The VRAM is inside the DRAM, which is cacheable.
+  Status = gDS->SetMemorySpaceAttributes (
+                  *VramBaseAddress,
+                  *VramSize,
+                  EFI_MEMORY_WC
+                  );
+  ASSERT_EFI_ERROR (Status);
+  if (EFI_ERROR (Status)) {
     gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
     return Status;
   }
@@ -150,15 +170,11 @@ LcdPlatformGetVram (
 }
 
 UINT32
-LcdPlatformGetMaxMode (
-  VOID
-  )
+LcdPlatformGetMaxMode (VOID)
 {
-  //
   // The following line will report correctly the total number of graphics modes
-  // that could be supported by the graphics driver:
-  //
-  return (sizeof(mResolutions) / sizeof(LCD_RESOLUTION));
+  // that could be supported by the graphics driver
+  return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION));
 }
 
 EFI_STATUS
@@ -174,25 +190,35 @@ LcdPlatformSetMode (
 
   // Set the video mode oscillator
   do {
-    Status = ArmPlatformSysConfigSetDevice (SYS_CFG_OSC_SITE1, PcdGet32(PcdHdLcdVideoModeOscId), mResolutions[ModeNumber].OscFreq);
+    Status = ArmPlatformSysConfigSetDevice (
+               SYS_CFG_OSC_SITE1,
+               PcdGet32 (PcdHdLcdVideoModeOscId),
+               mResolutions[ModeNumber].OscFreq
+               );
   } while (Status == EFI_TIMEOUT);
-  if (EFI_ERROR(Status)) {
+  if (EFI_ERROR (Status)) {
     ASSERT_EFI_ERROR (Status);
     return Status;
   }
 
   // Set the DVI into the new mode
   do {
-    Status = ArmPlatformSysConfigSet (SYS_CFG_DVIMODE, mResolutions[ModeNumber].Mode);
+    Status = ArmPlatformSysConfigSet (
+               SYS_CFG_DVIMODE,
+               mResolutions[ModeNumber].Mode
+               );
   } while (Status == EFI_TIMEOUT);
-  if (EFI_ERROR(Status)) {
+  if (EFI_ERROR (Status)) {
     ASSERT_EFI_ERROR (Status);
     return Status;
   }
 
   // Set the multiplexer
-  Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, ARM_VE_DAUGHTERBOARD_1_SITE);
-  if (EFI_ERROR(Status)) {
+  Status = ArmPlatformSysConfigSet (
+             SYS_CFG_MUXFPGA,
+             ARM_VE_DAUGHTERBOARD_1_SITE
+             );
+  if (EFI_ERROR (Status)) {
     ASSERT_EFI_ERROR (Status);
     return Status;
   }
@@ -216,25 +242,25 @@ LcdPlatformQueryMode (
   Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
 
   switch (mResolutions[ModeNumber].Bpp) {
-    case LCD_BITS_PER_PIXEL_24:
-      Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
-      Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
-      Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
-      Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
-      Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
-      break;
+  case LCD_BITS_PER_PIXEL_24:
+    Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
+    Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
+    Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
+    Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
+    Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
+    break;
 
-    case LCD_BITS_PER_PIXEL_16_555:
-    case LCD_BITS_PER_PIXEL_16_565:
-    case LCD_BITS_PER_PIXEL_12_444:
-    case LCD_BITS_PER_PIXEL_8:
-    case LCD_BITS_PER_PIXEL_4:
-    case LCD_BITS_PER_PIXEL_2:
-    case LCD_BITS_PER_PIXEL_1:
-    default:
-      // These are not supported
-      ASSERT(FALSE);
-      break;
+  case LCD_BITS_PER_PIXEL_16_555:
+  case LCD_BITS_PER_PIXEL_16_565:
+  case LCD_BITS_PER_PIXEL_12_444:
+  case LCD_BITS_PER_PIXEL_8:
+  case LCD_BITS_PER_PIXEL_4:
+  case LCD_BITS_PER_PIXEL_2:
+  case LCD_BITS_PER_PIXEL_1:
+  default:
+    // These are not supported
+    ASSERT (FALSE);
+    break;
   }
 
   return EFI_SUCCESS;
diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 3f3ceb3d2fa82f614e0c6dac8455c117745cf3a6..2586a6d8c2076c9aff15f50d652e462d783f13dc 100644
--- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2011-2015, ARM Ltd. All rights reserved.<BR>
+  Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
@@ -41,87 +41,102 @@ typedef struct {
   UINT32                     VFrontPorch;
 } LCD_RESOLUTION;
 
-
 LCD_RESOLUTION mResolutions[] = {
   { // Mode 0 : VGA : 640 x 480 x 24 bpp
-      VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, VGA_OSC_FREQUENCY,
-      VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
-      VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    VGA_OSC_FREQUENCY,
+    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
+    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
   },
   { // Mode 1 : SVGA : 800 x 600 x 24 bpp
-      SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, SVGA_OSC_FREQUENCY,
-      SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
-      SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    SVGA_OSC_FREQUENCY,
+    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
+    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
   },
   { // Mode 2 : XGA : 1024 x 768 x 24 bpp
-      XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, XGA_OSC_FREQUENCY,
-      XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
-      XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    XGA_OSC_FREQUENCY,
+    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
+    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
   },
   { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
-      SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (SXGA_OSC_FREQUENCY/2),
-      SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
-      SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
+    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    (SXGA_OSC_FREQUENCY/2),
+    SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
+    SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
   },
   { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
-      UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (UXGA_OSC_FREQUENCY/2),
-      UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
-      UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
+    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    (UXGA_OSC_FREQUENCY/2),
+    UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
+    UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
   },
   { // Mode 5 : HD : 1920 x 1080 x 24 bpp
-      HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (HD_OSC_FREQUENCY/2),
-      HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
-      HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
+    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    (HD_OSC_FREQUENCY/2),
+    HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
+    HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
   },
   { // Mode 6 : VGA : 640 x 480 x 16 bpp (565 Mode)
-      VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565, VGA_OSC_FREQUENCY,
-      VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
-      VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
+    VGA_OSC_FREQUENCY,
+    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
+    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
   },
   { // Mode 7 : SVGA : 800 x 600 x 16 bpp (565 Mode)
-      SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565, SVGA_OSC_FREQUENCY,
-      SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
-      SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
+    SVGA_OSC_FREQUENCY,
+    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
+    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
   },
   { // Mode 8 : XGA : 1024 x 768 x 16 bpp (565 Mode)
-      XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565, XGA_OSC_FREQUENCY,
-      XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
-      XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
+    XGA_OSC_FREQUENCY,
+    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
+    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
   },
   { // Mode 9 : VGA : 640 x 480 x 15 bpp
-      VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, VGA_OSC_FREQUENCY,
-      VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
-      VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+    VGA_OSC_FREQUENCY,
+    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
+    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
   },
   { // Mode 10 : SVGA : 800 x 600 x 15 bpp
-      SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, SVGA_OSC_FREQUENCY,
-      SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
-      SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+    SVGA_OSC_FREQUENCY,
+    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
+    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
   },
   { // Mode 11 : XGA : 1024 x 768 x 15 bpp
-      XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, XGA_OSC_FREQUENCY,
-      XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
-      XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+    XGA_OSC_FREQUENCY,
+    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
+    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
   },
   { // Mode 12 : XGA : 1024 x 768 x 15 bpp - All the timing info is derived from Linux Kernel Driver Settings
-      XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, 63500000,
-      XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
-      XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+    63500000,
+    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
+    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
   },
   { // Mode 13 : VGA : 640 x 480 x 12 bpp (444 Mode)
-      VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444, VGA_OSC_FREQUENCY,
-      VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
-      VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
+    VGA_OSC_FREQUENCY,
+    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
+    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
   },
   { // Mode 14 : SVGA : 800 x 600 x 12 bpp (444 Mode)
-      SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444, SVGA_OSC_FREQUENCY,
-      SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
-      SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
+    SVGA_OSC_FREQUENCY,
+    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
+    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
   },
   { // Mode 15 : XGA : 1024 x 768 x 12 bpp (444 Mode)
-      XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444, XGA_OSC_FREQUENCY,
-      XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
-      XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
+    XGA_OSC_FREQUENCY,
+    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
+    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
   }
 };
 
@@ -135,7 +150,6 @@ EFI_EDID_ACTIVE_PROTOCOL      mEdidActive = {
   NULL
 };
 
-
 EFI_STATUS
 LcdPlatformInitializeDisplay (
   IN EFI_HANDLE   Handle
@@ -143,16 +157,19 @@ LcdPlatformInitializeDisplay (
 {
   EFI_STATUS  Status;
 
-  // Set the FPGA multiplexer to select the video output from the motherboard or the daughterboard
+  // Set the FPGA multiplexer to select the video output from the motherboard
+  // or the daughterboard
   Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, PL111_CLCD_SITE);
-  if (!EFI_ERROR(Status)) {
+  if (!EFI_ERROR (Status)) {
     // Install the EDID Protocols
-    Status = gBS->InstallMultipleProtocolInterfaces(
-      &Handle,
-      &gEfiEdidDiscoveredProtocolGuid,  &mEdidDiscovered,
-      &gEfiEdidActiveProtocolGuid,      &mEdidActive,
-      NULL
-    );
+    Status = gBS->InstallMultipleProtocolInterfaces (
+                    &Handle,
+                    &gEfiEdidDiscoveredProtocolGuid,
+                    &mEdidDiscovered,
+                    &gEfiEdidActiveProtocolGuid,
+                    &mEdidActive,
+                    NULL
+                    );
   }
 
   return Status;
@@ -169,29 +186,38 @@ LcdPlatformGetVram (
   Status = EFI_SUCCESS;
 
   // Is it on the motherboard or on the daughterboard?
-  switch(PL111_CLCD_SITE) {
+  switch (PL111_CLCD_SITE) {
 
   case ARM_VE_MOTHERBOARD_SITE:
-    *VramBaseAddress = (EFI_PHYSICAL_ADDRESS) PL111_CLCD_VRAM_MOTHERBOARD_BASE;
+    *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)PL111_CLCD_VRAM_MOTHERBOARD_BASE;
     *VramSize = LCD_VRAM_SIZE;
     break;
 
   case ARM_VE_DAUGHTERBOARD_1_SITE:
-    *VramBaseAddress = (EFI_PHYSICAL_ADDRESS) LCD_VRAM_CORE_TILE_BASE;
+    *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)LCD_VRAM_CORE_TILE_BASE;
     *VramSize = LCD_VRAM_SIZE;
 
     // Allocate the VRAM from the DRAM so that nobody else uses it.
-    Status = gBS->AllocatePages( AllocateAddress, EfiBootServicesData, EFI_SIZE_TO_PAGES(((UINTN)LCD_VRAM_SIZE)), VramBaseAddress);
-    if (EFI_ERROR(Status)) {
+    Status = gBS->AllocatePages (
+                    AllocateAddress,
+                    EfiBootServicesData,
+                    EFI_SIZE_TO_PAGES (((UINTN)LCD_VRAM_SIZE)),
+                    VramBaseAddress
+                    );
+    if (EFI_ERROR (Status)) {
       return Status;
     }
 
-    // Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is cacheable.
-    Status = gDS->SetMemorySpaceAttributes (*VramBaseAddress, *VramSize,
-                    EFI_MEMORY_WC);
-    ASSERT_EFI_ERROR(Status);
-    if (EFI_ERROR(Status)) {
-      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES(*VramSize));
+    // Mark the VRAM as write-combining.
+    // The VRAM is inside the DRAM, which is cacheable.
+    Status = gDS->SetMemorySpaceAttributes (
+                    *VramBaseAddress,
+                    *VramSize,
+                    EFI_MEMORY_WC
+                    );
+    ASSERT_EFI_ERROR (Status);
+    if (EFI_ERROR (Status)) {
+      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
       return Status;
     }
     break;
@@ -206,19 +232,18 @@ LcdPlatformGetVram (
 }
 
 UINT32
-LcdPlatformGetMaxMode (
-  VOID
-  )
+LcdPlatformGetMaxMode (VOID)
 {
-  // The following line will report correctly the total number of graphics modes
-  // supported by the PL111CLCD.
-  //return (sizeof(mResolutions) / sizeof(CLCD_RESOLUTION)) - 1;
+  // The following line would correctly report the total number
+  // of graphics modes supported by the PL111CLCD.
+  // return (sizeof(mResolutions) / sizeof(CLCD_RESOLUTION)) - 1;
 
   // However, on some platforms it is desirable to ignore some graphics modes.
-  // This could be because the specific implementation of PL111 has certain limitations.
+  // This could be because the specific implementation of PL111 has
+  // certain limitations.
 
   // Set the maximum mode allowed
-  return (PcdGet32(PcdPL111LcdMaxMode));
+  return (PcdGet32 (PcdPL111LcdMaxMode));
 }
 
 EFI_STATUS
@@ -238,22 +263,26 @@ LcdPlatformSetMode (
 
   LcdSite = PL111_CLCD_SITE;
 
-  switch(LcdSite) {
+  switch (LcdSite) {
   case ARM_VE_MOTHERBOARD_SITE:
     Function = SYS_CFG_OSC;
     OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
     break;
   case ARM_VE_DAUGHTERBOARD_1_SITE:
     Function = SYS_CFG_OSC_SITE1;
-    OscillatorId = (UINT32)PcdGet32(PcdPL111LcdVideoModeOscId);
+    OscillatorId = (UINT32)PcdGet32 (PcdPL111LcdVideoModeOscId);
     break;
   default:
     return EFI_UNSUPPORTED;
   }
 
   // Set the video mode oscillator
-  Status = ArmPlatformSysConfigSetDevice (Function, OscillatorId, mResolutions[ModeNumber].OscFreq);
-  if (EFI_ERROR(Status)) {
+  Status = ArmPlatformSysConfigSetDevice (
+             Function,
+             OscillatorId,
+             mResolutions[ModeNumber].OscFreq
+             );
+  if (EFI_ERROR (Status)) {
     ASSERT_EFI_ERROR (Status);
     return Status;
   }
@@ -267,8 +296,11 @@ LcdPlatformSetMode (
     SysId &= ~ARM_FVP_SYS_ID_VARIANT_MASK;
     if (SysId != ARM_FVP_BASE_BOARD_SYS_ID) {
       // Set the DVI into the new mode
-      Status = ArmPlatformSysConfigSet (SYS_CFG_DVIMODE, mResolutions[ModeNumber].Mode);
-      if (EFI_ERROR(Status)) {
+      Status = ArmPlatformSysConfigSet (
+                 SYS_CFG_DVIMODE,
+                 mResolutions[ModeNumber].Mode
+                 );
+      if (EFI_ERROR (Status)) {
         ASSERT_EFI_ERROR (Status);
         return Status;
       }
@@ -277,7 +309,7 @@ LcdPlatformSetMode (
 
   // Set the multiplexer
   Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, LcdSite);
-  if (EFI_ERROR(Status)) {
+  if (EFI_ERROR (Status)) {
     ASSERT_EFI_ERROR (Status);
     return Status;
   }
@@ -301,25 +333,25 @@ LcdPlatformQueryMode (
   Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
 
   switch (mResolutions[ModeNumber].Bpp) {
-    case LCD_BITS_PER_PIXEL_24:
-      Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
-      Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
-      Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
-      Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
-      Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
-      break;
+  case LCD_BITS_PER_PIXEL_24:
+    Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
+    Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
+    Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
+    Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
+    Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
+    break;
 
-    case LCD_BITS_PER_PIXEL_16_555:
-    case LCD_BITS_PER_PIXEL_16_565:
-    case LCD_BITS_PER_PIXEL_12_444:
-    case LCD_BITS_PER_PIXEL_8:
-    case LCD_BITS_PER_PIXEL_4:
-    case LCD_BITS_PER_PIXEL_2:
-    case LCD_BITS_PER_PIXEL_1:
-    default:
-      // These are not supported
-      ASSERT(FALSE);
-      break;
+  case LCD_BITS_PER_PIXEL_16_555:
+  case LCD_BITS_PER_PIXEL_16_565:
+  case LCD_BITS_PER_PIXEL_12_444:
+  case LCD_BITS_PER_PIXEL_8:
+  case LCD_BITS_PER_PIXEL_4:
+  case LCD_BITS_PER_PIXEL_2:
+  case LCD_BITS_PER_PIXEL_1:
+  default:
+    // These are not supported
+    ASSERT (FALSE);
+    break;
   }
 
   return EFI_SUCCESS;
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 03/18] ARM/VExpressPkg: Tidy HdLcd/PL111Lcd code: Updated comments
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 01/18] ARM/VExpressPkg: Fix MODULE_TYPE of HDLCD/PL111 platform libraries evan.lloyd
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 02/18] ARM/VExpressPkg: Tidy HDLCD and PL11LCD platform Lib: Coding standard evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 14:08   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 04/18] ARM/VExpressPkg: Remove unused PcdPL111LcdMaxMode from HDLCD inf evan.lloyd
                   ` (15 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak at arm.com>

There is no functional modification in this change.
In this change some comments in HDLCD and PL111LCD platform library
code are modified and a few new comments are added. This is to
prevent mixing formatting changes with functional changes.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf |  2 +-
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c            | 74 ++++++++++++++++++++
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c      | 73 +++++++++++++++++++
 3 files changed, 148 insertions(+), 1 deletion(-)

diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
index 335c84841a4ff4b57c0d495bc48e93579b5ce576..e97febb91c89f82f8cad12823f5ffe182e87f8cd 100644
--- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
+++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
@@ -1,6 +1,6 @@
 #/** @file
 #
-#  Component description file for ArmVeGraphicsDxe module
+#  Component description file for PL111LcdArmVExpressLib module
 #
 #  Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
 #
diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index 851ba83b79f0fea7019269c30e7add58f5ff9cb2..e4d0a4c8407835df6ab62c02d18531c4d3f08c97 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -44,6 +44,8 @@ typedef struct {
   UINT32                     VFrontPorch;
 } LCD_RESOLUTION;
 
+/** The display modes supported by the platform.
+**/
 LCD_RESOLUTION mResolutions[] = {
   { // Mode 0 : VGA : 640 x 480 x 24 bpp
     VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
@@ -93,6 +95,13 @@ EFI_EDID_ACTIVE_PROTOCOL      mEdidActive = {
   NULL
 };
 
+/** HDLCD platform specific initialization function.
+
+  @param[in] Handle              Handle to the LCD device instance.
+
+  @retval EFI_SUCCESS            Plaform library initialized successfully.
+  @retval !(EFI_SUCCESS)         Other errors.
+**/
 EFI_STATUS
 LcdPlatformInitializeDisplay (
   IN EFI_HANDLE   Handle
@@ -123,6 +132,18 @@ LcdPlatformInitializeDisplay (
   return Status;
 }
 
+/** Allocate VRAM memory in DRAM for the frame buffer
+  (unless it is reserved already).
+
+  The allocated address can be used to set the frame buffer.
+
+  @param[out] VramBaseAddress     A pointer to the frame buffer address.
+  @param[out] VramSize            A pointer to the size of the frame
+                                  buffer in bytes
+
+  @retval EFI_SUCCESS             Frame buffer memory allocated successfully.
+  @retval !(EFI_SUCCESS)          Other errors.
+**/
 EFI_STATUS
 LcdPlatformGetVram (
   OUT EFI_PHYSICAL_ADDRESS*  VramBaseAddress,
@@ -169,6 +190,13 @@ LcdPlatformGetVram (
   return EFI_SUCCESS;
 }
 
+/** Return total number of modes supported.
+
+  Note: Valid mode numbers are 0 to MaxMode - 1
+  See Section 12.9 of the UEFI Specification 2.7
+
+  @retval UINT32             Mode Number.
+**/
 UINT32
 LcdPlatformGetMaxMode (VOID)
 {
@@ -177,6 +205,14 @@ LcdPlatformGetMaxMode (VOID)
   return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION));
 }
 
+/** Set the requested display mode.
+
+  @param[in] ModeNumber             Mode Number.
+
+  @retval EFI_SUCCESS               Mode set successfully.
+  @retval EFI_INVALID_PARAMETER     Requested mode not found.
+  @retval !(EFI_SUCCESS)            Other errors.
+**/
 EFI_STATUS
 LcdPlatformSetMode (
   IN UINT32                         ModeNumber
@@ -226,6 +262,17 @@ LcdPlatformSetMode (
   return Status;
 }
 
+/** Return information for the requested mode number.
+
+  @param[in]  ModeNumber          Mode Number.
+
+  @param[out] Info                Pointer for returned mode information
+                                  (on success).
+
+  @retval EFI_SUCCESS             Mode information for the requested mode
+                                  returned successfully.
+  @retval EFI_INVALID_PARAMETER   Requested mode not found.
+**/
 EFI_STATUS
 LcdPlatformQueryMode (
   IN  UINT32                                ModeNumber,
@@ -266,6 +313,23 @@ LcdPlatformQueryMode (
   return EFI_SUCCESS;
 }
 
+/** Return display timing information for the requested mode number.
+
+  @param[in]  ModeNumber          Mode Number.
+
+  @param[out] HRes                Pointer to horizontal resolution.
+  @param[out] HSync               Pointer to horizontal sync width.
+  @param[out] HBackPorch          Pointer to horizontal back porch.
+  @param[out] HFrontPorch         Pointer to horizontal front porch.
+  @param[out] VRes                Pointer to vertical resolution.
+  @param[out] VSync               Pointer to vertical sync width.
+  @param[out] VBackPorch          Pointer to vertical back porch.
+  @param[out] VFrontPorch         Pointer to vertical front porch.
+
+  @retval EFI_SUCCESS             Display timing information for the requested
+                                  mode returned successfully.
+  @retval EFI_INVALID_PARAMETER   Requested mode not found.
+**/
 EFI_STATUS
 LcdPlatformGetTimings (
   IN  UINT32                              ModeNumber,
@@ -295,6 +359,16 @@ LcdPlatformGetTimings (
   return EFI_SUCCESS;
 }
 
+/** Return bits per pixel information for a mode number.
+
+  @param[in]  ModeNumber          Mode Number.
+
+  @param[out] Bpp                 Pointer to value bits per pixel.
+
+  @retval EFI_SUCCESS             Bit per pixel information for the requested
+                                  mode returned successfully.
+  @retval EFI_INVALID_PARAMETER   Requested mode not found.
+**/
 EFI_STATUS
 LcdPlatformGetBpp (
   IN  UINT32                              ModeNumber,
diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 2586a6d8c2076c9aff15f50d652e462d783f13dc..0bbd40ceeb850209cd4842f34e72a0b635309a15 100644
--- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -41,6 +41,8 @@ typedef struct {
   UINT32                     VFrontPorch;
 } LCD_RESOLUTION;
 
+/** The display modes supported by the platform.
+**/
 LCD_RESOLUTION mResolutions[] = {
   { // Mode 0 : VGA : 640 x 480 x 24 bpp
     VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
@@ -150,6 +152,12 @@ EFI_EDID_ACTIVE_PROTOCOL      mEdidActive = {
   NULL
 };
 
+/** PL111 Platform specific initialization function.
+
+  @param[in] Handle              Handle to the LCD device instance.
+  @retval EFI_SUCCESS            Plaform library initialized successfully.
+  @retval !(EFI_SUCCESS)         Other errors.
+**/
 EFI_STATUS
 LcdPlatformInitializeDisplay (
   IN EFI_HANDLE   Handle
@@ -175,6 +183,18 @@ LcdPlatformInitializeDisplay (
   return Status;
 }
 
+/** Allocate VRAM memory in DRAM for the frame buffer
+  (unless it is reserved already).
+
+  The allocated address can be used to set the frame buffer.
+
+  @param[out] VramBaseAddress     A pointer to the frame buffer address.
+  @param[out] VramSize            A pointer to the size of the frame
+                                  buffer in bytes
+
+  @retval EFI_SUCCESS             Frame buffer memory allocated successfully.
+  @retval !(EFI_SUCCESS)          Other errors.
+**/
 EFI_STATUS
 LcdPlatformGetVram (
   OUT EFI_PHYSICAL_ADDRESS*  VramBaseAddress,
@@ -231,6 +251,13 @@ LcdPlatformGetVram (
   return Status;
 }
 
+/** Return total number of modes supported.
+
+  Note: Valid mode numbers are 0 to MaxMode - 1
+  See Section 12.9 of the UEFI Specification 2.7
+
+  @retval UINT32             Mode Number.
+**/
 UINT32
 LcdPlatformGetMaxMode (VOID)
 {
@@ -246,6 +273,15 @@ LcdPlatformGetMaxMode (VOID)
   return (PcdGet32 (PcdPL111LcdMaxMode));
 }
 
+/** Set the requested display mode.
+
+  @param[in] ModeNumber            Mode Number.
+
+  @retval  EFI_SUCCESS             Mode set successfully.
+  @retval  EFI_INVALID_PARAMETER   Requested mode not found.
+  @retval  EFI_UNSUPPORTED         PLL111 configuration not supported.
+  @retval  !(EFI_SUCCESS)          Other errors.
+**/
 EFI_STATUS
 LcdPlatformSetMode (
   IN UINT32                         ModeNumber
@@ -317,6 +353,16 @@ LcdPlatformSetMode (
   return Status;
 }
 
+/** Return information for the requested mode number.
+
+  @param[in]  ModeNumber         Mode Number.
+  @param[out] Info               Pointer for returned mode information
+                                 (on success).
+
+  @retval EFI_SUCCESS             Mode information for the requested mode
+                                  returned successfully.
+  @retval EFI_INVALID_PARAMETER   Requested mode not found.
+**/
 EFI_STATUS
 LcdPlatformQueryMode (
   IN  UINT32                                ModeNumber,
@@ -357,6 +403,23 @@ LcdPlatformQueryMode (
   return EFI_SUCCESS;
 }
 
+/** Return display timing information for the requested mode number.
+
+  @param[in]  ModeNumber          Mode Number.
+
+  @param[out] HRes                Pointer to horizontal resolution.
+  @param[out] HSync               Pointer to horizontal sync width.
+  @param[out] HBackPorch          Pointer to horizontal back porch.
+  @param[out] HFrontPorch         Pointer to horizontal front porch.
+  @param[out] VRes                Pointer to vertical resolution.
+  @param[out] VSync               Pointer to vertical sync width.
+  @param[out] VBackPorch          Pointer to vertical back porch.
+  @param[out] VFrontPorch         Pointer to vertical front porch.
+
+  @retval EFI_SUCCESS             Display timing information for the requested
+                                  mode returned successfully.
+  @retval EFI_INVALID_PARAMETER   Requested mode not found.
+**/
 EFI_STATUS
 LcdPlatformGetTimings (
   IN  UINT32                              ModeNumber,
@@ -386,6 +449,16 @@ LcdPlatformGetTimings (
   return EFI_SUCCESS;
 }
 
+/** Return bits per pixel information for a mode number.
+
+  @param[in]  ModeNumber          Mode Number.
+
+  @param[out] Bpp                 Pointer to value bits per pixel.
+
+  @retval EFI_SUCCESS             Bit per pixel information for the requested
+                                  mode returned successfully.
+  @retval EFI_INVALID_PARAMETER   Requested mode not found.
+**/
 EFI_STATUS
 LcdPlatformGetBpp (
   IN  UINT32                              ModeNumber,
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 04/18] ARM/VExpressPkg: Remove unused PcdPL111LcdMaxMode from HDLCD inf
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (2 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 03/18] ARM/VExpressPkg: Tidy HdLcd/PL111Lcd code: Updated comments evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 14:08   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 05/18] ARM/VExpressPkg: PL111 and HDLCD: add const qualifier evan.lloyd
                   ` (14 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak@arm.com>

PCD PcdPL111LcdMaxMode is not used in HDLCD platform library.
Presence of this PCD in HDLCD is probably due to copy/paste code
from PL111 Lcd platform library. This change removes it from
the HdLcdArmVExpressLib.inf file.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
---
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
index d44aa7776a4ac60d60f3b4386e67c53423287383..52158c4771b5b7651e234fdd73208dcae14c1025 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
@@ -40,5 +40,4 @@ [Protocols]
   gEfiEdidActiveProtocolGuid                    # Produced
 
 [Pcd]
-  gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
   gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 05/18] ARM/VExpressPkg: PL111 and HDLCD: add const qualifier
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (3 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 04/18] ARM/VExpressPkg: Remove unused PcdPL111LcdMaxMode from HDLCD inf evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 14:09   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS evan.lloyd
                   ` (13 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak at arm.com>

This change adds some STATIC and CONST qualifiers (mainly to arguments
of  functions) in PL111 and HdLcd platform libraries.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c       | 34 ++++++++++----------
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 32 +++++++++---------
 2 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index e4d0a4c8407835df6ab62c02d18531c4d3f08c97..6afd764897f49c64490ce891682f99bb0f5d993b 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -46,7 +46,7 @@ typedef struct {
 
 /** The display modes supported by the platform.
 **/
-LCD_RESOLUTION mResolutions[] = {
+STATIC CONST LCD_RESOLUTION mResolutions[] = {
   { // Mode 0 : VGA : 640 x 480 x 24 bpp
     VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
     VGA_OSC_FREQUENCY,
@@ -146,8 +146,8 @@ LcdPlatformInitializeDisplay (
 **/
 EFI_STATUS
 LcdPlatformGetVram (
-  OUT EFI_PHYSICAL_ADDRESS*  VramBaseAddress,
-  OUT UINTN*                 VramSize
+  OUT EFI_PHYSICAL_ADDRESS * CONST  VramBaseAddress,
+  OUT UINTN * CONST                 VramSize
   )
 {
   EFI_STATUS              Status;
@@ -215,7 +215,7 @@ LcdPlatformGetMaxMode (VOID)
 **/
 EFI_STATUS
 LcdPlatformSetMode (
-  IN UINT32                         ModeNumber
+  IN CONST UINT32                         ModeNumber
   )
 {
   EFI_STATUS            Status;
@@ -275,8 +275,8 @@ LcdPlatformSetMode (
 **/
 EFI_STATUS
 LcdPlatformQueryMode (
-  IN  UINT32                                ModeNumber,
-  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *Info
+  IN CONST UINT32                                   ModeNumber,
+  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST  Info
   )
 {
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
@@ -332,15 +332,15 @@ LcdPlatformQueryMode (
 **/
 EFI_STATUS
 LcdPlatformGetTimings (
-  IN  UINT32                              ModeNumber,
-  OUT UINT32*                             HRes,
-  OUT UINT32*                             HSync,
-  OUT UINT32*                             HBackPorch,
-  OUT UINT32*                             HFrontPorch,
-  OUT UINT32*                             VRes,
-  OUT UINT32*                             VSync,
-  OUT UINT32*                             VBackPorch,
-  OUT UINT32*                             VFrontPorch
+  IN  CONST UINT32                              ModeNumber,
+  OUT UINT32 * CONST                            HRes,
+  OUT UINT32 * CONST                            HSync,
+  OUT UINT32 * CONST                            HBackPorch,
+  OUT UINT32 * CONST                            HFrontPorch,
+  OUT UINT32 * CONST                            VRes,
+  OUT UINT32 * CONST                            VSync,
+  OUT UINT32 * CONST                            VBackPorch,
+  OUT UINT32 * CONST                            VFrontPorch
   )
 {
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
@@ -371,8 +371,8 @@ LcdPlatformGetTimings (
 **/
 EFI_STATUS
 LcdPlatformGetBpp (
-  IN  UINT32                              ModeNumber,
-  OUT LCD_BPP  *                          Bpp
+  IN CONST UINT32                        ModeNumber,
+  OUT LCD_BPP * CONST                    Bpp
   )
 {
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 0bbd40ceeb850209cd4842f34e72a0b635309a15..799fb3fc781ce04bb64cb1fa0b87f262a670ed78 100644
--- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -197,8 +197,8 @@ LcdPlatformInitializeDisplay (
 **/
 EFI_STATUS
 LcdPlatformGetVram (
-  OUT EFI_PHYSICAL_ADDRESS*  VramBaseAddress,
-  OUT UINTN*                 VramSize
+  OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
+  OUT UINTN * CONST                VramSize
   )
 {
   EFI_STATUS              Status;
@@ -284,7 +284,7 @@ LcdPlatformGetMaxMode (VOID)
 **/
 EFI_STATUS
 LcdPlatformSetMode (
-  IN UINT32                         ModeNumber
+  IN CONST UINT32                         ModeNumber
   )
 {
   EFI_STATUS            Status;
@@ -365,8 +365,8 @@ LcdPlatformSetMode (
 **/
 EFI_STATUS
 LcdPlatformQueryMode (
-  IN  UINT32                                ModeNumber,
-  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *Info
+  IN CONST UINT32                                  ModeNumber,
+  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
   )
 {
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
@@ -422,15 +422,15 @@ LcdPlatformQueryMode (
 **/
 EFI_STATUS
 LcdPlatformGetTimings (
-  IN  UINT32                              ModeNumber,
-  OUT UINT32*                             HRes,
-  OUT UINT32*                             HSync,
-  OUT UINT32*                             HBackPorch,
-  OUT UINT32*                             HFrontPorch,
-  OUT UINT32*                             VRes,
-  OUT UINT32*                             VSync,
-  OUT UINT32*                             VBackPorch,
-  OUT UINT32*                             VFrontPorch
+  IN  CONST UINT32                        ModeNumber,
+  OUT UINT32 * CONST                      HRes,
+  OUT UINT32 * CONST                      HSync,
+  OUT UINT32 * CONST                      HBackPorch,
+  OUT UINT32 * CONST                      HFrontPorch,
+  OUT UINT32 * CONST                      VRes,
+  OUT UINT32 * CONST                      VSync,
+  OUT UINT32 * CONST                      VBackPorch,
+  OUT UINT32 * CONST                      VFrontPorch
   )
 {
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
@@ -461,8 +461,8 @@ LcdPlatformGetTimings (
 **/
 EFI_STATUS
 LcdPlatformGetBpp (
-  IN  UINT32                              ModeNumber,
-  OUT LCD_BPP  *                          Bpp
+  IN  CONST UINT32                        ModeNumber,
+  OUT LCD_BPP * CONST                     Bpp
   )
 {
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (4 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 05/18] ARM/VExpressPkg: PL111 and HDLCD: add const qualifier evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 14:12   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 07/18] ARM/VExpressPkg: PL111LcdArmVExpressLib: Minor code cleanup evan.lloyd
                   ` (12 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak at arm.com>

This change adds some debug assertions e.g to catch NULL pointer errors
missing in PL11Lcd and HdLcd platform libraries.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c       | 22 +++++++++++++++++-
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 24 +++++++++++++++++++-
 2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index 6afd764897f49c64490ce891682f99bb0f5d993b..a8fe8696da0653017ce9fa6e4a86caf283bc04c9 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -153,6 +153,9 @@ LcdPlatformGetVram (
   EFI_STATUS              Status;
   EFI_ALLOCATE_TYPE       AllocationType;
 
+  ASSERT (VramBaseAddress != NULL);
+  ASSERT (VramSize != NULL);
+
   // Set the vram size
   *VramSize = LCD_VRAM_SIZE;
 
@@ -171,6 +174,7 @@ LcdPlatformGetVram (
                   VramBaseAddress
                   );
   if (EFI_ERROR (Status)) {
+    ASSERT (FALSE);
     return Status;
   }
 
@@ -181,8 +185,8 @@ LcdPlatformGetVram (
                   *VramSize,
                   EFI_MEMORY_WC
                   );
-  ASSERT_EFI_ERROR (Status);
   if (EFI_ERROR (Status)) {
+    ASSERT (FALSE);
     gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
     return Status;
   }
@@ -221,6 +225,7 @@ LcdPlatformSetMode (
   EFI_STATUS            Status;
 
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+    ASSERT (FALSE);
     return EFI_INVALID_PARAMETER;
   }
 
@@ -279,7 +284,10 @@ LcdPlatformQueryMode (
   OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST  Info
   )
 {
+  ASSERT (Info != NULL);
+
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+    ASSERT (FALSE);
     return EFI_INVALID_PARAMETER;
   }
 
@@ -343,7 +351,18 @@ LcdPlatformGetTimings (
   OUT UINT32 * CONST                            VFrontPorch
   )
 {
+  // One of the pointers is NULL
+  ASSERT (HRes != NULL);
+  ASSERT (HSync != NULL);
+  ASSERT (HBackPorch != NULL);
+  ASSERT (HFrontPorch != NULL);
+  ASSERT (VRes != NULL);
+  ASSERT (VSync != NULL);
+  ASSERT (VBackPorch != NULL);
+  ASSERT (VFrontPorch != NULL);
+
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+    ASSERT (FALSE);
     return EFI_INVALID_PARAMETER;
   }
 
@@ -376,6 +395,7 @@ LcdPlatformGetBpp (
   )
 {
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+    ASSERT (FALSE);
     return EFI_INVALID_PARAMETER;
   }
 
diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 799fb3fc781ce04bb64cb1fa0b87f262a670ed78..fd4eea8f8e2397bc7d4ddf4cfe3dcc97a5109edb 100644
--- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -205,6 +205,9 @@ LcdPlatformGetVram (
 
   Status = EFI_SUCCESS;
 
+  ASSERT (VramBaseAddress != NULL);
+  ASSERT (VramSize != NULL);
+
   // Is it on the motherboard or on the daughterboard?
   switch (PL111_CLCD_SITE) {
 
@@ -225,6 +228,7 @@ LcdPlatformGetVram (
                     VramBaseAddress
                     );
     if (EFI_ERROR (Status)) {
+      ASSERT (FALSE);
       return Status;
     }
 
@@ -235,8 +239,8 @@ LcdPlatformGetVram (
                     *VramSize,
                     EFI_MEMORY_WC
                     );
-    ASSERT_EFI_ERROR (Status);
     if (EFI_ERROR (Status)) {
+      ASSERT (FALSE);
       gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
       return Status;
     }
@@ -294,6 +298,7 @@ LcdPlatformSetMode (
   UINT32                SysId;
 
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+    ASSERT (FALSE);
     return EFI_INVALID_PARAMETER;
   }
 
@@ -369,7 +374,10 @@ LcdPlatformQueryMode (
   OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
   )
 {
+  ASSERT (Info != NULL);
+
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+    ASSERT (FALSE);
     return EFI_INVALID_PARAMETER;
   }
 
@@ -433,7 +441,18 @@ LcdPlatformGetTimings (
   OUT UINT32 * CONST                      VFrontPorch
   )
 {
+  // One of the pointers is NULL
+  ASSERT (HRes != NULL);
+  ASSERT (HSync != NULL);
+  ASSERT (HBackPorch != NULL);
+  ASSERT (HFrontPorch != NULL);
+  ASSERT (VRes != NULL);
+  ASSERT (VSync != NULL);
+  ASSERT (VBackPorch != NULL);
+  ASSERT (VFrontPorch != NULL);
+
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+    ASSERT (FALSE);
     return EFI_INVALID_PARAMETER;
   }
 
@@ -465,7 +484,10 @@ LcdPlatformGetBpp (
   OUT LCD_BPP * CONST                     Bpp
   )
 {
+  ASSERT (Bpp != NULL);
+
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+    ASSERT (FALSE);
     return EFI_INVALID_PARAMETER;
   }
 
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 07/18] ARM/VExpressPkg: PL111LcdArmVExpressLib: Minor code cleanup
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (5 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 14:13   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 08/18] ARM/VExpressPkg: PL111 and HDLCD: Use FixedPcdGet32 evan.lloyd
                   ` (11 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak at arm.com>

This minor change removes some unecessary initializations and variables
in PL111LcdArmVExpress.c

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index fd4eea8f8e2397bc7d4ddf4cfe3dcc97a5109edb..11335bb2cef9d7ca2606d4a8671382bf3dc2d254 100644
--- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -203,8 +203,6 @@ LcdPlatformGetVram (
 {
   EFI_STATUS              Status;
 
-  Status = EFI_SUCCESS;
-
   ASSERT (VramBaseAddress != NULL);
   ASSERT (VramSize != NULL);
 
@@ -214,6 +212,7 @@ LcdPlatformGetVram (
   case ARM_VE_MOTHERBOARD_SITE:
     *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)PL111_CLCD_VRAM_MOTHERBOARD_BASE;
     *VramSize = LCD_VRAM_SIZE;
+    Status = EFI_SUCCESS;
     break;
 
   case ARM_VE_DAUGHTERBOARD_1_SITE:
@@ -242,7 +241,6 @@ LcdPlatformGetVram (
     if (EFI_ERROR (Status)) {
       ASSERT (FALSE);
       gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
-      return Status;
     }
     break;
 
@@ -292,7 +290,6 @@ LcdPlatformSetMode (
   )
 {
   EFI_STATUS            Status;
-  UINT32                LcdSite;
   UINT32                OscillatorId;
   SYS_CONFIG_FUNCTION   Function;
   UINT32                SysId;
@@ -302,9 +299,7 @@ LcdPlatformSetMode (
     return EFI_INVALID_PARAMETER;
   }
 
-  LcdSite = PL111_CLCD_SITE;
-
-  switch (LcdSite) {
+  switch (PL111_CLCD_SITE) {
   case ARM_VE_MOTHERBOARD_SITE:
     Function = SYS_CFG_OSC;
     OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
@@ -349,11 +344,8 @@ LcdPlatformSetMode (
   }
 
   // Set the multiplexer
-  Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, LcdSite);
-  if (EFI_ERROR (Status)) {
-    ASSERT_EFI_ERROR (Status);
-    return Status;
-  }
+  Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, PL111_CLCD_SITE);
+  ASSERT_EFI_ERROR (Status);
 
   return Status;
 }
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 08/18] ARM/VExpressPkg: PL111 and HDLCD: Use FixedPcdGet32
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (6 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 07/18] ARM/VExpressPkg: PL111LcdArmVExpressLib: Minor code cleanup evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 14:14   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 09/18] ARM/VExpressPkg: PL11LcdArmVExpressLib: Improvement conditional evan.lloyd
                   ` (10 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak at arm.com>

This change replaces PcdGet32 with FixedPcdGet32 for the PCDs which
are defined as fixed PCDs.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf       | 2 +-
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf | 2 +-
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c            | 2 +-
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c      | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
index 52158c4771b5b7651e234fdd73208dcae14c1025..2e83736609cf8c63cb498368cd377f6a23964ef4 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
@@ -39,5 +39,5 @@ [Protocols]
   gEfiEdidDiscoveredProtocolGuid                # Produced
   gEfiEdidActiveProtocolGuid                    # Produced
 
-[Pcd]
+[FixedPcd]
   gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId
diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
index e97febb91c89f82f8cad12823f5ffe182e87f8cd..1ee878041559fa84a810f65175f2507bda663d76 100644
--- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
+++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
@@ -39,6 +39,6 @@ [Protocols]
   gEfiEdidDiscoveredProtocolGuid                # Produced
   gEfiEdidActiveProtocolGuid                    # Produced
 
-[Pcd]
+[FixedPcd]
   gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
   gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId
diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index a8fe8696da0653017ce9fa6e4a86caf283bc04c9..f8d19df79260cdfbe1876d6ccc10d49abd0637cf 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -233,7 +233,7 @@ LcdPlatformSetMode (
   do {
     Status = ArmPlatformSysConfigSetDevice (
                SYS_CFG_OSC_SITE1,
-               PcdGet32 (PcdHdLcdVideoModeOscId),
+               FixedPcdGet32 (PcdHdLcdVideoModeOscId),
                mResolutions[ModeNumber].OscFreq
                );
   } while (Status == EFI_TIMEOUT);
diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 11335bb2cef9d7ca2606d4a8671382bf3dc2d254..92918bb4ee6811db47791a435bc06a6dc77ae9a3 100644
--- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -272,7 +272,7 @@ LcdPlatformGetMaxMode (VOID)
   // certain limitations.
 
   // Set the maximum mode allowed
-  return (PcdGet32 (PcdPL111LcdMaxMode));
+  return (FixedPcdGet32 (PcdPL111LcdMaxMode));
 }
 
 /** Set the requested display mode.
@@ -306,7 +306,7 @@ LcdPlatformSetMode (
     break;
   case ARM_VE_DAUGHTERBOARD_1_SITE:
     Function = SYS_CFG_OSC_SITE1;
-    OscillatorId = (UINT32)PcdGet32 (PcdPL111LcdVideoModeOscId);
+    OscillatorId = FixedPcdGet32 (PcdPL111LcdVideoModeOscId);
     break;
   default:
     return EFI_UNSUPPORTED;
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 09/18] ARM/VExpressPkg: PL11LcdArmVExpressLib: Improvement conditional
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (7 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 08/18] ARM/VExpressPkg: PL111 and HDLCD: Use FixedPcdGet32 evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 14:16   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 10/18] ARM/VExpressPkg: HdLcdArmVExpressLib: Remove status check EFI_TIMEOUT evan.lloyd
                   ` (9 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak at arm.com>

PL111_CLCD_SITE and ARM_VE_MOTHERBOARD_SITE are both constants and
available at build time. Use conditional compilation to process the code
based on the value of PL111_CLCD_SITE, instead of selecting code in a
switch statement at runtime.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 40 +++++++-------------
 1 file changed, 14 insertions(+), 26 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 92918bb4ee6811db47791a435bc06a6dc77ae9a3..cf50b20fd9b1b44a81963655c2f88305ce6bdc67 100644
--- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -206,16 +206,11 @@ LcdPlatformGetVram (
   ASSERT (VramBaseAddress != NULL);
   ASSERT (VramSize != NULL);
 
-  // Is it on the motherboard or on the daughterboard?
-  switch (PL111_CLCD_SITE) {
-
-  case ARM_VE_MOTHERBOARD_SITE:
+#if (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
     *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)PL111_CLCD_VRAM_MOTHERBOARD_BASE;
     *VramSize = LCD_VRAM_SIZE;
     Status = EFI_SUCCESS;
-    break;
-
-  case ARM_VE_DAUGHTERBOARD_1_SITE:
+#elif (PL111_CLCD_SITE == ARM_VE_DAUGHTERBOARD_1_SITE)
     *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)LCD_VRAM_CORE_TILE_BASE;
     *VramSize = LCD_VRAM_SIZE;
 
@@ -242,13 +237,9 @@ LcdPlatformGetVram (
       ASSERT (FALSE);
       gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
     }
-    break;
-
-  default:
-    // Unsupported site
-    Status = EFI_UNSUPPORTED;
-    break;
-  }
+#else
+#error PL111LcdVExpressLib: Unsupported PL111_CLCD_SITE
+#endif // (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
 
   return Status;
 }
@@ -299,18 +290,15 @@ LcdPlatformSetMode (
     return EFI_INVALID_PARAMETER;
   }
 
-  switch (PL111_CLCD_SITE) {
-  case ARM_VE_MOTHERBOARD_SITE:
-    Function = SYS_CFG_OSC;
-    OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
-    break;
-  case ARM_VE_DAUGHTERBOARD_1_SITE:
-    Function = SYS_CFG_OSC_SITE1;
-    OscillatorId = FixedPcdGet32 (PcdPL111LcdVideoModeOscId);
-    break;
-  default:
-    return EFI_UNSUPPORTED;
-  }
+#if (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
+  Function = SYS_CFG_OSC;
+  OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
+#elif (PL111_CLCD_SITE == ARM_VE_DAUGHTERBOARD_1_SITE)
+  Function = SYS_CFG_OSC_SITE1;
+  OscillatorId = FixedPcdGet32 (PcdPL111LcdVideoModeOscId);
+#else
+#error PL111LcdVExpressLib: Unsupported PL111_CLCD_SITE
+#endif // (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
 
   // Set the video mode oscillator
   Status = ArmPlatformSysConfigSetDevice (
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 10/18] ARM/VExpressPkg: HdLcdArmVExpressLib: Remove status check EFI_TIMEOUT
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (8 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 09/18] ARM/VExpressPkg: PL11LcdArmVExpressLib: Improvement conditional evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 14:16   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 11/18] ARM/VExpressPkg: HdLcdArmVExpressLib: Remove redundant Bpp evan.lloyd
                   ` (8 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak at arm.com>

None of the ArmPlatformSys*  functions returns EFI_TIMEOUT. Hence checking
this in the do {} while loop in LcdPlatformSetMode is wrong. Therefore
remove this comparision and as a result remove the do {} while loop.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 22 ++++++++------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index f8d19df79260cdfbe1876d6ccc10d49abd0637cf..533d7fa4777e8f22429e2ae63a828dcb5401b5c0 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -230,25 +230,21 @@ LcdPlatformSetMode (
   }
 
   // Set the video mode oscillator
-  do {
-    Status = ArmPlatformSysConfigSetDevice (
-               SYS_CFG_OSC_SITE1,
-               FixedPcdGet32 (PcdHdLcdVideoModeOscId),
-               mResolutions[ModeNumber].OscFreq
-               );
-  } while (Status == EFI_TIMEOUT);
+  Status = ArmPlatformSysConfigSetDevice (
+             SYS_CFG_OSC_SITE1,
+             FixedPcdGet32 (PcdHdLcdVideoModeOscId),
+             mResolutions[ModeNumber].OscFreq
+             );
   if (EFI_ERROR (Status)) {
     ASSERT_EFI_ERROR (Status);
     return Status;
   }
 
   // Set the DVI into the new mode
-  do {
-    Status = ArmPlatformSysConfigSet (
-               SYS_CFG_DVIMODE,
-               mResolutions[ModeNumber].Mode
-               );
-  } while (Status == EFI_TIMEOUT);
+  Status = ArmPlatformSysConfigSet (
+             SYS_CFG_DVIMODE,
+             mResolutions[ModeNumber].Mode
+             );
   if (EFI_ERROR (Status)) {
     ASSERT_EFI_ERROR (Status);
     return Status;
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 11/18] ARM/VExpressPkg: HdLcdArmVExpressLib: Remove redundant Bpp
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (9 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 10/18] ARM/VExpressPkg: HdLcdArmVExpressLib: Remove status check EFI_TIMEOUT evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 14:17   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 12/18] ARM/VExpressPkg: Redefine LcdPlatformGetTimings function evan.lloyd
                   ` (7 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: EvanLloyd <evan.lloyd at arm.com>

Because of copy/paste effects, HdLcdArmVExpress.c contained a
table entry "LCD_BPP Bpp;" specifying the Bits per Pixel for each mode.
However, all modes are LCD_BITS_PER_PIXEL_24.

This change removes the table entry and related use of the field.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 42 ++++++--------------
 1 file changed, 13 insertions(+), 29 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index 533d7fa4777e8f22429e2ae63a828dcb5401b5c0..8496a0215bc78585b546f63312c9d7f1ad07adb6 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -32,7 +32,6 @@ typedef struct {
   UINT32                     Mode;
   UINT32                     HorizontalResolution;
   UINT32                     VerticalResolution;
-  LCD_BPP                    Bpp;
   UINT32                     OscFreq;
 
   // These are used by HDLCD
@@ -48,37 +47,37 @@ typedef struct {
 **/
 STATIC CONST LCD_RESOLUTION mResolutions[] = {
   { // Mode 0 : VGA : 640 x 480 x 24 bpp
-    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
     VGA_OSC_FREQUENCY,
     VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
     VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
   },
   { // Mode 1 : SVGA : 800 x 600 x 24 bpp
-    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS,
     SVGA_OSC_FREQUENCY,
     SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
     SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
   },
   { // Mode 2 : XGA : 1024 x 768 x 24 bpp
-    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS,
     XGA_OSC_FREQUENCY,
     XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
     XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
   },
   { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
-    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS,
     (SXGA_OSC_FREQUENCY/2),
     SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
     SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
   },
   { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
-    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS,
     (UXGA_OSC_FREQUENCY/2),
     UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
     UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
   },
   { // Mode 5 : HD : 1920 x 1080 x 24 bpp
-    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS,
     (HD_OSC_FREQUENCY/2),
     HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
     HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
@@ -292,27 +291,12 @@ LcdPlatformQueryMode (
   Info->VerticalResolution = mResolutions[ModeNumber].VerticalResolution;
   Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
 
-  switch (mResolutions[ModeNumber].Bpp) {
-  case LCD_BITS_PER_PIXEL_24:
-    Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
-    Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
-    Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
-    Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
-    Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
-    break;
-
-  case LCD_BITS_PER_PIXEL_16_555:
-  case LCD_BITS_PER_PIXEL_16_565:
-  case LCD_BITS_PER_PIXEL_12_444:
-  case LCD_BITS_PER_PIXEL_8:
-  case LCD_BITS_PER_PIXEL_4:
-  case LCD_BITS_PER_PIXEL_2:
-  case LCD_BITS_PER_PIXEL_1:
-  default:
-    // These are not supported
-    ASSERT (FALSE);
-    break;
-  }
+  /* Bits per Pixel is always LCD_BITS_PER_PIXEL_24 */
+  Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
+  Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
+  Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
+  Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
+  Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
 
   return EFI_SUCCESS;
 }
@@ -395,7 +379,7 @@ LcdPlatformGetBpp (
     return EFI_INVALID_PARAMETER;
   }
 
-  *Bpp = mResolutions[ModeNumber].Bpp;
+  *Bpp = LCD_BITS_PER_PIXEL_24;
 
   return EFI_SUCCESS;
 }
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 12/18] ARM/VExpressPkg: Redefine LcdPlatformGetTimings function
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (10 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 11/18] ARM/VExpressPkg: HdLcdArmVExpressLib: Remove redundant Bpp evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 14:18   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 13/18] ARM/VExpressPkg: PL111 and HDLCD: Add PCD to select pixel format evan.lloyd
                   ` (6 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak at arm.com>

The LcdPlatformGetTimings interface function takes similar sets of
multiple parameters for horizontal and vertical timings which can be
aggregated in a common data type. This change defines a structure
SCAN_TIMINGS for this which can be used to describe both horizontal and
vertical scan timings, and accordingly redefines the
LcdPlatformGetTiming interface, greatly reducing the amount of data
passed about.

Similarly the mode definition tables are also changed to use this data
type and thus enable pass through access.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c       | 104 +++++-------
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 168 ++++++++------------
 2 files changed, 108 insertions(+), 164 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index 8496a0215bc78585b546f63312c9d7f1ad07adb6..b448d70f86d6acbc6bdae9749c7b6d0205935ba7 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -30,57 +30,51 @@
 
 typedef struct {
   UINT32                     Mode;
-  UINT32                     HorizontalResolution;
-  UINT32                     VerticalResolution;
   UINT32                     OscFreq;
 
   // These are used by HDLCD
-  UINT32                     HSync;
-  UINT32                     HBackPorch;
-  UINT32                     HFrontPorch;
-  UINT32                     VSync;
-  UINT32                     VBackPorch;
-  UINT32                     VFrontPorch;
-} LCD_RESOLUTION;
+  SCAN_TIMINGS               Horizontal;
+  SCAN_TIMINGS               Vertical;
+} DISPLAY_MODE;
 
 /** The display modes supported by the platform.
 **/
-STATIC CONST LCD_RESOLUTION mResolutions[] = {
+STATIC CONST DISPLAY_MODE mDisplayModes[] = {
   { // Mode 0 : VGA : 640 x 480 x 24 bpp
-    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
+    VGA,
     VGA_OSC_FREQUENCY,
-    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
-    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
+    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
   },
   { // Mode 1 : SVGA : 800 x 600 x 24 bpp
-    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS,
+    SVGA,
     SVGA_OSC_FREQUENCY,
-    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
-    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
+    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
   },
   { // Mode 2 : XGA : 1024 x 768 x 24 bpp
-    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS,
+    XGA,
     XGA_OSC_FREQUENCY,
-    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
-    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
   },
   { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
-    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS,
+    SXGA,
     (SXGA_OSC_FREQUENCY/2),
-    SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
-    SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
+    {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
+    {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
   },
   { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
-    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS,
+    UXGA,
     (UXGA_OSC_FREQUENCY/2),
-    UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
-    UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
+    {UXGA_H_RES_PIXELS, UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH},
+    {UXGA_V_RES_PIXELS, UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH}
   },
   { // Mode 5 : HD : 1920 x 1080 x 24 bpp
-    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS,
+    HD,
     (HD_OSC_FREQUENCY/2),
-    HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
-    HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
+    {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
+    {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
   }
 };
 
@@ -205,7 +199,7 @@ LcdPlatformGetMaxMode (VOID)
 {
   // The following line will report correctly the total number of graphics modes
   // that could be supported by the graphics driver
-  return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION));
+  return (sizeof (mDisplayModes) / sizeof (DISPLAY_MODE));
 }
 
 /** Set the requested display mode.
@@ -242,7 +236,7 @@ LcdPlatformSetMode (
   // Set the DVI into the new mode
   Status = ArmPlatformSysConfigSet (
              SYS_CFG_DVIMODE,
-             mResolutions[ModeNumber].Mode
+             mDisplayModes[ModeNumber].Mode
              );
   if (EFI_ERROR (Status)) {
     ASSERT_EFI_ERROR (Status);
@@ -287,9 +281,9 @@ LcdPlatformQueryMode (
   }
 
   Info->Version = 0;
-  Info->HorizontalResolution = mResolutions[ModeNumber].HorizontalResolution;
-  Info->VerticalResolution = mResolutions[ModeNumber].VerticalResolution;
-  Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
+  Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
+  Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
+  Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
 
   /* Bits per Pixel is always LCD_BITS_PER_PIXEL_24 */
   Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
@@ -305,14 +299,10 @@ LcdPlatformQueryMode (
 
   @param[in]  ModeNumber          Mode Number.
 
-  @param[out] HRes                Pointer to horizontal resolution.
-  @param[out] HSync               Pointer to horizontal sync width.
-  @param[out] HBackPorch          Pointer to horizontal back porch.
-  @param[out] HFrontPorch         Pointer to horizontal front porch.
-  @param[out] VRes                Pointer to vertical resolution.
-  @param[out] VSync               Pointer to vertical sync width.
-  @param[out] VBackPorch          Pointer to vertical back porch.
-  @param[out] VFrontPorch         Pointer to vertical front porch.
+  @param[out] Horizontal          Pointer to horizontal timing parameters.
+                                  (Resolution, Sync, Back porch, Front porch)
+  @param[out] Vertical            Pointer to vertical timing parameters.
+                                  (Resolution, Sync, Back porch, Front porch)
 
   @retval EFI_SUCCESS             Display timing information for the requested
                                   mode returned successfully.
@@ -320,40 +310,22 @@ LcdPlatformQueryMode (
 **/
 EFI_STATUS
 LcdPlatformGetTimings (
-  IN  CONST UINT32                              ModeNumber,
-  OUT UINT32 * CONST                            HRes,
-  OUT UINT32 * CONST                            HSync,
-  OUT UINT32 * CONST                            HBackPorch,
-  OUT UINT32 * CONST                            HFrontPorch,
-  OUT UINT32 * CONST                            VRes,
-  OUT UINT32 * CONST                            VSync,
-  OUT UINT32 * CONST                            VBackPorch,
-  OUT UINT32 * CONST                            VFrontPorch
+  IN  CONST UINT32                  ModeNumber,
+  OUT CONST SCAN_TIMINGS         ** Horizontal,
+  OUT CONST SCAN_TIMINGS         ** Vertical
   )
 {
   // One of the pointers is NULL
-  ASSERT (HRes != NULL);
-  ASSERT (HSync != NULL);
-  ASSERT (HBackPorch != NULL);
-  ASSERT (HFrontPorch != NULL);
-  ASSERT (VRes != NULL);
-  ASSERT (VSync != NULL);
-  ASSERT (VBackPorch != NULL);
-  ASSERT (VFrontPorch != NULL);
+  ASSERT (Horizontal != NULL);
+  ASSERT (Vertical != NULL);
 
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
     ASSERT (FALSE);
     return EFI_INVALID_PARAMETER;
   }
 
-  *HRes           = mResolutions[ModeNumber].HorizontalResolution;
-  *HSync          = mResolutions[ModeNumber].HSync;
-  *HBackPorch     = mResolutions[ModeNumber].HBackPorch;
-  *HFrontPorch    = mResolutions[ModeNumber].HFrontPorch;
-  *VRes           = mResolutions[ModeNumber].VerticalResolution;
-  *VSync          = mResolutions[ModeNumber].VSync;
-  *VBackPorch     = mResolutions[ModeNumber].VBackPorch;
-  *VFrontPorch    = mResolutions[ModeNumber].VFrontPorch;
+  *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
+  *Vertical   = &mDisplayModes[ModeNumber].Vertical;
 
   return EFI_SUCCESS;
 }
diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index cf50b20fd9b1b44a81963655c2f88305ce6bdc67..439cbdb1a73145fc4dc9c3c9587ce3fd9b9fff56 100644
--- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -28,117 +28,111 @@
 
 typedef struct {
   UINT32                     Mode;
-  UINT32                     HorizontalResolution;
-  UINT32                     VerticalResolution;
   LCD_BPP                    Bpp;
   UINT32                     OscFreq;
 
-  UINT32                     HSync;
-  UINT32                     HBackPorch;
-  UINT32                     HFrontPorch;
-  UINT32                     VSync;
-  UINT32                     VBackPorch;
-  UINT32                     VFrontPorch;
-} LCD_RESOLUTION;
+  SCAN_TIMINGS               Horizontal;
+  SCAN_TIMINGS               Vertical;
+} DISPLAY_MODE;
 
 /** The display modes supported by the platform.
 **/
-LCD_RESOLUTION mResolutions[] = {
+STATIC CONST DISPLAY_MODE mDisplayModes[] = {
   { // Mode 0 : VGA : 640 x 480 x 24 bpp
-    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    VGA, LCD_BITS_PER_PIXEL_24,
     VGA_OSC_FREQUENCY,
-    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
-    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
+    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
   },
   { // Mode 1 : SVGA : 800 x 600 x 24 bpp
-    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    SVGA, LCD_BITS_PER_PIXEL_24,
     SVGA_OSC_FREQUENCY,
-    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
-    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
+    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
   },
   { // Mode 2 : XGA : 1024 x 768 x 24 bpp
-    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    XGA, LCD_BITS_PER_PIXEL_24,
     XGA_OSC_FREQUENCY,
-    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
-    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
   },
   { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
-    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    SXGA, LCD_BITS_PER_PIXEL_24,
     (SXGA_OSC_FREQUENCY/2),
-    SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
-    SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
+    {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
+    {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
   },
   { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
-    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    UXGA, LCD_BITS_PER_PIXEL_24,
     (UXGA_OSC_FREQUENCY/2),
-    UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
-    UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
+    {UXGA_H_RES_PIXELS, UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH},
+    {UXGA_V_RES_PIXELS, UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH}
   },
   { // Mode 5 : HD : 1920 x 1080 x 24 bpp
-    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+    HD, LCD_BITS_PER_PIXEL_24,
     (HD_OSC_FREQUENCY/2),
-    HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
-    HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
+    {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
+    {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
   },
   { // Mode 6 : VGA : 640 x 480 x 16 bpp (565 Mode)
-    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
+    VGA, LCD_BITS_PER_PIXEL_16_565,
     VGA_OSC_FREQUENCY,
-    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
-    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
+    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
   },
   { // Mode 7 : SVGA : 800 x 600 x 16 bpp (565 Mode)
-    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
+    SVGA, LCD_BITS_PER_PIXEL_16_565,
     SVGA_OSC_FREQUENCY,
-    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
-    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
+    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
   },
   { // Mode 8 : XGA : 1024 x 768 x 16 bpp (565 Mode)
-    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
+    XGA, LCD_BITS_PER_PIXEL_16_565,
     XGA_OSC_FREQUENCY,
-    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
-    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
   },
   { // Mode 9 : VGA : 640 x 480 x 15 bpp
-    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+    VGA, LCD_BITS_PER_PIXEL_16_555,
     VGA_OSC_FREQUENCY,
-    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
-    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
+    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
   },
   { // Mode 10 : SVGA : 800 x 600 x 15 bpp
-    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+    SVGA, LCD_BITS_PER_PIXEL_16_555,
     SVGA_OSC_FREQUENCY,
-    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
-    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
+    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
   },
   { // Mode 11 : XGA : 1024 x 768 x 15 bpp
-    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+    XGA, LCD_BITS_PER_PIXEL_16_555,
     XGA_OSC_FREQUENCY,
-    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
-    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
   },
   { // Mode 12 : XGA : 1024 x 768 x 15 bpp - All the timing info is derived from Linux Kernel Driver Settings
-    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+    XGA, LCD_BITS_PER_PIXEL_16_555,
     63500000,
-    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
-    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
   },
   { // Mode 13 : VGA : 640 x 480 x 12 bpp (444 Mode)
-    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
+    VGA, LCD_BITS_PER_PIXEL_12_444,
     VGA_OSC_FREQUENCY,
-    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
-    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
+    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
   },
   { // Mode 14 : SVGA : 800 x 600 x 12 bpp (444 Mode)
-    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
+    SVGA, LCD_BITS_PER_PIXEL_12_444,
     SVGA_OSC_FREQUENCY,
-    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
-    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
+    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
   },
   { // Mode 15 : XGA : 1024 x 768 x 12 bpp (444 Mode)
-    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
+    XGA, LCD_BITS_PER_PIXEL_12_444,
     XGA_OSC_FREQUENCY,
-    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
-    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
   }
 };
 
@@ -304,7 +298,7 @@ LcdPlatformSetMode (
   Status = ArmPlatformSysConfigSetDevice (
              Function,
              OscillatorId,
-             mResolutions[ModeNumber].OscFreq
+             mDisplayModes[ModeNumber].OscFreq
              );
   if (EFI_ERROR (Status)) {
     ASSERT_EFI_ERROR (Status);
@@ -322,7 +316,7 @@ LcdPlatformSetMode (
       // Set the DVI into the new mode
       Status = ArmPlatformSysConfigSet (
                  SYS_CFG_DVIMODE,
-                 mResolutions[ModeNumber].Mode
+                 mDisplayModes[ModeNumber].Mode
                  );
       if (EFI_ERROR (Status)) {
         ASSERT_EFI_ERROR (Status);
@@ -362,11 +356,11 @@ LcdPlatformQueryMode (
   }
 
   Info->Version = 0;
-  Info->HorizontalResolution = mResolutions[ModeNumber].HorizontalResolution;
-  Info->VerticalResolution = mResolutions[ModeNumber].VerticalResolution;
-  Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
+  Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
+  Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
+  Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
 
-  switch (mResolutions[ModeNumber].Bpp) {
+  switch (mDisplayModes[ModeNumber].Bpp) {
   case LCD_BITS_PER_PIXEL_24:
     Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
     Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
@@ -395,14 +389,10 @@ LcdPlatformQueryMode (
 
   @param[in]  ModeNumber          Mode Number.
 
-  @param[out] HRes                Pointer to horizontal resolution.
-  @param[out] HSync               Pointer to horizontal sync width.
-  @param[out] HBackPorch          Pointer to horizontal back porch.
-  @param[out] HFrontPorch         Pointer to horizontal front porch.
-  @param[out] VRes                Pointer to vertical resolution.
-  @param[out] VSync               Pointer to vertical sync width.
-  @param[out] VBackPorch          Pointer to vertical back porch.
-  @param[out] VFrontPorch         Pointer to vertical front porch.
+  @param[out] Horizontal          Pointer to horizontal timing parameters.
+                                  (Resolution, Sync, Back porch, Front porch)
+  @param[out] Vertical            Pointer to vertical timing parameters.
+                                  (Resolution, Sync, Back porch, Front porch)
 
   @retval EFI_SUCCESS             Display timing information for the requested
                                   mode returned successfully.
@@ -410,40 +400,22 @@ LcdPlatformQueryMode (
 **/
 EFI_STATUS
 LcdPlatformGetTimings (
-  IN  CONST UINT32                        ModeNumber,
-  OUT UINT32 * CONST                      HRes,
-  OUT UINT32 * CONST                      HSync,
-  OUT UINT32 * CONST                      HBackPorch,
-  OUT UINT32 * CONST                      HFrontPorch,
-  OUT UINT32 * CONST                      VRes,
-  OUT UINT32 * CONST                      VSync,
-  OUT UINT32 * CONST                      VBackPorch,
-  OUT UINT32 * CONST                      VFrontPorch
+  IN  CONST UINT32                  ModeNumber,
+  OUT CONST SCAN_TIMINGS         ** Horizontal,
+  OUT CONST SCAN_TIMINGS         ** Vertical
   )
 {
   // One of the pointers is NULL
-  ASSERT (HRes != NULL);
-  ASSERT (HSync != NULL);
-  ASSERT (HBackPorch != NULL);
-  ASSERT (HFrontPorch != NULL);
-  ASSERT (VRes != NULL);
-  ASSERT (VSync != NULL);
-  ASSERT (VBackPorch != NULL);
-  ASSERT (VFrontPorch != NULL);
+  ASSERT (Horizontal != NULL);
+  ASSERT (Vertical != NULL);
 
   if (ModeNumber >= LcdPlatformGetMaxMode ()) {
     ASSERT (FALSE);
     return EFI_INVALID_PARAMETER;
   }
 
-  *HRes           = mResolutions[ModeNumber].HorizontalResolution;
-  *HSync          = mResolutions[ModeNumber].HSync;
-  *HBackPorch     = mResolutions[ModeNumber].HBackPorch;
-  *HFrontPorch    = mResolutions[ModeNumber].HFrontPorch;
-  *VRes           = mResolutions[ModeNumber].VerticalResolution;
-  *VSync          = mResolutions[ModeNumber].VSync;
-  *VBackPorch     = mResolutions[ModeNumber].VBackPorch;
-  *VFrontPorch    = mResolutions[ModeNumber].VFrontPorch;
+  *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
+  *Vertical   = &mDisplayModes[ModeNumber].Vertical;
 
   return EFI_SUCCESS;
 }
@@ -471,7 +443,7 @@ LcdPlatformGetBpp (
     return EFI_INVALID_PARAMETER;
   }
 
-  *Bpp = mResolutions[ModeNumber].Bpp;
+  *Bpp = mDisplayModes[ModeNumber].Bpp;
 
   return EFI_SUCCESS;
 }
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 13/18] ARM/VExpressPkg: PL111 and HDLCD: Add PCD to select pixel format
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (11 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 12/18] ARM/VExpressPkg: Redefine LcdPlatformGetTimings function evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 16:00   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 14/18] ARM/VExpressPkg: Reserving framebuffer at build evan.lloyd
                   ` (5 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak at arm.com>

Current HDLCD and PL111 platform libraries do not support display modes
with PixelBlueGreenRedReserved8BitPerColor format,  i.e. because of
historical confusion, they do not support the UEFI default
PixelBlueGreenRedReserved8BitPerColor

LcdPlatformLib for PL111, LcdPlatformQueryMode function returns the
pixel format as PixelRedGreenBlueReserved8BitPerColor which is wrong,
because that does not match the display controller's pixel format which
is set to BGR in PL111Lcd GOP driver.

Also it is not possible to configure pixel format as RGB/BGR for the
display modes for a platform at build time.

This change adds PcdGopPixelFormat to configure pixel format as
    PixelRedGreenBlueReserved8BitPerColor    or
    PixelBlueGreenRedReserved8BitPerColor    or
    PixelBitMask.
With this change, pixel format can be selected in the platform specific
.dsc file for all supported display modes.

Support for PixelBitMask is not implemented in PL111 or HDLCD
GOP driver, hence  HDLCD and PL111 platform libraries will return error
EFI_UNSUPPORTED if PcdGopPixelFormat is set to PixelBitMask.
Indeed, it is not clear what selecting PixelBitMask might mean, but
the option is allowed as it might suit a custom platform.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf       |  1 +
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf |  1 +
 Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c            | 23 ++++++++----
 Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c      | 38 +++++++++-----------
 4 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
index 2e83736609cf8c63cb498368cd377f6a23964ef4..4cbd324338be76a0b0bfb811159d893628e74155 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
@@ -41,3 +41,4 @@ [Protocols]
 
 [FixedPcd]
   gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId
+  gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
index 1ee878041559fa84a810f65175f2507bda663d76..20045380149241ce14f41bcb70afcb8145fe821f 100644
--- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
+++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
@@ -42,3 +42,4 @@ [Protocols]
 [FixedPcd]
   gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
   gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId
+  gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index b448d70f86d6acbc6bdae9749c7b6d0205935ba7..f1c18ac955f621e9eab3dede86758f5f1b1a791d 100644
--- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -15,7 +15,6 @@
 #include <PiDxe.h>
 
 #include <Library/ArmPlatformSysConfigLib.h>
-#include <Library/IoLib.h>
 #include <Library/PcdLib.h>
 #include <Library/DebugLib.h>
 #include <Library/DxeServicesTableLib.h>
@@ -93,6 +92,10 @@ EFI_EDID_ACTIVE_PROTOCOL      mEdidActive = {
   @param[in] Handle              Handle to the LCD device instance.
 
   @retval EFI_SUCCESS            Plaform library initialized successfully.
+  @retval EFI_UNSUPPORTED        PcdGopPixelFormat must be
+                                 PixelRedGreenBlueReserved8BitPerColor OR
+                                 PixelBlueGreenRedReserved8BitPerColor
+                                 any other format is not supported.
   @retval !(EFI_SUCCESS)         Other errors.
 **/
 EFI_STATUS
@@ -101,6 +104,17 @@ LcdPlatformInitializeDisplay (
   )
 {
   EFI_STATUS  Status;
+  EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
+
+  // PixelBitMask and PixelBltOnly pixel formats are not supported
+  PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
+  if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
+    && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
+
+    ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
+      ||  PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
+   return EFI_UNSUPPORTED;
+  }
 
   // Set the FPGA multiplexer to select the video output from the
   // motherboard or the daughterboard
@@ -285,12 +299,7 @@ LcdPlatformQueryMode (
   Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
   Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
 
-  /* Bits per Pixel is always LCD_BITS_PER_PIXEL_24 */
-  Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
-  Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
-  Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
-  Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
-  Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
+  Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
 
   return EFI_SUCCESS;
 }
diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 439cbdb1a73145fc4dc9c3c9587ce3fd9b9fff56..16a74c76cf27526493165dc6d81384f752fd3f20 100644
--- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -149,7 +149,12 @@ EFI_EDID_ACTIVE_PROTOCOL      mEdidActive = {
 /** PL111 Platform specific initialization function.
 
   @param[in] Handle              Handle to the LCD device instance.
+
   @retval EFI_SUCCESS            Plaform library initialized successfully.
+  @retval EFI_UNSUPPORTED        PcdGopPixelFormat must be
+                                 PixelRedGreenBlueReserved8BitPerColor OR
+                                 PixelBlueGreenRedReserved8BitPerColor
+                                 any other format is not supported
   @retval !(EFI_SUCCESS)         Other errors.
 **/
 EFI_STATUS
@@ -158,6 +163,17 @@ LcdPlatformInitializeDisplay (
   )
 {
   EFI_STATUS  Status;
+  EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
+
+  // PixelBitMask and PixelBltOnly pixel formats are not supported
+  PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
+  if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
+    && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
+
+    ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
+      ||  PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
+   return EFI_UNSUPPORTED;
+  }
 
   // Set the FPGA multiplexer to select the video output from the motherboard
   // or the daughterboard
@@ -360,27 +376,7 @@ LcdPlatformQueryMode (
   Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
   Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
 
-  switch (mDisplayModes[ModeNumber].Bpp) {
-  case LCD_BITS_PER_PIXEL_24:
-    Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
-    Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
-    Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
-    Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
-    Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
-    break;
-
-  case LCD_BITS_PER_PIXEL_16_555:
-  case LCD_BITS_PER_PIXEL_16_565:
-  case LCD_BITS_PER_PIXEL_12_444:
-  case LCD_BITS_PER_PIXEL_8:
-  case LCD_BITS_PER_PIXEL_4:
-  case LCD_BITS_PER_PIXEL_2:
-  case LCD_BITS_PER_PIXEL_1:
-  default:
-    // These are not supported
-    ASSERT (FALSE);
-    break;
-  }
+  Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
 
   return EFI_SUCCESS;
 }
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 14/18] ARM/VExpressPkg: Reserving framebuffer at build
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (12 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 13/18] ARM/VExpressPkg: PL111 and HDLCD: Add PCD to select pixel format evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 16:02   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 15/18] ARM/VExpressPkg: New DP500/DP550/DP650 platform library evan.lloyd
                   ` (4 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak at arm.com>

This change uses two PCDs, PcdArmLcdFrameBufferBase and
PcdArmLcdFrameBufferSize introduced in correspondiong EDK2 patch to
reserve framebuffer in DRAM if these values are defined in platform
specific DSC file, avoiding the need to allocate dynamically.
This allows the framebuffer to appear as "I/O memory" outside of the
normal RAM map, which is similar to the "VRAM" case.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf |  4 +++-
 Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c          | 20 ++++++++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
index 4cbd2ff4b4faf11ccd4fe30117708d7cc4c1bf0e..c70c4ce64826174e6d15611de640ad3b902835b9 100644
--- a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
+++ b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
@@ -1,5 +1,5 @@
 #/* @file
-#  Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+#  Copyright (c) 2011-2017, ARM Limited. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -57,6 +57,8 @@ [FixedPcd]
   gArmTokenSpaceGuid.PcdArmPrimaryCore
 
   gArmPlatformTokenSpaceGuid.PcdCoreCount
+  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
+  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
 
 [Ppis]
   gArmMpCoreInfoPpiGuid
diff --git a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
index 6379e81751fca5e7972c5c30f305be65fd1ae71d..1e8f3205312ebf30fa1666130bc944261384359a 100644
--- a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
+++ b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
@@ -1,6 +1,6 @@
 /** @file
 *
-*  Copyright (c) 2011-2016, ARM Limited. All rights reserved.
+*  Copyright (c) 2011-2017, ARM Limited. All rights reserved.
 *
 *  This program and the accompanying materials
 *  are licensed and made available under the terms and conditions of the BSD License
@@ -20,8 +20,10 @@
 #include <Library/MemoryAllocationLib.h>
 #include <ArmPlatform.h>
 
+#define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0) ? 1 : 0)
+
 // Number of Virtual Memory Map Descriptors
-#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS          9
+#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR)
 
 // DDR attributes
 #define DDR_ATTRIBUTES_CACHED   ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
@@ -142,6 +144,20 @@ ArmPlatformGetVirtualMemoryMap (
   //
   VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
 
+  // Map region for the frame buffer in the system RAM
+#if (FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize) != 0)
+  VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
+  VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
+  VirtualMemoryTable[Index].Length = FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
+  // Map as Normal Non-Cacheable memory, so that we can use the accelerated
+  // SetMem/CopyMem routines that may use unaligned accesses or
+  // DC ZVA instructions. If mapped as device memory, these routine may cause
+  // alignment faults.
+  // NOTE: The attribute value is misleading, it indicates memory map type as
+  // an un-cached, un-buffered but allows buffering and reordering.
+  VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
+#endif
+
   // Map sparse memory region if present
   if (HasSparseMemory) {
     VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 15/18] ARM/VExpressPkg: New DP500/DP550/DP650 platform library.
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (13 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 14/18] ARM/VExpressPkg: Reserving framebuffer at build evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 16:07   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 16/18] ARM/JunoPkg: Mapping Non-Trused SRAM as device memory evan.lloyd
                   ` (3 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak at arm.com>

This change adds LcdPlatformLib implementation for ARM Mali
DP500/DP500/DP650 display processors for models (with DP550 support).

NOTE: Versions for actual hardware are liable to require extra handling
for clock input changes, etc.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
---
 Platform/ARM/VExpressPkg/ArmVExpressPkg.dec                            |   3 +-
 Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf         |  45 +++
 Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf |   3 +
 Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c           | 374 ++++++++++++++++++++
 Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c          |  10 +-
 5 files changed, 433 insertions(+), 2 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/ArmVExpressPkg.dec b/Platform/ARM/VExpressPkg/ArmVExpressPkg.dec
index 695553a94f7f7e963b5db995c5e54f1ae1559daf..a82bc905b3a2180e85f78a6c16aeba9fcb495bed 100644
--- a/Platform/ARM/VExpressPkg/ArmVExpressPkg.dec
+++ b/Platform/ARM/VExpressPkg/ArmVExpressPkg.dec
@@ -1,7 +1,7 @@
 #/** @file
 # Arm Versatile Express package.
 #
-#  Copyright (c) 2012-2015, ARM Limited. All rights reserved.
+#  Copyright (c) 2012-2017, ARM Limited. All rights reserved.
 #
 #  This program and the accompanying materials are licensed and made available
 #  under the terms and conditions of the BSD License which accompanies this
@@ -51,6 +51,7 @@ [PcdsFixedAtBuild.common]
   gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId|1|UINT32|0x00000003
 
   gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId|0|UINT32|0x00000005
+  gArmVExpressTokenSpaceGuid.PcdArmMaliDpMaxMode|0|UINT32|0x00000008
 
   #
   # Device path of block device on which Fastboot will flash partitions
diff --git a/Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf b/Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
new file mode 100644
index 0000000000000000000000000000000000000000..4c8f3c3b3b6540505fce173ef16e2f3eafeb048b
--- /dev/null
+++ b/Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
@@ -0,0 +1,45 @@
+#/** @file ArmMaliDpLib.inf
+#
+#  Component description file for ArmMaliDpLib module
+#
+#  Copyright (c) 2017, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution.  The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#**/
+
+[Defines]
+  INF_VERSION                    = 0x00010019
+  BASE_NAME                      = ArmMaliDpLib
+  FILE_GUID                      = 36C47FED-2F3F-49C7-89CE-31B13F0431D8
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = LcdPlatformLib
+
+[Sources.common]
+  ArmMaliDpLib.c
+
+[Packages]
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  MdePkg/MdePkg.dec
+  Platform/ARM/VExpressPkg/ArmVExpressPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  DxeServicesTableLib
+
+[FixedPcd.common]
+  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
+  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
+  gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
+
+  # MaxMode must be one number higher than the actual max mode,
+  # i.e. for actual maximum mode 2, set the value to 3.
+  # See Section 12.9 of the UEFI Specification 2.7
+  gArmVExpressTokenSpaceGuid.PcdArmMaliDpMaxMode
+
diff --git a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
index c70c4ce64826174e6d15611de640ad3b902835b9..c2d8749d0c08d6afc71f7c41a27075d58ff27557 100644
--- a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
+++ b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
@@ -60,5 +60,8 @@ [FixedPcd]
   gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
   gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
 
+  gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase
+  gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength
+
 [Ppis]
   gArmMpCoreInfoPpiGuid
diff --git a/Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c b/Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
new file mode 100644
index 0000000000000000000000000000000000000000..63f7c3b874b4fea80ab81c396a08e3e2e9b0581c
--- /dev/null
+++ b/Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
@@ -0,0 +1,374 @@
+/** @file ArmMaliDpLib.c
+
+  The file contains ARM Mali DP platform specific implementation.
+
+  Copyright (c) 2017, ARM Ltd. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiDxe.h>
+#include <ArmPlatform.h>
+#include <Library/DebugLib.h>
+#include <Library/DxeServicesTableLib.h>
+#include <Library/LcdPlatformLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+/** Check an address is within 40 bits.
+
+  The ARM Mali DP framebuffer address size can not be wider than 40 bits
+**/
+#define  DP_VALID_BASE_ADDR(Address)  ((Address >> 40) == 0)
+
+typedef struct {
+  UINT32                      OscFreq;
+  SCAN_TIMINGS                Horizontal;
+  SCAN_TIMINGS                Vertical;
+} DISPLAY_MODE;
+
+/** The display modes implemented by this driver.
+
+  On Models, the OSC frequencies (listed for each mode below) are not used.
+  However these frequencies are useful on hardware plaforms where related
+  clock (or PLL) settings are based on these pixel clocks.
+
+  Since the clock settings are defined externally, the driver must
+  communicate pixel clock frequencies to relevant modules
+  responsible for setting clocks. e.g. SCP.
+**/
+STATIC CONST DISPLAY_MODE mDisplayModes[] = {
+  {
+    // Mode 0 : VGA : 640 x 480 x 24 bpp.
+    VGA_OSC_FREQUENCY,
+    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
+    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 1 : WVGA : 800 x 480 x 24 bpp.
+    WVGA_OSC_FREQUENCY,
+    {WVGA_H_RES_PIXELS, WVGA_H_SYNC, WVGA_H_BACK_PORCH, WVGA_H_FRONT_PORCH},
+    {WVGA_V_RES_PIXELS, WVGA_V_SYNC, WVGA_V_BACK_PORCH, WVGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 2 : SVGA : 800 x 600 x 24 bpp.
+    SVGA_OSC_FREQUENCY,
+    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
+    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 3 : QHD : 960 x 540 x 24 bpp.
+    QHD_OSC_FREQUENCY,
+    {QHD_H_RES_PIXELS, QHD_H_SYNC, QHD_H_BACK_PORCH, QHD_H_FRONT_PORCH},
+    {QHD_V_RES_PIXELS, QHD_V_SYNC, QHD_V_BACK_PORCH, QHD_V_FRONT_PORCH}
+  },
+  {
+    // Mode 4 : WSVGA : 1024 x 600 x 24 bpp.
+    WSVGA_OSC_FREQUENCY,
+    {WSVGA_H_RES_PIXELS, WSVGA_H_SYNC, WSVGA_H_BACK_PORCH, WSVGA_H_FRONT_PORCH},
+    {WSVGA_V_RES_PIXELS, WSVGA_V_SYNC, WSVGA_V_BACK_PORCH, WSVGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 5 : XGA : 1024 x 768 x 24 bpp.
+    XGA_OSC_FREQUENCY,
+    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 6 : HD : 1280 x 720 x 24 bpp.
+    HD720_OSC_FREQUENCY,
+    {HD720_H_RES_PIXELS, HD720_H_SYNC, HD720_H_BACK_PORCH, HD720_H_FRONT_PORCH},
+    {HD720_V_RES_PIXELS, HD720_V_SYNC, HD720_V_BACK_PORCH, HD720_V_FRONT_PORCH}
+  },
+  {
+    // Mode 7 : WXGA : 1280 x 800 x 24 bpp.
+    WXGA_OSC_FREQUENCY,
+    {WXGA_H_RES_PIXELS, WXGA_H_SYNC, WXGA_H_BACK_PORCH, WXGA_H_FRONT_PORCH},
+    {WXGA_V_RES_PIXELS, WXGA_V_SYNC, WXGA_V_BACK_PORCH, WXGA_V_FRONT_PORCH}
+  },
+  { // Mode 8 : SXGA : 1280 x 1024 x 24 bpp.
+    SXGA_OSC_FREQUENCY,
+    {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
+    {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
+  },
+  { // Mode 9 : WSXGA+ : 1680 x 1050 x 24 bpp.
+    WSXGA_OSC_FREQUENCY,
+    {WSXGA_H_RES_PIXELS, WSXGA_H_SYNC, WSXGA_H_BACK_PORCH, WSXGA_H_FRONT_PORCH},
+    {WSXGA_V_RES_PIXELS,WSXGA_V_SYNC, WSXGA_V_BACK_PORCH, WSXGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 10 : HD : 1920 x 1080 x 24 bpp.
+    HD_OSC_FREQUENCY,
+    {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
+    {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
+  }
+};
+
+/** If PcdArmMaliDpMaxMode is 0, platform supports full range of modes
+  else platform supports modes from 0 to PcdArmMaliDpMaxMode - 1
+**/
+STATIC CONST UINT32 mMaxMode = ((FixedPcdGet32 (PcdArmMaliDpMaxMode) != 0)
+                                   ? FixedPcdGet32 (PcdArmMaliDpMaxMode)
+                                   : sizeof (mDisplayModes) / sizeof (DISPLAY_MODE));
+
+/** Platform related initialization function.
+
+  @param[in] Handle             Handle to the instance of the device.
+
+  @retval EFI_SUCCESS           Initialization of platform library successful.
+  @retval EFI_UNSUPPORTED       PcdGopPixelFormat must be
+                                PixelRedGreenBlueReserved8BitPerColor OR
+                                PixelBlueGreenRedReserved8BitPerColor
+                                any other format is not supported.
+**/
+EFI_STATUS
+LcdPlatformInitializeDisplay (
+  IN CONST EFI_HANDLE   Handle
+  )
+{
+  EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
+
+  (VOID)Handle;
+
+  // PixelBitMask and PixelBltOnly pixel formats are not supported
+  PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
+  if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
+    && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
+
+    ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
+      ||  PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
+   return EFI_UNSUPPORTED;
+  }
+
+  return EFI_SUCCESS;
+}
+
+/* Internal helper function to allocate memory if memory is not already
+  reserved for framebuffer
+
+  @param[in]  VramSize          Requested framebuffer size in bytes.
+  @param[out] VramBaseAddress   Pointer to memory allocated for framebuffer.
+
+  @retval EFI_SUCCESS           Framebuffer memory allocated successfully.
+  @retval EFI_UNSUPPORTED       Allocated address wider than 40 bits.
+  @retval !EFI_SUCCESS          Other errors.
+**/
+STATIC
+EFI_STATUS
+GetVram (
+  IN  UINTN                 CONST  VramSize,
+  OUT EFI_PHYSICAL_ADDRESS *CONST  VramBaseAddress
+  )
+{
+  EFI_STATUS Status;
+
+  // Check if memory is already reserved for the framebuffer.
+#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)
+
+#if (!DP_VALID_BASE_ADDR (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase)))
+#error ARM Mali DP framebuffer base address cannot be wider than 40 bits.
+#else
+  *VramBaseAddress =
+    (EFI_PHYSICAL_ADDRESS)FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
+
+  Status = EFI_SUCCESS;
+#endif
+
+#else
+  // If not already reserved, attempt to allocate the VRAM from the DRAM.
+  Status = gBS->AllocatePages (
+                  AllocateAnyPages,
+                  EfiBootServicesData,
+                  EFI_SIZE_TO_PAGES (*VramSize),
+                  VramBaseAddress
+                  );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "ArmMaliDpLib: Failed to allocate framebuffer.\n"));
+    ASSERT (FALSE);
+    return Status;
+  }
+
+  // ARM Mali DP framebuffer base address can not be wider than 40 bits.
+  if (!DP_VALID_BASE_ADDR (*VramBaseAddress)) {
+    gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
+    ASSERT (DP_VALID_BASE_ADDR (*VramBaseAddress));
+    return EFI_UNSUPPORTED;
+  }
+
+  // Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is
+  // cacheable, for ARM/AArch64 EFI_MEMORY_WC memory is actually uncached.
+  Status = gDS->SetMemorySpaceAttributes (
+                  *VramBaseAddress,
+                  *VramSize,
+                  EFI_MEMORY_WC
+                  );
+  if (EFI_ERROR (Status)) {
+    ASSERT (FALSE);
+    gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
+  }
+#endif
+
+  return Status;
+}
+
+/** Allocate VRAM memory in DRAM for the framebuffer
+  (unless it is reserved already).
+
+  The allocated address can be used to set the framebuffer as a base buffer
+  address for any layer of the ARM Mali DP.
+
+  @param[out] VramBaseAddress     A pointer to the framebuffer address.
+  @param[out] VramSize            A pointer to the size of the frame
+                                  buffer in bytes
+
+  @retval EFI_SUCCESS             Frame buffer memory allocation success.
+  @retval EFI_UNSUPPORTED         Allocated address wider than 40 bits
+  @retval !EFI_SUCCESS            Other errors.
+**/
+EFI_STATUS
+LcdPlatformGetVram (
+  OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
+  OUT UINTN                * CONST VramSize
+  )
+{
+  ASSERT (VramBaseAddress != NULL);
+  ASSERT (VramSize != NULL);
+
+  // Set the VRAM size.
+  *VramSize = (UINTN)FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
+
+  return GetVram (*VramSize, VramBaseAddress);
+}
+
+/** Return total number of modes supported.
+
+  Note: Valid mode numbers are 0 to MaxMode - 1
+  See Section 12.9 of the UEFI Specification 2.7
+
+  @retval UINT32             Mode Number.
+**/
+UINT32
+LcdPlatformGetMaxMode (VOID)
+{
+  return  mMaxMode;
+}
+
+/** Set the requested display mode.
+
+  @param[in] ModeNumber            Mode Number.
+
+  @retval EFI_SUCCESS              Mode set successful.
+  @retval EFI_INVALID_PARAMETER    Requested mode not found.
+**/
+EFI_STATUS
+LcdPlatformSetMode (
+  IN CONST UINT32 ModeNumber
+  )
+{
+
+  if (ModeNumber >= mMaxMode) {
+    ASSERT (ModeNumber < mMaxMode);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  // On models, platform specific clock/mux settings are not required.
+  // Display controller specific settings for Mali DP are done in LcdSetMode.
+  return EFI_SUCCESS;
+}
+
+/** Return information for the requested mode number.
+
+  @param[in]  ModeNumber          Mode Number.
+  @param[out] Info                Pointer for returned mode information
+                                  (on success).
+
+  @retval EFI_SUCCESS             Display mode information of the requested
+                                  mode returned successfully.
+**/
+EFI_STATUS
+LcdPlatformQueryMode (
+  IN  CONST UINT32                                 ModeNumber,
+  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
+  )
+{
+  ASSERT (ModeNumber < mMaxMode);
+  ASSERT (Info != NULL);
+
+  Info->Version = 0;
+  Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
+  Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
+  Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
+
+  Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
+
+  return EFI_SUCCESS;
+}
+
+/** Return the display timing information for the requested mode number.
+
+  @param[in]  ModeNumber         Mode Number.
+
+  @param[out] Horizontal         Pointer to horizontal timing parameters.
+                                 (Resolution, Sync, Back porch, Front porch)
+  @param[out] Vertical           Pointer to vertical timing parameters.
+                                 (Resolution, Sync, Back porch, Front porch)
+
+  @retval EFI_SUCCESS             Display timing information of the requested
+                                  mode returned successfully.
+  @retval EFI_INVALID_PARAMETER   Requested mode not found.
+**/
+EFI_STATUS
+LcdPlatformGetTimings (
+  IN  UINT32                ModeNumber,
+  OUT CONST SCAN_TIMINGS ** Horizontal,
+  OUT CONST SCAN_TIMINGS ** Vertical
+  )
+{
+  ASSERT (Horizontal != NULL);
+  ASSERT (Vertical != NULL);
+
+  if (ModeNumber >= mMaxMode) {
+    ASSERT (ModeNumber < mMaxMode);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
+  *Vertical = &mDisplayModes[ModeNumber].Vertical;
+
+  return EFI_SUCCESS;
+}
+
+/** Return bits per pixel information for a mode number.
+
+  @param[in]  ModeNumber          Mode Number.
+  @param[out] Bpp                 Pointer to value Bytes Per Pixel.
+
+  @retval EFI_SUCCESS             Bits per pixel information of the display
+                                  mode returned successfully.
+  @retval EFI_INVALID_PARAMETER   Requested mode not found.
+**/
+EFI_STATUS
+LcdPlatformGetBpp (
+  IN  CONST UINT32    ModeNumber,
+  OUT LCD_BPP * CONST Bpp
+  )
+{
+  ASSERT (Bpp != NULL);
+  if (ModeNumber >= mMaxMode) {
+    // Check valid ModeNumber.
+    ASSERT (ModeNumber < mMaxMode);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  *Bpp = LCD_BITS_PER_PIXEL_24;
+
+  return EFI_SUCCESS;
+}
diff --git a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
index 1e8f3205312ebf30fa1666130bc944261384359a..f0b482f91a84d91ac9914c18b7941dd32ab8c8a7 100644
--- a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
+++ b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
@@ -21,9 +21,10 @@
 #include <ArmPlatform.h>
 
 #define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0) ? 1 : 0)
+#define DP_BASE_DESCRIPTOR      ((FixedPcdGet64 (PcdArmMaliDpBase) != 0) ? 1 : 0)
 
 // Number of Virtual Memory Map Descriptors
-#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR)
+#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR + DP_BASE_DESCRIPTOR)
 
 // DDR attributes
 #define DDR_ATTRIBUTES_CACHED   ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
@@ -158,6 +159,13 @@ ArmPlatformGetVirtualMemoryMap (
   VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
 #endif
 
+#if (FixedPcdGet64 (PcdArmMaliDpBase) != 0)
+  // DP500/DP550/DP650 peripheral memory region
+  VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdArmMaliDpBase);
+  VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64 (PcdArmMaliDpBase);
+  VirtualMemoryTable[Index].Length = FixedPcdGet32 (PcdArmMaliDpMemoryRegionLength);
+  VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
+#endif
   // Map sparse memory region if present
   if (HasSparseMemory) {
     VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 16/18] ARM/JunoPkg: Mapping Non-Trused SRAM as device memory
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (14 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 15/18] ARM/VExpressPkg: New DP500/DP550/DP650 platform library evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 16:08   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 17/18] ARM/JunoPkg: Adding SCMI MTL library evan.lloyd
                   ` (2 subsequent siblings)
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak@arm.com>

This fix changes the cache attribute of Non-Trusted SRAM on the Juno
platform to device memory. This change is required to avoid coherency
problems as Non-Trusted SRAM is used as a shared memory between the
application processor and the SCP for communication. This change is a
prerequisite for upcoming SCMI driver for the Juno platform.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
---
 Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
index aa8d7d9c3b0d41e62d1849e6e88760e3066617f7..afb2db0050c65b0d1b2b69c9038e168755c152c1 100644
--- a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
+++ b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
@@ -1,6 +1,6 @@
 /** @file
 *
-*  Copyright (c) 2013-2015, ARM Limited. All rights reserved.
+*  Copyright (c) 2013-2017, ARM Limited. All rights reserved.
 *
 *  This program and the accompanying materials
 *  are licensed and made available under the terms and conditions of the BSD License
@@ -111,7 +111,9 @@ ArmPlatformGetVirtualMemoryMap (
   VirtualMemoryTable[++Index].PhysicalBase  = ARM_JUNO_NON_SECURE_SRAM_BASE;
   VirtualMemoryTable[Index].VirtualBase     = ARM_JUNO_NON_SECURE_SRAM_BASE;
   VirtualMemoryTable[Index].Length          = ARM_JUNO_NON_SECURE_SRAM_SZ;
-  VirtualMemoryTable[Index].Attributes      = CacheAttributes;
+  // This memory is shared between the application processor
+  // and the SCP. To avoid coherency problems, map it as device memory.
+  VirtualMemoryTable[Index].Attributes      = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
 
   // PCI Root Complex
   VirtualMemoryTable[++Index].PhysicalBase  = PcdGet64 (PcdPcieControlBaseAddress);
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 17/18] ARM/JunoPkg: Adding SCMI MTL library
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (15 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 16/18] ARM/JunoPkg: Mapping Non-Trused SRAM as device memory evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 16:12   ` Ard Biesheuvel
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library evan.lloyd
  2017-12-22 19:29 ` [PATCH edk2-platforms v2 00/18] ARM: Update GOP Ard Biesheuvel
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak@arm.com>

This change adds a new Mailbox Transport Layer library for the Juno
platform. This library is required for ArmScmiDxe driver communication
with the SCP.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
---
 Platform/ARM/JunoPkg/ArmJuno.dec                    |   9 +-
 Platform/ARM/JunoPkg/ArmJuno.dsc                    |   3 +
 Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf      |  39 ++++
 Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h |  94 ++++++++++
 Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c        | 195 ++++++++++++++++++++
 5 files changed, 339 insertions(+), 1 deletion(-)

diff --git a/Platform/ARM/JunoPkg/ArmJuno.dec b/Platform/ARM/JunoPkg/ArmJuno.dec
index 60cef6d23a2d904103b9806d871fd2b89fff51c3..b733480c3198d135df16ca024b5e85ff350e11c7 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.dec
+++ b/Platform/ARM/JunoPkg/ArmJuno.dec
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2013-2015, ARM Limited. All rights reserved.
+#  Copyright (c) 2013-2017, ARM Limited. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -46,3 +46,10 @@ [PcdsFixedAtBuild.common]
   # Juno Device Trees are loaded from NOR Flash
   gArmJunoTokenSpaceGuid.PcdJunoFdtDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/board.dtb"|VOID*|0x00000008
 
+  # MHU Register base used by SCMI Mailbox transport
+  gArmJunoTokenSpaceGuid.PcdArmMtlDoorBell|0x2B1F0000|UINT64|0x00000024
+
+  # ARM_JUNO_NON_SECURE_SRAM_BASE used by SCMI Mailbox transport
+  gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase|0x2E000000|UINT64|0x00000025
+  gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize|0x80|UINT32|0x00000026
+
diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc b/Platform/ARM/JunoPkg/ArmJuno.dsc
index 5c2a29fe8330bbf308e31e34b617517a5aebcf6d..fe860956a4dc497cac52be70bab3657246a08bd0 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.dsc
+++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
@@ -47,6 +47,9 @@ [LibraryClasses.common]
   # USB Requirements
   UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
 
+  # SCMI Mailbox Transport Layer
+  ArmMtl|Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
+
 [LibraryClasses.common.SEC]
   PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
   ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
diff --git a/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf b/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
new file mode 100644
index 0000000000000000000000000000000000000000..69e845f93f9332205fd5d36af2753681304058e3
--- /dev/null
+++ b/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
@@ -0,0 +1,39 @@
+#/** @file
+#  Copyright (c) 2017, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution.  The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#**/
+
+[Defines]
+  INF_VERSION                    = 0x00010019
+  BASE_NAME                      = ArmMtl
+  FILE_GUID                      = 21FB2D8F-C6C8-4B2C-A616-A30CB2FBA277
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = ArmMtl
+
+[Sources.common]
+  ArmMtl.c
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  MdePkg/MdePkg.dec
+  Platform/ARM/JunoPkg/ArmJuno.dec
+
+[LibraryClasses]
+  ArmLib
+  DebugLib
+  IoLib
+  UefiBootServicesTableLib
+
+[FixedPcd.common]
+  gArmJunoTokenSpaceGuid.PcdArmMtlDoorBell
+  gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase
+  gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize
diff --git a/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h b/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h
new file mode 100644
index 0000000000000000000000000000000000000000..825fc788722bbe01ede24d9f867565c4c1dc938b
--- /dev/null
+++ b/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h
@@ -0,0 +1,94 @@
+/** @file
+
+  Copyright (c) 2017, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  System Control and Management Interface V1.0
+    http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
+    DEN0056A_System_Control_and_Management_Interface.pdf
+
+  Juno ARM Development Platform SoC
+    https://www.arm.com/files/pdf/
+    DDI0515D1a_juno_arm_development_platform_soc_trm.pdf
+**/
+
+#ifndef ARM_MTL_PRIVATE_H_
+#define ARM_MTL_PRIVATE_H_
+
+// Mailbox transport layer.
+#define MTL_DOORBELL_MODIFY_MASK   (0x00000001U)
+#define MTL_DOORBELL_PRESERVE_MASK (~MTL_DOORBELL_MODIFY_MASK)
+
+#define MTL_DOORBELL_BASE    (FixedPcdGet64 (PcdArmMtlDoorBell))
+#define MTL_MAILBOX_BASE     (FixedPcdGet64 (PcdArmMtlMailBoxBase))
+#define MTL_MAILBOX_SIZE     (FixedPcdGet32 (PcdArmMtlMailBoxSize))
+
+#define MTL_POLL         0
+#define MTL_INTR         1
+
+/* For Juno, the mailbox for high priority is non-trusted SRAM + 256.
+
+   NOTE: Below is not documented anywhere (yet)
+
+   The payload sizes are 128 bytes.
+
+   There are two channels:
+
+   Channel 0
+    - Agent (OS) to Platform (SCP) memory base: non-trusted SRAM + 0
+    - Platform (SCP) to Agent (OS) memory base: non-trusted SRAM + 128
+    - Doorbell (both directions): MHU, bit 0
+
+   Channel 1
+    - Agent (OS) to Platform (SCP) memory base: non-trusted SRAM + 256
+    - Platform (SCP) to Agent (OS) memory base: non-trusted SRAM + 384
+    - Doorbell (both directions): MHU, bit 0
+*/
+#define MTL_MAILBOX_HIGH_PRIORITY_OFFSET (MTL_MAILBOX_SIZE * 2)
+
+// ARM MHU interrupt registers.
+#define CPU_INTR_L_SET  0x108
+#define CPU_INTR_H_SET  0x128
+
+// MTL uses MHU interrupt registers for communication with the SCP.
+#define MTL_DOORBELL_REGISTER_LOW   (MTL_DOORBELL_BASE + CPU_INTR_L_SET)
+#define MTL_DOORBELL_REGISTER_HIGH  (MTL_DOORBELL_BASE + CPU_INTR_H_SET)
+
+#define MTL_CHANNEL_BUSY    0
+#define MTL_CHANNEL_FREE    1
+
+// Response timeout value on a MHU channel 20ms.
+#define  RESPONSE_TIMEOUT  20000
+
+/* As per SCMI spec. as a agent UEFI(or OS) can access only two channels
+   (low or high priority) secure channel is only accessible
+   to ARM Trusted firmware. */
+#define  NUM_CHANNELS      2
+
+/* Each channel must use a doorbell register to interrupt the SCP firmware.
+   on Juno these are MHU interrupt registers for low and high priority
+   channels. */
+#define  DOORBELL_LOW   {                                \
+                          MTL_DOORBELL_REGISTER_LOW,     \
+                          MTL_DOORBELL_MODIFY_MASK,      \
+                          MTL_DOORBELL_PRESERVE_MASK     \
+                        }
+
+#define  DOORBELL_HIGH  {                                \
+                          MTL_DOORBELL_REGISTER_HIGH,    \
+                          MTL_DOORBELL_MODIFY_MASK,      \
+                          MTL_DOORBELL_PRESERVE_MASK     \
+                        }
+
+// Arbitarary poll time.
+#define MTL_POLL_WAIT_TIME 100
+
+#endif /* ARM_MTL_PRIVATE_H_ */
+
diff --git a/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c b/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c
new file mode 100644
index 0000000000000000000000000000000000000000..b5e469f9a51a8f739526c7eeb873c32403d191f9
--- /dev/null
+++ b/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c
@@ -0,0 +1,195 @@
+/** @file
+
+  Copyright (c) 2017, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  System Control and Management Interface V1.0
+    http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
+    DEN0056A_System_Control_and_Management_Interface.pdf
+**/
+
+#include <Uefi.h>
+#include <Library/ArmMtl.h>
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#include "ArmMtlPrivate.h"
+
+// Each channel has a shared mailbox and a doorbell register.
+STATIC CONST MTL_CHANNEL Channels[NUM_CHANNELS] = {
+    // Low priority channel.
+    {
+      MTL_CHANNEL_TYPE_LOW,
+      (MTL_MAILBOX*)(MTL_MAILBOX_BASE),
+      DOORBELL_LOW
+    },
+    // High priority channel
+    {
+      MTL_CHANNEL_TYPE_HIGH,
+      (MTL_MAILBOX*)(MTL_MAILBOX_BASE + MTL_MAILBOX_HIGH_PRIORITY_OFFSET),
+      DOORBELL_HIGH
+    }
+  };
+
+/** Wait until channel is free.
+
+  @param[in] Channel                Pointer to a channel.
+  @param[in] TimeOutInMicroSeconds  Time out in micro seconds.
+
+  @retval EFI_SUCCESS               Channel is free.
+  @retval EFI_TIMOUT                Time out error.
+**/
+EFI_STATUS
+MtlWaitUntilChannelFree (
+  IN MTL_CHANNEL  *Channel,
+  IN UINTN        TimeOutInMicroSeconds
+  )
+{
+  while (TimeOutInMicroSeconds != 0) {
+    // If channel is free then we have received the reply.
+    if (Channel->MailBox->ChannelStatus == MTL_CHANNEL_FREE) {
+      return EFI_SUCCESS;
+    }
+    if (TimeOutInMicroSeconds < MTL_POLL_WAIT_TIME) {
+      gBS->Stall (TimeOutInMicroSeconds);
+      break;
+    }
+    // Wait for some arbitrary time.
+    gBS->Stall (MTL_POLL_WAIT_TIME);
+    TimeOutInMicroSeconds -= MTL_POLL_WAIT_TIME;
+  }
+
+  // No response from SCP.
+  if (Channel->MailBox->ChannelStatus != MTL_CHANNEL_FREE) {
+    ASSERT (FALSE);
+    return EFI_TIMEOUT;
+  }
+
+  return EFI_SUCCESS;
+}
+
+/** Return the address of the message payload.
+
+  @param[in] Channel   Pointer to a channel.
+
+  @retval UINT32*      Pointer to the payload.
+**/
+UINT32*
+MtlGetChannelPayload (
+  IN  MTL_CHANNEL  *Channel
+  )
+{
+  return Channel->MailBox->Payload;
+}
+
+/** Return pointer to a channel for the requested channel type.
+
+  @param[in] ChannelType        ChannelType, Low or High priority channel.
+                                MTL_CHANNEL_TYPE_LOW or
+                                MTL_CHANNEL_TYPE_HIGH
+
+  @param[out] Channel           Holds pointer to the channel.
+
+  @retval EFI_SUCCESS           Pointer to channel is returned.
+  @retval EFI_UNSUPPORTED       Requested channel type not supported.
+**/
+EFI_STATUS
+MtlGetChannel (
+  IN  MTL_CHANNEL_TYPE  ChannelType,
+  OUT MTL_CHANNEL       **Channel
+  )
+{
+  if (ChannelType != MTL_CHANNEL_TYPE_LOW
+    && ChannelType != MTL_CHANNEL_TYPE_HIGH) {
+    return EFI_UNSUPPORTED;
+  }
+
+  *Channel = (MTL_CHANNEL*)&Channels[ChannelType];
+
+  return EFI_SUCCESS;
+}
+
+/** Mark the channel busy and ring the doorbell.
+
+  @param[in] Channel               Pointer to a channel.
+  @param[in] MessageHeader         Message header.
+
+  @param[out] PayloadLength        Message length.
+
+  @retval EFI_SUCCESS              Message sent successfully.
+  @retval EFI_DEVICE_ERROR         Channel is busy.
+**/
+EFI_STATUS
+MtlSendMessage (
+  IN  MTL_CHANNEL  *Channel,
+  IN  UINT32       MessageHeader,
+  OUT UINT32       PayloadLength
+  )
+{
+  MTL_MAILBOX *MailBox = Channel->MailBox;
+
+  if (Channel->MailBox->ChannelStatus != MTL_CHANNEL_FREE) {
+    return EFI_DEVICE_ERROR;
+  }
+
+  // Mark the channel busy before ringing doorbell.
+  Channel->MailBox->ChannelStatus = MTL_CHANNEL_BUSY;
+
+  MailBox->Flags         = MTL_POLL;
+  MailBox->MessageHeader = MessageHeader;
+
+  // Add length of message header.
+  MailBox->Length = PayloadLength + sizeof (MessageHeader);
+
+  // Ring the doorbell. It sets SET bit of the MHU register.
+  MmioWrite32 (
+    Channel->DoorBell.PhysicalAddress,
+    Channel->DoorBell.ModifyMask
+    );
+
+  return EFI_SUCCESS;
+}
+
+/** Wait for a response on a channel.
+
+  If channel is free after sending message, it implies SCP responded
+  with a response on the channel.
+
+  @param[in] Channel               Pointer to a channel.
+
+  @retval EFI_SUCCESS              Message received successfully.
+  @retval EFI_TIMOUT               Timeout error.
+**/
+EFI_STATUS
+MtlReceiveMessage (
+  IN  MTL_CHANNEL  *Channel,
+  OUT UINT32       *MessageHeader,
+  OUT UINT32       *PayloadLength
+  )
+{
+  EFI_STATUS Status;
+
+  MTL_MAILBOX *MailBox = Channel->MailBox;
+
+  Status = MtlWaitUntilChannelFree (Channel, RESPONSE_TIMEOUT);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  *MessageHeader = MailBox->MessageHeader;
+
+  // Deduct message header length.
+  *PayloadLength = MailBox->Length - sizeof (*MessageHeader);
+
+  return EFI_SUCCESS;
+}
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (16 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 17/18] ARM/JunoPkg: Adding SCMI MTL library evan.lloyd
@ 2017-12-22 19:08 ` evan.lloyd
  2017-12-23 16:22   ` Ard Biesheuvel
  2017-12-22 19:29 ` [PATCH edk2-platforms v2 00/18] ARM: Update GOP Ard Biesheuvel
  18 siblings, 1 reply; 57+ messages in thread
From: evan.lloyd @ 2017-12-22 19:08 UTC (permalink / raw)
  To: edk2-devel
  Cc: Arvind Chauhan, Daniil Egranov, Thomas Panakamattam Abraham,
	"ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
	"nd

From: Girish Pathak <girish.pathak@arm.com>

This change adds the HDLCD platform lib for the Juno plaform. This
library will be instantiated as a LcdPlatformLib to link with
LcdGraphicsOutputDxe for the Juno platform.

HDLCD platform library depends on the Arm SCMI DXE driver for
communication with the SCP for clock setting. Therefore this change also
enables building of Arm SCMI DXE driver for the Juno platform.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
---
 Platform/ARM/JunoPkg/ArmJuno.dec                                 |   8 +
 Platform/ARM/JunoPkg/ArmJuno.dsc                                 |  29 +
 Platform/ARM/JunoPkg/ArmJuno.fdf                                 |  12 +-
 Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf           |   5 +-
 Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf |  40 ++
 Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c             |  18 +-
 Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c      | 559 ++++++++++++++++++++
 7 files changed, 668 insertions(+), 3 deletions(-)

diff --git a/Platform/ARM/JunoPkg/ArmJuno.dec b/Platform/ARM/JunoPkg/ArmJuno.dec
index b733480c3198d135df16ca024b5e85ff350e11c7..cd6710feb2faf0bd17b5ea39a21dbe5406cd4ffd 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.dec
+++ b/Platform/ARM/JunoPkg/ArmJuno.dec
@@ -53,3 +53,11 @@ [PcdsFixedAtBuild.common]
   gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase|0x2E000000|UINT64|0x00000025
   gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize|0x80|UINT32|0x00000026
 
+  # MaxMode must be one number higher than the actual max mode,
+  # i.e. for actual maximum mode 2, set the value to 3.
+  #
+  # Default value zero allows platform to enumerate maximum supported mode.
+  #
+  # For a list of mode numbers look in HdLcdArmJuno.c
+  gArmJunoTokenSpaceGuid.PcdArmHdLcdMaxMode|0|UINT32|0x00000017
+
diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc b/Platform/ARM/JunoPkg/ArmJuno.dsc
index fe860956a4dc497cac52be70bab3657246a08bd0..9027c5b0728a6941f850636b3bc315fd33b867fb 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.dsc
+++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
@@ -50,6 +50,11 @@ [LibraryClasses.common]
   # SCMI Mailbox Transport Layer
   ArmMtl|Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
 
+!ifndef HEADLESS_PLATFORM
+  LcdPlatformLib|Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
+  LcdHwLib|ArmPlatformPkg/Library/HdLcd/HdLcd.inf
+!endif
+
 [LibraryClasses.common.SEC]
   PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
   ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
@@ -100,7 +105,15 @@ [PcdsFixedAtBuild.common]
 
   # System Memory (2GB - 16MB of Trusted DRAM at the top of the 32bit address space)
   gArmTokenSpaceGuid.PcdSystemMemoryBase|0x80000000
+
+!ifdef HEADLESS_PLATFORM
   gArmTokenSpaceGuid.PcdSystemMemorySize|0x7F000000
+!else
+  gArmTokenSpaceGuid.PcdSystemMemorySize|0x7B000000
+  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0xFB000000
+  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x04000000
+  gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect|TRUE
+!endif
 
   # Juno Dual-Cluster profile
   gArmPlatformTokenSpaceGuid.PcdCoreCount|6
@@ -142,6 +155,11 @@ [PcdsFixedAtBuild.common]
   gArmTokenSpaceGuid.PcdGicDistributorBase|0x2C010000
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x2C02F000
 
+!ifndef HEADLESS_PLATFORM
+  # ARM Juno HDLCD Base
+  gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x7FF60000
+!endif
+
   #
   # PLDA PCI Root Complex
   #
@@ -314,6 +332,11 @@ [Components.common]
   MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
   MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
 
+!ifndef HEADLESS_PLATFORM
+  # Graphic Output Protocol
+  ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
+!endif
+
   #
   # Juno platform driver
   #
@@ -347,6 +370,12 @@ [Components.common]
       BdsLib|Platform/ARM/Library/BdsLib/BdsLib.inf
   }
 
+  # SCMI Driver
+  ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf {
+    <LibraryClasses>
+      BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+  }
+
 [Components.AARCH64]
   #
   # EBC
diff --git a/Platform/ARM/JunoPkg/ArmJuno.fdf b/Platform/ARM/JunoPkg/ArmJuno.fdf
index ee9d0e7f4f6e6ac99ded6a14e88eb2c7854dd473..0b62760cbb3ff93490204ac636b41d5a867dfb80 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.fdf
+++ b/Platform/ARM/JunoPkg/ArmJuno.fdf
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2013-2015, ARM Limited. All rights reserved.
+#  Copyright (c) 2013-2017, ARM Limited. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -163,6 +163,13 @@ [FV.FvMain]
   INF MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouseDxe.inf
   INF MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
 
+!ifndef HEADLESS_PLATFORM
+  #
+  # Graphics Output Protocol
+  #
+  INF ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
+!endif
+
   #
   # PCI Support
   #
@@ -223,6 +230,9 @@ [FV.FvMain]
   # after the device drivers (eg: Ethernet) to ensure we have support for them.
   INF Platform/ARM/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf
 
+  # SCMI Driver
+  INF ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
+
 !if $(ARCH) == AARCH64
   #
   # EBC
diff --git a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf
index 2dd384daba3d6076ba4898a0251ebc91bc0beee2..f131035be684f22e9f4c00417759b7845b29dcc6 100644
--- a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf
+++ b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2013-2016, ARM Limited. All rights reserved.
+#  Copyright (c) 2013-2017, ARM Limited. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -57,6 +57,9 @@ [FixedPcd]
   gArmJunoTokenSpaceGuid.PcdPciConfigurationSpaceBaseAddress
   gArmJunoTokenSpaceGuid.PcdPciConfigurationSpaceSize
 
+  # Frame Buffer Memory
+  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
+  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
 
   #
   # PL011 Serial Debug UART
diff --git a/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
new file mode 100644
index 0000000000000000000000000000000000000000..a10bff135abf154484d36c67083b498846f24753
--- /dev/null
+++ b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
@@ -0,0 +1,40 @@
+#/** @file
+#
+#  Component description file for HdLcdArmJunoLib module
+#
+#  Copyright (c) 2013-2017, ARM Ltd. All rights reserved.<BR>
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution.  The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#**/
+
+[Defines]
+  INF_VERSION                    = 0x00010019
+  BASE_NAME                      = HdLcdArmJunoLib
+  FILE_GUID                      = 7B1D26F7-7B88-47ED-B193-DD3BDF319006
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = LcdPlatformLib
+
+[Sources.common]
+  HdLcdArmJuno.c
+
+[Packages]
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  MdePkg/MdePkg.dec
+  Platform/ARM/JunoPkg/ArmJuno.dec
+
+[LibraryClasses]
+  BaseLib
+
+[FixedPcd]
+  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
+  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
+  gArmJunoTokenSpaceGuid.PcdArmHdLcdMaxMode
+  gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
diff --git a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
index afb2db0050c65b0d1b2b69c9038e168755c152c1..baa5221cb906ed5d077414475da006cf2e5cafc5 100644
--- a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
+++ b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
@@ -21,8 +21,10 @@
 
 #include <ArmPlatform.h>
 
+#define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize) != 0) ? 1 : 0)
+
 // The total number of descriptors, including the final "end-of-table" descriptor.
-#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 16
+#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (16 + FRAME_BUFFER_DESCRIPTOR)
 
 // DDR attributes
 #define DDR_ATTRIBUTES_CACHED           ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
@@ -151,6 +153,20 @@ ArmPlatformGetVirtualMemoryMap (
   VirtualMemoryTable[Index].Length          = ARM_JUNO_SOC_PERIPHERALS_SZ;
   VirtualMemoryTable[Index].Attributes      = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
 
+  // Frame Buffer Memory
+#if (FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize) != 0)
+  VirtualMemoryTable[++Index].PhysicalBase  = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
+  VirtualMemoryTable[Index].VirtualBase     = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
+  VirtualMemoryTable[Index].Length          = FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
+  // Map as Normal Non-Cacheable memory, so that we can use the accelerated
+  // SetMem/CopyMem routines that may use unaligned accesses or
+  // DC ZVA instructions. If mapped as device memory, these routine may cause
+  // alignment faults.
+  // NOTE: The attribute value is misleading, it indicates memory map type as
+  // an un-cached, un-buffered but allows buffering and reordering.
+  VirtualMemoryTable[Index].Attributes      = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
+#endif
+
   // DDR - 2GB
   VirtualMemoryTable[++Index].PhysicalBase  = PcdGet64 (PcdSystemMemoryBase);
   VirtualMemoryTable[Index].VirtualBase     = PcdGet64 (PcdSystemMemoryBase);
diff --git a/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
new file mode 100644
index 0000000000000000000000000000000000000000..72be0a39846fb0a78ebcf3248b6c51377adf4f73
--- /dev/null
+++ b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
@@ -0,0 +1,559 @@
+/** @file
+
+  Copyright (c) 2013-2017, ARM Ltd. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiDxe.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DxeServicesTableLib.h>
+#include <Library/LcdPlatformLib.h>
+#include <Library/PcdLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Drivers/ArmScmi.h>
+#include <Drivers/ArmScmiClockProtocol.h>
+
+/* Display timings on Juno for 1920x1080.
+  On Juno due to instability of the PLLs, we set OSC
+  frequency to 138.5 MHz which is stable for most monitors.
+  Frequency 148.5MHz does not work with some monitors.
+  148.5 MHz is set by SCP firmware by default.
+
+#define JUNO_HD_OSC_FREQUENCY               148500000
+*/
+#define JUNO_HD_OSC_FREQUENCY               138500000
+#define JUNO_HD_H_SYNC                      ( 32 - 1)
+#define JUNO_HD_H_FRONT_PORCH               ( 48 - 1)
+#define JUNO_HD_H_BACK_PORCH                ( 80 - 1)
+#define JUNO_HD_V_SYNC                      (  5 - 1)
+#define JUNO_HD_V_FRONT_PORCH               (  3 - 1)
+#define JUNO_HD_V_BACK_PORCH                ( 23 - 1)
+
+/* SCMI defined clock device name and ID. This is not documented but
+   obtained using clock management protocol's CLOCK_ATTRIBUTES command.
+
+   Generally we must discover clock device ID using clock name and then
+   set/get rate using CLOCK_RATE_SET/CLOCK_RATE_GET commands. However
+   because LcdGraphicsOutputDxe is a DXE driver, which gets initialized
+   at boot time, for faster boot, in release build we will directly use
+   this already known value as an argument to rate get/set functions.
+
+   We expect these values not to change in future SCP firmware releases.
+
+   DEBUG build however will probe SCP firmware and discover clock device
+   ID for HDLCD.
+*/
+#define ARM_JUNO_CSS_CLK_NAME_HDLCD_0       "HDLCD_0"
+#define ARM_JUNO_CSS_CLKID_HDLCD_0           3
+
+typedef struct {
+  UINT32                      Mode;
+  UINT32                      OscFreq;
+  SCAN_TIMINGS                Horizontal;
+  SCAN_TIMINGS                Vertical;
+} DISPLAY_MODE;
+
+STATIC CONST DISPLAY_MODE mDisplayModes[] = {
+  {
+    // Mode 0 : VGA : 640 x 480 x 24 bpp.
+    VGA,
+    VGA_OSC_FREQUENCY,
+    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
+    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 1 : WVGA : 800 x 480 x 24 bpp.
+    WVGA,
+    WVGA_OSC_FREQUENCY,
+    {WVGA_H_RES_PIXELS, WVGA_H_SYNC, WVGA_H_BACK_PORCH, WVGA_H_FRONT_PORCH},
+    {WVGA_V_RES_PIXELS, WVGA_V_SYNC, WVGA_V_BACK_PORCH, WVGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 2 : SVGA : 800 x 600 x 24 bpp.
+    SVGA,
+    SVGA_OSC_FREQUENCY,
+    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
+    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 3 : QHD : 960 x 540 x 24 bpp.
+    QHD,
+    QHD_OSC_FREQUENCY,
+    {QHD_H_RES_PIXELS, QHD_H_SYNC, QHD_H_BACK_PORCH, QHD_H_FRONT_PORCH},
+    {QHD_V_RES_PIXELS, QHD_V_SYNC, QHD_V_BACK_PORCH, QHD_V_FRONT_PORCH}
+  },
+  {
+    // Mode 4 : WSVGA : 1024 x 600 x 24 bpp.
+    WSVGA,
+    WSVGA_OSC_FREQUENCY,
+    {WSVGA_H_RES_PIXELS, WSVGA_H_SYNC, WSVGA_H_BACK_PORCH, WSVGA_H_FRONT_PORCH},
+    {WSVGA_V_RES_PIXELS, WSVGA_V_SYNC, WSVGA_V_BACK_PORCH, WSVGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 5 : XGA : 1024 x 768 x 24 bpp.
+    XGA,
+    XGA_OSC_FREQUENCY,
+    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 6 : HD : 1280 x 720 x 24 bpp.
+    HD720,
+    HD720_OSC_FREQUENCY,
+    {HD720_H_RES_PIXELS, HD720_H_SYNC, HD720_H_BACK_PORCH, HD720_H_FRONT_PORCH},
+    {HD720_V_RES_PIXELS, HD720_V_SYNC, HD720_V_BACK_PORCH, HD720_V_FRONT_PORCH}
+  },
+  {
+    // Mode 7 : WXGA : 1280 x 800 x 24 bpp.
+    WXGA,
+    WXGA_OSC_FREQUENCY,
+    {WXGA_H_RES_PIXELS, WXGA_H_SYNC, WXGA_H_BACK_PORCH, WXGA_H_FRONT_PORCH},
+    {WXGA_V_RES_PIXELS, WXGA_V_SYNC, WXGA_V_BACK_PORCH, WXGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 8 : SXGA : 1280 x 1024 x 24 bpp.
+    SXGA,
+    SXGA_OSC_FREQUENCY,
+    {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
+    {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 9 : WSXGA+ : 1680 x 1050 x 24 bpp.
+    WSXGA,
+    WSXGA_OSC_FREQUENCY,
+    {WSXGA_H_RES_PIXELS, WSXGA_H_SYNC, WSXGA_H_BACK_PORCH, WSXGA_H_FRONT_PORCH},
+    {WSXGA_V_RES_PIXELS, WSXGA_V_SYNC, WSXGA_V_BACK_PORCH, WSXGA_V_FRONT_PORCH}
+  },
+  {
+    // Mode 10 : HD : 1920 x 1080 x 24 bpp.
+    HD,
+    JUNO_HD_OSC_FREQUENCY,
+    {HD_H_RES_PIXELS, JUNO_HD_H_SYNC, JUNO_HD_H_BACK_PORCH, JUNO_HD_H_FRONT_PORCH},
+    {HD_V_RES_PIXELS, JUNO_HD_V_SYNC, JUNO_HD_V_BACK_PORCH, JUNO_HD_V_FRONT_PORCH}
+  }
+};
+
+/* If PcdArmMaliDpMaxMode is 0, platform supports full range of modes
+   else platform supports modes from 0 to PcdArmHdLcdMaxMode - 1
+*/
+STATIC CONST UINT32 mMaxMode = ((FixedPcdGet32 (PcdArmHdLcdMaxMode) != 0)
+                                   ? FixedPcdGet32 (PcdArmHdLcdMaxMode)
+                                   : sizeof (mDisplayModes) / sizeof (DISPLAY_MODE));
+
+/** HDLCD platform specific initialization function.
+
+  @param[in] Handle              Handle to the LCD device instance.
+
+  @retval EFI_SUCCESS            Plaform library initialized successfully.
+  @retval EFI_UNSUPPORTED        PcdGopPixelFormat must be
+                                 PixelRedGreenBlueReserved8BitPerColor OR
+                                 PixelBlueGreenRedReserved8BitPerColor
+                                 any other format is not supported.
+  @retval !(EFI_SUCCESS)         Other errors.
+**/
+EFI_STATUS
+LcdPlatformInitializeDisplay (
+  IN CONST EFI_HANDLE   Handle
+  )
+{
+  (VOID)Handle;
+  EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
+
+  // PixelBitMask and PixelBltOnly pixel formats are not supported.
+  PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
+  if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
+    && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
+
+    ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
+      ||  PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
+   return EFI_UNSUPPORTED;
+  }
+
+  return EFI_SUCCESS;
+}
+
+/** Allocate VRAM memory in DRAM for the frame buffer
+  (unless it is reserved already).
+
+  The allocated address can be used to set the frame buffer.
+
+  @param[out] VramBaseAddress     A pointer to the frame buffer address.
+  @param[out] VramSize            A pointer to the size of the frame
+                                  buffer in bytes
+
+  @retval EFI_SUCCESS             Frame buffer memory allocated successfully.
+  @retval !(EFI_SUCCESS)          Other errors.
+**/
+EFI_STATUS
+LcdPlatformGetVram (
+  OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
+  OUT UINTN                * CONST VramSize
+  )
+{
+  EFI_STATUS      Status = EFI_SUCCESS;
+
+  ASSERT (VramBaseAddress != NULL);
+  ASSERT (VramSize != NULL);
+
+  // Set the VRAM size.
+  *VramSize = (UINTN)FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
+
+  // Check if memory is already reserved for the frame buffer.
+#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)
+  *VramBaseAddress =
+     (EFI_PHYSICAL_ADDRESS)FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
+#else
+  // If not already reserved, attempt to allocate the VRAM from the DRAM.
+  Status = gBS->AllocatePages (
+                  AllocateAnyPages,
+                  EfiBootServicesData,
+                  EFI_SIZE_TO_PAGES (*VramSize),
+                  VramBaseAddress
+                  );
+
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "HdLcdArmJuno: Failed to allocate frame buffer.\n"));
+    ASSERT_EFI_ERROR (Status);
+    return Status;
+  }
+
+  /* Mark the VRAM as write-combining.
+     The VRAM is inside the DRAM, which is cacheable.
+  */
+  Status = gDS->SetMemorySpaceAttributes (
+                  *VramBaseAddress,
+                  *VramSize,
+                  EFI_MEMORY_WC
+                  );
+  if (EFI_ERROR (Status)) {
+    ASSERT_EFI_ERROR (Status);
+    gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
+  }
+#endif
+
+  return Status;
+}
+
+/** Return total number of modes supported.
+
+  Note: Valid mode numbers are 0 to MaxMode - 1
+  See Section 12.9 of the UEFI Specification 2.7
+
+  @retval UINT32             Mode Number.
+**/
+UINT32
+LcdPlatformGetMaxMode (VOID)
+{
+  return  mMaxMode;
+}
+
+#if !defined(MDEPKG_NDEBUG)
+/** Probe Clock device ID of the HDLCD clock and current pixel clock frequency.
+  NOTE: We will probe information only in DEBUG build.
+
+  @param[in]  ClockProtocol   A pointer to SCMI clock protocol
+                              interface instance.
+  @param[out] ClockId         ID of the clock device
+
+  @retval EFI_SUCCESS         Clock ID of the HDLCD device returned
+                              successfully.
+  @retval EFI_UNSUPPORTED     SCMI clock management protocol unsupported.
+  @retval EFI_DEVICE_ERROR    SCMI error.
+  @retval EFI_NOT_FOUND       Not found valid clock device ID of the HDLCD.
+**/
+STATIC
+EFI_STATUS
+ProbeHdLcdClock (
+  IN  SCMI_CLOCK_PROTOCOL  *ClockProtocol,
+  OUT UINT32               *ClockId
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      CurrentHdLcdFreq;
+
+  UINT32      TotalClocks;
+  UINT32      ClockProtocolVersion;
+  BOOLEAN     Enabled;
+  CHAR8       ClockName[SCMI_MAX_STR_LEN];
+  BOOLEAN     ClockFound = FALSE;
+
+  UINT32                 TotalRates = 0;
+  UINT32                 ClockRateSize;
+  SCMI_CLOCK_RATE        ClockRate;
+  SCMI_CLOCK_RATE_FORMAT ClockRateFormat;
+
+  Status = ClockProtocol->GetVersion (ClockProtocol, &ClockProtocolVersion);
+  if (EFI_ERROR (Status)) {
+    ASSERT (FALSE);
+    return Status;
+  }
+
+  DEBUG ((DEBUG_ERROR, "SCMI clock management protocol version = %x\n",
+    ClockProtocolVersion));
+
+  if (ClockProtocolVersion != SCMI_CLOCK_PROTOCOL_VERSION) {
+    ASSERT (FALSE);
+    return EFI_UNSUPPORTED;
+  }
+
+  Status = ClockProtocol->GetTotalClocks (ClockProtocol, &TotalClocks);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  DEBUG ((DEBUG_ERROR, "Total number of clocks supported by SCMI clock management protocol = %d\n",
+    TotalClocks));
+
+  for (*ClockId = 0; *ClockId < TotalClocks; (*ClockId)++) {
+    Status = ClockProtocol->GetClockAttributes (
+                              ClockProtocol,
+                              *ClockId,
+                              &Enabled,
+                              ClockName
+                              );
+    if (EFI_ERROR (Status)) {
+      // In current implementation of SCMI, some clocks are not accessible to
+      // calling agents (in our case UEFI is an agent) which results in an
+      // EFI_DEVICE_ERROR error. A bug fix for this is in discussions and will
+      // be fixed in future versions of the SCP firmware. Irrespective of a fix
+      // we must iterate over each clock to see if it matches with HDLCD.
+      continue;
+    }
+
+    if (AsciiStrnCmp ((CONST CHAR8*)ClockName,
+          (CONST CHAR8*)ARM_JUNO_CSS_CLK_NAME_HDLCD_0,
+          sizeof (ARM_JUNO_CSS_CLK_NAME_HDLCD_0)) == 0) {
+      ClockFound = TRUE;
+      break;
+    }
+  }
+
+  if (!ClockFound) {
+    return EFI_NOT_FOUND;
+  }
+
+  ClockRateSize = sizeof (ClockRate);
+  Status = ClockProtocol->DescribeRates (
+                            ClockProtocol,
+                            *ClockId,
+                            &ClockRateFormat,
+                            &TotalRates,
+                            &ClockRateSize,
+                            &ClockRate
+                            );
+  if (EFI_ERROR (Status)) {
+    ASSERT (FALSE);
+    return Status;
+  }
+
+  Status = ClockProtocol->RateGet (ClockProtocol, *ClockId, &CurrentHdLcdFreq);
+  if (EFI_ERROR (Status)) {
+    ASSERT (FALSE);
+    return Status;
+  }
+
+  DEBUG ((DEBUG_ERROR, "Clock ID = %d Clock name = %a\n", *ClockId, ClockName));
+  DEBUG ((DEBUG_ERROR, "Minimum frequency = %uHz\n", ClockRate.Min));
+  DEBUG ((DEBUG_ERROR, "Maximum frequency = %uHz\n", ClockRate.Max));
+  DEBUG ((DEBUG_ERROR, "Clock rate step = %uHz\n", ClockRate.Step));
+
+  DEBUG ((DEBUG_ERROR, "HDLCD Current frequency = %uHz\n", CurrentHdLcdFreq));
+
+  return EFI_SUCCESS;
+}
+#endif
+
+/** Set the requested display mode.
+
+  @param[in] ModeNumber             Mode Number.
+
+  @retval EFI_SUCCESS              Mode set successfully.
+  @retval EFI_NOT_FOUND            Clock protocol instance not found.
+  @retval EFI_DEVICE_ERROR         SCMI error.
+  @retval EFI_INVALID_PARAMETER    Requested mode not found.
+  @retval !(EFI_SUCCESS)            Other errors.
+*/
+EFI_STATUS
+LcdPlatformSetMode (
+  IN CONST UINT32  ModeNumber
+  )
+{
+  EFI_STATUS          Status;
+  SCMI_CLOCK_PROTOCOL *ClockProtocol;
+  UINT32              ClockId;
+
+  EFI_GUID ClockProtocolGuid = ARM_SCMI_CLOCK_PROTOCOL_GUID;
+
+  if (ModeNumber >= mMaxMode) {
+    ASSERT (ModeNumber < mMaxMode);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  // Display debug information in boot log.
+  DEBUG ((DEBUG_ERROR, "HDLCD Display controller:\n"));
+
+  DEBUG ((DEBUG_ERROR, "Required frequency for resolution %dx%d = %uHz\n",
+            mDisplayModes[ModeNumber].Horizontal.Resolution,
+            mDisplayModes[ModeNumber].Vertical.Resolution,
+            mDisplayModes[ModeNumber].OscFreq));
+
+  Status = gBS->LocateProtocol (
+                  &ClockProtocolGuid,
+                  NULL,
+                  (VOID**)&ClockProtocol
+                  );
+  if (EFI_ERROR (Status)) {
+    ASSERT (FALSE);
+    return Status;
+  }
+
+#if !defined(MDEPKG_NDEBUG)
+  /* Avoid probing clock device id in RELEASE build */
+  Status = ProbeHdLcdClock (ClockProtocol, &ClockId);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  ASSERT (ClockId == ARM_JUNO_CSS_CLKID_HDLCD_0);
+#else
+  ClockId = ARM_JUNO_CSS_CLKID_HDLCD_0;
+#endif
+
+  // Set HDLCD clock required for the requested mode
+  Status = ClockProtocol->RateSet (
+                            ClockProtocol,
+                            ClockId,
+                            mDisplayModes[ModeNumber].OscFreq
+                            );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "SCMI error: %r\n", Status));
+    return Status;
+  }
+
+#if !defined(MDEPKG_NDEBUG)
+  UINT64  CurrentHdLcdFreq;
+  // Actual value set can differ from requested frequency so verify.
+  Status = ClockProtocol->RateGet (
+                            ClockProtocol,
+                            ARM_JUNO_CSS_CLKID_HDLCD_0,
+                            &CurrentHdLcdFreq
+                            );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "SCMI Error: %r\n", Status));
+  } else {
+    DEBUG ((DEBUG_ERROR, "Mode = %d, Requested frequency change = %uHz, Actual changed frequency = %uHz\n",
+      ModeNumber,
+      mDisplayModes[ModeNumber].OscFreq,
+      CurrentHdLcdFreq
+      ));
+  }
+#endif
+
+  return Status;
+}
+
+/** Return information for the requested mode number.
+
+  @param[in]  ModeNumber          Mode Number.
+
+  @param[out] Info                Pointer for returned mode information
+                                  (on success).
+
+  @retval EFI_SUCCESS             Mode information for the requested mode
+                                  returned successfully.
+  @retval EFI_INVALID_PARAMETER   Requested mode not found.
+**/
+EFI_STATUS
+LcdPlatformQueryMode (
+  IN  CONST UINT32                                  ModeNumber,
+  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST  Info
+  )
+{
+  if (ModeNumber >= mMaxMode ){
+    ASSERT (ModeNumber < mMaxMode);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  ASSERT (Info != NULL);
+
+  Info->Version = 0;
+  Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
+  Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
+  Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
+
+  Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
+
+  return EFI_SUCCESS;
+}
+
+/** Return display timing information for the requested mode number.
+
+  @param[in]  ModeNumber          Mode Number.
+
+  @param[out] Horizontal          Pointer to horizontal timing parameters.
+                                  (Resolution, Sync, Back porch, Front porch)
+  @param[out] Vertical            Pointer to vertical timing parameters.
+                                  (Resolution, Sync, Back porch, Front porch)
+
+  @retval EFI_SUCCESS             Display timing information for the requested
+                                  mode returned successfully.
+  @retval EFI_INVALID_PARAMETER   Requested mode not found.
+**/
+EFI_STATUS
+LcdPlatformGetTimings (
+  IN  UINT32               ModeNumber,
+  OUT CONST SCAN_TIMINGS   **Horizontal,
+  OUT CONST SCAN_TIMINGS   **Vertical
+  )
+{
+  if (ModeNumber >= mMaxMode ){
+    ASSERT (ModeNumber < mMaxMode);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  ASSERT (Horizontal != NULL);
+  ASSERT (Vertical != NULL);
+
+  *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
+  *Vertical   = &mDisplayModes[ModeNumber].Vertical;
+
+  return EFI_SUCCESS;
+}
+
+/** Return bits per pixel information for a mode number.
+
+  @param[in]  ModeNumber          Mode Number.
+
+  @param[out] Bpp                 Pointer to value bits per pixel.
+
+  @retval EFI_SUCCESS             Bit per pixel information for the requested
+                                  mode returned successfully.
+  @retval EFI_INVALID_PARAMETER   Requested mode not found.
+**/
+EFI_STATUS
+LcdPlatformGetBpp (
+  IN  CONST UINT32         ModeNumber,
+  OUT LCD_BPP      * CONST Bpp
+  )
+{
+  if (ModeNumber >= mMaxMode) {
+    // Check valid ModeNumber and Bpp.
+    ASSERT (ModeNumber < mMaxMode);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  ASSERT (Bpp != NULL);
+
+  *Bpp = LCD_BITS_PER_PIXEL_24;
+
+  return EFI_SUCCESS;
+}
-- 
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")



^ permalink raw reply related	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 00/18] ARM: Update GOP
  2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
                   ` (17 preceding siblings ...)
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library evan.lloyd
@ 2017-12-22 19:29 ` Ard Biesheuvel
  2018-01-02 10:28   ` Evan Lloyd
  18 siblings, 1 reply; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-22 19:29 UTC (permalink / raw)
  To: Evan Lloyd, Leif Lindholm, Ard Biesheuvel, Matteo Carlini
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Panakamattam Abraham

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: EvanLloyd <evan.lloyd@arm.com>
>

Hello Evan,

Before reviewing in detail, could you please confirm that replying to
the addresses below is going to work as expected for non @arm.com
reviewers? They look a bit odd, but perhaps the arm.com SMTP server
doesn't care??

Cc: Arvind Chauhan <Arvind.Chauhan@arm.com>, Daniil Egranov
<Daniil.Egranov@arm.com>, Thomas Panakamattam Abraham
<thomas.abraham@arm.com>, "ard.biesheuvel@linaro.org"@arm.com,
"leif.lindholm@linaro.org"@arm.com, "Matteo.Carlini@arm.com"@arm.com,
"nd@arm.com"@arm.com

-- 
Ard.


> This patch series addresses comments on the original
> (https://lists.01.org/pipermail/edk2-devel/2017-September/015356.html)
> reworking of the Graphics Output Protocol code in Platform/ARM.
> It also contains updates for the new SCMI protocol (MTL Library).
>
> After a number of format and quality modifications, several errors
> are corrected and new functionality added for Mali DP.
>
> The changes are tested on Juno, and FVP.
>
> Code is available for examination at:
>   https://github.com/EvanLloyd/edk2-platforms/tree/166_gop_v2
>
> Ard Biesheuvel (1):
>   ARM/VExpressPkg: Fix MODULE_TYPE of HDLCD/PL111 platform libraries
>
> EvanLloyd (1):
>   ARM/VExpressPkg: HdLcdArmVExpressLib: Remove redundant Bpp
>
> Girish Pathak (16):
>   ARM/VExpressPkg: Tidy HDLCD and PL11LCD platform Lib: Coding standard
>   ARM/VExpressPkg: Tidy HdLcd/PL111Lcd code: Updated comments
>   ARM/VExpressPkg: Remove unused PcdPL111LcdMaxMode from HDLCD inf
>   ARM/VExpressPkg: PL111 and HDLCD: add const qualifier
>   ARM/VExpressPkg: Add and update debug ASSERTS
>   ARM/VExpressPkg: PL111LcdArmVExpressLib: Minor code cleanup
>   ARM/VExpressPkg: PL111 and HDLCD: Use FixedPcdGet32
>   ARM/VExpressPkg: PL11LcdArmVExpressLib: Improvement conditional
>   ARM/VExpressPkg: HdLcdArmVExpressLib: Remove status check EFI_TIMEOUT
>   ARM/VExpressPkg: Redefine LcdPlatformGetTimings function
>   ARM/VExpressPkg: PL111 and HDLCD: Add PCD to select pixel format
>   ARM/VExpressPkg: Reserving framebuffer at build
>   ARM/VExpressPkg: New DP500/DP550/DP650 platform library.
>   ARM/JunoPkg: Mapping Non-Trused SRAM as device memory
>   ARM/JunoPkg: Adding SCMI MTL library
>   ARM/JunoPkg: Add HDLCD platform library
>
>  Platform/ARM/JunoPkg/ArmJuno.dec                                                   |  17 +-
>  Platform/ARM/VExpressPkg/ArmVExpressPkg.dec                                        |   3 +-
>  Platform/ARM/JunoPkg/ArmJuno.dsc                                                   |  32 ++
>  Platform/ARM/JunoPkg/ArmJuno.fdf                                                   |  12 +-
>  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf                             |   5 +-
>  Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf                                     |  39 ++
>  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf                   |  40 ++
>  Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf                     |  45 ++
>  Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf             |   7 +-
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf       |  13 +-
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf |   9 +-
>  Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h                                |  94 ++++
>  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c                               |  24 +-
>  Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c                                       | 195 +++++++
>  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c                        | 559 ++++++++++++++++++++
>  Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c                       | 374 +++++++++++++
>  Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c                      |  28 +-
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c            | 309 +++++++----
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c      | 425 +++++++++------
>  19 files changed, 1920 insertions(+), 310 deletions(-)
>  create mode 100644 Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
>  create mode 100644 Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
>  create mode 100644 Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
>  create mode 100644 Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h
>  create mode 100644 Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c
>  create mode 100644 Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
>  create mode 100644 Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
>
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 02/18] ARM/VExpressPkg: Tidy HDLCD and PL11LCD platform Lib: Coding standard
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 02/18] ARM/VExpressPkg: Tidy HDLCD and PL11LCD platform Lib: Coding standard evan.lloyd
@ 2017-12-23 14:07   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 14:07 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Panakamattam Abraham, "ard.biesheuvel,
	"leif.lindholm, "Matteo.Carlini, "nd

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak at arm.com>
>
> There is no functional modification in this change
> As preparation for further work, the formatting is corrected to meet
> the EDKII coding standard.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf  |   5 +-
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c       | 136 ++++++-----
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 238 +++++++++++---------
>  3 files changed, 218 insertions(+), 161 deletions(-)
>
> diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> index 18d210ce718db45e018681cd1ccdad48f4adc7f3..d44aa7776a4ac60d60f3b4386e67c53423287383 100644
> --- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> +++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> @@ -1,6 +1,6 @@
>  #/** @file
>  #
> -#  Component description file for HdLcdArmLib module
> +#  Component description file for HdLcdArmVExpress module
>  #
>  #  Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
>  #
> @@ -23,8 +23,7 @@ [Defines]
>    LIBRARY_CLASS                  = LcdPlatformLib
>
>  [Sources.common]
> -
> -HdLcdArmVExpress.c
> +  HdLcdArmVExpress.c
>
>  [Packages]
>    ArmPlatformPkg/ArmPlatformPkg.dec
> diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index b1106ee19b98cebac01820924514eac79b97d0d5..851ba83b79f0fea7019269c30e7add58f5ff9cb2 100644
> --- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -1,6 +1,6 @@
> -/**
> +/** @file
>
> -  Copyright (c) 2012, ARM Ltd. All rights reserved.
> +  Copyright (c) 2012-2017, ARM Ltd. All rights reserved.
>
>    This program and the accompanying materials
>    are licensed and made available under the terms and conditions of the BSD License
> @@ -44,35 +44,40 @@ typedef struct {
>    UINT32                     VFrontPorch;
>  } LCD_RESOLUTION;
>
> -
>  LCD_RESOLUTION mResolutions[] = {
>    { // Mode 0 : VGA : 640 x 480 x 24 bpp
> -    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, VGA_OSC_FREQUENCY,
> +    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    VGA_OSC_FREQUENCY,
>      VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
>      VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
>    },
>    { // Mode 1 : SVGA : 800 x 600 x 24 bpp
> -    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, SVGA_OSC_FREQUENCY,
> +    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    SVGA_OSC_FREQUENCY,
>      SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
>      SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
>    },
>    { // Mode 2 : XGA : 1024 x 768 x 24 bpp
> -    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, XGA_OSC_FREQUENCY,
> +    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    XGA_OSC_FREQUENCY,
>      XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
>      XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
>    },
>    { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
> -    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (SXGA_OSC_FREQUENCY/2),
> +    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    (SXGA_OSC_FREQUENCY/2),
>      SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
>      SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
>    },
>    { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
> -    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (UXGA_OSC_FREQUENCY/2),
> +    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    (UXGA_OSC_FREQUENCY/2),
>      UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
>      UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
>    },
>    { // Mode 5 : HD : 1920 x 1080 x 24 bpp
> -    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (HD_OSC_FREQUENCY/2),
> +    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    (HD_OSC_FREQUENCY/2),
>      HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
>      HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
>    }
> @@ -95,19 +100,25 @@ LcdPlatformInitializeDisplay (
>  {
>    EFI_STATUS  Status;
>
> -  // Set the FPGA multiplexer to select the video output from the motherboard or the daughterboard
> -  Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, ARM_VE_DAUGHTERBOARD_1_SITE);
> -  if (EFI_ERROR(Status)) {
> +  // Set the FPGA multiplexer to select the video output from the
> +  // motherboard or the daughterboard
> +  Status = ArmPlatformSysConfigSet (
> +             SYS_CFG_MUXFPGA,
> +             ARM_VE_DAUGHTERBOARD_1_SITE
> +             );
> +  if (EFI_ERROR (Status)) {
>      return Status;
>    }
>
>    // Install the EDID Protocols
>    Status = gBS->InstallMultipleProtocolInterfaces (
> -    &Handle,
> -    &gEfiEdidDiscoveredProtocolGuid,  &mEdidDiscovered,
> -    &gEfiEdidActiveProtocolGuid,      &mEdidActive,
> -    NULL
> -  );
> +                  &Handle,
> +                  &gEfiEdidDiscoveredProtocolGuid,
> +                  &mEdidDiscovered,
> +                  &gEfiEdidActiveProtocolGuid,
> +                  &mEdidActive,
> +                  NULL
> +                  );
>
>    return Status;
>  }
> @@ -132,16 +143,25 @@ LcdPlatformGetVram (
>    } else {
>      AllocationType = AllocateAddress;
>    }
> -  Status = gBS->AllocatePages (AllocationType, EfiBootServicesData, EFI_SIZE_TO_PAGES(((UINTN)LCD_VRAM_SIZE)), VramBaseAddress);
> -  if (EFI_ERROR(Status)) {
> +  Status = gBS->AllocatePages (
> +                  AllocationType,
> +                  EfiBootServicesData,
> +                  EFI_SIZE_TO_PAGES (((UINTN)LCD_VRAM_SIZE)),
> +                  VramBaseAddress
> +                  );
> +  if (EFI_ERROR (Status)) {
>      return Status;
>    }
>
> -  // Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is cacheable.
> -  Status = gDS->SetMemorySpaceAttributes (*VramBaseAddress, *VramSize,
> -                  EFI_MEMORY_WC);
> -  ASSERT_EFI_ERROR(Status);
> -  if (EFI_ERROR(Status)) {
> +  // Mark the VRAM as write-combining.
> +  // The VRAM is inside the DRAM, which is cacheable.
> +  Status = gDS->SetMemorySpaceAttributes (
> +                  *VramBaseAddress,
> +                  *VramSize,
> +                  EFI_MEMORY_WC
> +                  );
> +  ASSERT_EFI_ERROR (Status);
> +  if (EFI_ERROR (Status)) {
>      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
>      return Status;
>    }
> @@ -150,15 +170,11 @@ LcdPlatformGetVram (
>  }
>
>  UINT32
> -LcdPlatformGetMaxMode (
> -  VOID
> -  )
> +LcdPlatformGetMaxMode (VOID)
>  {
> -  //
>    // The following line will report correctly the total number of graphics modes
> -  // that could be supported by the graphics driver:
> -  //
> -  return (sizeof(mResolutions) / sizeof(LCD_RESOLUTION));
> +  // that could be supported by the graphics driver
> +  return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION));
>  }
>
>  EFI_STATUS
> @@ -174,25 +190,35 @@ LcdPlatformSetMode (
>
>    // Set the video mode oscillator
>    do {
> -    Status = ArmPlatformSysConfigSetDevice (SYS_CFG_OSC_SITE1, PcdGet32(PcdHdLcdVideoModeOscId), mResolutions[ModeNumber].OscFreq);
> +    Status = ArmPlatformSysConfigSetDevice (
> +               SYS_CFG_OSC_SITE1,
> +               PcdGet32 (PcdHdLcdVideoModeOscId),
> +               mResolutions[ModeNumber].OscFreq
> +               );
>    } while (Status == EFI_TIMEOUT);
> -  if (EFI_ERROR(Status)) {
> +  if (EFI_ERROR (Status)) {
>      ASSERT_EFI_ERROR (Status);
>      return Status;
>    }
>
>    // Set the DVI into the new mode
>    do {
> -    Status = ArmPlatformSysConfigSet (SYS_CFG_DVIMODE, mResolutions[ModeNumber].Mode);
> +    Status = ArmPlatformSysConfigSet (
> +               SYS_CFG_DVIMODE,
> +               mResolutions[ModeNumber].Mode
> +               );
>    } while (Status == EFI_TIMEOUT);
> -  if (EFI_ERROR(Status)) {
> +  if (EFI_ERROR (Status)) {
>      ASSERT_EFI_ERROR (Status);
>      return Status;
>    }
>
>    // Set the multiplexer
> -  Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, ARM_VE_DAUGHTERBOARD_1_SITE);
> -  if (EFI_ERROR(Status)) {
> +  Status = ArmPlatformSysConfigSet (
> +             SYS_CFG_MUXFPGA,
> +             ARM_VE_DAUGHTERBOARD_1_SITE
> +             );
> +  if (EFI_ERROR (Status)) {
>      ASSERT_EFI_ERROR (Status);
>      return Status;
>    }
> @@ -216,25 +242,25 @@ LcdPlatformQueryMode (
>    Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
>
>    switch (mResolutions[ModeNumber].Bpp) {
> -    case LCD_BITS_PER_PIXEL_24:
> -      Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
> -      Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
> -      Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
> -      Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
> -      Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> -      break;
> +  case LCD_BITS_PER_PIXEL_24:
> +    Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
> +    Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
> +    Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
> +    Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
> +    Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> +    break;
>
> -    case LCD_BITS_PER_PIXEL_16_555:
> -    case LCD_BITS_PER_PIXEL_16_565:
> -    case LCD_BITS_PER_PIXEL_12_444:
> -    case LCD_BITS_PER_PIXEL_8:
> -    case LCD_BITS_PER_PIXEL_4:
> -    case LCD_BITS_PER_PIXEL_2:
> -    case LCD_BITS_PER_PIXEL_1:
> -    default:
> -      // These are not supported
> -      ASSERT(FALSE);
> -      break;
> +  case LCD_BITS_PER_PIXEL_16_555:
> +  case LCD_BITS_PER_PIXEL_16_565:
> +  case LCD_BITS_PER_PIXEL_12_444:
> +  case LCD_BITS_PER_PIXEL_8:
> +  case LCD_BITS_PER_PIXEL_4:
> +  case LCD_BITS_PER_PIXEL_2:
> +  case LCD_BITS_PER_PIXEL_1:
> +  default:
> +    // These are not supported
> +    ASSERT (FALSE);
> +    break;
>    }
>
>    return EFI_SUCCESS;
> diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 3f3ceb3d2fa82f614e0c6dac8455c117745cf3a6..2586a6d8c2076c9aff15f50d652e462d783f13dc 100644
> --- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -1,6 +1,6 @@
>  /** @file
>
> -  Copyright (c) 2011-2015, ARM Ltd. All rights reserved.<BR>
> +  Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
>    This program and the accompanying materials
>    are licensed and made available under the terms and conditions of the BSD License
>    which accompanies this distribution.  The full text of the license may be found at
> @@ -41,87 +41,102 @@ typedef struct {
>    UINT32                     VFrontPorch;
>  } LCD_RESOLUTION;
>
> -
>  LCD_RESOLUTION mResolutions[] = {
>    { // Mode 0 : VGA : 640 x 480 x 24 bpp
> -      VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, VGA_OSC_FREQUENCY,
> -      VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> -      VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> +    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    VGA_OSC_FREQUENCY,
> +    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> +    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
>    },
>    { // Mode 1 : SVGA : 800 x 600 x 24 bpp
> -      SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, SVGA_OSC_FREQUENCY,
> -      SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> -      SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> +    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    SVGA_OSC_FREQUENCY,
> +    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> +    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
>    },
>    { // Mode 2 : XGA : 1024 x 768 x 24 bpp
> -      XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, XGA_OSC_FREQUENCY,
> -      XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> -      XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> +    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    XGA_OSC_FREQUENCY,
> +    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> +    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
>    },
>    { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
> -      SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (SXGA_OSC_FREQUENCY/2),
> -      SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
> -      SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
> +    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    (SXGA_OSC_FREQUENCY/2),
> +    SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
> +    SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
>    },
>    { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
> -      UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (UXGA_OSC_FREQUENCY/2),
> -      UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
> -      UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
> +    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    (UXGA_OSC_FREQUENCY/2),
> +    UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
> +    UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
>    },
>    { // Mode 5 : HD : 1920 x 1080 x 24 bpp
> -      HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (HD_OSC_FREQUENCY/2),
> -      HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
> -      HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
> +    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    (HD_OSC_FREQUENCY/2),
> +    HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
> +    HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
>    },
>    { // Mode 6 : VGA : 640 x 480 x 16 bpp (565 Mode)
> -      VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565, VGA_OSC_FREQUENCY,
> -      VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> -      VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> +    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
> +    VGA_OSC_FREQUENCY,
> +    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> +    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
>    },
>    { // Mode 7 : SVGA : 800 x 600 x 16 bpp (565 Mode)
> -      SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565, SVGA_OSC_FREQUENCY,
> -      SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> -      SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> +    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
> +    SVGA_OSC_FREQUENCY,
> +    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> +    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
>    },
>    { // Mode 8 : XGA : 1024 x 768 x 16 bpp (565 Mode)
> -      XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565, XGA_OSC_FREQUENCY,
> -      XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> -      XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> +    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
> +    XGA_OSC_FREQUENCY,
> +    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> +    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
>    },
>    { // Mode 9 : VGA : 640 x 480 x 15 bpp
> -      VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, VGA_OSC_FREQUENCY,
> -      VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> -      VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> +    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> +    VGA_OSC_FREQUENCY,
> +    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> +    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
>    },
>    { // Mode 10 : SVGA : 800 x 600 x 15 bpp
> -      SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, SVGA_OSC_FREQUENCY,
> -      SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> -      SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> +    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> +    SVGA_OSC_FREQUENCY,
> +    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> +    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
>    },
>    { // Mode 11 : XGA : 1024 x 768 x 15 bpp
> -      XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, XGA_OSC_FREQUENCY,
> -      XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> -      XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> +    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> +    XGA_OSC_FREQUENCY,
> +    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> +    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
>    },
>    { // Mode 12 : XGA : 1024 x 768 x 15 bpp - All the timing info is derived from Linux Kernel Driver Settings
> -      XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, 63500000,
> -      XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> -      XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> +    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> +    63500000,
> +    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> +    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
>    },
>    { // Mode 13 : VGA : 640 x 480 x 12 bpp (444 Mode)
> -      VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444, VGA_OSC_FREQUENCY,
> -      VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> -      VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> +    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
> +    VGA_OSC_FREQUENCY,
> +    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> +    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
>    },
>    { // Mode 14 : SVGA : 800 x 600 x 12 bpp (444 Mode)
> -      SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444, SVGA_OSC_FREQUENCY,
> -      SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> -      SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> +    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
> +    SVGA_OSC_FREQUENCY,
> +    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> +    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
>    },
>    { // Mode 15 : XGA : 1024 x 768 x 12 bpp (444 Mode)
> -      XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444, XGA_OSC_FREQUENCY,
> -      XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> -      XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> +    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
> +    XGA_OSC_FREQUENCY,
> +    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> +    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
>    }
>  };
>
> @@ -135,7 +150,6 @@ EFI_EDID_ACTIVE_PROTOCOL      mEdidActive = {
>    NULL
>  };
>
> -
>  EFI_STATUS
>  LcdPlatformInitializeDisplay (
>    IN EFI_HANDLE   Handle
> @@ -143,16 +157,19 @@ LcdPlatformInitializeDisplay (
>  {
>    EFI_STATUS  Status;
>
> -  // Set the FPGA multiplexer to select the video output from the motherboard or the daughterboard
> +  // Set the FPGA multiplexer to select the video output from the motherboard
> +  // or the daughterboard
>    Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, PL111_CLCD_SITE);
> -  if (!EFI_ERROR(Status)) {
> +  if (!EFI_ERROR (Status)) {
>      // Install the EDID Protocols
> -    Status = gBS->InstallMultipleProtocolInterfaces(
> -      &Handle,
> -      &gEfiEdidDiscoveredProtocolGuid,  &mEdidDiscovered,
> -      &gEfiEdidActiveProtocolGuid,      &mEdidActive,
> -      NULL
> -    );
> +    Status = gBS->InstallMultipleProtocolInterfaces (
> +                    &Handle,
> +                    &gEfiEdidDiscoveredProtocolGuid,
> +                    &mEdidDiscovered,
> +                    &gEfiEdidActiveProtocolGuid,
> +                    &mEdidActive,
> +                    NULL
> +                    );
>    }
>
>    return Status;
> @@ -169,29 +186,38 @@ LcdPlatformGetVram (
>    Status = EFI_SUCCESS;
>
>    // Is it on the motherboard or on the daughterboard?
> -  switch(PL111_CLCD_SITE) {
> +  switch (PL111_CLCD_SITE) {
>
>    case ARM_VE_MOTHERBOARD_SITE:
> -    *VramBaseAddress = (EFI_PHYSICAL_ADDRESS) PL111_CLCD_VRAM_MOTHERBOARD_BASE;
> +    *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)PL111_CLCD_VRAM_MOTHERBOARD_BASE;
>      *VramSize = LCD_VRAM_SIZE;
>      break;
>
>    case ARM_VE_DAUGHTERBOARD_1_SITE:
> -    *VramBaseAddress = (EFI_PHYSICAL_ADDRESS) LCD_VRAM_CORE_TILE_BASE;
> +    *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)LCD_VRAM_CORE_TILE_BASE;
>      *VramSize = LCD_VRAM_SIZE;
>
>      // Allocate the VRAM from the DRAM so that nobody else uses it.
> -    Status = gBS->AllocatePages( AllocateAddress, EfiBootServicesData, EFI_SIZE_TO_PAGES(((UINTN)LCD_VRAM_SIZE)), VramBaseAddress);
> -    if (EFI_ERROR(Status)) {
> +    Status = gBS->AllocatePages (
> +                    AllocateAddress,
> +                    EfiBootServicesData,
> +                    EFI_SIZE_TO_PAGES (((UINTN)LCD_VRAM_SIZE)),
> +                    VramBaseAddress
> +                    );
> +    if (EFI_ERROR (Status)) {
>        return Status;
>      }
>
> -    // Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is cacheable.
> -    Status = gDS->SetMemorySpaceAttributes (*VramBaseAddress, *VramSize,
> -                    EFI_MEMORY_WC);
> -    ASSERT_EFI_ERROR(Status);
> -    if (EFI_ERROR(Status)) {
> -      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES(*VramSize));
> +    // Mark the VRAM as write-combining.
> +    // The VRAM is inside the DRAM, which is cacheable.
> +    Status = gDS->SetMemorySpaceAttributes (
> +                    *VramBaseAddress,
> +                    *VramSize,
> +                    EFI_MEMORY_WC
> +                    );
> +    ASSERT_EFI_ERROR (Status);
> +    if (EFI_ERROR (Status)) {
> +      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
>        return Status;
>      }
>      break;
> @@ -206,19 +232,18 @@ LcdPlatformGetVram (
>  }
>
>  UINT32
> -LcdPlatformGetMaxMode (
> -  VOID
> -  )
> +LcdPlatformGetMaxMode (VOID)
>  {
> -  // The following line will report correctly the total number of graphics modes
> -  // supported by the PL111CLCD.
> -  //return (sizeof(mResolutions) / sizeof(CLCD_RESOLUTION)) - 1;
> +  // The following line would correctly report the total number
> +  // of graphics modes supported by the PL111CLCD.
> +  // return (sizeof(mResolutions) / sizeof(CLCD_RESOLUTION)) - 1;
>
>    // However, on some platforms it is desirable to ignore some graphics modes.
> -  // This could be because the specific implementation of PL111 has certain limitations.
> +  // This could be because the specific implementation of PL111 has
> +  // certain limitations.
>
>    // Set the maximum mode allowed
> -  return (PcdGet32(PcdPL111LcdMaxMode));
> +  return (PcdGet32 (PcdPL111LcdMaxMode));
>  }
>
>  EFI_STATUS
> @@ -238,22 +263,26 @@ LcdPlatformSetMode (
>
>    LcdSite = PL111_CLCD_SITE;
>
> -  switch(LcdSite) {
> +  switch (LcdSite) {
>    case ARM_VE_MOTHERBOARD_SITE:
>      Function = SYS_CFG_OSC;
>      OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
>      break;
>    case ARM_VE_DAUGHTERBOARD_1_SITE:
>      Function = SYS_CFG_OSC_SITE1;
> -    OscillatorId = (UINT32)PcdGet32(PcdPL111LcdVideoModeOscId);
> +    OscillatorId = (UINT32)PcdGet32 (PcdPL111LcdVideoModeOscId);
>      break;
>    default:
>      return EFI_UNSUPPORTED;
>    }
>
>    // Set the video mode oscillator
> -  Status = ArmPlatformSysConfigSetDevice (Function, OscillatorId, mResolutions[ModeNumber].OscFreq);
> -  if (EFI_ERROR(Status)) {
> +  Status = ArmPlatformSysConfigSetDevice (
> +             Function,
> +             OscillatorId,
> +             mResolutions[ModeNumber].OscFreq
> +             );
> +  if (EFI_ERROR (Status)) {
>      ASSERT_EFI_ERROR (Status);
>      return Status;
>    }
> @@ -267,8 +296,11 @@ LcdPlatformSetMode (
>      SysId &= ~ARM_FVP_SYS_ID_VARIANT_MASK;
>      if (SysId != ARM_FVP_BASE_BOARD_SYS_ID) {
>        // Set the DVI into the new mode
> -      Status = ArmPlatformSysConfigSet (SYS_CFG_DVIMODE, mResolutions[ModeNumber].Mode);
> -      if (EFI_ERROR(Status)) {
> +      Status = ArmPlatformSysConfigSet (
> +                 SYS_CFG_DVIMODE,
> +                 mResolutions[ModeNumber].Mode
> +                 );
> +      if (EFI_ERROR (Status)) {
>          ASSERT_EFI_ERROR (Status);
>          return Status;
>        }
> @@ -277,7 +309,7 @@ LcdPlatformSetMode (
>
>    // Set the multiplexer
>    Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, LcdSite);
> -  if (EFI_ERROR(Status)) {
> +  if (EFI_ERROR (Status)) {
>      ASSERT_EFI_ERROR (Status);
>      return Status;
>    }
> @@ -301,25 +333,25 @@ LcdPlatformQueryMode (
>    Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
>
>    switch (mResolutions[ModeNumber].Bpp) {
> -    case LCD_BITS_PER_PIXEL_24:
> -      Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
> -      Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
> -      Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
> -      Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
> -      Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> -      break;
> +  case LCD_BITS_PER_PIXEL_24:
> +    Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
> +    Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
> +    Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
> +    Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
> +    Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> +    break;
>
> -    case LCD_BITS_PER_PIXEL_16_555:
> -    case LCD_BITS_PER_PIXEL_16_565:
> -    case LCD_BITS_PER_PIXEL_12_444:
> -    case LCD_BITS_PER_PIXEL_8:
> -    case LCD_BITS_PER_PIXEL_4:
> -    case LCD_BITS_PER_PIXEL_2:
> -    case LCD_BITS_PER_PIXEL_1:
> -    default:
> -      // These are not supported
> -      ASSERT(FALSE);
> -      break;
> +  case LCD_BITS_PER_PIXEL_16_555:
> +  case LCD_BITS_PER_PIXEL_16_565:
> +  case LCD_BITS_PER_PIXEL_12_444:
> +  case LCD_BITS_PER_PIXEL_8:
> +  case LCD_BITS_PER_PIXEL_4:
> +  case LCD_BITS_PER_PIXEL_2:
> +  case LCD_BITS_PER_PIXEL_1:
> +  default:
> +    // These are not supported
> +    ASSERT (FALSE);
> +    break;
>    }
>
>    return EFI_SUCCESS;
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 03/18] ARM/VExpressPkg: Tidy HdLcd/PL111Lcd code: Updated comments
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 03/18] ARM/VExpressPkg: Tidy HdLcd/PL111Lcd code: Updated comments evan.lloyd
@ 2017-12-23 14:08   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 14:08 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, "Matteo.Carlini, "leif.lindholm,
	"nd, Arvind Chauhan, Thomas Panakamattam Abraham,
	"ard.biesheuvel

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak at arm.com>
>
> There is no functional modification in this change.
> In this change some comments in HDLCD and PL111LCD platform library
> code are modified and a few new comments are added. This is to
> prevent mixing formatting changes with functional changes.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf |  2 +-
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c            | 74 ++++++++++++++++++++
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c      | 73 +++++++++++++++++++
>  3 files changed, 148 insertions(+), 1 deletion(-)
>
> diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> index 335c84841a4ff4b57c0d495bc48e93579b5ce576..e97febb91c89f82f8cad12823f5ffe182e87f8cd 100644
> --- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> +++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> @@ -1,6 +1,6 @@
>  #/** @file
>  #
> -#  Component description file for ArmVeGraphicsDxe module
> +#  Component description file for PL111LcdArmVExpressLib module
>  #
>  #  Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
>  #
> diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index 851ba83b79f0fea7019269c30e7add58f5ff9cb2..e4d0a4c8407835df6ab62c02d18531c4d3f08c97 100644
> --- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -44,6 +44,8 @@ typedef struct {
>    UINT32                     VFrontPorch;
>  } LCD_RESOLUTION;
>
> +/** The display modes supported by the platform.
> +**/
>  LCD_RESOLUTION mResolutions[] = {
>    { // Mode 0 : VGA : 640 x 480 x 24 bpp
>      VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> @@ -93,6 +95,13 @@ EFI_EDID_ACTIVE_PROTOCOL      mEdidActive = {
>    NULL
>  };
>
> +/** HDLCD platform specific initialization function.
> +
> +  @param[in] Handle              Handle to the LCD device instance.
> +
> +  @retval EFI_SUCCESS            Plaform library initialized successfully.
> +  @retval !(EFI_SUCCESS)         Other errors.
> +**/
>  EFI_STATUS
>  LcdPlatformInitializeDisplay (
>    IN EFI_HANDLE   Handle
> @@ -123,6 +132,18 @@ LcdPlatformInitializeDisplay (
>    return Status;
>  }
>
> +/** Allocate VRAM memory in DRAM for the frame buffer
> +  (unless it is reserved already).
> +
> +  The allocated address can be used to set the frame buffer.
> +
> +  @param[out] VramBaseAddress     A pointer to the frame buffer address.
> +  @param[out] VramSize            A pointer to the size of the frame
> +                                  buffer in bytes
> +
> +  @retval EFI_SUCCESS             Frame buffer memory allocated successfully.
> +  @retval !(EFI_SUCCESS)          Other errors.
> +**/
>  EFI_STATUS
>  LcdPlatformGetVram (
>    OUT EFI_PHYSICAL_ADDRESS*  VramBaseAddress,
> @@ -169,6 +190,13 @@ LcdPlatformGetVram (
>    return EFI_SUCCESS;
>  }
>
> +/** Return total number of modes supported.
> +
> +  Note: Valid mode numbers are 0 to MaxMode - 1
> +  See Section 12.9 of the UEFI Specification 2.7
> +
> +  @retval UINT32             Mode Number.
> +**/
>  UINT32
>  LcdPlatformGetMaxMode (VOID)
>  {
> @@ -177,6 +205,14 @@ LcdPlatformGetMaxMode (VOID)
>    return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION));
>  }
>
> +/** Set the requested display mode.
> +
> +  @param[in] ModeNumber             Mode Number.
> +
> +  @retval EFI_SUCCESS               Mode set successfully.
> +  @retval EFI_INVALID_PARAMETER     Requested mode not found.
> +  @retval !(EFI_SUCCESS)            Other errors.
> +**/
>  EFI_STATUS
>  LcdPlatformSetMode (
>    IN UINT32                         ModeNumber
> @@ -226,6 +262,17 @@ LcdPlatformSetMode (
>    return Status;
>  }
>
> +/** Return information for the requested mode number.
> +
> +  @param[in]  ModeNumber          Mode Number.
> +
> +  @param[out] Info                Pointer for returned mode information
> +                                  (on success).
> +
> +  @retval EFI_SUCCESS             Mode information for the requested mode
> +                                  returned successfully.
> +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> +**/
>  EFI_STATUS
>  LcdPlatformQueryMode (
>    IN  UINT32                                ModeNumber,
> @@ -266,6 +313,23 @@ LcdPlatformQueryMode (
>    return EFI_SUCCESS;
>  }
>
> +/** Return display timing information for the requested mode number.
> +
> +  @param[in]  ModeNumber          Mode Number.
> +
> +  @param[out] HRes                Pointer to horizontal resolution.
> +  @param[out] HSync               Pointer to horizontal sync width.
> +  @param[out] HBackPorch          Pointer to horizontal back porch.
> +  @param[out] HFrontPorch         Pointer to horizontal front porch.
> +  @param[out] VRes                Pointer to vertical resolution.
> +  @param[out] VSync               Pointer to vertical sync width.
> +  @param[out] VBackPorch          Pointer to vertical back porch.
> +  @param[out] VFrontPorch         Pointer to vertical front porch.
> +
> +  @retval EFI_SUCCESS             Display timing information for the requested
> +                                  mode returned successfully.
> +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> +**/
>  EFI_STATUS
>  LcdPlatformGetTimings (
>    IN  UINT32                              ModeNumber,
> @@ -295,6 +359,16 @@ LcdPlatformGetTimings (
>    return EFI_SUCCESS;
>  }
>
> +/** Return bits per pixel information for a mode number.
> +
> +  @param[in]  ModeNumber          Mode Number.
> +
> +  @param[out] Bpp                 Pointer to value bits per pixel.
> +
> +  @retval EFI_SUCCESS             Bit per pixel information for the requested
> +                                  mode returned successfully.
> +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> +**/
>  EFI_STATUS
>  LcdPlatformGetBpp (
>    IN  UINT32                              ModeNumber,
> diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 2586a6d8c2076c9aff15f50d652e462d783f13dc..0bbd40ceeb850209cd4842f34e72a0b635309a15 100644
> --- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -41,6 +41,8 @@ typedef struct {
>    UINT32                     VFrontPorch;
>  } LCD_RESOLUTION;
>
> +/** The display modes supported by the platform.
> +**/
>  LCD_RESOLUTION mResolutions[] = {
>    { // Mode 0 : VGA : 640 x 480 x 24 bpp
>      VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> @@ -150,6 +152,12 @@ EFI_EDID_ACTIVE_PROTOCOL      mEdidActive = {
>    NULL
>  };
>
> +/** PL111 Platform specific initialization function.
> +
> +  @param[in] Handle              Handle to the LCD device instance.
> +  @retval EFI_SUCCESS            Plaform library initialized successfully.
> +  @retval !(EFI_SUCCESS)         Other errors.
> +**/
>  EFI_STATUS
>  LcdPlatformInitializeDisplay (
>    IN EFI_HANDLE   Handle
> @@ -175,6 +183,18 @@ LcdPlatformInitializeDisplay (
>    return Status;
>  }
>
> +/** Allocate VRAM memory in DRAM for the frame buffer
> +  (unless it is reserved already).
> +
> +  The allocated address can be used to set the frame buffer.
> +
> +  @param[out] VramBaseAddress     A pointer to the frame buffer address.
> +  @param[out] VramSize            A pointer to the size of the frame
> +                                  buffer in bytes
> +
> +  @retval EFI_SUCCESS             Frame buffer memory allocated successfully.
> +  @retval !(EFI_SUCCESS)          Other errors.
> +**/
>  EFI_STATUS
>  LcdPlatformGetVram (
>    OUT EFI_PHYSICAL_ADDRESS*  VramBaseAddress,
> @@ -231,6 +251,13 @@ LcdPlatformGetVram (
>    return Status;
>  }
>
> +/** Return total number of modes supported.
> +
> +  Note: Valid mode numbers are 0 to MaxMode - 1
> +  See Section 12.9 of the UEFI Specification 2.7
> +
> +  @retval UINT32             Mode Number.
> +**/
>  UINT32
>  LcdPlatformGetMaxMode (VOID)
>  {
> @@ -246,6 +273,15 @@ LcdPlatformGetMaxMode (VOID)
>    return (PcdGet32 (PcdPL111LcdMaxMode));
>  }
>
> +/** Set the requested display mode.
> +
> +  @param[in] ModeNumber            Mode Number.
> +
> +  @retval  EFI_SUCCESS             Mode set successfully.
> +  @retval  EFI_INVALID_PARAMETER   Requested mode not found.
> +  @retval  EFI_UNSUPPORTED         PLL111 configuration not supported.
> +  @retval  !(EFI_SUCCESS)          Other errors.
> +**/
>  EFI_STATUS
>  LcdPlatformSetMode (
>    IN UINT32                         ModeNumber
> @@ -317,6 +353,16 @@ LcdPlatformSetMode (
>    return Status;
>  }
>
> +/** Return information for the requested mode number.
> +
> +  @param[in]  ModeNumber         Mode Number.
> +  @param[out] Info               Pointer for returned mode information
> +                                 (on success).
> +
> +  @retval EFI_SUCCESS             Mode information for the requested mode
> +                                  returned successfully.
> +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> +**/
>  EFI_STATUS
>  LcdPlatformQueryMode (
>    IN  UINT32                                ModeNumber,
> @@ -357,6 +403,23 @@ LcdPlatformQueryMode (
>    return EFI_SUCCESS;
>  }
>
> +/** Return display timing information for the requested mode number.
> +
> +  @param[in]  ModeNumber          Mode Number.
> +
> +  @param[out] HRes                Pointer to horizontal resolution.
> +  @param[out] HSync               Pointer to horizontal sync width.
> +  @param[out] HBackPorch          Pointer to horizontal back porch.
> +  @param[out] HFrontPorch         Pointer to horizontal front porch.
> +  @param[out] VRes                Pointer to vertical resolution.
> +  @param[out] VSync               Pointer to vertical sync width.
> +  @param[out] VBackPorch          Pointer to vertical back porch.
> +  @param[out] VFrontPorch         Pointer to vertical front porch.
> +
> +  @retval EFI_SUCCESS             Display timing information for the requested
> +                                  mode returned successfully.
> +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> +**/
>  EFI_STATUS
>  LcdPlatformGetTimings (
>    IN  UINT32                              ModeNumber,
> @@ -386,6 +449,16 @@ LcdPlatformGetTimings (
>    return EFI_SUCCESS;
>  }
>
> +/** Return bits per pixel information for a mode number.
> +
> +  @param[in]  ModeNumber          Mode Number.
> +
> +  @param[out] Bpp                 Pointer to value bits per pixel.
> +
> +  @retval EFI_SUCCESS             Bit per pixel information for the requested
> +                                  mode returned successfully.
> +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> +**/
>  EFI_STATUS
>  LcdPlatformGetBpp (
>    IN  UINT32                              ModeNumber,
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 04/18] ARM/VExpressPkg: Remove unused PcdPL111LcdMaxMode from HDLCD inf
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 04/18] ARM/VExpressPkg: Remove unused PcdPL111LcdMaxMode from HDLCD inf evan.lloyd
@ 2017-12-23 14:08   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 14:08 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Panakamattam Abraham, "ard.biesheuvel,
	"leif.lindholm, "Matteo.Carlini, "nd

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> PCD PcdPL111LcdMaxMode is not used in HDLCD platform library.
> Presence of this PCD in HDLCD is probably due to copy/paste code
> from PL111 Lcd platform library. This change removes it from
> the HdLcdArmVExpressLib.inf file.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>

I think this one needs your signoff as well, Evan?


Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> index d44aa7776a4ac60d60f3b4386e67c53423287383..52158c4771b5b7651e234fdd73208dcae14c1025 100644
> --- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> +++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> @@ -40,5 +40,4 @@ [Protocols]
>    gEfiEdidActiveProtocolGuid                    # Produced
>
>  [Pcd]
> -  gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
>    gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 05/18] ARM/VExpressPkg: PL111 and HDLCD: add const qualifier
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 05/18] ARM/VExpressPkg: PL111 and HDLCD: add const qualifier evan.lloyd
@ 2017-12-23 14:09   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 14:09 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Panakamattam Abraham, "ard.biesheuvel,
	"leif.lindholm, "Matteo.Carlini, "nd

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak at arm.com>
>
> This change adds some STATIC and CONST qualifiers (mainly to arguments
> of  functions) in PL111 and HdLcd platform libraries.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>

Please drop this patch, I don't see the point.

> ---
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c       | 34 ++++++++++----------
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 32 +++++++++---------
>  2 files changed, 33 insertions(+), 33 deletions(-)
>
> diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index e4d0a4c8407835df6ab62c02d18531c4d3f08c97..6afd764897f49c64490ce891682f99bb0f5d993b 100644
> --- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -46,7 +46,7 @@ typedef struct {
>
>  /** The display modes supported by the platform.
>  **/
> -LCD_RESOLUTION mResolutions[] = {
> +STATIC CONST LCD_RESOLUTION mResolutions[] = {
>    { // Mode 0 : VGA : 640 x 480 x 24 bpp
>      VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
>      VGA_OSC_FREQUENCY,
> @@ -146,8 +146,8 @@ LcdPlatformInitializeDisplay (
>  **/
>  EFI_STATUS
>  LcdPlatformGetVram (
> -  OUT EFI_PHYSICAL_ADDRESS*  VramBaseAddress,
> -  OUT UINTN*                 VramSize
> +  OUT EFI_PHYSICAL_ADDRESS * CONST  VramBaseAddress,
> +  OUT UINTN * CONST                 VramSize
>    )
>  {
>    EFI_STATUS              Status;
> @@ -215,7 +215,7 @@ LcdPlatformGetMaxMode (VOID)
>  **/
>  EFI_STATUS
>  LcdPlatformSetMode (
> -  IN UINT32                         ModeNumber
> +  IN CONST UINT32                         ModeNumber
>    )
>  {
>    EFI_STATUS            Status;
> @@ -275,8 +275,8 @@ LcdPlatformSetMode (
>  **/
>  EFI_STATUS
>  LcdPlatformQueryMode (
> -  IN  UINT32                                ModeNumber,
> -  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *Info
> +  IN CONST UINT32                                   ModeNumber,
> +  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST  Info
>    )
>  {
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -332,15 +332,15 @@ LcdPlatformQueryMode (
>  **/
>  EFI_STATUS
>  LcdPlatformGetTimings (
> -  IN  UINT32                              ModeNumber,
> -  OUT UINT32*                             HRes,
> -  OUT UINT32*                             HSync,
> -  OUT UINT32*                             HBackPorch,
> -  OUT UINT32*                             HFrontPorch,
> -  OUT UINT32*                             VRes,
> -  OUT UINT32*                             VSync,
> -  OUT UINT32*                             VBackPorch,
> -  OUT UINT32*                             VFrontPorch
> +  IN  CONST UINT32                              ModeNumber,
> +  OUT UINT32 * CONST                            HRes,
> +  OUT UINT32 * CONST                            HSync,
> +  OUT UINT32 * CONST                            HBackPorch,
> +  OUT UINT32 * CONST                            HFrontPorch,
> +  OUT UINT32 * CONST                            VRes,
> +  OUT UINT32 * CONST                            VSync,
> +  OUT UINT32 * CONST                            VBackPorch,
> +  OUT UINT32 * CONST                            VFrontPorch
>    )
>  {
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -371,8 +371,8 @@ LcdPlatformGetTimings (
>  **/
>  EFI_STATUS
>  LcdPlatformGetBpp (
> -  IN  UINT32                              ModeNumber,
> -  OUT LCD_BPP  *                          Bpp
> +  IN CONST UINT32                        ModeNumber,
> +  OUT LCD_BPP * CONST                    Bpp
>    )
>  {
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 0bbd40ceeb850209cd4842f34e72a0b635309a15..799fb3fc781ce04bb64cb1fa0b87f262a670ed78 100644
> --- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -197,8 +197,8 @@ LcdPlatformInitializeDisplay (
>  **/
>  EFI_STATUS
>  LcdPlatformGetVram (
> -  OUT EFI_PHYSICAL_ADDRESS*  VramBaseAddress,
> -  OUT UINTN*                 VramSize
> +  OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> +  OUT UINTN * CONST                VramSize
>    )
>  {
>    EFI_STATUS              Status;
> @@ -284,7 +284,7 @@ LcdPlatformGetMaxMode (VOID)
>  **/
>  EFI_STATUS
>  LcdPlatformSetMode (
> -  IN UINT32                         ModeNumber
> +  IN CONST UINT32                         ModeNumber
>    )
>  {
>    EFI_STATUS            Status;
> @@ -365,8 +365,8 @@ LcdPlatformSetMode (
>  **/
>  EFI_STATUS
>  LcdPlatformQueryMode (
> -  IN  UINT32                                ModeNumber,
> -  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *Info
> +  IN CONST UINT32                                  ModeNumber,
> +  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
>    )
>  {
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -422,15 +422,15 @@ LcdPlatformQueryMode (
>  **/
>  EFI_STATUS
>  LcdPlatformGetTimings (
> -  IN  UINT32                              ModeNumber,
> -  OUT UINT32*                             HRes,
> -  OUT UINT32*                             HSync,
> -  OUT UINT32*                             HBackPorch,
> -  OUT UINT32*                             HFrontPorch,
> -  OUT UINT32*                             VRes,
> -  OUT UINT32*                             VSync,
> -  OUT UINT32*                             VBackPorch,
> -  OUT UINT32*                             VFrontPorch
> +  IN  CONST UINT32                        ModeNumber,
> +  OUT UINT32 * CONST                      HRes,
> +  OUT UINT32 * CONST                      HSync,
> +  OUT UINT32 * CONST                      HBackPorch,
> +  OUT UINT32 * CONST                      HFrontPorch,
> +  OUT UINT32 * CONST                      VRes,
> +  OUT UINT32 * CONST                      VSync,
> +  OUT UINT32 * CONST                      VBackPorch,
> +  OUT UINT32 * CONST                      VFrontPorch
>    )
>  {
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -461,8 +461,8 @@ LcdPlatformGetTimings (
>  **/
>  EFI_STATUS
>  LcdPlatformGetBpp (
> -  IN  UINT32                              ModeNumber,
> -  OUT LCD_BPP  *                          Bpp
> +  IN  CONST UINT32                        ModeNumber,
> +  OUT LCD_BPP * CONST                     Bpp
>    )
>  {
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS evan.lloyd
@ 2017-12-23 14:12   ` Ard Biesheuvel
  2018-01-04 18:55     ` Girish Pathak
  0 siblings, 1 reply; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 14:12 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, "Matteo.Carlini, "leif.lindholm,
	"nd, Arvind Chauhan, Thomas Panakamattam Abraham,
	"ard.biesheuvel

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak at arm.com>
>
> This change adds some debug assertions e.g to catch NULL pointer errors
> missing in PL11Lcd and HdLcd platform libraries.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
> ---
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c       | 22 +++++++++++++++++-
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 24 +++++++++++++++++++-
>  2 files changed, 44 insertions(+), 2 deletions(-)
>
> diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index 6afd764897f49c64490ce891682f99bb0f5d993b..a8fe8696da0653017ce9fa6e4a86caf283bc04c9 100644
> --- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -153,6 +153,9 @@ LcdPlatformGetVram (
>    EFI_STATUS              Status;
>    EFI_ALLOCATE_TYPE       AllocationType;
>
> +  ASSERT (VramBaseAddress != NULL);
> +  ASSERT (VramSize != NULL);
> +
>    // Set the vram size
>    *VramSize = LCD_VRAM_SIZE;
>
> @@ -171,6 +174,7 @@ LcdPlatformGetVram (
>                    VramBaseAddress
>                    );
>    if (EFI_ERROR (Status)) {
> +    ASSERT (FALSE);
>      return Status;
>    }
>
> @@ -181,8 +185,8 @@ LcdPlatformGetVram (
>                    *VramSize,
>                    EFI_MEMORY_WC
>                    );
> -  ASSERT_EFI_ERROR (Status);
>    if (EFI_ERROR (Status)) {
> +    ASSERT (FALSE);

As in the sibling patch against EDK2, this patch makes it more
difficult to figure out what went wrong when you hit the ASSERT.
ASSERT_EFI_ERROR prints the value of Status, ASSERT(FALSE) only prints
'0 != 1'

>      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
>      return Status;
>    }
> @@ -221,6 +225,7 @@ LcdPlatformSetMode (
>    EFI_STATUS            Status;
>
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> +    ASSERT (FALSE);

These are fine: the code itself explains adequately which condition
triggered the ASSERT to fire.

>      return EFI_INVALID_PARAMETER;
>    }
>
> @@ -279,7 +284,10 @@ LcdPlatformQueryMode (
>    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST  Info
>    )
>  {
> +  ASSERT (Info != NULL);
> +
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> +    ASSERT (FALSE);
>      return EFI_INVALID_PARAMETER;
>    }
>
> @@ -343,7 +351,18 @@ LcdPlatformGetTimings (
>    OUT UINT32 * CONST                            VFrontPorch
>    )
>  {
> +  // One of the pointers is NULL
> +  ASSERT (HRes != NULL);
> +  ASSERT (HSync != NULL);
> +  ASSERT (HBackPorch != NULL);
> +  ASSERT (HFrontPorch != NULL);
> +  ASSERT (VRes != NULL);
> +  ASSERT (VSync != NULL);
> +  ASSERT (VBackPorch != NULL);
> +  ASSERT (VFrontPorch != NULL);
> +
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> +    ASSERT (FALSE);
>      return EFI_INVALID_PARAMETER;
>    }
>
> @@ -376,6 +395,7 @@ LcdPlatformGetBpp (
>    )
>  {
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> +    ASSERT (FALSE);
>      return EFI_INVALID_PARAMETER;
>    }
>
> diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 799fb3fc781ce04bb64cb1fa0b87f262a670ed78..fd4eea8f8e2397bc7d4ddf4cfe3dcc97a5109edb 100644
> --- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -205,6 +205,9 @@ LcdPlatformGetVram (
>
>    Status = EFI_SUCCESS;
>
> +  ASSERT (VramBaseAddress != NULL);
> +  ASSERT (VramSize != NULL);
> +
>    // Is it on the motherboard or on the daughterboard?
>    switch (PL111_CLCD_SITE) {
>
> @@ -225,6 +228,7 @@ LcdPlatformGetVram (
>                      VramBaseAddress
>                      );
>      if (EFI_ERROR (Status)) {
> +      ASSERT (FALSE);
>        return Status;
>      }
>
> @@ -235,8 +239,8 @@ LcdPlatformGetVram (
>                      *VramSize,
>                      EFI_MEMORY_WC
>                      );
> -    ASSERT_EFI_ERROR (Status);
>      if (EFI_ERROR (Status)) {
> +      ASSERT (FALSE);
>        gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
>        return Status;
>      }
> @@ -294,6 +298,7 @@ LcdPlatformSetMode (
>    UINT32                SysId;
>
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> +    ASSERT (FALSE);
>      return EFI_INVALID_PARAMETER;
>    }
>
> @@ -369,7 +374,10 @@ LcdPlatformQueryMode (
>    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
>    )
>  {
> +  ASSERT (Info != NULL);
> +
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> +    ASSERT (FALSE);
>      return EFI_INVALID_PARAMETER;
>    }
>
> @@ -433,7 +441,18 @@ LcdPlatformGetTimings (
>    OUT UINT32 * CONST                      VFrontPorch
>    )
>  {
> +  // One of the pointers is NULL
> +  ASSERT (HRes != NULL);
> +  ASSERT (HSync != NULL);
> +  ASSERT (HBackPorch != NULL);
> +  ASSERT (HFrontPorch != NULL);
> +  ASSERT (VRes != NULL);
> +  ASSERT (VSync != NULL);
> +  ASSERT (VBackPorch != NULL);
> +  ASSERT (VFrontPorch != NULL);
> +
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> +    ASSERT (FALSE);
>      return EFI_INVALID_PARAMETER;
>    }
>
> @@ -465,7 +484,10 @@ LcdPlatformGetBpp (
>    OUT LCD_BPP * CONST                     Bpp
>    )
>  {
> +  ASSERT (Bpp != NULL);
> +
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> +    ASSERT (FALSE);
>      return EFI_INVALID_PARAMETER;
>    }
>
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 07/18] ARM/VExpressPkg: PL111LcdArmVExpressLib: Minor code cleanup
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 07/18] ARM/VExpressPkg: PL111LcdArmVExpressLib: Minor code cleanup evan.lloyd
@ 2017-12-23 14:13   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 14:13 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, "Matteo.Carlini, "leif.lindholm,
	"nd, Arvind Chauhan, Thomas Panakamattam Abraham,
	"ard.biesheuvel

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak at arm.com>
>
> This minor change removes some unecessary initializations and variables
> in PL111LcdArmVExpress.c
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index fd4eea8f8e2397bc7d4ddf4cfe3dcc97a5109edb..11335bb2cef9d7ca2606d4a8671382bf3dc2d254 100644
> --- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -203,8 +203,6 @@ LcdPlatformGetVram (
>  {
>    EFI_STATUS              Status;
>
> -  Status = EFI_SUCCESS;
> -
>    ASSERT (VramBaseAddress != NULL);
>    ASSERT (VramSize != NULL);
>
> @@ -214,6 +212,7 @@ LcdPlatformGetVram (
>    case ARM_VE_MOTHERBOARD_SITE:
>      *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)PL111_CLCD_VRAM_MOTHERBOARD_BASE;
>      *VramSize = LCD_VRAM_SIZE;
> +    Status = EFI_SUCCESS;
>      break;
>
>    case ARM_VE_DAUGHTERBOARD_1_SITE:
> @@ -242,7 +241,6 @@ LcdPlatformGetVram (
>      if (EFI_ERROR (Status)) {
>        ASSERT (FALSE);
>        gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> -      return Status;
>      }
>      break;
>
> @@ -292,7 +290,6 @@ LcdPlatformSetMode (
>    )
>  {
>    EFI_STATUS            Status;
> -  UINT32                LcdSite;
>    UINT32                OscillatorId;
>    SYS_CONFIG_FUNCTION   Function;
>    UINT32                SysId;
> @@ -302,9 +299,7 @@ LcdPlatformSetMode (
>      return EFI_INVALID_PARAMETER;
>    }
>
> -  LcdSite = PL111_CLCD_SITE;
> -
> -  switch (LcdSite) {
> +  switch (PL111_CLCD_SITE) {
>    case ARM_VE_MOTHERBOARD_SITE:
>      Function = SYS_CFG_OSC;
>      OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
> @@ -349,11 +344,8 @@ LcdPlatformSetMode (
>    }
>
>    // Set the multiplexer
> -  Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, LcdSite);
> -  if (EFI_ERROR (Status)) {
> -    ASSERT_EFI_ERROR (Status);
> -    return Status;
> -  }
> +  Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, PL111_CLCD_SITE);
> +  ASSERT_EFI_ERROR (Status);
>
>    return Status;
>  }
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 08/18] ARM/VExpressPkg: PL111 and HDLCD: Use FixedPcdGet32
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 08/18] ARM/VExpressPkg: PL111 and HDLCD: Use FixedPcdGet32 evan.lloyd
@ 2017-12-23 14:14   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 14:14 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, "Matteo.Carlini, "leif.lindholm,
	"nd, Arvind Chauhan, Thomas Panakamattam Abraham,
	"ard.biesheuvel

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak at arm.com>
>
> This change replaces PcdGet32 with FixedPcdGet32 for the PCDs which
> are defined as fixed PCDs.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf       | 2 +-
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf | 2 +-
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c            | 2 +-
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c      | 4 ++--
>  4 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> index 52158c4771b5b7651e234fdd73208dcae14c1025..2e83736609cf8c63cb498368cd377f6a23964ef4 100644
> --- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> +++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> @@ -39,5 +39,5 @@ [Protocols]
>    gEfiEdidDiscoveredProtocolGuid                # Produced
>    gEfiEdidActiveProtocolGuid                    # Produced
>
> -[Pcd]
> +[FixedPcd]
>    gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId
> diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> index e97febb91c89f82f8cad12823f5ffe182e87f8cd..1ee878041559fa84a810f65175f2507bda663d76 100644
> --- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> +++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> @@ -39,6 +39,6 @@ [Protocols]
>    gEfiEdidDiscoveredProtocolGuid                # Produced
>    gEfiEdidActiveProtocolGuid                    # Produced
>
> -[Pcd]
> +[FixedPcd]
>    gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
>    gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId
> diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index a8fe8696da0653017ce9fa6e4a86caf283bc04c9..f8d19df79260cdfbe1876d6ccc10d49abd0637cf 100644
> --- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -233,7 +233,7 @@ LcdPlatformSetMode (
>    do {
>      Status = ArmPlatformSysConfigSetDevice (
>                 SYS_CFG_OSC_SITE1,
> -               PcdGet32 (PcdHdLcdVideoModeOscId),
> +               FixedPcdGet32 (PcdHdLcdVideoModeOscId),
>                 mResolutions[ModeNumber].OscFreq
>                 );
>    } while (Status == EFI_TIMEOUT);
> diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 11335bb2cef9d7ca2606d4a8671382bf3dc2d254..92918bb4ee6811db47791a435bc06a6dc77ae9a3 100644
> --- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -272,7 +272,7 @@ LcdPlatformGetMaxMode (VOID)
>    // certain limitations.
>
>    // Set the maximum mode allowed
> -  return (PcdGet32 (PcdPL111LcdMaxMode));
> +  return (FixedPcdGet32 (PcdPL111LcdMaxMode));
>  }
>
>  /** Set the requested display mode.
> @@ -306,7 +306,7 @@ LcdPlatformSetMode (
>      break;
>    case ARM_VE_DAUGHTERBOARD_1_SITE:
>      Function = SYS_CFG_OSC_SITE1;
> -    OscillatorId = (UINT32)PcdGet32 (PcdPL111LcdVideoModeOscId);
> +    OscillatorId = FixedPcdGet32 (PcdPL111LcdVideoModeOscId);
>      break;
>    default:
>      return EFI_UNSUPPORTED;
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 09/18] ARM/VExpressPkg: PL11LcdArmVExpressLib: Improvement conditional
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 09/18] ARM/VExpressPkg: PL11LcdArmVExpressLib: Improvement conditional evan.lloyd
@ 2017-12-23 14:16   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 14:16 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Panakamattam Abraham, "ard.biesheuvel,
	"leif.lindholm, "Matteo.Carlini, "nd

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak at arm.com>
>
> PL111_CLCD_SITE and ARM_VE_MOTHERBOARD_SITE are both constants and
> available at build time. Use conditional compilation to process the code
> based on the value of PL111_CLCD_SITE, instead of selecting code in a
> switch statement at runtime.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>

Please drop this patch. Replacing C conditionals with CPP conditionals
makes the code more difficult to read, and reduces build time
coverage. The compiler is perfectly capable of removing the
unreachable code (and these are not hot paths anyway)

> ---
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 40 +++++++-------------
>  1 file changed, 14 insertions(+), 26 deletions(-)
>
> diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 92918bb4ee6811db47791a435bc06a6dc77ae9a3..cf50b20fd9b1b44a81963655c2f88305ce6bdc67 100644
> --- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -206,16 +206,11 @@ LcdPlatformGetVram (
>    ASSERT (VramBaseAddress != NULL);
>    ASSERT (VramSize != NULL);
>
> -  // Is it on the motherboard or on the daughterboard?
> -  switch (PL111_CLCD_SITE) {
> -
> -  case ARM_VE_MOTHERBOARD_SITE:
> +#if (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
>      *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)PL111_CLCD_VRAM_MOTHERBOARD_BASE;
>      *VramSize = LCD_VRAM_SIZE;
>      Status = EFI_SUCCESS;
> -    break;
> -
> -  case ARM_VE_DAUGHTERBOARD_1_SITE:
> +#elif (PL111_CLCD_SITE == ARM_VE_DAUGHTERBOARD_1_SITE)
>      *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)LCD_VRAM_CORE_TILE_BASE;
>      *VramSize = LCD_VRAM_SIZE;
>
> @@ -242,13 +237,9 @@ LcdPlatformGetVram (
>        ASSERT (FALSE);
>        gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
>      }
> -    break;
> -
> -  default:
> -    // Unsupported site
> -    Status = EFI_UNSUPPORTED;
> -    break;
> -  }
> +#else
> +#error PL111LcdVExpressLib: Unsupported PL111_CLCD_SITE
> +#endif // (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
>
>    return Status;
>  }
> @@ -299,18 +290,15 @@ LcdPlatformSetMode (
>      return EFI_INVALID_PARAMETER;
>    }
>
> -  switch (PL111_CLCD_SITE) {
> -  case ARM_VE_MOTHERBOARD_SITE:
> -    Function = SYS_CFG_OSC;
> -    OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
> -    break;
> -  case ARM_VE_DAUGHTERBOARD_1_SITE:
> -    Function = SYS_CFG_OSC_SITE1;
> -    OscillatorId = FixedPcdGet32 (PcdPL111LcdVideoModeOscId);
> -    break;
> -  default:
> -    return EFI_UNSUPPORTED;
> -  }
> +#if (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
> +  Function = SYS_CFG_OSC;
> +  OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
> +#elif (PL111_CLCD_SITE == ARM_VE_DAUGHTERBOARD_1_SITE)
> +  Function = SYS_CFG_OSC_SITE1;
> +  OscillatorId = FixedPcdGet32 (PcdPL111LcdVideoModeOscId);
> +#else
> +#error PL111LcdVExpressLib: Unsupported PL111_CLCD_SITE
> +#endif // (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
>
>    // Set the video mode oscillator
>    Status = ArmPlatformSysConfigSetDevice (
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 10/18] ARM/VExpressPkg: HdLcdArmVExpressLib: Remove status check EFI_TIMEOUT
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 10/18] ARM/VExpressPkg: HdLcdArmVExpressLib: Remove status check EFI_TIMEOUT evan.lloyd
@ 2017-12-23 14:16   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 14:16 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, "Matteo.Carlini, "leif.lindholm,
	"nd, Arvind Chauhan, Thomas Panakamattam Abraham,
	"ard.biesheuvel

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak at arm.com>
>
> None of the ArmPlatformSys*  functions returns EFI_TIMEOUT. Hence checking
> this in the do {} while loop in LcdPlatformSetMode is wrong. Therefore
> remove this comparision and as a result remove the do {} while loop.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 22 ++++++++------------
>  1 file changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index f8d19df79260cdfbe1876d6ccc10d49abd0637cf..533d7fa4777e8f22429e2ae63a828dcb5401b5c0 100644
> --- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -230,25 +230,21 @@ LcdPlatformSetMode (
>    }
>
>    // Set the video mode oscillator
> -  do {
> -    Status = ArmPlatformSysConfigSetDevice (
> -               SYS_CFG_OSC_SITE1,
> -               FixedPcdGet32 (PcdHdLcdVideoModeOscId),
> -               mResolutions[ModeNumber].OscFreq
> -               );
> -  } while (Status == EFI_TIMEOUT);
> +  Status = ArmPlatformSysConfigSetDevice (
> +             SYS_CFG_OSC_SITE1,
> +             FixedPcdGet32 (PcdHdLcdVideoModeOscId),
> +             mResolutions[ModeNumber].OscFreq
> +             );
>    if (EFI_ERROR (Status)) {
>      ASSERT_EFI_ERROR (Status);
>      return Status;
>    }
>
>    // Set the DVI into the new mode
> -  do {
> -    Status = ArmPlatformSysConfigSet (
> -               SYS_CFG_DVIMODE,
> -               mResolutions[ModeNumber].Mode
> -               );
> -  } while (Status == EFI_TIMEOUT);
> +  Status = ArmPlatformSysConfigSet (
> +             SYS_CFG_DVIMODE,
> +             mResolutions[ModeNumber].Mode
> +             );
>    if (EFI_ERROR (Status)) {
>      ASSERT_EFI_ERROR (Status);
>      return Status;
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 11/18] ARM/VExpressPkg: HdLcdArmVExpressLib: Remove redundant Bpp
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 11/18] ARM/VExpressPkg: HdLcdArmVExpressLib: Remove redundant Bpp evan.lloyd
@ 2017-12-23 14:17   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 14:17 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Panakamattam Abraham, "ard.biesheuvel,
	"leif.lindholm, "Matteo.Carlini, "nd

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: EvanLloyd <evan.lloyd at arm.com>
>
> Because of copy/paste effects, HdLcdArmVExpress.c contained a
> table entry "LCD_BPP Bpp;" specifying the Bits per Pixel for each mode.
> However, all modes are LCD_BITS_PER_PIXEL_24.
>
> This change removes the table entry and related use of the field.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 42 ++++++--------------
>  1 file changed, 13 insertions(+), 29 deletions(-)
>
> diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index 533d7fa4777e8f22429e2ae63a828dcb5401b5c0..8496a0215bc78585b546f63312c9d7f1ad07adb6 100644
> --- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -32,7 +32,6 @@ typedef struct {
>    UINT32                     Mode;
>    UINT32                     HorizontalResolution;
>    UINT32                     VerticalResolution;
> -  LCD_BPP                    Bpp;
>    UINT32                     OscFreq;
>
>    // These are used by HDLCD
> @@ -48,37 +47,37 @@ typedef struct {
>  **/
>  STATIC CONST LCD_RESOLUTION mResolutions[] = {
>    { // Mode 0 : VGA : 640 x 480 x 24 bpp
> -    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
>      VGA_OSC_FREQUENCY,
>      VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
>      VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
>    },
>    { // Mode 1 : SVGA : 800 x 600 x 24 bpp
> -    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS,
>      SVGA_OSC_FREQUENCY,
>      SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
>      SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
>    },
>    { // Mode 2 : XGA : 1024 x 768 x 24 bpp
> -    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS,
>      XGA_OSC_FREQUENCY,
>      XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
>      XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
>    },
>    { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
> -    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS,
>      (SXGA_OSC_FREQUENCY/2),
>      SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
>      SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
>    },
>    { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
> -    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS,
>      (UXGA_OSC_FREQUENCY/2),
>      UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
>      UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
>    },
>    { // Mode 5 : HD : 1920 x 1080 x 24 bpp
> -    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS,
>      (HD_OSC_FREQUENCY/2),
>      HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
>      HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
> @@ -292,27 +291,12 @@ LcdPlatformQueryMode (
>    Info->VerticalResolution = mResolutions[ModeNumber].VerticalResolution;
>    Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
>
> -  switch (mResolutions[ModeNumber].Bpp) {
> -  case LCD_BITS_PER_PIXEL_24:
> -    Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
> -    Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
> -    Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
> -    Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
> -    Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> -    break;
> -
> -  case LCD_BITS_PER_PIXEL_16_555:
> -  case LCD_BITS_PER_PIXEL_16_565:
> -  case LCD_BITS_PER_PIXEL_12_444:
> -  case LCD_BITS_PER_PIXEL_8:
> -  case LCD_BITS_PER_PIXEL_4:
> -  case LCD_BITS_PER_PIXEL_2:
> -  case LCD_BITS_PER_PIXEL_1:
> -  default:
> -    // These are not supported
> -    ASSERT (FALSE);
> -    break;
> -  }
> +  /* Bits per Pixel is always LCD_BITS_PER_PIXEL_24 */
> +  Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
> +  Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
> +  Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
> +  Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
> +  Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
>
>    return EFI_SUCCESS;
>  }
> @@ -395,7 +379,7 @@ LcdPlatformGetBpp (
>      return EFI_INVALID_PARAMETER;
>    }
>
> -  *Bpp = mResolutions[ModeNumber].Bpp;
> +  *Bpp = LCD_BITS_PER_PIXEL_24;
>
>    return EFI_SUCCESS;
>  }
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 12/18] ARM/VExpressPkg: Redefine LcdPlatformGetTimings function
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 12/18] ARM/VExpressPkg: Redefine LcdPlatformGetTimings function evan.lloyd
@ 2017-12-23 14:18   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 14:18 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Panakamattam Abraham, "ard.biesheuvel,
	"leif.lindholm, "Matteo.Carlini, "nd

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak at arm.com>
>
> The LcdPlatformGetTimings interface function takes similar sets of
> multiple parameters for horizontal and vertical timings which can be
> aggregated in a common data type. This change defines a structure
> SCAN_TIMINGS for this which can be used to describe both horizontal and
> vertical scan timings, and accordingly redefines the
> LcdPlatformGetTiming interface, greatly reducing the amount of data
> passed about.
>
> Similarly the mode definition tables are also changed to use this data
> type and thus enable pass through access.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c       | 104 +++++-------
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 168 ++++++++------------
>  2 files changed, 108 insertions(+), 164 deletions(-)
>
> diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index 8496a0215bc78585b546f63312c9d7f1ad07adb6..b448d70f86d6acbc6bdae9749c7b6d0205935ba7 100644
> --- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -30,57 +30,51 @@
>
>  typedef struct {
>    UINT32                     Mode;
> -  UINT32                     HorizontalResolution;
> -  UINT32                     VerticalResolution;
>    UINT32                     OscFreq;
>
>    // These are used by HDLCD
> -  UINT32                     HSync;
> -  UINT32                     HBackPorch;
> -  UINT32                     HFrontPorch;
> -  UINT32                     VSync;
> -  UINT32                     VBackPorch;
> -  UINT32                     VFrontPorch;
> -} LCD_RESOLUTION;
> +  SCAN_TIMINGS               Horizontal;
> +  SCAN_TIMINGS               Vertical;
> +} DISPLAY_MODE;
>
>  /** The display modes supported by the platform.
>  **/
> -STATIC CONST LCD_RESOLUTION mResolutions[] = {
> +STATIC CONST DISPLAY_MODE mDisplayModes[] = {
>    { // Mode 0 : VGA : 640 x 480 x 24 bpp
> -    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
> +    VGA,
>      VGA_OSC_FREQUENCY,
> -    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> -    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> +    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> +    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
>    },
>    { // Mode 1 : SVGA : 800 x 600 x 24 bpp
> -    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS,
> +    SVGA,
>      SVGA_OSC_FREQUENCY,
> -    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> -    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> +    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> +    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
>    },
>    { // Mode 2 : XGA : 1024 x 768 x 24 bpp
> -    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS,
> +    XGA,
>      XGA_OSC_FREQUENCY,
> -    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> -    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> +    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> +    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
>    },
>    { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
> -    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS,
> +    SXGA,
>      (SXGA_OSC_FREQUENCY/2),
> -    SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
> -    SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
> +    {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
> +    {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
>    },
>    { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
> -    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS,
> +    UXGA,
>      (UXGA_OSC_FREQUENCY/2),
> -    UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
> -    UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
> +    {UXGA_H_RES_PIXELS, UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH},
> +    {UXGA_V_RES_PIXELS, UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH}
>    },
>    { // Mode 5 : HD : 1920 x 1080 x 24 bpp
> -    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS,
> +    HD,
>      (HD_OSC_FREQUENCY/2),
> -    HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
> -    HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
> +    {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
> +    {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
>    }
>  };
>
> @@ -205,7 +199,7 @@ LcdPlatformGetMaxMode (VOID)
>  {
>    // The following line will report correctly the total number of graphics modes
>    // that could be supported by the graphics driver
> -  return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION));
> +  return (sizeof (mDisplayModes) / sizeof (DISPLAY_MODE));
>  }
>
>  /** Set the requested display mode.
> @@ -242,7 +236,7 @@ LcdPlatformSetMode (
>    // Set the DVI into the new mode
>    Status = ArmPlatformSysConfigSet (
>               SYS_CFG_DVIMODE,
> -             mResolutions[ModeNumber].Mode
> +             mDisplayModes[ModeNumber].Mode
>               );
>    if (EFI_ERROR (Status)) {
>      ASSERT_EFI_ERROR (Status);
> @@ -287,9 +281,9 @@ LcdPlatformQueryMode (
>    }
>
>    Info->Version = 0;
> -  Info->HorizontalResolution = mResolutions[ModeNumber].HorizontalResolution;
> -  Info->VerticalResolution = mResolutions[ModeNumber].VerticalResolution;
> -  Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
> +  Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
> +  Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
> +  Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
>
>    /* Bits per Pixel is always LCD_BITS_PER_PIXEL_24 */
>    Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
> @@ -305,14 +299,10 @@ LcdPlatformQueryMode (
>
>    @param[in]  ModeNumber          Mode Number.
>
> -  @param[out] HRes                Pointer to horizontal resolution.
> -  @param[out] HSync               Pointer to horizontal sync width.
> -  @param[out] HBackPorch          Pointer to horizontal back porch.
> -  @param[out] HFrontPorch         Pointer to horizontal front porch.
> -  @param[out] VRes                Pointer to vertical resolution.
> -  @param[out] VSync               Pointer to vertical sync width.
> -  @param[out] VBackPorch          Pointer to vertical back porch.
> -  @param[out] VFrontPorch         Pointer to vertical front porch.
> +  @param[out] Horizontal          Pointer to horizontal timing parameters.
> +                                  (Resolution, Sync, Back porch, Front porch)
> +  @param[out] Vertical            Pointer to vertical timing parameters.
> +                                  (Resolution, Sync, Back porch, Front porch)
>
>    @retval EFI_SUCCESS             Display timing information for the requested
>                                    mode returned successfully.
> @@ -320,40 +310,22 @@ LcdPlatformQueryMode (
>  **/
>  EFI_STATUS
>  LcdPlatformGetTimings (
> -  IN  CONST UINT32                              ModeNumber,
> -  OUT UINT32 * CONST                            HRes,
> -  OUT UINT32 * CONST                            HSync,
> -  OUT UINT32 * CONST                            HBackPorch,
> -  OUT UINT32 * CONST                            HFrontPorch,
> -  OUT UINT32 * CONST                            VRes,
> -  OUT UINT32 * CONST                            VSync,
> -  OUT UINT32 * CONST                            VBackPorch,
> -  OUT UINT32 * CONST                            VFrontPorch
> +  IN  CONST UINT32                  ModeNumber,
> +  OUT CONST SCAN_TIMINGS         ** Horizontal,
> +  OUT CONST SCAN_TIMINGS         ** Vertical
>    )
>  {
>    // One of the pointers is NULL
> -  ASSERT (HRes != NULL);
> -  ASSERT (HSync != NULL);
> -  ASSERT (HBackPorch != NULL);
> -  ASSERT (HFrontPorch != NULL);
> -  ASSERT (VRes != NULL);
> -  ASSERT (VSync != NULL);
> -  ASSERT (VBackPorch != NULL);
> -  ASSERT (VFrontPorch != NULL);
> +  ASSERT (Horizontal != NULL);
> +  ASSERT (Vertical != NULL);
>
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>      ASSERT (FALSE);
>      return EFI_INVALID_PARAMETER;
>    }
>
> -  *HRes           = mResolutions[ModeNumber].HorizontalResolution;
> -  *HSync          = mResolutions[ModeNumber].HSync;
> -  *HBackPorch     = mResolutions[ModeNumber].HBackPorch;
> -  *HFrontPorch    = mResolutions[ModeNumber].HFrontPorch;
> -  *VRes           = mResolutions[ModeNumber].VerticalResolution;
> -  *VSync          = mResolutions[ModeNumber].VSync;
> -  *VBackPorch     = mResolutions[ModeNumber].VBackPorch;
> -  *VFrontPorch    = mResolutions[ModeNumber].VFrontPorch;
> +  *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
> +  *Vertical   = &mDisplayModes[ModeNumber].Vertical;
>
>    return EFI_SUCCESS;
>  }
> diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index cf50b20fd9b1b44a81963655c2f88305ce6bdc67..439cbdb1a73145fc4dc9c3c9587ce3fd9b9fff56 100644
> --- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -28,117 +28,111 @@
>
>  typedef struct {
>    UINT32                     Mode;
> -  UINT32                     HorizontalResolution;
> -  UINT32                     VerticalResolution;
>    LCD_BPP                    Bpp;
>    UINT32                     OscFreq;
>
> -  UINT32                     HSync;
> -  UINT32                     HBackPorch;
> -  UINT32                     HFrontPorch;
> -  UINT32                     VSync;
> -  UINT32                     VBackPorch;
> -  UINT32                     VFrontPorch;
> -} LCD_RESOLUTION;
> +  SCAN_TIMINGS               Horizontal;
> +  SCAN_TIMINGS               Vertical;
> +} DISPLAY_MODE;
>
>  /** The display modes supported by the platform.
>  **/
> -LCD_RESOLUTION mResolutions[] = {
> +STATIC CONST DISPLAY_MODE mDisplayModes[] = {
>    { // Mode 0 : VGA : 640 x 480 x 24 bpp
> -    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    VGA, LCD_BITS_PER_PIXEL_24,
>      VGA_OSC_FREQUENCY,
> -    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> -    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> +    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> +    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
>    },
>    { // Mode 1 : SVGA : 800 x 600 x 24 bpp
> -    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    SVGA, LCD_BITS_PER_PIXEL_24,
>      SVGA_OSC_FREQUENCY,
> -    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> -    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> +    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> +    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
>    },
>    { // Mode 2 : XGA : 1024 x 768 x 24 bpp
> -    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    XGA, LCD_BITS_PER_PIXEL_24,
>      XGA_OSC_FREQUENCY,
> -    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> -    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> +    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> +    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
>    },
>    { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
> -    SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    SXGA, LCD_BITS_PER_PIXEL_24,
>      (SXGA_OSC_FREQUENCY/2),
> -    SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
> -    SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
> +    {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
> +    {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
>    },
>    { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
> -    UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    UXGA, LCD_BITS_PER_PIXEL_24,
>      (UXGA_OSC_FREQUENCY/2),
> -    UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
> -    UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
> +    {UXGA_H_RES_PIXELS, UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH},
> +    {UXGA_V_RES_PIXELS, UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH}
>    },
>    { // Mode 5 : HD : 1920 x 1080 x 24 bpp
> -    HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> +    HD, LCD_BITS_PER_PIXEL_24,
>      (HD_OSC_FREQUENCY/2),
> -    HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
> -    HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
> +    {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
> +    {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
>    },
>    { // Mode 6 : VGA : 640 x 480 x 16 bpp (565 Mode)
> -    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
> +    VGA, LCD_BITS_PER_PIXEL_16_565,
>      VGA_OSC_FREQUENCY,
> -    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> -    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> +    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> +    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
>    },
>    { // Mode 7 : SVGA : 800 x 600 x 16 bpp (565 Mode)
> -    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
> +    SVGA, LCD_BITS_PER_PIXEL_16_565,
>      SVGA_OSC_FREQUENCY,
> -    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> -    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> +    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> +    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
>    },
>    { // Mode 8 : XGA : 1024 x 768 x 16 bpp (565 Mode)
> -    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
> +    XGA, LCD_BITS_PER_PIXEL_16_565,
>      XGA_OSC_FREQUENCY,
> -    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> -    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> +    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> +    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
>    },
>    { // Mode 9 : VGA : 640 x 480 x 15 bpp
> -    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> +    VGA, LCD_BITS_PER_PIXEL_16_555,
>      VGA_OSC_FREQUENCY,
> -    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> -    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> +    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> +    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
>    },
>    { // Mode 10 : SVGA : 800 x 600 x 15 bpp
> -    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> +    SVGA, LCD_BITS_PER_PIXEL_16_555,
>      SVGA_OSC_FREQUENCY,
> -    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> -    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> +    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> +    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
>    },
>    { // Mode 11 : XGA : 1024 x 768 x 15 bpp
> -    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> +    XGA, LCD_BITS_PER_PIXEL_16_555,
>      XGA_OSC_FREQUENCY,
> -    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> -    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> +    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> +    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
>    },
>    { // Mode 12 : XGA : 1024 x 768 x 15 bpp - All the timing info is derived from Linux Kernel Driver Settings
> -    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> +    XGA, LCD_BITS_PER_PIXEL_16_555,
>      63500000,
> -    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> -    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> +    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> +    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
>    },
>    { // Mode 13 : VGA : 640 x 480 x 12 bpp (444 Mode)
> -    VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
> +    VGA, LCD_BITS_PER_PIXEL_12_444,
>      VGA_OSC_FREQUENCY,
> -    VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> -    VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> +    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> +    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
>    },
>    { // Mode 14 : SVGA : 800 x 600 x 12 bpp (444 Mode)
> -    SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
> +    SVGA, LCD_BITS_PER_PIXEL_12_444,
>      SVGA_OSC_FREQUENCY,
> -    SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> -    SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> +    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> +    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
>    },
>    { // Mode 15 : XGA : 1024 x 768 x 12 bpp (444 Mode)
> -    XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
> +    XGA, LCD_BITS_PER_PIXEL_12_444,
>      XGA_OSC_FREQUENCY,
> -    XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> -    XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> +    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> +    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
>    }
>  };
>
> @@ -304,7 +298,7 @@ LcdPlatformSetMode (
>    Status = ArmPlatformSysConfigSetDevice (
>               Function,
>               OscillatorId,
> -             mResolutions[ModeNumber].OscFreq
> +             mDisplayModes[ModeNumber].OscFreq
>               );
>    if (EFI_ERROR (Status)) {
>      ASSERT_EFI_ERROR (Status);
> @@ -322,7 +316,7 @@ LcdPlatformSetMode (
>        // Set the DVI into the new mode
>        Status = ArmPlatformSysConfigSet (
>                   SYS_CFG_DVIMODE,
> -                 mResolutions[ModeNumber].Mode
> +                 mDisplayModes[ModeNumber].Mode
>                   );
>        if (EFI_ERROR (Status)) {
>          ASSERT_EFI_ERROR (Status);
> @@ -362,11 +356,11 @@ LcdPlatformQueryMode (
>    }
>
>    Info->Version = 0;
> -  Info->HorizontalResolution = mResolutions[ModeNumber].HorizontalResolution;
> -  Info->VerticalResolution = mResolutions[ModeNumber].VerticalResolution;
> -  Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
> +  Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
> +  Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
> +  Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
>
> -  switch (mResolutions[ModeNumber].Bpp) {
> +  switch (mDisplayModes[ModeNumber].Bpp) {
>    case LCD_BITS_PER_PIXEL_24:
>      Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
>      Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
> @@ -395,14 +389,10 @@ LcdPlatformQueryMode (
>
>    @param[in]  ModeNumber          Mode Number.
>
> -  @param[out] HRes                Pointer to horizontal resolution.
> -  @param[out] HSync               Pointer to horizontal sync width.
> -  @param[out] HBackPorch          Pointer to horizontal back porch.
> -  @param[out] HFrontPorch         Pointer to horizontal front porch.
> -  @param[out] VRes                Pointer to vertical resolution.
> -  @param[out] VSync               Pointer to vertical sync width.
> -  @param[out] VBackPorch          Pointer to vertical back porch.
> -  @param[out] VFrontPorch         Pointer to vertical front porch.
> +  @param[out] Horizontal          Pointer to horizontal timing parameters.
> +                                  (Resolution, Sync, Back porch, Front porch)
> +  @param[out] Vertical            Pointer to vertical timing parameters.
> +                                  (Resolution, Sync, Back porch, Front porch)
>
>    @retval EFI_SUCCESS             Display timing information for the requested
>                                    mode returned successfully.
> @@ -410,40 +400,22 @@ LcdPlatformQueryMode (
>  **/
>  EFI_STATUS
>  LcdPlatformGetTimings (
> -  IN  CONST UINT32                        ModeNumber,
> -  OUT UINT32 * CONST                      HRes,
> -  OUT UINT32 * CONST                      HSync,
> -  OUT UINT32 * CONST                      HBackPorch,
> -  OUT UINT32 * CONST                      HFrontPorch,
> -  OUT UINT32 * CONST                      VRes,
> -  OUT UINT32 * CONST                      VSync,
> -  OUT UINT32 * CONST                      VBackPorch,
> -  OUT UINT32 * CONST                      VFrontPorch
> +  IN  CONST UINT32                  ModeNumber,
> +  OUT CONST SCAN_TIMINGS         ** Horizontal,
> +  OUT CONST SCAN_TIMINGS         ** Vertical
>    )
>  {
>    // One of the pointers is NULL
> -  ASSERT (HRes != NULL);
> -  ASSERT (HSync != NULL);
> -  ASSERT (HBackPorch != NULL);
> -  ASSERT (HFrontPorch != NULL);
> -  ASSERT (VRes != NULL);
> -  ASSERT (VSync != NULL);
> -  ASSERT (VBackPorch != NULL);
> -  ASSERT (VFrontPorch != NULL);
> +  ASSERT (Horizontal != NULL);
> +  ASSERT (Vertical != NULL);
>
>    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>      ASSERT (FALSE);
>      return EFI_INVALID_PARAMETER;
>    }
>
> -  *HRes           = mResolutions[ModeNumber].HorizontalResolution;
> -  *HSync          = mResolutions[ModeNumber].HSync;
> -  *HBackPorch     = mResolutions[ModeNumber].HBackPorch;
> -  *HFrontPorch    = mResolutions[ModeNumber].HFrontPorch;
> -  *VRes           = mResolutions[ModeNumber].VerticalResolution;
> -  *VSync          = mResolutions[ModeNumber].VSync;
> -  *VBackPorch     = mResolutions[ModeNumber].VBackPorch;
> -  *VFrontPorch    = mResolutions[ModeNumber].VFrontPorch;
> +  *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
> +  *Vertical   = &mDisplayModes[ModeNumber].Vertical;
>
>    return EFI_SUCCESS;
>  }
> @@ -471,7 +443,7 @@ LcdPlatformGetBpp (
>      return EFI_INVALID_PARAMETER;
>    }
>
> -  *Bpp = mResolutions[ModeNumber].Bpp;
> +  *Bpp = mDisplayModes[ModeNumber].Bpp;
>
>    return EFI_SUCCESS;
>  }
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 13/18] ARM/VExpressPkg: PL111 and HDLCD: Add PCD to select pixel format
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 13/18] ARM/VExpressPkg: PL111 and HDLCD: Add PCD to select pixel format evan.lloyd
@ 2017-12-23 16:00   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 16:00 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Panakamattam Abraham, "ard.biesheuvel,
	"leif.lindholm, "Matteo.Carlini, "nd

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak at arm.com>
>
> Current HDLCD and PL111 platform libraries do not support display modes
> with PixelBlueGreenRedReserved8BitPerColor format,  i.e. because of
> historical confusion, they do not support the UEFI default
> PixelBlueGreenRedReserved8BitPerColor
>
> LcdPlatformLib for PL111, LcdPlatformQueryMode function returns the
> pixel format as PixelRedGreenBlueReserved8BitPerColor which is wrong,
> because that does not match the display controller's pixel format which
> is set to BGR in PL111Lcd GOP driver.
>
> Also it is not possible to configure pixel format as RGB/BGR for the
> display modes for a platform at build time.
>
> This change adds PcdGopPixelFormat to configure pixel format as
>     PixelRedGreenBlueReserved8BitPerColor    or
>     PixelBlueGreenRedReserved8BitPerColor    or
>     PixelBitMask.
> With this change, pixel format can be selected in the platform specific
> .dsc file for all supported display modes.
>
> Support for PixelBitMask is not implemented in PL111 or HDLCD
> GOP driver, hence  HDLCD and PL111 platform libraries will return error
> EFI_UNSUPPORTED if PcdGopPixelFormat is set to PixelBitMask.
> Indeed, it is not clear what selecting PixelBitMask might mean, but
> the option is allowed as it might suit a custom platform.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
> ---
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf       |  1 +
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf |  1 +
>  Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c            | 23 ++++++++----
>  Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c      | 38 +++++++++-----------
>  4 files changed, 35 insertions(+), 28 deletions(-)
>
> diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> index 2e83736609cf8c63cb498368cd377f6a23964ef4..4cbd324338be76a0b0bfb811159d893628e74155 100644
> --- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> +++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> @@ -41,3 +41,4 @@ [Protocols]
>
>  [FixedPcd]
>    gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId
> +  gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
> diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> index 1ee878041559fa84a810f65175f2507bda663d76..20045380149241ce14f41bcb70afcb8145fe821f 100644
> --- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> +++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> @@ -42,3 +42,4 @@ [Protocols]
>  [FixedPcd]
>    gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
>    gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId
> +  gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
> diff --git a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index b448d70f86d6acbc6bdae9749c7b6d0205935ba7..f1c18ac955f621e9eab3dede86758f5f1b1a791d 100644
> --- a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -15,7 +15,6 @@
>  #include <PiDxe.h>
>
>  #include <Library/ArmPlatformSysConfigLib.h>
> -#include <Library/IoLib.h>
>  #include <Library/PcdLib.h>
>  #include <Library/DebugLib.h>
>  #include <Library/DxeServicesTableLib.h>
> @@ -93,6 +92,10 @@ EFI_EDID_ACTIVE_PROTOCOL      mEdidActive = {
>    @param[in] Handle              Handle to the LCD device instance.
>
>    @retval EFI_SUCCESS            Plaform library initialized successfully.
> +  @retval EFI_UNSUPPORTED        PcdGopPixelFormat must be
> +                                 PixelRedGreenBlueReserved8BitPerColor OR
> +                                 PixelBlueGreenRedReserved8BitPerColor
> +                                 any other format is not supported.
>    @retval !(EFI_SUCCESS)         Other errors.
>  **/
>  EFI_STATUS
> @@ -101,6 +104,17 @@ LcdPlatformInitializeDisplay (
>    )
>  {
>    EFI_STATUS  Status;
> +  EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
> +
> +  // PixelBitMask and PixelBltOnly pixel formats are not supported
> +  PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> +  if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
> +    && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
> +

Please fix the weird indentation here

> +    ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
> +      ||  PixelFormat == PixelBlueGreenRedReserved8BitPerColor);

and here (just put the boolean operator on the previous line)

> +   return EFI_UNSUPPORTED;
> +  }
>
>    // Set the FPGA multiplexer to select the video output from the
>    // motherboard or the daughterboard
> @@ -285,12 +299,7 @@ LcdPlatformQueryMode (
>    Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
>    Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
>
> -  /* Bits per Pixel is always LCD_BITS_PER_PIXEL_24 */
> -  Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
> -  Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
> -  Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
> -  Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
> -  Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> +  Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
>
>    return EFI_SUCCESS;
>  }
> diff --git a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 439cbdb1a73145fc4dc9c3c9587ce3fd9b9fff56..16a74c76cf27526493165dc6d81384f752fd3f20 100644
> --- a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -149,7 +149,12 @@ EFI_EDID_ACTIVE_PROTOCOL      mEdidActive = {
>  /** PL111 Platform specific initialization function.
>
>    @param[in] Handle              Handle to the LCD device instance.
> +
>    @retval EFI_SUCCESS            Plaform library initialized successfully.
> +  @retval EFI_UNSUPPORTED        PcdGopPixelFormat must be
> +                                 PixelRedGreenBlueReserved8BitPerColor OR
> +                                 PixelBlueGreenRedReserved8BitPerColor
> +                                 any other format is not supported
>    @retval !(EFI_SUCCESS)         Other errors.
>  **/
>  EFI_STATUS
> @@ -158,6 +163,17 @@ LcdPlatformInitializeDisplay (
>    )
>  {
>    EFI_STATUS  Status;
> +  EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
> +
> +  // PixelBitMask and PixelBltOnly pixel formats are not supported
> +  PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> +  if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
> +    && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
> +
> +    ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
> +      ||  PixelFormat == PixelBlueGreenRedReserved8BitPerColor);

Same here

> +   return EFI_UNSUPPORTED;
> +  }
>
>    // Set the FPGA multiplexer to select the video output from the motherboard
>    // or the daughterboard
> @@ -360,27 +376,7 @@ LcdPlatformQueryMode (
>    Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
>    Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
>
> -  switch (mDisplayModes[ModeNumber].Bpp) {
> -  case LCD_BITS_PER_PIXEL_24:
> -    Info->PixelFormat                   = PixelRedGreenBlueReserved8BitPerColor;
> -    Info->PixelInformation.RedMask      = LCD_24BPP_RED_MASK;
> -    Info->PixelInformation.GreenMask    = LCD_24BPP_GREEN_MASK;
> -    Info->PixelInformation.BlueMask     = LCD_24BPP_BLUE_MASK;
> -    Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> -    break;
> -
> -  case LCD_BITS_PER_PIXEL_16_555:
> -  case LCD_BITS_PER_PIXEL_16_565:
> -  case LCD_BITS_PER_PIXEL_12_444:
> -  case LCD_BITS_PER_PIXEL_8:
> -  case LCD_BITS_PER_PIXEL_4:
> -  case LCD_BITS_PER_PIXEL_2:
> -  case LCD_BITS_PER_PIXEL_1:
> -  default:
> -    // These are not supported
> -    ASSERT (FALSE);
> -    break;
> -  }
> +  Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
>
>    return EFI_SUCCESS;
>  }
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>

With the above fixed

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 14/18] ARM/VExpressPkg: Reserving framebuffer at build
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 14/18] ARM/VExpressPkg: Reserving framebuffer at build evan.lloyd
@ 2017-12-23 16:02   ` Ard Biesheuvel
  2018-01-03 11:04     ` Evan Lloyd
  0 siblings, 1 reply; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 16:02 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Panakamattam Abraham, "ard.biesheuvel,
	"leif.lindholm, "Matteo.Carlini, "nd

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak at arm.com>
>
> This change uses two PCDs, PcdArmLcdFrameBufferBase and
> PcdArmLcdFrameBufferSize introduced in correspondiong EDK2 patch to
> reserve framebuffer in DRAM if these values are defined in platform
> specific DSC file, avoiding the need to allocate dynamically.
> This allows the framebuffer to appear as "I/O memory" outside of the
> normal RAM map, which is similar to the "VRAM" case.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
> ---
>  Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf |  4 +++-
>  Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c          | 20 ++++++++++++++++++--
>  2 files changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> index 4cbd2ff4b4faf11ccd4fe30117708d7cc4c1bf0e..c70c4ce64826174e6d15611de640ad3b902835b9 100644
> --- a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> +++ b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> @@ -1,5 +1,5 @@
>  #/* @file
> -#  Copyright (c) 2011-2014, ARM Limited. All rights reserved.
> +#  Copyright (c) 2011-2017, ARM Limited. All rights reserved.
>  #
>  #  This program and the accompanying materials
>  #  are licensed and made available under the terms and conditions of the BSD License
> @@ -57,6 +57,8 @@ [FixedPcd]
>    gArmTokenSpaceGuid.PcdArmPrimaryCore
>
>    gArmPlatformTokenSpaceGuid.PcdCoreCount
> +  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
> +  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
>

As mentioned in the review of the other patch, please move these into
VExpressPkg

>  [Ppis]
>    gArmMpCoreInfoPpiGuid
> diff --git a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> index 6379e81751fca5e7972c5c30f305be65fd1ae71d..1e8f3205312ebf30fa1666130bc944261384359a 100644
> --- a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> +++ b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> @@ -1,6 +1,6 @@
>  /** @file
>  *
> -*  Copyright (c) 2011-2016, ARM Limited. All rights reserved.
> +*  Copyright (c) 2011-2017, ARM Limited. All rights reserved.
>  *
>  *  This program and the accompanying materials
>  *  are licensed and made available under the terms and conditions of the BSD License
> @@ -20,8 +20,10 @@
>  #include <Library/MemoryAllocationLib.h>
>  #include <ArmPlatform.h>
>
> +#define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0) ? 1 : 0)
> +
>  // Number of Virtual Memory Map Descriptors
> -#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS          9
> +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR)
>
>  // DDR attributes
>  #define DDR_ATTRIBUTES_CACHED   ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
> @@ -142,6 +144,20 @@ ArmPlatformGetVirtualMemoryMap (
>    //
>    VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
>
> +  // Map region for the frame buffer in the system RAM
> +#if (FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize) != 0)
> +  VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
> +  VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
> +  VirtualMemoryTable[Index].Length = FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
> +  // Map as Normal Non-Cacheable memory, so that we can use the accelerated
> +  // SetMem/CopyMem routines that may use unaligned accesses or
> +  // DC ZVA instructions. If mapped as device memory, these routine may cause
> +  // alignment faults.
> +  // NOTE: The attribute value is misleading, it indicates memory map type as
> +  // an un-cached, un-buffered but allows buffering and reordering.
> +  VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
> +#endif
> +

Whose responsibility is it to ensure that this region is removed from
SystemMemoryBase/SystemMemorySize? If it is up to the .DSC author,
could you please add an ASSERT() here that they don't overlap?

>    // Map sparse memory region if present
>    if (HasSparseMemory) {
>      VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 15/18] ARM/VExpressPkg: New DP500/DP550/DP650 platform library.
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 15/18] ARM/VExpressPkg: New DP500/DP550/DP650 platform library evan.lloyd
@ 2017-12-23 16:07   ` Ard Biesheuvel
  2018-01-08 18:51     ` Evan Lloyd
  0 siblings, 1 reply; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 16:07 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Panakamattam Abraham, "ard.biesheuvel,
	"leif.lindholm, "Matteo.Carlini, "nd

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak at arm.com>
>
> This change adds LcdPlatformLib implementation for ARM Mali
> DP500/DP500/DP650 display processors for models (with DP550 support).
>
> NOTE: Versions for actual hardware are liable to require extra handling
> for clock input changes, etc.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
> ---
>  Platform/ARM/VExpressPkg/ArmVExpressPkg.dec                            |   3 +-
>  Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf         |  45 +++
>  Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf |   3 +
>  Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c           | 374 ++++++++++++++++++++
>  Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c          |  10 +-
>  5 files changed, 433 insertions(+), 2 deletions(-)
>
> diff --git a/Platform/ARM/VExpressPkg/ArmVExpressPkg.dec b/Platform/ARM/VExpressPkg/ArmVExpressPkg.dec
> index 695553a94f7f7e963b5db995c5e54f1ae1559daf..a82bc905b3a2180e85f78a6c16aeba9fcb495bed 100644
> --- a/Platform/ARM/VExpressPkg/ArmVExpressPkg.dec
> +++ b/Platform/ARM/VExpressPkg/ArmVExpressPkg.dec
> @@ -1,7 +1,7 @@
>  #/** @file
>  # Arm Versatile Express package.
>  #
> -#  Copyright (c) 2012-2015, ARM Limited. All rights reserved.
> +#  Copyright (c) 2012-2017, ARM Limited. All rights reserved.
>  #
>  #  This program and the accompanying materials are licensed and made available
>  #  under the terms and conditions of the BSD License which accompanies this
> @@ -51,6 +51,7 @@ [PcdsFixedAtBuild.common]
>    gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId|1|UINT32|0x00000003
>
>    gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId|0|UINT32|0x00000005
> +  gArmVExpressTokenSpaceGuid.PcdArmMaliDpMaxMode|0|UINT32|0x00000008
>
>    #
>    # Device path of block device on which Fastboot will flash partitions
> diff --git a/Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf b/Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
> new file mode 100644
> index 0000000000000000000000000000000000000000..4c8f3c3b3b6540505fce173ef16e2f3eafeb048b
> --- /dev/null
> +++ b/Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
> @@ -0,0 +1,45 @@
> +#/** @file ArmMaliDpLib.inf
> +#
> +#  Component description file for ArmMaliDpLib module
> +#
> +#  Copyright (c) 2017, ARM Limited. All rights reserved.
> +#
> +#  This program and the accompanying materials
> +#  are licensed and made available under the terms and conditions of the BSD License
> +#  which accompanies this distribution.  The full text of the license may be found at
> +#  http://opensource.org/licenses/bsd-license.php
> +#
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#**/
> +
> +[Defines]
> +  INF_VERSION                    = 0x00010019
> +  BASE_NAME                      = ArmMaliDpLib
> +  FILE_GUID                      = 36C47FED-2F3F-49C7-89CE-31B13F0431D8
> +  MODULE_TYPE                    = BASE
> +  VERSION_STRING                 = 1.0
> +  LIBRARY_CLASS                  = LcdPlatformLib
> +
> +[Sources.common]
> +  ArmMaliDpLib.c
> +
> +[Packages]
> +  ArmPlatformPkg/ArmPlatformPkg.dec
> +  MdePkg/MdePkg.dec
> +  Platform/ARM/VExpressPkg/ArmVExpressPkg.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  DxeServicesTableLib
> +
> +[FixedPcd.common]
> +  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
> +  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
> +  gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
> +
> +  # MaxMode must be one number higher than the actual max mode,
> +  # i.e. for actual maximum mode 2, set the value to 3.
> +  # See Section 12.9 of the UEFI Specification 2.7
> +  gArmVExpressTokenSpaceGuid.PcdArmMaliDpMaxMode
> +
> diff --git a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> index c70c4ce64826174e6d15611de640ad3b902835b9..c2d8749d0c08d6afc71f7c41a27075d58ff27557 100644
> --- a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> +++ b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> @@ -60,5 +60,8 @@ [FixedPcd]
>    gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
>    gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
>
> +  gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase
> +  gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength
> +
>  [Ppis]
>    gArmMpCoreInfoPpiGuid
> diff --git a/Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c b/Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..63f7c3b874b4fea80ab81c396a08e3e2e9b0581c
> --- /dev/null
> +++ b/Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
> @@ -0,0 +1,374 @@
> +/** @file ArmMaliDpLib.c
> +
> +  The file contains ARM Mali DP platform specific implementation.
> +
> +  Copyright (c) 2017, ARM Ltd. All rights reserved.
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD License
> +  which accompanies this distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <PiDxe.h>
> +#include <ArmPlatform.h>
> +#include <Library/DebugLib.h>
> +#include <Library/DxeServicesTableLib.h>
> +#include <Library/LcdPlatformLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +
> +/** Check an address is within 40 bits.
> +
> +  The ARM Mali DP framebuffer address size can not be wider than 40 bits
> +**/
> +#define  DP_VALID_BASE_ADDR(Address)  ((Address >> 40) == 0)
> +
> +typedef struct {
> +  UINT32                      OscFreq;
> +  SCAN_TIMINGS                Horizontal;
> +  SCAN_TIMINGS                Vertical;
> +} DISPLAY_MODE;
> +
> +/** The display modes implemented by this driver.
> +
> +  On Models, the OSC frequencies (listed for each mode below) are not used.
> +  However these frequencies are useful on hardware plaforms where related
> +  clock (or PLL) settings are based on these pixel clocks.
> +
> +  Since the clock settings are defined externally, the driver must
> +  communicate pixel clock frequencies to relevant modules
> +  responsible for setting clocks. e.g. SCP.
> +**/
> +STATIC CONST DISPLAY_MODE mDisplayModes[] = {
> +  {
> +    // Mode 0 : VGA : 640 x 480 x 24 bpp.
> +    VGA_OSC_FREQUENCY,
> +    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> +    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 1 : WVGA : 800 x 480 x 24 bpp.
> +    WVGA_OSC_FREQUENCY,
> +    {WVGA_H_RES_PIXELS, WVGA_H_SYNC, WVGA_H_BACK_PORCH, WVGA_H_FRONT_PORCH},
> +    {WVGA_V_RES_PIXELS, WVGA_V_SYNC, WVGA_V_BACK_PORCH, WVGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 2 : SVGA : 800 x 600 x 24 bpp.
> +    SVGA_OSC_FREQUENCY,
> +    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> +    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 3 : QHD : 960 x 540 x 24 bpp.
> +    QHD_OSC_FREQUENCY,
> +    {QHD_H_RES_PIXELS, QHD_H_SYNC, QHD_H_BACK_PORCH, QHD_H_FRONT_PORCH},
> +    {QHD_V_RES_PIXELS, QHD_V_SYNC, QHD_V_BACK_PORCH, QHD_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 4 : WSVGA : 1024 x 600 x 24 bpp.
> +    WSVGA_OSC_FREQUENCY,
> +    {WSVGA_H_RES_PIXELS, WSVGA_H_SYNC, WSVGA_H_BACK_PORCH, WSVGA_H_FRONT_PORCH},
> +    {WSVGA_V_RES_PIXELS, WSVGA_V_SYNC, WSVGA_V_BACK_PORCH, WSVGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 5 : XGA : 1024 x 768 x 24 bpp.
> +    XGA_OSC_FREQUENCY,
> +    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> +    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 6 : HD : 1280 x 720 x 24 bpp.
> +    HD720_OSC_FREQUENCY,
> +    {HD720_H_RES_PIXELS, HD720_H_SYNC, HD720_H_BACK_PORCH, HD720_H_FRONT_PORCH},
> +    {HD720_V_RES_PIXELS, HD720_V_SYNC, HD720_V_BACK_PORCH, HD720_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 7 : WXGA : 1280 x 800 x 24 bpp.
> +    WXGA_OSC_FREQUENCY,
> +    {WXGA_H_RES_PIXELS, WXGA_H_SYNC, WXGA_H_BACK_PORCH, WXGA_H_FRONT_PORCH},
> +    {WXGA_V_RES_PIXELS, WXGA_V_SYNC, WXGA_V_BACK_PORCH, WXGA_V_FRONT_PORCH}
> +  },
> +  { // Mode 8 : SXGA : 1280 x 1024 x 24 bpp.
> +    SXGA_OSC_FREQUENCY,
> +    {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
> +    {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
> +  },
> +  { // Mode 9 : WSXGA+ : 1680 x 1050 x 24 bpp.
> +    WSXGA_OSC_FREQUENCY,
> +    {WSXGA_H_RES_PIXELS, WSXGA_H_SYNC, WSXGA_H_BACK_PORCH, WSXGA_H_FRONT_PORCH},
> +    {WSXGA_V_RES_PIXELS,WSXGA_V_SYNC, WSXGA_V_BACK_PORCH, WSXGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 10 : HD : 1920 x 1080 x 24 bpp.
> +    HD_OSC_FREQUENCY,
> +    {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
> +    {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
> +  }
> +};
> +
> +/** If PcdArmMaliDpMaxMode is 0, platform supports full range of modes
> +  else platform supports modes from 0 to PcdArmMaliDpMaxMode - 1
> +**/
> +STATIC CONST UINT32 mMaxMode = ((FixedPcdGet32 (PcdArmMaliDpMaxMode) != 0)
> +                                   ? FixedPcdGet32 (PcdArmMaliDpMaxMode)
> +                                   : sizeof (mDisplayModes) / sizeof (DISPLAY_MODE));
> +
> +/** Platform related initialization function.
> +
> +  @param[in] Handle             Handle to the instance of the device.
> +
> +  @retval EFI_SUCCESS           Initialization of platform library successful.
> +  @retval EFI_UNSUPPORTED       PcdGopPixelFormat must be
> +                                PixelRedGreenBlueReserved8BitPerColor OR
> +                                PixelBlueGreenRedReserved8BitPerColor
> +                                any other format is not supported.
> +**/
> +EFI_STATUS
> +LcdPlatformInitializeDisplay (
> +  IN CONST EFI_HANDLE   Handle
> +  )
> +{
> +  EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
> +
> +  (VOID)Handle;
> +
> +  // PixelBitMask and PixelBltOnly pixel formats are not supported
> +  PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> +  if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
> +    && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
> +
> +    ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
> +      ||  PixelFormat == PixelBlueGreenRedReserved8BitPerColor);

Please fix the funky indentation

> +   return EFI_UNSUPPORTED;
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/* Internal helper function to allocate memory if memory is not already
> +  reserved for framebuffer
> +
> +  @param[in]  VramSize          Requested framebuffer size in bytes.
> +  @param[out] VramBaseAddress   Pointer to memory allocated for framebuffer.
> +
> +  @retval EFI_SUCCESS           Framebuffer memory allocated successfully.
> +  @retval EFI_UNSUPPORTED       Allocated address wider than 40 bits.
> +  @retval !EFI_SUCCESS          Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +GetVram (
> +  IN  UINTN                 CONST  VramSize,
> +  OUT EFI_PHYSICAL_ADDRESS *CONST  VramBaseAddress
> +  )
> +{
> +  EFI_STATUS Status;
> +
> +  // Check if memory is already reserved for the framebuffer.
> +#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)
> +

Please don't use CPP conditionals for control flow

> +#if (!DP_VALID_BASE_ADDR (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase)))
> +#error ARM Mali DP framebuffer base address cannot be wider than 40 bits.
> +#else
> +  *VramBaseAddress =
> +    (EFI_PHYSICAL_ADDRESS)FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
> +
> +  Status = EFI_SUCCESS;
> +#endif
> +
> +#else
> +  // If not already reserved, attempt to allocate the VRAM from the DRAM.
> +  Status = gBS->AllocatePages (
> +                  AllocateAnyPages,
> +                  EfiBootServicesData,
> +                  EFI_SIZE_TO_PAGES (*VramSize),
> +                  VramBaseAddress
> +                  );
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "ArmMaliDpLib: Failed to allocate framebuffer.\n"));
> +    ASSERT (FALSE);
> +    return Status;
> +  }
> +
> +  // ARM Mali DP framebuffer base address can not be wider than 40 bits.
> +  if (!DP_VALID_BASE_ADDR (*VramBaseAddress)) {
> +    gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> +    ASSERT (DP_VALID_BASE_ADDR (*VramBaseAddress));
> +    return EFI_UNSUPPORTED;
> +  }
> +
> +  // Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is
> +  // cacheable, for ARM/AArch64 EFI_MEMORY_WC memory is actually uncached.
> +  Status = gDS->SetMemorySpaceAttributes (
> +                  *VramBaseAddress,
> +                  *VramSize,
> +                  EFI_MEMORY_WC

Please add EFI_MEMORY_XP here

> +                  );
> +  if (EFI_ERROR (Status)) {
> +    ASSERT (FALSE);
> +    gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> +  }
> +#endif
> +
> +  return Status;
> +}
> +
> +/** Allocate VRAM memory in DRAM for the framebuffer
> +  (unless it is reserved already).
> +
> +  The allocated address can be used to set the framebuffer as a base buffer
> +  address for any layer of the ARM Mali DP.
> +
> +  @param[out] VramBaseAddress     A pointer to the framebuffer address.
> +  @param[out] VramSize            A pointer to the size of the frame
> +                                  buffer in bytes
> +
> +  @retval EFI_SUCCESS             Frame buffer memory allocation success.
> +  @retval EFI_UNSUPPORTED         Allocated address wider than 40 bits
> +  @retval !EFI_SUCCESS            Other errors.
> +**/
> +EFI_STATUS
> +LcdPlatformGetVram (
> +  OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> +  OUT UINTN                * CONST VramSize
> +  )
> +{
> +  ASSERT (VramBaseAddress != NULL);
> +  ASSERT (VramSize != NULL);
> +
> +  // Set the VRAM size.
> +  *VramSize = (UINTN)FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
> +
> +  return GetVram (*VramSize, VramBaseAddress);
> +}
> +
> +/** Return total number of modes supported.
> +
> +  Note: Valid mode numbers are 0 to MaxMode - 1
> +  See Section 12.9 of the UEFI Specification 2.7
> +
> +  @retval UINT32             Mode Number.
> +**/
> +UINT32
> +LcdPlatformGetMaxMode (VOID)
> +{
> +  return  mMaxMode;
> +}
> +
> +/** Set the requested display mode.
> +
> +  @param[in] ModeNumber            Mode Number.
> +
> +  @retval EFI_SUCCESS              Mode set successful.
> +  @retval EFI_INVALID_PARAMETER    Requested mode not found.
> +**/
> +EFI_STATUS
> +LcdPlatformSetMode (
> +  IN CONST UINT32 ModeNumber
> +  )
> +{
> +
> +  if (ModeNumber >= mMaxMode) {
> +    ASSERT (ModeNumber < mMaxMode);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  // On models, platform specific clock/mux settings are not required.
> +  // Display controller specific settings for Mali DP are done in LcdSetMode.
> +  return EFI_SUCCESS;
> +}
> +
> +/** Return information for the requested mode number.
> +
> +  @param[in]  ModeNumber          Mode Number.
> +  @param[out] Info                Pointer for returned mode information
> +                                  (on success).
> +
> +  @retval EFI_SUCCESS             Display mode information of the requested
> +                                  mode returned successfully.
> +**/
> +EFI_STATUS
> +LcdPlatformQueryMode (
> +  IN  CONST UINT32                                 ModeNumber,
> +  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> +  )
> +{
> +  ASSERT (ModeNumber < mMaxMode);
> +  ASSERT (Info != NULL);
> +
> +  Info->Version = 0;
> +  Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
> +  Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
> +  Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
> +
> +  Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/** Return the display timing information for the requested mode number.
> +
> +  @param[in]  ModeNumber         Mode Number.
> +
> +  @param[out] Horizontal         Pointer to horizontal timing parameters.
> +                                 (Resolution, Sync, Back porch, Front porch)
> +  @param[out] Vertical           Pointer to vertical timing parameters.
> +                                 (Resolution, Sync, Back porch, Front porch)
> +
> +  @retval EFI_SUCCESS             Display timing information of the requested
> +                                  mode returned successfully.
> +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> +**/
> +EFI_STATUS
> +LcdPlatformGetTimings (
> +  IN  UINT32                ModeNumber,
> +  OUT CONST SCAN_TIMINGS ** Horizontal,
> +  OUT CONST SCAN_TIMINGS ** Vertical
> +  )
> +{
> +  ASSERT (Horizontal != NULL);
> +  ASSERT (Vertical != NULL);
> +
> +  if (ModeNumber >= mMaxMode) {
> +    ASSERT (ModeNumber < mMaxMode);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
> +  *Vertical = &mDisplayModes[ModeNumber].Vertical;
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/** Return bits per pixel information for a mode number.
> +
> +  @param[in]  ModeNumber          Mode Number.
> +  @param[out] Bpp                 Pointer to value Bytes Per Pixel.
> +
> +  @retval EFI_SUCCESS             Bits per pixel information of the display
> +                                  mode returned successfully.
> +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> +**/
> +EFI_STATUS
> +LcdPlatformGetBpp (
> +  IN  CONST UINT32    ModeNumber,
> +  OUT LCD_BPP * CONST Bpp
> +  )
> +{
> +  ASSERT (Bpp != NULL);
> +  if (ModeNumber >= mMaxMode) {
> +    // Check valid ModeNumber.
> +    ASSERT (ModeNumber < mMaxMode);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  *Bpp = LCD_BITS_PER_PIXEL_24;
> +
> +  return EFI_SUCCESS;
> +}
> diff --git a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> index 1e8f3205312ebf30fa1666130bc944261384359a..f0b482f91a84d91ac9914c18b7941dd32ab8c8a7 100644
> --- a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> +++ b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> @@ -21,9 +21,10 @@
>  #include <ArmPlatform.h>
>
>  #define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0) ? 1 : 0)
> +#define DP_BASE_DESCRIPTOR      ((FixedPcdGet64 (PcdArmMaliDpBase) != 0) ? 1 : 0)
>
>  // Number of Virtual Memory Map Descriptors
> -#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR)
> +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR + DP_BASE_DESCRIPTOR)
>
>  // DDR attributes
>  #define DDR_ATTRIBUTES_CACHED   ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
> @@ -158,6 +159,13 @@ ArmPlatformGetVirtualMemoryMap (
>    VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
>  #endif
>
> +#if (FixedPcdGet64 (PcdArmMaliDpBase) != 0)
> +  // DP500/DP550/DP650 peripheral memory region
> +  VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdArmMaliDpBase);
> +  VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64 (PcdArmMaliDpBase);
> +  VirtualMemoryTable[Index].Length = FixedPcdGet32 (PcdArmMaliDpMemoryRegionLength);
> +  VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
> +#endif
>    // Map sparse memory region if present
>    if (HasSparseMemory) {
>      VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 16/18] ARM/JunoPkg: Mapping Non-Trused SRAM as device memory
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 16/18] ARM/JunoPkg: Mapping Non-Trused SRAM as device memory evan.lloyd
@ 2017-12-23 16:08   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 16:08 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Panakamattam Abraham, "ard.biesheuvel,
	"leif.lindholm, "Matteo.Carlini, "nd

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> This fix changes the cache attribute of Non-Trusted SRAM on the Juno
> platform to device memory. This change is required to avoid coherency
> problems as Non-Trusted SRAM is used as a shared memory between the
> application processor and the SCP for communication. This change is a
> prerequisite for upcoming SCMI driver for the Juno platform.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>

Evan, this needs your signoff as well I think?

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
> index aa8d7d9c3b0d41e62d1849e6e88760e3066617f7..afb2db0050c65b0d1b2b69c9038e168755c152c1 100644
> --- a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
> +++ b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
> @@ -1,6 +1,6 @@
>  /** @file
>  *
> -*  Copyright (c) 2013-2015, ARM Limited. All rights reserved.
> +*  Copyright (c) 2013-2017, ARM Limited. All rights reserved.
>  *
>  *  This program and the accompanying materials
>  *  are licensed and made available under the terms and conditions of the BSD License
> @@ -111,7 +111,9 @@ ArmPlatformGetVirtualMemoryMap (
>    VirtualMemoryTable[++Index].PhysicalBase  = ARM_JUNO_NON_SECURE_SRAM_BASE;
>    VirtualMemoryTable[Index].VirtualBase     = ARM_JUNO_NON_SECURE_SRAM_BASE;
>    VirtualMemoryTable[Index].Length          = ARM_JUNO_NON_SECURE_SRAM_SZ;
> -  VirtualMemoryTable[Index].Attributes      = CacheAttributes;
> +  // This memory is shared between the application processor
> +  // and the SCP. To avoid coherency problems, map it as device memory.
> +  VirtualMemoryTable[Index].Attributes      = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
>
>    // PCI Root Complex
>    VirtualMemoryTable[++Index].PhysicalBase  = PcdGet64 (PcdPcieControlBaseAddress);
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 17/18] ARM/JunoPkg: Adding SCMI MTL library
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 17/18] ARM/JunoPkg: Adding SCMI MTL library evan.lloyd
@ 2017-12-23 16:12   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 16:12 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Panakamattam Abraham, "ard.biesheuvel,
	"leif.lindholm, "Matteo.Carlini, "nd

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> This change adds a new Mailbox Transport Layer library for the Juno
> platform. This library is required for ArmScmiDxe driver communication
> with the SCP.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> ---
>  Platform/ARM/JunoPkg/ArmJuno.dec                    |   9 +-
>  Platform/ARM/JunoPkg/ArmJuno.dsc                    |   3 +
>  Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf      |  39 ++++
>  Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h |  94 ++++++++++
>  Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c        | 195 ++++++++++++++++++++
>  5 files changed, 339 insertions(+), 1 deletion(-)
>
> diff --git a/Platform/ARM/JunoPkg/ArmJuno.dec b/Platform/ARM/JunoPkg/ArmJuno.dec
> index 60cef6d23a2d904103b9806d871fd2b89fff51c3..b733480c3198d135df16ca024b5e85ff350e11c7 100644
> --- a/Platform/ARM/JunoPkg/ArmJuno.dec
> +++ b/Platform/ARM/JunoPkg/ArmJuno.dec
> @@ -1,5 +1,5 @@
>  #
> -#  Copyright (c) 2013-2015, ARM Limited. All rights reserved.
> +#  Copyright (c) 2013-2017, ARM Limited. All rights reserved.
>  #
>  #  This program and the accompanying materials
>  #  are licensed and made available under the terms and conditions of the BSD License
> @@ -46,3 +46,10 @@ [PcdsFixedAtBuild.common]
>    # Juno Device Trees are loaded from NOR Flash
>    gArmJunoTokenSpaceGuid.PcdJunoFdtDevicePath|L"VenHw(E7223039-5836-41E1-B542-D7EC736C5E59)/board.dtb"|VOID*|0x00000008
>
> +  # MHU Register base used by SCMI Mailbox transport
> +  gArmJunoTokenSpaceGuid.PcdArmMtlDoorBell|0x2B1F0000|UINT64|0x00000024
> +
> +  # ARM_JUNO_NON_SECURE_SRAM_BASE used by SCMI Mailbox transport
> +  gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase|0x2E000000|UINT64|0x00000025
> +  gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize|0x80|UINT32|0x00000026
> +
> diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc b/Platform/ARM/JunoPkg/ArmJuno.dsc
> index 5c2a29fe8330bbf308e31e34b617517a5aebcf6d..fe860956a4dc497cac52be70bab3657246a08bd0 100644
> --- a/Platform/ARM/JunoPkg/ArmJuno.dsc
> +++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
> @@ -47,6 +47,9 @@ [LibraryClasses.common]
>    # USB Requirements
>    UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
>
> +  # SCMI Mailbox Transport Layer
> +  ArmMtl|Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
> +
>  [LibraryClasses.common.SEC]
>    PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
>    ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
> diff --git a/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf b/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
> new file mode 100644
> index 0000000000000000000000000000000000000000..69e845f93f9332205fd5d36af2753681304058e3
> --- /dev/null
> +++ b/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
> @@ -0,0 +1,39 @@
> +#/** @file
> +#  Copyright (c) 2017, ARM Limited. All rights reserved.
> +#
> +#  This program and the accompanying materials
> +#  are licensed and made available under the terms and conditions of the BSD License
> +#  which accompanies this distribution.  The full text of the license may be found at
> +#  http://opensource.org/licenses/bsd-license.php
> +#
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#**/
> +
> +[Defines]
> +  INF_VERSION                    = 0x00010019
> +  BASE_NAME                      = ArmMtl

Please rename this library *instance* to something Juno-specific,
e.g., ArmJunoMtlLib

> +  FILE_GUID                      = 21FB2D8F-C6C8-4B2C-A616-A30CB2FBA277
> +  MODULE_TYPE                    = BASE
> +  VERSION_STRING                 = 1.0
> +  LIBRARY_CLASS                  = ArmMtl
> +

Please rename to ArmMtlLib (as mentioned in the related EDK2 patch)

> +[Sources.common]
> +  ArmMtl.c
> +
> +[Packages]
> +  ArmPkg/ArmPkg.dec
> +  ArmPlatformPkg/ArmPlatformPkg.dec
> +  MdePkg/MdePkg.dec
> +  Platform/ARM/JunoPkg/ArmJuno.dec
> +
> +[LibraryClasses]
> +  ArmLib
> +  DebugLib
> +  IoLib
> +  UefiBootServicesTableLib
> +
> +[FixedPcd.common]
> +  gArmJunoTokenSpaceGuid.PcdArmMtlDoorBell
> +  gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase
> +  gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize
> diff --git a/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h b/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..825fc788722bbe01ede24d9f867565c4c1dc938b
> --- /dev/null
> +++ b/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h
> @@ -0,0 +1,94 @@
> +/** @file
> +
> +  Copyright (c) 2017, ARM Limited. All rights reserved.
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD License
> +  which accompanies this distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +  System Control and Management Interface V1.0
> +    http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
> +    DEN0056A_System_Control_and_Management_Interface.pdf
> +
> +  Juno ARM Development Platform SoC
> +    https://www.arm.com/files/pdf/
> +    DDI0515D1a_juno_arm_development_platform_soc_trm.pdf
> +**/
> +
> +#ifndef ARM_MTL_PRIVATE_H_
> +#define ARM_MTL_PRIVATE_H_
> +
> +// Mailbox transport layer.
> +#define MTL_DOORBELL_MODIFY_MASK   (0x00000001U)
> +#define MTL_DOORBELL_PRESERVE_MASK (~MTL_DOORBELL_MODIFY_MASK)
> +
> +#define MTL_DOORBELL_BASE    (FixedPcdGet64 (PcdArmMtlDoorBell))
> +#define MTL_MAILBOX_BASE     (FixedPcdGet64 (PcdArmMtlMailBoxBase))
> +#define MTL_MAILBOX_SIZE     (FixedPcdGet32 (PcdArmMtlMailBoxSize))
> +
> +#define MTL_POLL         0
> +#define MTL_INTR         1
> +
> +/* For Juno, the mailbox for high priority is non-trusted SRAM + 256.
> +
> +   NOTE: Below is not documented anywhere (yet)
> +
> +   The payload sizes are 128 bytes.
> +
> +   There are two channels:
> +
> +   Channel 0
> +    - Agent (OS) to Platform (SCP) memory base: non-trusted SRAM + 0
> +    - Platform (SCP) to Agent (OS) memory base: non-trusted SRAM + 128
> +    - Doorbell (both directions): MHU, bit 0
> +
> +   Channel 1
> +    - Agent (OS) to Platform (SCP) memory base: non-trusted SRAM + 256
> +    - Platform (SCP) to Agent (OS) memory base: non-trusted SRAM + 384
> +    - Doorbell (both directions): MHU, bit 0
> +*/
> +#define MTL_MAILBOX_HIGH_PRIORITY_OFFSET (MTL_MAILBOX_SIZE * 2)
> +
> +// ARM MHU interrupt registers.
> +#define CPU_INTR_L_SET  0x108
> +#define CPU_INTR_H_SET  0x128
> +
> +// MTL uses MHU interrupt registers for communication with the SCP.
> +#define MTL_DOORBELL_REGISTER_LOW   (MTL_DOORBELL_BASE + CPU_INTR_L_SET)
> +#define MTL_DOORBELL_REGISTER_HIGH  (MTL_DOORBELL_BASE + CPU_INTR_H_SET)
> +
> +#define MTL_CHANNEL_BUSY    0
> +#define MTL_CHANNEL_FREE    1
> +
> +// Response timeout value on a MHU channel 20ms.
> +#define  RESPONSE_TIMEOUT  20000
> +
> +/* As per SCMI spec. as a agent UEFI(or OS) can access only two channels
> +   (low or high priority) secure channel is only accessible
> +   to ARM Trusted firmware. */
> +#define  NUM_CHANNELS      2
> +
> +/* Each channel must use a doorbell register to interrupt the SCP firmware.
> +   on Juno these are MHU interrupt registers for low and high priority
> +   channels. */
> +#define  DOORBELL_LOW   {                                \
> +                          MTL_DOORBELL_REGISTER_LOW,     \
> +                          MTL_DOORBELL_MODIFY_MASK,      \
> +                          MTL_DOORBELL_PRESERVE_MASK     \
> +                        }
> +
> +#define  DOORBELL_HIGH  {                                \
> +                          MTL_DOORBELL_REGISTER_HIGH,    \
> +                          MTL_DOORBELL_MODIFY_MASK,      \
> +                          MTL_DOORBELL_PRESERVE_MASK     \
> +                        }
> +
> +// Arbitarary poll time.
> +#define MTL_POLL_WAIT_TIME 100
> +
> +#endif /* ARM_MTL_PRIVATE_H_ */
> +
> diff --git a/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c b/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..b5e469f9a51a8f739526c7eeb873c32403d191f9
> --- /dev/null
> +++ b/Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c
> @@ -0,0 +1,195 @@
> +/** @file
> +
> +  Copyright (c) 2017, ARM Limited. All rights reserved.
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD License
> +  which accompanies this distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +  System Control and Management Interface V1.0
> +    http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
> +    DEN0056A_System_Control_and_Management_Interface.pdf
> +**/
> +
> +#include <Uefi.h>

For a BASE library, you should include <Base.h> and possibly
<Uefi/UefiBaseType.h> if you are using UEFI types. Uefi.h is intended
for UEFI drivers and applications

> +#include <Library/ArmMtl.h>
> +#include <Library/DebugLib.h>
> +#include <Library/IoLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +
> +#include "ArmMtlPrivate.h"
> +
> +// Each channel has a shared mailbox and a doorbell register.
> +STATIC CONST MTL_CHANNEL Channels[NUM_CHANNELS] = {
> +    // Low priority channel.
> +    {
> +      MTL_CHANNEL_TYPE_LOW,
> +      (MTL_MAILBOX*)(MTL_MAILBOX_BASE),
> +      DOORBELL_LOW
> +    },
> +    // High priority channel
> +    {
> +      MTL_CHANNEL_TYPE_HIGH,
> +      (MTL_MAILBOX*)(MTL_MAILBOX_BASE + MTL_MAILBOX_HIGH_PRIORITY_OFFSET),
> +      DOORBELL_HIGH
> +    }
> +  };
> +
> +/** Wait until channel is free.
> +
> +  @param[in] Channel                Pointer to a channel.
> +  @param[in] TimeOutInMicroSeconds  Time out in micro seconds.
> +
> +  @retval EFI_SUCCESS               Channel is free.
> +  @retval EFI_TIMOUT                Time out error.
> +**/
> +EFI_STATUS
> +MtlWaitUntilChannelFree (
> +  IN MTL_CHANNEL  *Channel,
> +  IN UINTN        TimeOutInMicroSeconds
> +  )
> +{
> +  while (TimeOutInMicroSeconds != 0) {
> +    // If channel is free then we have received the reply.
> +    if (Channel->MailBox->ChannelStatus == MTL_CHANNEL_FREE) {
> +      return EFI_SUCCESS;
> +    }
> +    if (TimeOutInMicroSeconds < MTL_POLL_WAIT_TIME) {
> +      gBS->Stall (TimeOutInMicroSeconds);
> +      break;
> +    }
> +    // Wait for some arbitrary time.
> +    gBS->Stall (MTL_POLL_WAIT_TIME);
> +    TimeOutInMicroSeconds -= MTL_POLL_WAIT_TIME;
> +  }
> +
> +  // No response from SCP.
> +  if (Channel->MailBox->ChannelStatus != MTL_CHANNEL_FREE) {
> +    ASSERT (FALSE);
> +    return EFI_TIMEOUT;
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/** Return the address of the message payload.
> +
> +  @param[in] Channel   Pointer to a channel.
> +
> +  @retval UINT32*      Pointer to the payload.
> +**/
> +UINT32*
> +MtlGetChannelPayload (
> +  IN  MTL_CHANNEL  *Channel
> +  )
> +{
> +  return Channel->MailBox->Payload;
> +}
> +
> +/** Return pointer to a channel for the requested channel type.
> +
> +  @param[in] ChannelType        ChannelType, Low or High priority channel.
> +                                MTL_CHANNEL_TYPE_LOW or
> +                                MTL_CHANNEL_TYPE_HIGH
> +
> +  @param[out] Channel           Holds pointer to the channel.
> +
> +  @retval EFI_SUCCESS           Pointer to channel is returned.
> +  @retval EFI_UNSUPPORTED       Requested channel type not supported.
> +**/
> +EFI_STATUS
> +MtlGetChannel (
> +  IN  MTL_CHANNEL_TYPE  ChannelType,
> +  OUT MTL_CHANNEL       **Channel
> +  )
> +{
> +  if (ChannelType != MTL_CHANNEL_TYPE_LOW
> +    && ChannelType != MTL_CHANNEL_TYPE_HIGH) {
> +    return EFI_UNSUPPORTED;
> +  }
> +
> +  *Channel = (MTL_CHANNEL*)&Channels[ChannelType];
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/** Mark the channel busy and ring the doorbell.
> +
> +  @param[in] Channel               Pointer to a channel.
> +  @param[in] MessageHeader         Message header.
> +
> +  @param[out] PayloadLength        Message length.
> +
> +  @retval EFI_SUCCESS              Message sent successfully.
> +  @retval EFI_DEVICE_ERROR         Channel is busy.
> +**/
> +EFI_STATUS
> +MtlSendMessage (
> +  IN  MTL_CHANNEL  *Channel,
> +  IN  UINT32       MessageHeader,
> +  OUT UINT32       PayloadLength
> +  )
> +{
> +  MTL_MAILBOX *MailBox = Channel->MailBox;
> +
> +  if (Channel->MailBox->ChannelStatus != MTL_CHANNEL_FREE) {
> +    return EFI_DEVICE_ERROR;
> +  }
> +
> +  // Mark the channel busy before ringing doorbell.
> +  Channel->MailBox->ChannelStatus = MTL_CHANNEL_BUSY;
> +
> +  MailBox->Flags         = MTL_POLL;
> +  MailBox->MessageHeader = MessageHeader;
> +
> +  // Add length of message header.
> +  MailBox->Length = PayloadLength + sizeof (MessageHeader);
> +
> +  // Ring the doorbell. It sets SET bit of the MHU register.
> +  MmioWrite32 (
> +    Channel->DoorBell.PhysicalAddress,
> +    Channel->DoorBell.ModifyMask
> +    );
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/** Wait for a response on a channel.
> +
> +  If channel is free after sending message, it implies SCP responded
> +  with a response on the channel.
> +
> +  @param[in] Channel               Pointer to a channel.
> +
> +  @retval EFI_SUCCESS              Message received successfully.
> +  @retval EFI_TIMOUT               Timeout error.
> +**/
> +EFI_STATUS
> +MtlReceiveMessage (
> +  IN  MTL_CHANNEL  *Channel,
> +  OUT UINT32       *MessageHeader,
> +  OUT UINT32       *PayloadLength
> +  )
> +{
> +  EFI_STATUS Status;
> +
> +  MTL_MAILBOX *MailBox = Channel->MailBox;
> +
> +  Status = MtlWaitUntilChannelFree (Channel, RESPONSE_TIMEOUT);
> +  if (EFI_ERROR (Status)) {
> +    return Status;
> +  }
> +
> +  *MessageHeader = MailBox->MessageHeader;
> +
> +  // Deduct message header length.
> +  *PayloadLength = MailBox->Length - sizeof (*MessageHeader);
> +
> +  return EFI_SUCCESS;
> +}
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library
  2017-12-22 19:08 ` [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library evan.lloyd
@ 2017-12-23 16:22   ` Ard Biesheuvel
  2018-01-09 18:21     ` Evan Lloyd
  0 siblings, 1 reply; 57+ messages in thread
From: Ard Biesheuvel @ 2017-12-23 16:22 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Panakamattam Abraham, "ard.biesheuvel,
	"leif.lindholm, "Matteo.Carlini, "nd

On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> This change adds the HDLCD platform lib for the Juno plaform. This
> library will be instantiated as a LcdPlatformLib to link with
> LcdGraphicsOutputDxe for the Juno platform.
>
> HDLCD platform library depends on the Arm SCMI DXE driver for
> communication with the SCP for clock setting. Therefore this change also
> enables building of Arm SCMI DXE driver for the Juno platform.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pathak@arm.com>

Missing signoff?

> ---
>  Platform/ARM/JunoPkg/ArmJuno.dec                                 |   8 +
>  Platform/ARM/JunoPkg/ArmJuno.dsc                                 |  29 +
>  Platform/ARM/JunoPkg/ArmJuno.fdf                                 |  12 +-
>  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf           |   5 +-
>  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf |  40 ++
>  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c             |  18 +-
>  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c      | 559 ++++++++++++++++++++
>  7 files changed, 668 insertions(+), 3 deletions(-)
>
> diff --git a/Platform/ARM/JunoPkg/ArmJuno.dec b/Platform/ARM/JunoPkg/ArmJuno.dec
> index b733480c3198d135df16ca024b5e85ff350e11c7..cd6710feb2faf0bd17b5ea39a21dbe5406cd4ffd 100644
> --- a/Platform/ARM/JunoPkg/ArmJuno.dec
> +++ b/Platform/ARM/JunoPkg/ArmJuno.dec
> @@ -53,3 +53,11 @@ [PcdsFixedAtBuild.common]
>    gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase|0x2E000000|UINT64|0x00000025
>    gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize|0x80|UINT32|0x00000026
>
> +  # MaxMode must be one number higher than the actual max mode,
> +  # i.e. for actual maximum mode 2, set the value to 3.
> +  #
> +  # Default value zero allows platform to enumerate maximum supported mode.
> +  #
> +  # For a list of mode numbers look in HdLcdArmJuno.c
> +  gArmJunoTokenSpaceGuid.PcdArmHdLcdMaxMode|0|UINT32|0x00000017
> +
> diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc b/Platform/ARM/JunoPkg/ArmJuno.dsc
> index fe860956a4dc497cac52be70bab3657246a08bd0..9027c5b0728a6941f850636b3bc315fd33b867fb 100644
> --- a/Platform/ARM/JunoPkg/ArmJuno.dsc
> +++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
> @@ -50,6 +50,11 @@ [LibraryClasses.common]
>    # SCMI Mailbox Transport Layer
>    ArmMtl|Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
>
> +!ifndef HEADLESS_PLATFORM

Wouldn't it make more sense to add a macro ENABLE_HDLCD, rather than
inverting the logic?

> +  LcdPlatformLib|Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
> +  LcdHwLib|ArmPlatformPkg/Library/HdLcd/HdLcd.inf
> +!endif
> +
>  [LibraryClasses.common.SEC]
>    PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
>    ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
> @@ -100,7 +105,15 @@ [PcdsFixedAtBuild.common]
>
>    # System Memory (2GB - 16MB of Trusted DRAM at the top of the 32bit address space)
>    gArmTokenSpaceGuid.PcdSystemMemoryBase|0x80000000
> +
> +!ifdef HEADLESS_PLATFORM
>    gArmTokenSpaceGuid.PcdSystemMemorySize|0x7F000000
> +!else
> +  gArmTokenSpaceGuid.PcdSystemMemorySize|0x7B000000
> +  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0xFB000000
> +  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x04000000
> +  gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect|TRUE
> +!endif
>
>    # Juno Dual-Cluster profile
>    gArmPlatformTokenSpaceGuid.PcdCoreCount|6
> @@ -142,6 +155,11 @@ [PcdsFixedAtBuild.common]
>    gArmTokenSpaceGuid.PcdGicDistributorBase|0x2C010000
>    gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x2C02F000
>
> +!ifndef HEADLESS_PLATFORM
> +  # ARM Juno HDLCD Base
> +  gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x7FF60000
> +!endif
> +
>    #
>    # PLDA PCI Root Complex
>    #
> @@ -314,6 +332,11 @@ [Components.common]
>    MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
>    MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
>
> +!ifndef HEADLESS_PLATFORM
> +  # Graphic Output Protocol
> +  ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
> +!endif
> +
>    #
>    # Juno platform driver
>    #
> @@ -347,6 +370,12 @@ [Components.common]
>        BdsLib|Platform/ARM/Library/BdsLib/BdsLib.inf
>    }
>
> +  # SCMI Driver
> +  ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf {
> +    <LibraryClasses>
> +      BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf

I take it your trusted SRAM does not tolerate unaligned memcpy()
because it is mapped as device memory. Couldn't you map it as
non-cacheable memory instead? (I meant to ask in response to the other
patch but I forgot)


> +  }
> +
>  [Components.AARCH64]
>    #
>    # EBC
> diff --git a/Platform/ARM/JunoPkg/ArmJuno.fdf b/Platform/ARM/JunoPkg/ArmJuno.fdf
> index ee9d0e7f4f6e6ac99ded6a14e88eb2c7854dd473..0b62760cbb3ff93490204ac636b41d5a867dfb80 100644
> --- a/Platform/ARM/JunoPkg/ArmJuno.fdf
> +++ b/Platform/ARM/JunoPkg/ArmJuno.fdf
> @@ -1,5 +1,5 @@
>  #
> -#  Copyright (c) 2013-2015, ARM Limited. All rights reserved.
> +#  Copyright (c) 2013-2017, ARM Limited. All rights reserved.
>  #
>  #  This program and the accompanying materials
>  #  are licensed and made available under the terms and conditions of the BSD License
> @@ -163,6 +163,13 @@ [FV.FvMain]
>    INF MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouseDxe.inf
>    INF MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
>
> +!ifndef HEADLESS_PLATFORM
> +  #
> +  # Graphics Output Protocol
> +  #
> +  INF ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
> +!endif
> +
>    #
>    # PCI Support
>    #
> @@ -223,6 +230,9 @@ [FV.FvMain]
>    # after the device drivers (eg: Ethernet) to ensure we have support for them.
>    INF Platform/ARM/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf
>
> +  # SCMI Driver
> +  INF ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> +
>  !if $(ARCH) == AARCH64
>    #
>    # EBC
> diff --git a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf
> index 2dd384daba3d6076ba4898a0251ebc91bc0beee2..f131035be684f22e9f4c00417759b7845b29dcc6 100644
> --- a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf
> +++ b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf
> @@ -1,5 +1,5 @@
>  #
> -#  Copyright (c) 2013-2016, ARM Limited. All rights reserved.
> +#  Copyright (c) 2013-2017, ARM Limited. All rights reserved.
>  #
>  #  This program and the accompanying materials
>  #  are licensed and made available under the terms and conditions of the BSD License
> @@ -57,6 +57,9 @@ [FixedPcd]
>    gArmJunoTokenSpaceGuid.PcdPciConfigurationSpaceBaseAddress
>    gArmJunoTokenSpaceGuid.PcdPciConfigurationSpaceSize
>
> +  # Frame Buffer Memory
> +  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
> +  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
>
>    #
>    # PL011 Serial Debug UART
> diff --git a/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
> new file mode 100644
> index 0000000000000000000000000000000000000000..a10bff135abf154484d36c67083b498846f24753
> --- /dev/null
> +++ b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
> @@ -0,0 +1,40 @@
> +#/** @file
> +#
> +#  Component description file for HdLcdArmJunoLib module
> +#
> +#  Copyright (c) 2013-2017, ARM Ltd. All rights reserved.<BR>
> +#
> +#  This program and the accompanying materials
> +#  are licensed and made available under the terms and conditions of the BSD License
> +#  which accompanies this distribution.  The full text of the license may be found at
> +#  http://opensource.org/licenses/bsd-license.php
> +#
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#**/
> +
> +[Defines]
> +  INF_VERSION                    = 0x00010019
> +  BASE_NAME                      = HdLcdArmJunoLib
> +  FILE_GUID                      = 7B1D26F7-7B88-47ED-B193-DD3BDF319006
> +  MODULE_TYPE                    = BASE
> +  VERSION_STRING                 = 1.0
> +  LIBRARY_CLASS                  = LcdPlatformLib
> +
> +[Sources.common]
> +  HdLcdArmJuno.c
> +
> +[Packages]
> +  ArmPlatformPkg/ArmPlatformPkg.dec
> +  MdePkg/MdePkg.dec
> +  Platform/ARM/JunoPkg/ArmJuno.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +
> +[FixedPcd]
> +  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
> +  gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
> +  gArmJunoTokenSpaceGuid.PcdArmHdLcdMaxMode
> +  gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
> diff --git a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
> index afb2db0050c65b0d1b2b69c9038e168755c152c1..baa5221cb906ed5d077414475da006cf2e5cafc5 100644
> --- a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
> +++ b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
> @@ -21,8 +21,10 @@
>
>  #include <ArmPlatform.h>
>
> +#define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize) != 0) ? 1 : 0)
> +
>  // The total number of descriptors, including the final "end-of-table" descriptor.
> -#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 16
> +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (16 + FRAME_BUFFER_DESCRIPTOR)
>
>  // DDR attributes
>  #define DDR_ATTRIBUTES_CACHED           ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
> @@ -151,6 +153,20 @@ ArmPlatformGetVirtualMemoryMap (
>    VirtualMemoryTable[Index].Length          = ARM_JUNO_SOC_PERIPHERALS_SZ;
>    VirtualMemoryTable[Index].Attributes      = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
>
> +  // Frame Buffer Memory
> +#if (FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize) != 0)

Please use a normal if()

> +  VirtualMemoryTable[++Index].PhysicalBase  = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
> +  VirtualMemoryTable[Index].VirtualBase     = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
> +  VirtualMemoryTable[Index].Length          = FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
> +  // Map as Normal Non-Cacheable memory, so that we can use the accelerated
> +  // SetMem/CopyMem routines that may use unaligned accesses or
> +  // DC ZVA instructions. If mapped as device memory, these routine may cause
> +  // alignment faults.
> +  // NOTE: The attribute value is misleading, it indicates memory map type as
> +  // an un-cached, un-buffered but allows buffering and reordering.
> +  VirtualMemoryTable[Index].Attributes      = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
> +#endif
> +
>    // DDR - 2GB
>    VirtualMemoryTable[++Index].PhysicalBase  = PcdGet64 (PcdSystemMemoryBase);
>    VirtualMemoryTable[Index].VirtualBase     = PcdGet64 (PcdSystemMemoryBase);
> diff --git a/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..72be0a39846fb0a78ebcf3248b6c51377adf4f73
> --- /dev/null
> +++ b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
> @@ -0,0 +1,559 @@
> +/** @file
> +
> +  Copyright (c) 2013-2017, ARM Ltd. All rights reserved.
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD License
> +  which accompanies this distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <PiDxe.h>
> +#include <Library/BaseLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/DxeServicesTableLib.h>
> +#include <Library/LcdPlatformLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Drivers/ArmScmi.h>
> +#include <Drivers/ArmScmiClockProtocol.h>
> +
> +/* Display timings on Juno for 1920x1080.
> +  On Juno due to instability of the PLLs, we set OSC
> +  frequency to 138.5 MHz which is stable for most monitors.
> +  Frequency 148.5MHz does not work with some monitors.
> +  148.5 MHz is set by SCP firmware by default.
> +
> +#define JUNO_HD_OSC_FREQUENCY               148500000
> +*/
> +#define JUNO_HD_OSC_FREQUENCY               138500000
> +#define JUNO_HD_H_SYNC                      ( 32 - 1)
> +#define JUNO_HD_H_FRONT_PORCH               ( 48 - 1)
> +#define JUNO_HD_H_BACK_PORCH                ( 80 - 1)
> +#define JUNO_HD_V_SYNC                      (  5 - 1)
> +#define JUNO_HD_V_FRONT_PORCH               (  3 - 1)
> +#define JUNO_HD_V_BACK_PORCH                ( 23 - 1)
> +
> +/* SCMI defined clock device name and ID. This is not documented but
> +   obtained using clock management protocol's CLOCK_ATTRIBUTES command.
> +
> +   Generally we must discover clock device ID using clock name and then
> +   set/get rate using CLOCK_RATE_SET/CLOCK_RATE_GET commands. However
> +   because LcdGraphicsOutputDxe is a DXE driver, which gets initialized
> +   at boot time, for faster boot, in release build we will directly use
> +   this already known value as an argument to rate get/set functions.
> +
> +   We expect these values not to change in future SCP firmware releases.
> +
> +   DEBUG build however will probe SCP firmware and discover clock device
> +   ID for HDLCD.
> +*/
> +#define ARM_JUNO_CSS_CLK_NAME_HDLCD_0       "HDLCD_0"
> +#define ARM_JUNO_CSS_CLKID_HDLCD_0           3
> +
> +typedef struct {
> +  UINT32                      Mode;
> +  UINT32                      OscFreq;
> +  SCAN_TIMINGS                Horizontal;
> +  SCAN_TIMINGS                Vertical;
> +} DISPLAY_MODE;
> +
> +STATIC CONST DISPLAY_MODE mDisplayModes[] = {
> +  {
> +    // Mode 0 : VGA : 640 x 480 x 24 bpp.
> +    VGA,
> +    VGA_OSC_FREQUENCY,
> +    {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> +    {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 1 : WVGA : 800 x 480 x 24 bpp.
> +    WVGA,
> +    WVGA_OSC_FREQUENCY,
> +    {WVGA_H_RES_PIXELS, WVGA_H_SYNC, WVGA_H_BACK_PORCH, WVGA_H_FRONT_PORCH},
> +    {WVGA_V_RES_PIXELS, WVGA_V_SYNC, WVGA_V_BACK_PORCH, WVGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 2 : SVGA : 800 x 600 x 24 bpp.
> +    SVGA,
> +    SVGA_OSC_FREQUENCY,
> +    {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> +    {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 3 : QHD : 960 x 540 x 24 bpp.
> +    QHD,
> +    QHD_OSC_FREQUENCY,
> +    {QHD_H_RES_PIXELS, QHD_H_SYNC, QHD_H_BACK_PORCH, QHD_H_FRONT_PORCH},
> +    {QHD_V_RES_PIXELS, QHD_V_SYNC, QHD_V_BACK_PORCH, QHD_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 4 : WSVGA : 1024 x 600 x 24 bpp.
> +    WSVGA,
> +    WSVGA_OSC_FREQUENCY,
> +    {WSVGA_H_RES_PIXELS, WSVGA_H_SYNC, WSVGA_H_BACK_PORCH, WSVGA_H_FRONT_PORCH},
> +    {WSVGA_V_RES_PIXELS, WSVGA_V_SYNC, WSVGA_V_BACK_PORCH, WSVGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 5 : XGA : 1024 x 768 x 24 bpp.
> +    XGA,
> +    XGA_OSC_FREQUENCY,
> +    {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> +    {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 6 : HD : 1280 x 720 x 24 bpp.
> +    HD720,
> +    HD720_OSC_FREQUENCY,
> +    {HD720_H_RES_PIXELS, HD720_H_SYNC, HD720_H_BACK_PORCH, HD720_H_FRONT_PORCH},
> +    {HD720_V_RES_PIXELS, HD720_V_SYNC, HD720_V_BACK_PORCH, HD720_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 7 : WXGA : 1280 x 800 x 24 bpp.
> +    WXGA,
> +    WXGA_OSC_FREQUENCY,
> +    {WXGA_H_RES_PIXELS, WXGA_H_SYNC, WXGA_H_BACK_PORCH, WXGA_H_FRONT_PORCH},
> +    {WXGA_V_RES_PIXELS, WXGA_V_SYNC, WXGA_V_BACK_PORCH, WXGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 8 : SXGA : 1280 x 1024 x 24 bpp.
> +    SXGA,
> +    SXGA_OSC_FREQUENCY,
> +    {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
> +    {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 9 : WSXGA+ : 1680 x 1050 x 24 bpp.
> +    WSXGA,
> +    WSXGA_OSC_FREQUENCY,
> +    {WSXGA_H_RES_PIXELS, WSXGA_H_SYNC, WSXGA_H_BACK_PORCH, WSXGA_H_FRONT_PORCH},
> +    {WSXGA_V_RES_PIXELS, WSXGA_V_SYNC, WSXGA_V_BACK_PORCH, WSXGA_V_FRONT_PORCH}
> +  },
> +  {
> +    // Mode 10 : HD : 1920 x 1080 x 24 bpp.
> +    HD,
> +    JUNO_HD_OSC_FREQUENCY,
> +    {HD_H_RES_PIXELS, JUNO_HD_H_SYNC, JUNO_HD_H_BACK_PORCH, JUNO_HD_H_FRONT_PORCH},
> +    {HD_V_RES_PIXELS, JUNO_HD_V_SYNC, JUNO_HD_V_BACK_PORCH, JUNO_HD_V_FRONT_PORCH}
> +  }
> +};
> +
> +/* If PcdArmMaliDpMaxMode is 0, platform supports full range of modes
> +   else platform supports modes from 0 to PcdArmHdLcdMaxMode - 1
> +*/
> +STATIC CONST UINT32 mMaxMode = ((FixedPcdGet32 (PcdArmHdLcdMaxMode) != 0)
> +                                   ? FixedPcdGet32 (PcdArmHdLcdMaxMode)
> +                                   : sizeof (mDisplayModes) / sizeof (DISPLAY_MODE));
> +
> +/** HDLCD platform specific initialization function.
> +
> +  @param[in] Handle              Handle to the LCD device instance.
> +
> +  @retval EFI_SUCCESS            Plaform library initialized successfully.
> +  @retval EFI_UNSUPPORTED        PcdGopPixelFormat must be
> +                                 PixelRedGreenBlueReserved8BitPerColor OR
> +                                 PixelBlueGreenRedReserved8BitPerColor
> +                                 any other format is not supported.
> +  @retval !(EFI_SUCCESS)         Other errors.
> +**/
> +EFI_STATUS
> +LcdPlatformInitializeDisplay (
> +  IN CONST EFI_HANDLE   Handle
> +  )
> +{
> +  (VOID)Handle;
> +  EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
> +
> +  // PixelBitMask and PixelBltOnly pixel formats are not supported.
> +  PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> +  if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
> +    && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
> +
> +    ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
> +      ||  PixelFormat == PixelBlueGreenRedReserved8BitPerColor);

Please fix weird indentation

> +   return EFI_UNSUPPORTED;
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/** Allocate VRAM memory in DRAM for the frame buffer
> +  (unless it is reserved already).
> +
> +  The allocated address can be used to set the frame buffer.
> +
> +  @param[out] VramBaseAddress     A pointer to the frame buffer address.
> +  @param[out] VramSize            A pointer to the size of the frame
> +                                  buffer in bytes
> +
> +  @retval EFI_SUCCESS             Frame buffer memory allocated successfully.
> +  @retval !(EFI_SUCCESS)          Other errors.
> +**/
> +EFI_STATUS
> +LcdPlatformGetVram (
> +  OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> +  OUT UINTN                * CONST VramSize
> +  )
> +{
> +  EFI_STATUS      Status = EFI_SUCCESS;
> +
> +  ASSERT (VramBaseAddress != NULL);
> +  ASSERT (VramSize != NULL);
> +
> +  // Set the VRAM size.
> +  *VramSize = (UINTN)FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
> +
> +  // Check if memory is already reserved for the frame buffer.
> +#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)

Please don't use CPP conditionals for control flow

> +  *VramBaseAddress =
> +     (EFI_PHYSICAL_ADDRESS)FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
> +#else
> +  // If not already reserved, attempt to allocate the VRAM from the DRAM.
> +  Status = gBS->AllocatePages (
> +                  AllocateAnyPages,
> +                  EfiBootServicesData,
> +                  EFI_SIZE_TO_PAGES (*VramSize),
> +                  VramBaseAddress
> +                  );
> +
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "HdLcdArmJuno: Failed to allocate frame buffer.\n"));
> +    ASSERT_EFI_ERROR (Status);
> +    return Status;
> +  }
> +
> +  /* Mark the VRAM as write-combining.
> +     The VRAM is inside the DRAM, which is cacheable.
> +  */
> +  Status = gDS->SetMemorySpaceAttributes (
> +                  *VramBaseAddress,
> +                  *VramSize,
> +                  EFI_MEMORY_WC
> +                  );
> +  if (EFI_ERROR (Status)) {
> +    ASSERT_EFI_ERROR (Status);
> +    gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> +  }
> +#endif
> +
> +  return Status;
> +}
> +
> +/** Return total number of modes supported.
> +
> +  Note: Valid mode numbers are 0 to MaxMode - 1
> +  See Section 12.9 of the UEFI Specification 2.7
> +
> +  @retval UINT32             Mode Number.
> +**/
> +UINT32
> +LcdPlatformGetMaxMode (VOID)
> +{
> +  return  mMaxMode;
> +}
> +
> +#if !defined(MDEPKG_NDEBUG)
> +/** Probe Clock device ID of the HDLCD clock and current pixel clock frequency.
> +  NOTE: We will probe information only in DEBUG build.
> +
> +  @param[in]  ClockProtocol   A pointer to SCMI clock protocol
> +                              interface instance.
> +  @param[out] ClockId         ID of the clock device
> +
> +  @retval EFI_SUCCESS         Clock ID of the HDLCD device returned
> +                              successfully.
> +  @retval EFI_UNSUPPORTED     SCMI clock management protocol unsupported.
> +  @retval EFI_DEVICE_ERROR    SCMI error.
> +  @retval EFI_NOT_FOUND       Not found valid clock device ID of the HDLCD.
> +**/
> +STATIC
> +EFI_STATUS
> +ProbeHdLcdClock (
> +  IN  SCMI_CLOCK_PROTOCOL  *ClockProtocol,
> +  OUT UINT32               *ClockId
> +  )
> +{
> +  EFI_STATUS  Status;
> +  UINT64      CurrentHdLcdFreq;
> +
> +  UINT32      TotalClocks;
> +  UINT32      ClockProtocolVersion;
> +  BOOLEAN     Enabled;
> +  CHAR8       ClockName[SCMI_MAX_STR_LEN];
> +  BOOLEAN     ClockFound = FALSE;
> +
> +  UINT32                 TotalRates = 0;
> +  UINT32                 ClockRateSize;
> +  SCMI_CLOCK_RATE        ClockRate;
> +  SCMI_CLOCK_RATE_FORMAT ClockRateFormat;
> +
> +  Status = ClockProtocol->GetVersion (ClockProtocol, &ClockProtocolVersion);
> +  if (EFI_ERROR (Status)) {
> +    ASSERT (FALSE);
> +    return Status;
> +  }
> +
> +  DEBUG ((DEBUG_ERROR, "SCMI clock management protocol version = %x\n",
> +    ClockProtocolVersion));
> +
> +  if (ClockProtocolVersion != SCMI_CLOCK_PROTOCOL_VERSION) {
> +    ASSERT (FALSE);
> +    return EFI_UNSUPPORTED;
> +  }
> +
> +  Status = ClockProtocol->GetTotalClocks (ClockProtocol, &TotalClocks);
> +  if (EFI_ERROR (Status)) {
> +    return Status;
> +  }
> +
> +  DEBUG ((DEBUG_ERROR, "Total number of clocks supported by SCMI clock management protocol = %d\n",
> +    TotalClocks));
> +
> +  for (*ClockId = 0; *ClockId < TotalClocks; (*ClockId)++) {
> +    Status = ClockProtocol->GetClockAttributes (
> +                              ClockProtocol,
> +                              *ClockId,
> +                              &Enabled,
> +                              ClockName
> +                              );
> +    if (EFI_ERROR (Status)) {
> +      // In current implementation of SCMI, some clocks are not accessible to
> +      // calling agents (in our case UEFI is an agent) which results in an
> +      // EFI_DEVICE_ERROR error. A bug fix for this is in discussions and will
> +      // be fixed in future versions of the SCP firmware. Irrespective of a fix
> +      // we must iterate over each clock to see if it matches with HDLCD.
> +      continue;
> +    }
> +
> +    if (AsciiStrnCmp ((CONST CHAR8*)ClockName,
> +          (CONST CHAR8*)ARM_JUNO_CSS_CLK_NAME_HDLCD_0,
> +          sizeof (ARM_JUNO_CSS_CLK_NAME_HDLCD_0)) == 0) {
> +      ClockFound = TRUE;
> +      break;
> +    }
> +  }
> +
> +  if (!ClockFound) {
> +    return EFI_NOT_FOUND;
> +  }
> +
> +  ClockRateSize = sizeof (ClockRate);
> +  Status = ClockProtocol->DescribeRates (
> +                            ClockProtocol,
> +                            *ClockId,
> +                            &ClockRateFormat,
> +                            &TotalRates,
> +                            &ClockRateSize,
> +                            &ClockRate
> +                            );
> +  if (EFI_ERROR (Status)) {
> +    ASSERT (FALSE);
> +    return Status;
> +  }
> +
> +  Status = ClockProtocol->RateGet (ClockProtocol, *ClockId, &CurrentHdLcdFreq);
> +  if (EFI_ERROR (Status)) {
> +    ASSERT (FALSE);
> +    return Status;
> +  }
> +
> +  DEBUG ((DEBUG_ERROR, "Clock ID = %d Clock name = %a\n", *ClockId, ClockName));
> +  DEBUG ((DEBUG_ERROR, "Minimum frequency = %uHz\n", ClockRate.Min));
> +  DEBUG ((DEBUG_ERROR, "Maximum frequency = %uHz\n", ClockRate.Max));
> +  DEBUG ((DEBUG_ERROR, "Clock rate step = %uHz\n", ClockRate.Step));
> +
> +  DEBUG ((DEBUG_ERROR, "HDLCD Current frequency = %uHz\n", CurrentHdLcdFreq));
> +
> +  return EFI_SUCCESS;
> +}
> +#endif
> +
> +/** Set the requested display mode.
> +
> +  @param[in] ModeNumber             Mode Number.
> +
> +  @retval EFI_SUCCESS              Mode set successfully.
> +  @retval EFI_NOT_FOUND            Clock protocol instance not found.
> +  @retval EFI_DEVICE_ERROR         SCMI error.
> +  @retval EFI_INVALID_PARAMETER    Requested mode not found.
> +  @retval !(EFI_SUCCESS)            Other errors.
> +*/
> +EFI_STATUS
> +LcdPlatformSetMode (
> +  IN CONST UINT32  ModeNumber
> +  )
> +{
> +  EFI_STATUS          Status;
> +  SCMI_CLOCK_PROTOCOL *ClockProtocol;
> +  UINT32              ClockId;
> +
> +  EFI_GUID ClockProtocolGuid = ARM_SCMI_CLOCK_PROTOCOL_GUID;
> +
> +  if (ModeNumber >= mMaxMode) {
> +    ASSERT (ModeNumber < mMaxMode);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  // Display debug information in boot log.
> +  DEBUG ((DEBUG_ERROR, "HDLCD Display controller:\n"));
> +
> +  DEBUG ((DEBUG_ERROR, "Required frequency for resolution %dx%d = %uHz\n",
> +            mDisplayModes[ModeNumber].Horizontal.Resolution,
> +            mDisplayModes[ModeNumber].Vertical.Resolution,
> +            mDisplayModes[ModeNumber].OscFreq));
> +
> +  Status = gBS->LocateProtocol (
> +                  &ClockProtocolGuid,
> +                  NULL,
> +                  (VOID**)&ClockProtocol
> +                  );
> +  if (EFI_ERROR (Status)) {
> +    ASSERT (FALSE);
> +    return Status;
> +  }
> +
> +#if !defined(MDEPKG_NDEBUG)
> +  /* Avoid probing clock device id in RELEASE build */
> +  Status = ProbeHdLcdClock (ClockProtocol, &ClockId);
> +  if (EFI_ERROR (Status)) {
> +    return Status;
> +  }
> +
> +  ASSERT (ClockId == ARM_JUNO_CSS_CLKID_HDLCD_0);
> +#else
> +  ClockId = ARM_JUNO_CSS_CLKID_HDLCD_0;
> +#endif
> +
> +  // Set HDLCD clock required for the requested mode
> +  Status = ClockProtocol->RateSet (
> +                            ClockProtocol,
> +                            ClockId,
> +                            mDisplayModes[ModeNumber].OscFreq
> +                            );
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "SCMI error: %r\n", Status));
> +    return Status;
> +  }
> +
> +#if !defined(MDEPKG_NDEBUG)
> +  UINT64  CurrentHdLcdFreq;
> +  // Actual value set can differ from requested frequency so verify.
> +  Status = ClockProtocol->RateGet (
> +                            ClockProtocol,
> +                            ARM_JUNO_CSS_CLKID_HDLCD_0,
> +                            &CurrentHdLcdFreq
> +                            );
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "SCMI Error: %r\n", Status));
> +  } else {
> +    DEBUG ((DEBUG_ERROR, "Mode = %d, Requested frequency change = %uHz, Actual changed frequency = %uHz\n",
> +      ModeNumber,
> +      mDisplayModes[ModeNumber].OscFreq,
> +      CurrentHdLcdFreq
> +      ));
> +  }
> +#endif
> +
> +  return Status;
> +}
> +
> +/** Return information for the requested mode number.
> +
> +  @param[in]  ModeNumber          Mode Number.
> +
> +  @param[out] Info                Pointer for returned mode information
> +                                  (on success).
> +
> +  @retval EFI_SUCCESS             Mode information for the requested mode
> +                                  returned successfully.
> +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> +**/
> +EFI_STATUS
> +LcdPlatformQueryMode (
> +  IN  CONST UINT32                                  ModeNumber,
> +  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST  Info
> +  )
> +{
> +  if (ModeNumber >= mMaxMode ){
> +    ASSERT (ModeNumber < mMaxMode);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  ASSERT (Info != NULL);
> +
> +  Info->Version = 0;
> +  Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
> +  Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
> +  Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
> +
> +  Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/** Return display timing information for the requested mode number.
> +
> +  @param[in]  ModeNumber          Mode Number.
> +
> +  @param[out] Horizontal          Pointer to horizontal timing parameters.
> +                                  (Resolution, Sync, Back porch, Front porch)
> +  @param[out] Vertical            Pointer to vertical timing parameters.
> +                                  (Resolution, Sync, Back porch, Front porch)
> +
> +  @retval EFI_SUCCESS             Display timing information for the requested
> +                                  mode returned successfully.
> +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> +**/
> +EFI_STATUS
> +LcdPlatformGetTimings (
> +  IN  UINT32               ModeNumber,
> +  OUT CONST SCAN_TIMINGS   **Horizontal,
> +  OUT CONST SCAN_TIMINGS   **Vertical
> +  )
> +{
> +  if (ModeNumber >= mMaxMode ){
> +    ASSERT (ModeNumber < mMaxMode);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  ASSERT (Horizontal != NULL);
> +  ASSERT (Vertical != NULL);
> +
> +  *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
> +  *Vertical   = &mDisplayModes[ModeNumber].Vertical;
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/** Return bits per pixel information for a mode number.
> +
> +  @param[in]  ModeNumber          Mode Number.
> +
> +  @param[out] Bpp                 Pointer to value bits per pixel.
> +
> +  @retval EFI_SUCCESS             Bit per pixel information for the requested
> +                                  mode returned successfully.
> +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> +**/
> +EFI_STATUS
> +LcdPlatformGetBpp (
> +  IN  CONST UINT32         ModeNumber,
> +  OUT LCD_BPP      * CONST Bpp
> +  )
> +{
> +  if (ModeNumber >= mMaxMode) {
> +    // Check valid ModeNumber and Bpp.
> +    ASSERT (ModeNumber < mMaxMode);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  ASSERT (Bpp != NULL);
> +
> +  *Bpp = LCD_BITS_PER_PIXEL_24;
> +
> +  return EFI_SUCCESS;
> +}
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 00/18] ARM: Update GOP
  2017-12-22 19:29 ` [PATCH edk2-platforms v2 00/18] ARM: Update GOP Ard Biesheuvel
@ 2018-01-02 10:28   ` Evan Lloyd
  0 siblings, 0 replies; 57+ messages in thread
From: Evan Lloyd @ 2018-01-02 10:28 UTC (permalink / raw)
  To: Ard Biesheuvel, Leif Lindholm, Matteo Carlini
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Abraham

Hi Ard.
Happy New Year!
I have no idea what has caused that.  I haven't changed the script I use to generate patches, so I'm off to consult our IT guys to find out what's up.
I'll resume when I've done that.

Sorry,
Evan

> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 22 December 2017 19:30
> To: Evan Lloyd <Evan.Lloyd@arm.com>; Leif Lindholm
> <leif.lindholm@linaro.org>; Ard Biesheuvel <ard.biesheuvel@linaro.org>;
> Matteo Carlini <Matteo.Carlini@arm.com>
> Cc: edk2-devel@lists.01.org; Arvind Chauhan <Arvind.Chauhan@arm.com>;
> Daniil Egranov <Daniil.Egranov@arm.com>; Thomas Abraham
> <thomas.abraham@arm.com>
> Subject: Re: [PATCH edk2-platforms v2 00/18] ARM: Update GOP
>
> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> > From: EvanLloyd <evan.lloyd@arm.com>
> >
>
> Hello Evan,
>
> Before reviewing in detail, could you please confirm that replying to the
> addresses below is going to work as expected for non @arm.com reviewers?
> They look a bit odd, but perhaps the arm.com SMTP server doesn't care??
>
> Cc: Arvind Chauhan <Arvind.Chauhan@arm.com>, Daniil Egranov
> <Daniil.Egranov@arm.com>, Thomas Panakamattam Abraham
> <thomas.abraham@arm.com>, "ard.biesheuvel@linaro.org"@arm.com,
> "leif.lindholm@linaro.org"@arm.com,
> "Matteo.Carlini@arm.com"@arm.com, "nd@arm.com"@arm.com
>
> --
> Ard.
>
>
> > This patch series addresses comments on the original
> > (https://lists.01.org/pipermail/edk2-devel/2017-September/015356.html)
> > reworking of the Graphics Output Protocol code in Platform/ARM.
> > It also contains updates for the new SCMI protocol (MTL Library).
> >
> > After a number of format and quality modifications, several errors
> > are corrected and new functionality added for Mali DP.
> >
> > The changes are tested on Juno, and FVP.
> >
> > Code is available for examination at:
> >   https://github.com/EvanLloyd/edk2-platforms/tree/166_gop_v2
> >
> > Ard Biesheuvel (1):
> >   ARM/VExpressPkg: Fix MODULE_TYPE of HDLCD/PL111 platform libraries
> >
> > EvanLloyd (1):
> >   ARM/VExpressPkg: HdLcdArmVExpressLib: Remove redundant Bpp
> >
> > Girish Pathak (16):
> >   ARM/VExpressPkg: Tidy HDLCD and PL11LCD platform Lib: Coding
> standard
> >   ARM/VExpressPkg: Tidy HdLcd/PL111Lcd code: Updated comments
> >   ARM/VExpressPkg: Remove unused PcdPL111LcdMaxMode from HDLCD
> inf
> >   ARM/VExpressPkg: PL111 and HDLCD: add const qualifier
> >   ARM/VExpressPkg: Add and update debug ASSERTS
> >   ARM/VExpressPkg: PL111LcdArmVExpressLib: Minor code cleanup
> >   ARM/VExpressPkg: PL111 and HDLCD: Use FixedPcdGet32
> >   ARM/VExpressPkg: PL11LcdArmVExpressLib: Improvement conditional
> >   ARM/VExpressPkg: HdLcdArmVExpressLib: Remove status check
> EFI_TIMEOUT
> >   ARM/VExpressPkg: Redefine LcdPlatformGetTimings function
> >   ARM/VExpressPkg: PL111 and HDLCD: Add PCD to select pixel format
> >   ARM/VExpressPkg: Reserving framebuffer at build
> >   ARM/VExpressPkg: New DP500/DP550/DP650 platform library.
> >   ARM/JunoPkg: Mapping Non-Trused SRAM as device memory
> >   ARM/JunoPkg: Adding SCMI MTL library
> >   ARM/JunoPkg: Add HDLCD platform library
> >
> >  Platform/ARM/JunoPkg/ArmJuno.dec                                                   |  17
> +-
> >  Platform/ARM/VExpressPkg/ArmVExpressPkg.dec
> |   3 +-
> >  Platform/ARM/JunoPkg/ArmJuno.dsc                                                   |  32
> ++
> >  Platform/ARM/JunoPkg/ArmJuno.fdf                                                   |  12
> +-
> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf
> |   5 +-
> >  Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
> |  39 ++
> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
> |  40 ++
> >  Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
> |  45 ++
> >
> Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib
> .inf             |   7 +-
> >
> Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExp
> ressLib.inf       |  13 +-
> >
> Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
> mVExpressLib.inf |   9 +-
> >  Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h
> |  94 ++++
> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
> |  24 +-
> >  Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c
> | 195 +++++++
> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
> | 559 ++++++++++++++++++++
> >  Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
> | 374 +++++++++++++
> >  Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> |  28 +-
> >
> Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExp
> ress.c            | 309 +++++++----
> >
> Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
> mVExpress.c      | 425 +++++++++------
> >  19 files changed, 1920 insertions(+), 310 deletions(-)
> >  create mode 100644
> Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
> >  create mode 100644
> Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
> >  create mode 100644
> Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
> >  create mode 100644
> Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtlPrivate.h
> >  create mode 100644 Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.c
> >  create mode 100644
> Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
> >  create mode 100644
> Platform/ARM/VExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
> >
> > --
> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 14/18] ARM/VExpressPkg: Reserving framebuffer at build
  2017-12-23 16:02   ` Ard Biesheuvel
@ 2018-01-03 11:04     ` Evan Lloyd
  0 siblings, 0 replies; 57+ messages in thread
From: Evan Lloyd @ 2018-01-03 11:04 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Abraham, "ard.biesheuvel@linaro.org"@arm.com,
	"leif.lindholm@linaro.org"@arm.com,
	"Matteo.Carlini@arm.com"@arm.com,
	"nd@arm.com"@arm.com



> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 23 December 2017 16:03
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org; Arvind Chauhan <Arvind.Chauhan@arm.com>;
> Daniil Egranov <Daniil.Egranov@arm.com>; Thomas Abraham
> <thomas.abraham@arm.com>; "ard.biesheuvel@linaro.org"@arm.com;
> "leif.lindholm@linaro.org"@arm.com;
> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
> Subject: Re: [PATCH edk2-platforms v2 14/18] ARM/VExpressPkg:
> Reserving framebuffer at build
>
> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> > From: Girish Pathak <girish.pathak at arm.com>
> >
> > This change uses two PCDs, PcdArmLcdFrameBufferBase and
> > PcdArmLcdFrameBufferSize introduced in correspondiong EDK2 patch to
> > reserve framebuffer in DRAM if these values are defined in platform
> > specific DSC file, avoiding the need to allocate dynamically.
> > This allows the framebuffer to appear as "I/O memory" outside of the
> > normal RAM map, which is similar to the "VRAM" case.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
...
> > +  VirtualMemoryTable[Index].Attributes =
> > +ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
> > +#endif
> > +
>
> Whose responsibility is it to ensure that this region is removed from
> SystemMemoryBase/SystemMemorySize? If it is up to the .DSC author,
> could you please add an ASSERT() here that they don't overlap?

 [[Evan Lloyd]] That is an excellent suggestion, thank you - we'll add that.

>
> >    // Map sparse memory region if present
> >    if (HasSparseMemory) {
> >      VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
> > --
> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS
  2017-12-23 14:12   ` Ard Biesheuvel
@ 2018-01-04 18:55     ` Girish Pathak
  2018-01-04 19:24       ` Ard Biesheuvel
  0 siblings, 1 reply; 57+ messages in thread
From: Girish Pathak @ 2018-01-04 18:55 UTC (permalink / raw)
  To: Ard Biesheuvel, Evan Lloyd
  Cc: Matteo Carlini, nd, edk2-devel@lists.01.org, Thomas Abraham,
	Arvind Chauhan, leif.lindholm@linaro.org

Hi Ard,

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Ard Biesheuvel
> Sent: 23 December 2017 14:12
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: "Matteo.Carlini@arm.com"@arm.com;
> "leif.lindholm@linaro.org"@arm.com; "nd@arm.com"@arm.com; edk2-
> devel@lists.01.org; Thomas Abraham <thomas.abraham@arm.com>; Arvind
> Chauhan <Arvind.Chauhan@arm.com>;
> "ard.biesheuvel@linaro.org"@arm.com
> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add
> and update debug ASSERTS
> 
> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> > From: Girish Pathak <girish.pathak at arm.com>
> >
> > This change adds some debug assertions e.g to catch NULL pointer
> > errors missing in PL11Lcd and HdLcd platform libraries.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> > Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
> > ---
> >
> Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpr
> ess.c       | 22 +++++++++++++++++-
> >
> >
> Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArm
> VEx
> > press.c | 24 +++++++++++++++++++-
> >  2 files changed, 44 insertions(+), 2 deletions(-)
> >
> > diff --git
> >
> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
> pres
> > s.c
> >
> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
> pres
> > s.c index
> >
> 6afd764897f49c64490ce891682f99bb0f5d993b..a8fe8696da0653017ce9fa6e4a
> 86
> > caf283bc04c9 100644
> > ---
> >
> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
> pres
> > s.c
> > +++
> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
> > +++ press.c
> > @@ -153,6 +153,9 @@ LcdPlatformGetVram (
> >    EFI_STATUS              Status;
> >    EFI_ALLOCATE_TYPE       AllocationType;
> >
> > +  ASSERT (VramBaseAddress != NULL);
> > +  ASSERT (VramSize != NULL);
> > +
> >    // Set the vram size
> >    *VramSize = LCD_VRAM_SIZE;
> >
> > @@ -171,6 +174,7 @@ LcdPlatformGetVram (
> >                    VramBaseAddress
> >                    );
> >    if (EFI_ERROR (Status)) {
> > +    ASSERT (FALSE);
> >      return Status;
> >    }
> >
> > @@ -181,8 +185,8 @@ LcdPlatformGetVram (
> >                    *VramSize,
> >                    EFI_MEMORY_WC
> >                    );
> > -  ASSERT_EFI_ERROR (Status);
> >    if (EFI_ERROR (Status)) {
> > +    ASSERT (FALSE);
> 
> As in the sibling patch against EDK2, this patch makes it more difficult to
> figure out what went wrong when you hit the ASSERT.
> ASSERT_EFI_ERROR prints the value of Status, ASSERT(FALSE) only prints
> '0 != 1'
> 

This change(and other similar changes) is in response to review comments on patch v1
https://lists.01.org/pipermail/edk2-devel/2017-October/015995.html 

with above reference, Can you please confirm if we should revert to the patch v1 version ?

> >      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> >      return Status;
> >    }
> > @@ -221,6 +225,7 @@ LcdPlatformSetMode (
> >    EFI_STATUS            Status;
> >
> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > +    ASSERT (FALSE);
> 
> These are fine: the code itself explains adequately which condition triggered
> the ASSERT to fire.
> 
> >      return EFI_INVALID_PARAMETER;
> >    }
> >
> > @@ -279,7 +284,10 @@ LcdPlatformQueryMode (
> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST  Info
> >    )
> >  {
> > +  ASSERT (Info != NULL);
> > +
> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > +    ASSERT (FALSE);
> >      return EFI_INVALID_PARAMETER;
> >    }
> >
> > @@ -343,7 +351,18 @@ LcdPlatformGetTimings (
> >    OUT UINT32 * CONST                            VFrontPorch
> >    )
> >  {
> > +  // One of the pointers is NULL
> > +  ASSERT (HRes != NULL);
> > +  ASSERT (HSync != NULL);
> > +  ASSERT (HBackPorch != NULL);
> > +  ASSERT (HFrontPorch != NULL);
> > +  ASSERT (VRes != NULL);
> > +  ASSERT (VSync != NULL);
> > +  ASSERT (VBackPorch != NULL);
> > +  ASSERT (VFrontPorch != NULL);
> > +
> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > +    ASSERT (FALSE);
> >      return EFI_INVALID_PARAMETER;
> >    }
> >
> > @@ -376,6 +395,7 @@ LcdPlatformGetBpp (
> >    )
> >  {
> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > +    ASSERT (FALSE);
> >      return EFI_INVALID_PARAMETER;
> >    }
> >
> > diff --git
> >
> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
> mV
> > Express.c
> >
> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
> mV
> > Express.c index
> >
> 799fb3fc781ce04bb64cb1fa0b87f262a670ed78..fd4eea8f8e2397bc7d4ddf4cfe
> 3d
> > cc97a5109edb 100644
> > ---
> >
> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
> mV
> > Express.c
> > +++
> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
> > +++ ArmVExpress.c
> > @@ -205,6 +205,9 @@ LcdPlatformGetVram (
> >
> >    Status = EFI_SUCCESS;
> >
> > +  ASSERT (VramBaseAddress != NULL);
> > +  ASSERT (VramSize != NULL);
> > +
> >    // Is it on the motherboard or on the daughterboard?
> >    switch (PL111_CLCD_SITE) {
> >
> > @@ -225,6 +228,7 @@ LcdPlatformGetVram (
> >                      VramBaseAddress
> >                      );
> >      if (EFI_ERROR (Status)) {
> > +      ASSERT (FALSE);
> >        return Status;
> >      }
> >
> > @@ -235,8 +239,8 @@ LcdPlatformGetVram (
> >                      *VramSize,
> >                      EFI_MEMORY_WC
> >                      );
> > -    ASSERT_EFI_ERROR (Status);
> >      if (EFI_ERROR (Status)) {
> > +      ASSERT (FALSE);
> >        gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> (*VramSize));
> >        return Status;
> >      }
> > @@ -294,6 +298,7 @@ LcdPlatformSetMode (
> >    UINT32                SysId;
> >
> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > +    ASSERT (FALSE);
> >      return EFI_INVALID_PARAMETER;
> >    }
> >
> > @@ -369,7 +374,10 @@ LcdPlatformQueryMode (
> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> >    )
> >  {
> > +  ASSERT (Info != NULL);
> > +
> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > +    ASSERT (FALSE);
> >      return EFI_INVALID_PARAMETER;
> >    }
> >
> > @@ -433,7 +441,18 @@ LcdPlatformGetTimings (
> >    OUT UINT32 * CONST                      VFrontPorch
> >    )
> >  {
> > +  // One of the pointers is NULL
> > +  ASSERT (HRes != NULL);
> > +  ASSERT (HSync != NULL);
> > +  ASSERT (HBackPorch != NULL);
> > +  ASSERT (HFrontPorch != NULL);
> > +  ASSERT (VRes != NULL);
> > +  ASSERT (VSync != NULL);
> > +  ASSERT (VBackPorch != NULL);
> > +  ASSERT (VFrontPorch != NULL);
> > +
> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > +    ASSERT (FALSE);
> >      return EFI_INVALID_PARAMETER;
> >    }
> >
> > @@ -465,7 +484,10 @@ LcdPlatformGetBpp (
> >    OUT LCD_BPP * CONST                     Bpp
> >    )
> >  {
> > +  ASSERT (Bpp != NULL);
> > +
> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > +    ASSERT (FALSE);
> >      return EFI_INVALID_PARAMETER;
> >    }
> >
> > --
> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS
  2018-01-04 18:55     ` Girish Pathak
@ 2018-01-04 19:24       ` Ard Biesheuvel
  2018-01-04 19:51         ` Evan Lloyd
  2018-03-14 12:24         ` Leif Lindholm
  0 siblings, 2 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2018-01-04 19:24 UTC (permalink / raw)
  To: Girish Pathak
  Cc: Evan Lloyd, Matteo Carlini, nd, edk2-devel@lists.01.org,
	Thomas Abraham, Arvind Chauhan, leif.lindholm@linaro.org

On 4 January 2018 at 18:55, Girish Pathak <Girish.Pathak@arm.com> wrote:
> Hi Ard,
>
>> -----Original Message-----
>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>> Ard Biesheuvel
>> Sent: 23 December 2017 14:12
>> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> Cc: "Matteo.Carlini@arm.com"@arm.com;
>> "leif.lindholm@linaro.org"@arm.com; "nd@arm.com"@arm.com; edk2-
>> devel@lists.01.org; Thomas Abraham <thomas.abraham@arm.com>; Arvind
>> Chauhan <Arvind.Chauhan@arm.com>;
>> "ard.biesheuvel@linaro.org"@arm.com
>> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add
>> and update debug ASSERTS
>>
>> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
>> > From: Girish Pathak <girish.pathak at arm.com>
>> >
>> > This change adds some debug assertions e.g to catch NULL pointer
>> > errors missing in PL11Lcd and HdLcd platform libraries.
>> >
>> > Contributed-under: TianoCore Contribution Agreement 1.1
>> > Signed-off-by: Girish Pathak <girish.pathak@arm.com>
>> > Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
>> > ---
>> >
>> Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpr
>> ess.c       | 22 +++++++++++++++++-
>> >
>> >
>> Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArm
>> VEx
>> > press.c | 24 +++++++++++++++++++-
>> >  2 files changed, 44 insertions(+), 2 deletions(-)
>> >
>> > diff --git
>> >
>> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
>> pres
>> > s.c
>> >
>> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
>> pres
>> > s.c index
>> >
>> 6afd764897f49c64490ce891682f99bb0f5d993b..a8fe8696da0653017ce9fa6e4a
>> 86
>> > caf283bc04c9 100644
>> > ---
>> >
>> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
>> pres
>> > s.c
>> > +++
>> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
>> > +++ press.c
>> > @@ -153,6 +153,9 @@ LcdPlatformGetVram (
>> >    EFI_STATUS              Status;
>> >    EFI_ALLOCATE_TYPE       AllocationType;
>> >
>> > +  ASSERT (VramBaseAddress != NULL);
>> > +  ASSERT (VramSize != NULL);
>> > +
>> >    // Set the vram size
>> >    *VramSize = LCD_VRAM_SIZE;
>> >
>> > @@ -171,6 +174,7 @@ LcdPlatformGetVram (
>> >                    VramBaseAddress
>> >                    );
>> >    if (EFI_ERROR (Status)) {
>> > +    ASSERT (FALSE);
>> >      return Status;
>> >    }
>> >
>> > @@ -181,8 +185,8 @@ LcdPlatformGetVram (
>> >                    *VramSize,
>> >                    EFI_MEMORY_WC
>> >                    );
>> > -  ASSERT_EFI_ERROR (Status);
>> >    if (EFI_ERROR (Status)) {
>> > +    ASSERT (FALSE);
>>
>> As in the sibling patch against EDK2, this patch makes it more difficult to
>> figure out what went wrong when you hit the ASSERT.
>> ASSERT_EFI_ERROR prints the value of Status, ASSERT(FALSE) only prints
>> '0 != 1'
>>
>
> This change(and other similar changes) is in response to review comments on patch v1
> https://lists.01.org/pipermail/edk2-devel/2017-October/015995.html
>
> with above reference, Can you please confirm if we should revert to the patch v1 version ?
>

I guess Leif and I are in disagreement here. In particular, I think his comment

"""
ASSERT (FALSE)?  (You already know Status is an EFI_ERROR, and a
console message saying ASSERT (Status) is not getting you out of
looking at the source code to find out what happened.)
"""

is misguided, given that ASSERT_EFI_ERROR (Status) will actually print
the value of Status to the debug console.

However, the objections against putting function calls in ASSERT()s
are justified: ASSERT() should not have side effects if its condition
is met, and function calls may have side effects.

I suppose we should wait for Leif to return on the 22nd before
proceeding with the review.
Apologies for the confusion, and for the delay.



>> >      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
>> >      return Status;
>> >    }
>> > @@ -221,6 +225,7 @@ LcdPlatformSetMode (
>> >    EFI_STATUS            Status;
>> >
>> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > +    ASSERT (FALSE);
>>
>> These are fine: the code itself explains adequately which condition triggered
>> the ASSERT to fire.
>>
>> >      return EFI_INVALID_PARAMETER;
>> >    }
>> >
>> > @@ -279,7 +284,10 @@ LcdPlatformQueryMode (
>> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST  Info
>> >    )
>> >  {
>> > +  ASSERT (Info != NULL);
>> > +
>> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > +    ASSERT (FALSE);
>> >      return EFI_INVALID_PARAMETER;
>> >    }
>> >
>> > @@ -343,7 +351,18 @@ LcdPlatformGetTimings (
>> >    OUT UINT32 * CONST                            VFrontPorch
>> >    )
>> >  {
>> > +  // One of the pointers is NULL
>> > +  ASSERT (HRes != NULL);
>> > +  ASSERT (HSync != NULL);
>> > +  ASSERT (HBackPorch != NULL);
>> > +  ASSERT (HFrontPorch != NULL);
>> > +  ASSERT (VRes != NULL);
>> > +  ASSERT (VSync != NULL);
>> > +  ASSERT (VBackPorch != NULL);
>> > +  ASSERT (VFrontPorch != NULL);
>> > +
>> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > +    ASSERT (FALSE);
>> >      return EFI_INVALID_PARAMETER;
>> >    }
>> >
>> > @@ -376,6 +395,7 @@ LcdPlatformGetBpp (
>> >    )
>> >  {
>> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > +    ASSERT (FALSE);
>> >      return EFI_INVALID_PARAMETER;
>> >    }
>> >
>> > diff --git
>> >
>> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
>> mV
>> > Express.c
>> >
>> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
>> mV
>> > Express.c index
>> >
>> 799fb3fc781ce04bb64cb1fa0b87f262a670ed78..fd4eea8f8e2397bc7d4ddf4cfe
>> 3d
>> > cc97a5109edb 100644
>> > ---
>> >
>> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
>> mV
>> > Express.c
>> > +++
>> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
>> > +++ ArmVExpress.c
>> > @@ -205,6 +205,9 @@ LcdPlatformGetVram (
>> >
>> >    Status = EFI_SUCCESS;
>> >
>> > +  ASSERT (VramBaseAddress != NULL);
>> > +  ASSERT (VramSize != NULL);
>> > +
>> >    // Is it on the motherboard or on the daughterboard?
>> >    switch (PL111_CLCD_SITE) {
>> >
>> > @@ -225,6 +228,7 @@ LcdPlatformGetVram (
>> >                      VramBaseAddress
>> >                      );
>> >      if (EFI_ERROR (Status)) {
>> > +      ASSERT (FALSE);
>> >        return Status;
>> >      }
>> >
>> > @@ -235,8 +239,8 @@ LcdPlatformGetVram (
>> >                      *VramSize,
>> >                      EFI_MEMORY_WC
>> >                      );
>> > -    ASSERT_EFI_ERROR (Status);
>> >      if (EFI_ERROR (Status)) {
>> > +      ASSERT (FALSE);
>> >        gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
>> (*VramSize));
>> >        return Status;
>> >      }
>> > @@ -294,6 +298,7 @@ LcdPlatformSetMode (
>> >    UINT32                SysId;
>> >
>> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > +    ASSERT (FALSE);
>> >      return EFI_INVALID_PARAMETER;
>> >    }
>> >
>> > @@ -369,7 +374,10 @@ LcdPlatformQueryMode (
>> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
>> >    )
>> >  {
>> > +  ASSERT (Info != NULL);
>> > +
>> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > +    ASSERT (FALSE);
>> >      return EFI_INVALID_PARAMETER;
>> >    }
>> >
>> > @@ -433,7 +441,18 @@ LcdPlatformGetTimings (
>> >    OUT UINT32 * CONST                      VFrontPorch
>> >    )
>> >  {
>> > +  // One of the pointers is NULL
>> > +  ASSERT (HRes != NULL);
>> > +  ASSERT (HSync != NULL);
>> > +  ASSERT (HBackPorch != NULL);
>> > +  ASSERT (HFrontPorch != NULL);
>> > +  ASSERT (VRes != NULL);
>> > +  ASSERT (VSync != NULL);
>> > +  ASSERT (VBackPorch != NULL);
>> > +  ASSERT (VFrontPorch != NULL);
>> > +
>> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > +    ASSERT (FALSE);
>> >      return EFI_INVALID_PARAMETER;
>> >    }
>> >
>> > @@ -465,7 +484,10 @@ LcdPlatformGetBpp (
>> >    OUT LCD_BPP * CONST                     Bpp
>> >    )
>> >  {
>> > +  ASSERT (Bpp != NULL);
>> > +
>> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > +    ASSERT (FALSE);
>> >      return EFI_INVALID_PARAMETER;
>> >    }
>> >
>> > --
>> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>> >
>> > _______________________________________________
>> > edk2-devel mailing list
>> > edk2-devel@lists.01.org
>> > https://lists.01.org/mailman/listinfo/edk2-devel
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS
  2018-01-04 19:24       ` Ard Biesheuvel
@ 2018-01-04 19:51         ` Evan Lloyd
  2018-01-04 19:54           ` Ard Biesheuvel
  2018-03-14 12:24         ` Leif Lindholm
  1 sibling, 1 reply; 57+ messages in thread
From: Evan Lloyd @ 2018-01-04 19:51 UTC (permalink / raw)
  To: Ard Biesheuvel, Girish Pathak
  Cc: Matteo Carlini, nd, edk2-devel@lists.01.org, Thomas Abraham,
	Arvind Chauhan, leif.lindholm@linaro.org



> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 04 January 2018 19:24
> To: Girish Pathak <Girish.Pathak@arm.com>
> Cc: Evan Lloyd <Evan.Lloyd@arm.com>; Matteo Carlini
> <Matteo.Carlini@arm.com>; nd <nd@arm.com>; edk2-devel@lists.01.org;
> Thomas Abraham <thomas.abraham@arm.com>; Arvind Chauhan
> <Arvind.Chauhan@arm.com>; leif.lindholm@linaro.org
> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg:
> Add and update debug ASSERTS
> 
> On 4 January 2018 at 18:55, Girish Pathak <Girish.Pathak@arm.com>
> wrote:
> > Hi Ard,
> >
> >> -----Original Message-----
> >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf
> >> Of Ard Biesheuvel
> >> Sent: 23 December 2017 14:12
> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
> >> Cc: "Matteo.Carlini@arm.com"@arm.com;
> >> "leif.lindholm@linaro.org"@arm.com; "nd@arm.com"@arm.com; edk2-
> >> devel@lists.01.org; Thomas Abraham <thomas.abraham@arm.com>;
> Arvind
> >> Chauhan <Arvind.Chauhan@arm.com>;
> "ard.biesheuvel@linaro.org"@arm.com
> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg:
> >> Add and update debug ASSERTS
> >>
> >> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> >> > From: Girish Pathak <girish.pathak at arm.com>
> >> >
> >> > This change adds some debug assertions e.g to catch NULL pointer
> >> > errors missing in PL11Lcd and HdLcd platform libraries.
> >> >
> >> > Contributed-under: TianoCore Contribution Agreement 1.1
> >> > Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> >> > Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
> >> > ---
> >> >
> >>
> Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExp
> r
> >> ess.c       | 22 +++++++++++++++++-
> >> >
> >> >
> >>
> Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
> m
> >> VEx
> >> > press.c | 24 +++++++++++++++++++-
> >> >  2 files changed, 44 insertions(+), 2 deletions(-)
> >> >
> >> > diff --git
> >> >
> >>
> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
> x
> >> pres
> >> > s.c
> >> >
> >>
> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
> x
> >> pres
> >> > s.c index
> >> >
> >>
> 6afd764897f49c64490ce891682f99bb0f5d993b..a8fe8696da0653017ce9fa
> 6e4a
> >> 86
> >> > caf283bc04c9 100644
> >> > ---
> >> >
> >>
> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
> x
> >> pres
> >> > s.c
> >> > +++
> >>
> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
> x
> >> > +++ press.c
> >> > @@ -153,6 +153,9 @@ LcdPlatformGetVram (
> >> >    EFI_STATUS              Status;
> >> >    EFI_ALLOCATE_TYPE       AllocationType;
> >> >
> >> > +  ASSERT (VramBaseAddress != NULL);  ASSERT (VramSize != NULL);
> >> > +
> >> >    // Set the vram size
> >> >    *VramSize = LCD_VRAM_SIZE;
> >> >
> >> > @@ -171,6 +174,7 @@ LcdPlatformGetVram (
> >> >                    VramBaseAddress
> >> >                    );
> >> >    if (EFI_ERROR (Status)) {
> >> > +    ASSERT (FALSE);
> >> >      return Status;
> >> >    }
> >> >
> >> > @@ -181,8 +185,8 @@ LcdPlatformGetVram (
> >> >                    *VramSize,
> >> >                    EFI_MEMORY_WC
> >> >                    );
> >> > -  ASSERT_EFI_ERROR (Status);
> >> >    if (EFI_ERROR (Status)) {
> >> > +    ASSERT (FALSE);
> >>
> >> As in the sibling patch against EDK2, this patch makes it more
> >> difficult to figure out what went wrong when you hit the ASSERT.
> >> ASSERT_EFI_ERROR prints the value of Status, ASSERT(FALSE) only
> >> prints
> >> '0 != 1'
> >>
> >
> > This change(and other similar changes) is in response to review
> > comments on patch v1
> > https://lists.01.org/pipermail/edk2-devel/2017-October/015995.html
> >
> > with above reference, Can you please confirm if we should revert to the
> patch v1 version ?
> >
> 
> I guess Leif and I are in disagreement here. In particular, I think his comment
> 
> """
> ASSERT (FALSE)?  (You already know Status is an EFI_ERROR, and a console
> message saying ASSERT (Status) is not getting you out of looking at the
> source code to find out what happened.) """
> 
> is misguided, given that ASSERT_EFI_ERROR (Status) will actually print the
> value of Status to the debug console.
> 
> However, the objections against putting function calls in ASSERT()s are
> justified: ASSERT() should not have side effects if its condition is met, and
> function calls may have side effects.
> 
> I suppose we should wait for Leif to return on the 22nd before proceeding
> with the review.
> Apologies for the confusion, and for the delay.

 [[Evan Lloyd]] An alternative might be for Girish to take the other route Leif suggested, and cache the condition in a variable.
That might be a slight overhead, and the (presumably BOOLEAN) variable may need careful naming, but...

> 
> 
> 
> >> >      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> (*VramSize));
> >> >      return Status;
> >> >    }
> >> > @@ -221,6 +225,7 @@ LcdPlatformSetMode (
> >> >    EFI_STATUS            Status;
> >> >
> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > +    ASSERT (FALSE);
> >>
> >> These are fine: the code itself explains adequately which condition
> >> triggered the ASSERT to fire.
> >>
> >> >      return EFI_INVALID_PARAMETER;
> >> >    }
> >> >
> >> > @@ -279,7 +284,10 @@ LcdPlatformQueryMode (
> >> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST  Info
> >> >    )
> >> >  {
> >> > +  ASSERT (Info != NULL);
> >> > +
> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > +    ASSERT (FALSE);
> >> >      return EFI_INVALID_PARAMETER;
> >> >    }
> >> >
> >> > @@ -343,7 +351,18 @@ LcdPlatformGetTimings (
> >> >    OUT UINT32 * CONST                            VFrontPorch
> >> >    )
> >> >  {
> >> > +  // One of the pointers is NULL
> >> > +  ASSERT (HRes != NULL);
> >> > +  ASSERT (HSync != NULL);
> >> > +  ASSERT (HBackPorch != NULL);
> >> > +  ASSERT (HFrontPorch != NULL);
> >> > +  ASSERT (VRes != NULL);
> >> > +  ASSERT (VSync != NULL);
> >> > +  ASSERT (VBackPorch != NULL);
> >> > +  ASSERT (VFrontPorch != NULL);
> >> > +
> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > +    ASSERT (FALSE);
> >> >      return EFI_INVALID_PARAMETER;
> >> >    }
> >> >
> >> > @@ -376,6 +395,7 @@ LcdPlatformGetBpp (
> >> >    )
> >> >  {
> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > +    ASSERT (FALSE);
> >> >      return EFI_INVALID_PARAMETER;
> >> >    }
> >> >
> >> > diff --git
> >> >
> >>
> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
> Ar
> >> mV
> >> > Express.c
> >> >
> >>
> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
> Ar
> >> mV
> >> > Express.c index
> >> >
> >>
> 799fb3fc781ce04bb64cb1fa0b87f262a670ed78..fd4eea8f8e2397bc7d4ddf
> 4cfe
> >> 3d
> >> > cc97a5109edb 100644
> >> > ---
> >> >
> >>
> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
> Ar
> >> mV
> >> > Express.c
> >> > +++
> >>
> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
> >> > +++ ArmVExpress.c
> >> > @@ -205,6 +205,9 @@ LcdPlatformGetVram (
> >> >
> >> >    Status = EFI_SUCCESS;
> >> >
> >> > +  ASSERT (VramBaseAddress != NULL);  ASSERT (VramSize != NULL);
> >> > +
> >> >    // Is it on the motherboard or on the daughterboard?
> >> >    switch (PL111_CLCD_SITE) {
> >> >
> >> > @@ -225,6 +228,7 @@ LcdPlatformGetVram (
> >> >                      VramBaseAddress
> >> >                      );
> >> >      if (EFI_ERROR (Status)) {
> >> > +      ASSERT (FALSE);
> >> >        return Status;
> >> >      }
> >> >
> >> > @@ -235,8 +239,8 @@ LcdPlatformGetVram (
> >> >                      *VramSize,
> >> >                      EFI_MEMORY_WC
> >> >                      );
> >> > -    ASSERT_EFI_ERROR (Status);
> >> >      if (EFI_ERROR (Status)) {
> >> > +      ASSERT (FALSE);
> >> >        gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> >> (*VramSize));
> >> >        return Status;
> >> >      }
> >> > @@ -294,6 +298,7 @@ LcdPlatformSetMode (
> >> >    UINT32                SysId;
> >> >
> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > +    ASSERT (FALSE);
> >> >      return EFI_INVALID_PARAMETER;
> >> >    }
> >> >
> >> > @@ -369,7 +374,10 @@ LcdPlatformQueryMode (
> >> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> >> >    )
> >> >  {
> >> > +  ASSERT (Info != NULL);
> >> > +
> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > +    ASSERT (FALSE);
> >> >      return EFI_INVALID_PARAMETER;
> >> >    }
> >> >
> >> > @@ -433,7 +441,18 @@ LcdPlatformGetTimings (
> >> >    OUT UINT32 * CONST                      VFrontPorch
> >> >    )
> >> >  {
> >> > +  // One of the pointers is NULL
> >> > +  ASSERT (HRes != NULL);
> >> > +  ASSERT (HSync != NULL);
> >> > +  ASSERT (HBackPorch != NULL);
> >> > +  ASSERT (HFrontPorch != NULL);
> >> > +  ASSERT (VRes != NULL);
> >> > +  ASSERT (VSync != NULL);
> >> > +  ASSERT (VBackPorch != NULL);
> >> > +  ASSERT (VFrontPorch != NULL);
> >> > +
> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > +    ASSERT (FALSE);
> >> >      return EFI_INVALID_PARAMETER;
> >> >    }
> >> >
> >> > @@ -465,7 +484,10 @@ LcdPlatformGetBpp (
> >> >    OUT LCD_BPP * CONST                     Bpp
> >> >    )
> >> >  {
> >> > +  ASSERT (Bpp != NULL);
> >> > +
> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > +    ASSERT (FALSE);
> >> >      return EFI_INVALID_PARAMETER;
> >> >    }
> >> >
> >> > --
> >> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >> >
> >> > _______________________________________________
> >> > edk2-devel mailing list
> >> > edk2-devel@lists.01.org
> >> > https://lists.01.org/mailman/listinfo/edk2-devel
> >> _______________________________________________
> >> edk2-devel mailing list
> >> edk2-devel@lists.01.org
> >> https://lists.01.org/mailman/listinfo/edk2-devel

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS
  2018-01-04 19:51         ` Evan Lloyd
@ 2018-01-04 19:54           ` Ard Biesheuvel
  2018-02-28 20:27             ` Evan Lloyd
  0 siblings, 1 reply; 57+ messages in thread
From: Ard Biesheuvel @ 2018-01-04 19:54 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: Girish Pathak, Matteo Carlini, nd, edk2-devel@lists.01.org,
	Thomas Abraham, Arvind Chauhan, leif.lindholm@linaro.org

On 4 January 2018 at 19:51, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
>
>
>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: 04 January 2018 19:24
>> To: Girish Pathak <Girish.Pathak@arm.com>
>> Cc: Evan Lloyd <Evan.Lloyd@arm.com>; Matteo Carlini
>> <Matteo.Carlini@arm.com>; nd <nd@arm.com>; edk2-devel@lists.01.org;
>> Thomas Abraham <thomas.abraham@arm.com>; Arvind Chauhan
>> <Arvind.Chauhan@arm.com>; leif.lindholm@linaro.org
>> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg:
>> Add and update debug ASSERTS
>>
>> On 4 January 2018 at 18:55, Girish Pathak <Girish.Pathak@arm.com>
>> wrote:
>> > Hi Ard,
>> >
>> >> -----Original Message-----
>> >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf
>> >> Of Ard Biesheuvel
>> >> Sent: 23 December 2017 14:12
>> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> >> Cc: "Matteo.Carlini@arm.com"@arm.com;
>> >> "leif.lindholm@linaro.org"@arm.com; "nd@arm.com"@arm.com; edk2-
>> >> devel@lists.01.org; Thomas Abraham <thomas.abraham@arm.com>;
>> Arvind
>> >> Chauhan <Arvind.Chauhan@arm.com>;
>> "ard.biesheuvel@linaro.org"@arm.com
>> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg:
>> >> Add and update debug ASSERTS
>> >>
>> >> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
>> >> > From: Girish Pathak <girish.pathak at arm.com>
>> >> >
>> >> > This change adds some debug assertions e.g to catch NULL pointer
>> >> > errors missing in PL11Lcd and HdLcd platform libraries.
>> >> >
>> >> > Contributed-under: TianoCore Contribution Agreement 1.1
>> >> > Signed-off-by: Girish Pathak <girish.pathak@arm.com>
>> >> > Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
>> >> > ---
>> >> >
>> >>
>> Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExp
>> r
>> >> ess.c       | 22 +++++++++++++++++-
>> >> >
>> >> >
>> >>
>> Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
>> m
>> >> VEx
>> >> > press.c | 24 +++++++++++++++++++-
>> >> >  2 files changed, 44 insertions(+), 2 deletions(-)
>> >> >
>> >> > diff --git
>> >> >
>> >>
>> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
>> x
>> >> pres
>> >> > s.c
>> >> >
>> >>
>> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
>> x
>> >> pres
>> >> > s.c index
>> >> >
>> >>
>> 6afd764897f49c64490ce891682f99bb0f5d993b..a8fe8696da0653017ce9fa
>> 6e4a
>> >> 86
>> >> > caf283bc04c9 100644
>> >> > ---
>> >> >
>> >>
>> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
>> x
>> >> pres
>> >> > s.c
>> >> > +++
>> >>
>> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
>> x
>> >> > +++ press.c
>> >> > @@ -153,6 +153,9 @@ LcdPlatformGetVram (
>> >> >    EFI_STATUS              Status;
>> >> >    EFI_ALLOCATE_TYPE       AllocationType;
>> >> >
>> >> > +  ASSERT (VramBaseAddress != NULL);  ASSERT (VramSize != NULL);
>> >> > +
>> >> >    // Set the vram size
>> >> >    *VramSize = LCD_VRAM_SIZE;
>> >> >
>> >> > @@ -171,6 +174,7 @@ LcdPlatformGetVram (
>> >> >                    VramBaseAddress
>> >> >                    );
>> >> >    if (EFI_ERROR (Status)) {
>> >> > +    ASSERT (FALSE);
>> >> >      return Status;
>> >> >    }
>> >> >
>> >> > @@ -181,8 +185,8 @@ LcdPlatformGetVram (
>> >> >                    *VramSize,
>> >> >                    EFI_MEMORY_WC
>> >> >                    );
>> >> > -  ASSERT_EFI_ERROR (Status);
>> >> >    if (EFI_ERROR (Status)) {
>> >> > +    ASSERT (FALSE);
>> >>
>> >> As in the sibling patch against EDK2, this patch makes it more
>> >> difficult to figure out what went wrong when you hit the ASSERT.
>> >> ASSERT_EFI_ERROR prints the value of Status, ASSERT(FALSE) only
>> >> prints
>> >> '0 != 1'
>> >>
>> >
>> > This change(and other similar changes) is in response to review
>> > comments on patch v1
>> > https://lists.01.org/pipermail/edk2-devel/2017-October/015995.html
>> >
>> > with above reference, Can you please confirm if we should revert to the
>> patch v1 version ?
>> >
>>
>> I guess Leif and I are in disagreement here. In particular, I think his comment
>>
>> """
>> ASSERT (FALSE)?  (You already know Status is an EFI_ERROR, and a console
>> message saying ASSERT (Status) is not getting you out of looking at the
>> source code to find out what happened.) """
>>
>> is misguided, given that ASSERT_EFI_ERROR (Status) will actually print the
>> value of Status to the debug console.
>>
>> However, the objections against putting function calls in ASSERT()s are
>> justified: ASSERT() should not have side effects if its condition is met, and
>> function calls may have side effects.
>>
>> I suppose we should wait for Leif to return on the 22nd before proceeding
>> with the review.
>> Apologies for the confusion, and for the delay.
>
>  [[Evan Lloyd]] An alternative might be for Girish to take the other route Leif suggested, and cache the condition in a variable.
> That might be a slight overhead, and the (presumably BOOLEAN) variable may need careful naming, but...
>

If we are going to use a boolean to record the result of the
comparison, and ASSERT() on it in the if () block if the comparison is
false, I don't see what the difference is with doing ASSERT (FALSE)
directly.


>>
>>
>>
>> >> >      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
>> (*VramSize));
>> >> >      return Status;
>> >> >    }
>> >> > @@ -221,6 +225,7 @@ LcdPlatformSetMode (
>> >> >    EFI_STATUS            Status;
>> >> >
>> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> > +    ASSERT (FALSE);
>> >>
>> >> These are fine: the code itself explains adequately which condition
>> >> triggered the ASSERT to fire.
>> >>
>> >> >      return EFI_INVALID_PARAMETER;
>> >> >    }
>> >> >
>> >> > @@ -279,7 +284,10 @@ LcdPlatformQueryMode (
>> >> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST  Info
>> >> >    )
>> >> >  {
>> >> > +  ASSERT (Info != NULL);
>> >> > +
>> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> > +    ASSERT (FALSE);
>> >> >      return EFI_INVALID_PARAMETER;
>> >> >    }
>> >> >
>> >> > @@ -343,7 +351,18 @@ LcdPlatformGetTimings (
>> >> >    OUT UINT32 * CONST                            VFrontPorch
>> >> >    )
>> >> >  {
>> >> > +  // One of the pointers is NULL
>> >> > +  ASSERT (HRes != NULL);
>> >> > +  ASSERT (HSync != NULL);
>> >> > +  ASSERT (HBackPorch != NULL);
>> >> > +  ASSERT (HFrontPorch != NULL);
>> >> > +  ASSERT (VRes != NULL);
>> >> > +  ASSERT (VSync != NULL);
>> >> > +  ASSERT (VBackPorch != NULL);
>> >> > +  ASSERT (VFrontPorch != NULL);
>> >> > +
>> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> > +    ASSERT (FALSE);
>> >> >      return EFI_INVALID_PARAMETER;
>> >> >    }
>> >> >
>> >> > @@ -376,6 +395,7 @@ LcdPlatformGetBpp (
>> >> >    )
>> >> >  {
>> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> > +    ASSERT (FALSE);
>> >> >      return EFI_INVALID_PARAMETER;
>> >> >    }
>> >> >
>> >> > diff --git
>> >> >
>> >>
>> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
>> Ar
>> >> mV
>> >> > Express.c
>> >> >
>> >>
>> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
>> Ar
>> >> mV
>> >> > Express.c index
>> >> >
>> >>
>> 799fb3fc781ce04bb64cb1fa0b87f262a670ed78..fd4eea8f8e2397bc7d4ddf
>> 4cfe
>> >> 3d
>> >> > cc97a5109edb 100644
>> >> > ---
>> >> >
>> >>
>> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
>> Ar
>> >> mV
>> >> > Express.c
>> >> > +++
>> >>
>> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
>> >> > +++ ArmVExpress.c
>> >> > @@ -205,6 +205,9 @@ LcdPlatformGetVram (
>> >> >
>> >> >    Status = EFI_SUCCESS;
>> >> >
>> >> > +  ASSERT (VramBaseAddress != NULL);  ASSERT (VramSize != NULL);
>> >> > +
>> >> >    // Is it on the motherboard or on the daughterboard?
>> >> >    switch (PL111_CLCD_SITE) {
>> >> >
>> >> > @@ -225,6 +228,7 @@ LcdPlatformGetVram (
>> >> >                      VramBaseAddress
>> >> >                      );
>> >> >      if (EFI_ERROR (Status)) {
>> >> > +      ASSERT (FALSE);
>> >> >        return Status;
>> >> >      }
>> >> >
>> >> > @@ -235,8 +239,8 @@ LcdPlatformGetVram (
>> >> >                      *VramSize,
>> >> >                      EFI_MEMORY_WC
>> >> >                      );
>> >> > -    ASSERT_EFI_ERROR (Status);
>> >> >      if (EFI_ERROR (Status)) {
>> >> > +      ASSERT (FALSE);
>> >> >        gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
>> >> (*VramSize));
>> >> >        return Status;
>> >> >      }
>> >> > @@ -294,6 +298,7 @@ LcdPlatformSetMode (
>> >> >    UINT32                SysId;
>> >> >
>> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> > +    ASSERT (FALSE);
>> >> >      return EFI_INVALID_PARAMETER;
>> >> >    }
>> >> >
>> >> > @@ -369,7 +374,10 @@ LcdPlatformQueryMode (
>> >> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
>> >> >    )
>> >> >  {
>> >> > +  ASSERT (Info != NULL);
>> >> > +
>> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> > +    ASSERT (FALSE);
>> >> >      return EFI_INVALID_PARAMETER;
>> >> >    }
>> >> >
>> >> > @@ -433,7 +441,18 @@ LcdPlatformGetTimings (
>> >> >    OUT UINT32 * CONST                      VFrontPorch
>> >> >    )
>> >> >  {
>> >> > +  // One of the pointers is NULL
>> >> > +  ASSERT (HRes != NULL);
>> >> > +  ASSERT (HSync != NULL);
>> >> > +  ASSERT (HBackPorch != NULL);
>> >> > +  ASSERT (HFrontPorch != NULL);
>> >> > +  ASSERT (VRes != NULL);
>> >> > +  ASSERT (VSync != NULL);
>> >> > +  ASSERT (VBackPorch != NULL);
>> >> > +  ASSERT (VFrontPorch != NULL);
>> >> > +
>> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> > +    ASSERT (FALSE);
>> >> >      return EFI_INVALID_PARAMETER;
>> >> >    }
>> >> >
>> >> > @@ -465,7 +484,10 @@ LcdPlatformGetBpp (
>> >> >    OUT LCD_BPP * CONST                     Bpp
>> >> >    )
>> >> >  {
>> >> > +  ASSERT (Bpp != NULL);
>> >> > +
>> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> > +    ASSERT (FALSE);
>> >> >      return EFI_INVALID_PARAMETER;
>> >> >    }
>> >> >
>> >> > --
>> >> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>> >> >
>> >> > _______________________________________________
>> >> > edk2-devel mailing list
>> >> > edk2-devel@lists.01.org
>> >> > https://lists.01.org/mailman/listinfo/edk2-devel
>> >> _______________________________________________
>> >> edk2-devel mailing list
>> >> edk2-devel@lists.01.org
>> >> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 15/18] ARM/VExpressPkg: New DP500/DP550/DP650 platform library.
  2017-12-23 16:07   ` Ard Biesheuvel
@ 2018-01-08 18:51     ` Evan Lloyd
  2018-01-24 11:27       ` Alexei Fedorov
  0 siblings, 1 reply; 57+ messages in thread
From: Evan Lloyd @ 2018-01-08 18:51 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Abraham, "ard.biesheuvel@linaro.org"@arm.com,
	"leif.lindholm@linaro.org"@arm.com,
	"Matteo.Carlini@arm.com"@arm.com,
	"nd@arm.com"@arm.com



> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 23 December 2017 16:07
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org; Arvind Chauhan <Arvind.Chauhan@arm.com>;
> Daniil Egranov <Daniil.Egranov@arm.com>; Thomas Abraham
> <thomas.abraham@arm.com>; "ard.biesheuvel@linaro.org"@arm.com;
> "leif.lindholm@linaro.org"@arm.com;
> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
> Subject: Re: [PATCH edk2-platforms v2 15/18] ARM/VExpressPkg: New
> DP500/DP550/DP650 platform library.
>
> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> > From: Girish Pathak <girish.pathak at arm.com>
> >
...
> > +
> > +/* Internal helper function to allocate memory if memory is not
> > +already
> > +  reserved for framebuffer
> > +
> > +  @param[in]  VramSize          Requested framebuffer size in bytes.
> > +  @param[out] VramBaseAddress   Pointer to memory allocated for
> framebuffer.
> > +
> > +  @retval EFI_SUCCESS           Framebuffer memory allocated successfully.
> > +  @retval EFI_UNSUPPORTED       Allocated address wider than 40 bits.
> > +  @retval !EFI_SUCCESS          Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +GetVram (
> > +  IN  UINTN                 CONST  VramSize,
> > +  OUT EFI_PHYSICAL_ADDRESS *CONST  VramBaseAddress
> > +  )
> > +{
> > +  EFI_STATUS Status;
> > +
> > +  // Check if memory is already reserved for the framebuffer.
> > +#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)
> > +
>
> Please don't use CPP conditionals for control flow
>
> > +#if (!DP_VALID_BASE_ADDR (FixedPcdGet64
> > +(PcdArmLcdDdrFrameBufferBase))) #error ARM Mali DP framebuffer
> base address cannot be wider than 40 bits.
> > +#else
> > +  *VramBaseAddress =
> > +    (EFI_PHYSICAL_ADDRESS)FixedPcdGet64
> > +(PcdArmLcdDdrFrameBufferBase);
> > +
> > +  Status = EFI_SUCCESS;
> > +#endif
> > +
> > +#else
> > +  // If not already reserved, attempt to allocate the VRAM from the
> DRAM.
> > +  Status = gBS->AllocatePages (
> > +                  AllocateAnyPages,
> > +                  EfiBootServicesData,
> > +                  EFI_SIZE_TO_PAGES (*VramSize),
> > +                  VramBaseAddress
> > +                  );
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "ArmMaliDpLib: Failed to allocate
> framebuffer.\n"));
> > +    ASSERT (FALSE);
> > +    return Status;
> > +  }
> > +
> > +  // ARM Mali DP framebuffer base address can not be wider than 40 bits.
> > +  if (!DP_VALID_BASE_ADDR (*VramBaseAddress)) {
> > +    gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> (*VramSize));
> > +    ASSERT (DP_VALID_BASE_ADDR (*VramBaseAddress));
> > +    return EFI_UNSUPPORTED;
> > +  }
> > +
> > +  // Mark the VRAM as write-combining. The VRAM is inside the DRAM,
> > + which is  // cacheable, for ARM/AArch64 EFI_MEMORY_WC memory is
> actually uncached.
> > +  Status = gDS->SetMemorySpaceAttributes (
> > +                  *VramBaseAddress,
> > +                  *VramSize,
> > +                  EFI_MEMORY_WC
>
> Please add EFI_MEMORY_XP here
>

 [[Evan Lloyd]] We can do that, happily.  However, in looking at this we found that the UEFI spec has in "2.3.6 AArch64 Platforms", section "2.3.6.1 Memory types":
EFI_MEMORY_XP, ...                                                                             Not used or defined

Does that suggest we need a minor spec update?

> > +                  );
> > +  if (EFI_ERROR (Status)) {
> > +    ASSERT (FALSE);
> > +    gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> (*VramSize));
> > +  }
> > +#endif
> > +
> > +  return Status;
> > +}
> > +
> > +/** Allocate VRAM memory in DRAM for the framebuffer
> > +  (unless it is reserved already).
> > +
> > +  The allocated address can be used to set the framebuffer as a base
> > + buffer  address for any layer of the ARM Mali DP.
> > +
> > +  @param[out] VramBaseAddress     A pointer to the framebuffer
> address.
> > +  @param[out] VramSize            A pointer to the size of the frame
> > +                                  buffer in bytes
> > +
> > +  @retval EFI_SUCCESS             Frame buffer memory allocation success.
> > +  @retval EFI_UNSUPPORTED         Allocated address wider than 40 bits
> > +  @retval !EFI_SUCCESS            Other errors.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformGetVram (
> > +  OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> > +  OUT UINTN                * CONST VramSize
> > +  )
> > +{
> > +  ASSERT (VramBaseAddress != NULL);
> > +  ASSERT (VramSize != NULL);
> > +
> > +  // Set the VRAM size.
> > +  *VramSize = (UINTN)FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
> > +
> > +  return GetVram (*VramSize, VramBaseAddress); }
> > +
> > +/** Return total number of modes supported.
> > +
> > +  Note: Valid mode numbers are 0 to MaxMode - 1  See Section 12.9 of
> > + the UEFI Specification 2.7
> > +
> > +  @retval UINT32             Mode Number.
> > +**/
> > +UINT32
> > +LcdPlatformGetMaxMode (VOID)
> > +{
> > +  return  mMaxMode;
> > +}
> > +
> > +/** Set the requested display mode.
> > +
> > +  @param[in] ModeNumber            Mode Number.
> > +
> > +  @retval EFI_SUCCESS              Mode set successful.
> > +  @retval EFI_INVALID_PARAMETER    Requested mode not found.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformSetMode (
> > +  IN CONST UINT32 ModeNumber
> > +  )
> > +{
> > +
> > +  if (ModeNumber >= mMaxMode) {
> > +    ASSERT (ModeNumber < mMaxMode);
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  // On models, platform specific clock/mux settings are not required.
> > +  // Display controller specific settings for Mali DP are done in
> LcdSetMode.
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +/** Return information for the requested mode number.
> > +
> > +  @param[in]  ModeNumber          Mode Number.
> > +  @param[out] Info                Pointer for returned mode information
> > +                                  (on success).
> > +
> > +  @retval EFI_SUCCESS             Display mode information of the
> requested
> > +                                  mode returned successfully.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformQueryMode (
> > +  IN  CONST UINT32                                 ModeNumber,
> > +  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> > +  )
> > +{
> > +  ASSERT (ModeNumber < mMaxMode);
> > +  ASSERT (Info != NULL);
> > +
> > +  Info->Version = 0;
> > +  Info->HorizontalResolution =
> > + mDisplayModes[ModeNumber].Horizontal.Resolution;
> > +  Info->VerticalResolution =
> > + mDisplayModes[ModeNumber].Vertical.Resolution;
> > +  Info->PixelsPerScanLine =
> > + mDisplayModes[ModeNumber].Horizontal.Resolution;
> > +
> > +  Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +/** Return the display timing information for the requested mode
> number.
> > +
> > +  @param[in]  ModeNumber         Mode Number.
> > +
> > +  @param[out] Horizontal         Pointer to horizontal timing parameters.
> > +                                 (Resolution, Sync, Back porch, Front porch)
> > +  @param[out] Vertical           Pointer to vertical timing parameters.
> > +                                 (Resolution, Sync, Back porch, Front
> > + porch)
> > +
> > +  @retval EFI_SUCCESS             Display timing information of the
> requested
> > +                                  mode returned successfully.
> > +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformGetTimings (
> > +  IN  UINT32                ModeNumber,
> > +  OUT CONST SCAN_TIMINGS ** Horizontal,
> > +  OUT CONST SCAN_TIMINGS ** Vertical
> > +  )
> > +{
> > +  ASSERT (Horizontal != NULL);
> > +  ASSERT (Vertical != NULL);
> > +
> > +  if (ModeNumber >= mMaxMode) {
> > +    ASSERT (ModeNumber < mMaxMode);
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
> > +  *Vertical = &mDisplayModes[ModeNumber].Vertical;
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +/** Return bits per pixel information for a mode number.
> > +
> > +  @param[in]  ModeNumber          Mode Number.
> > +  @param[out] Bpp                 Pointer to value Bytes Per Pixel.
> > +
> > +  @retval EFI_SUCCESS             Bits per pixel information of the display
> > +                                  mode returned successfully.
> > +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformGetBpp (
> > +  IN  CONST UINT32    ModeNumber,
> > +  OUT LCD_BPP * CONST Bpp
> > +  )
> > +{
> > +  ASSERT (Bpp != NULL);
> > +  if (ModeNumber >= mMaxMode) {
> > +    // Check valid ModeNumber.
> > +    ASSERT (ModeNumber < mMaxMode);
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  *Bpp = LCD_BITS_PER_PIXEL_24;
> > +
> > +  return EFI_SUCCESS;
> > +}
> > diff --git
> >
> a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> >
> b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> > index
> >
> 1e8f3205312ebf30fa1666130bc944261384359a..f0b482f91a84d91ac9914
> c18b794
> > 1dd32ab8c8a7 100644
> > ---
> a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> > +++
> b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> > @@ -21,9 +21,10 @@
> >  #include <ArmPlatform.h>
> >
> >  #define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet64
> > (PcdArmLcdDdrFrameBufferBase) != 0) ? 1 : 0)
> > +#define DP_BASE_DESCRIPTOR      ((FixedPcdGet64
> (PcdArmMaliDpBase) != 0) ? 1 : 0)
> >
> >  // Number of Virtual Memory Map Descriptors -#define
> > MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 +
> FRAME_BUFFER_DESCRIPTOR)
> > +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 +
> > +FRAME_BUFFER_DESCRIPTOR + DP_BASE_DESCRIPTOR)
> >
> >  // DDR attributes
> >  #define DDR_ATTRIBUTES_CACHED
> ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
> > @@ -158,6 +159,13 @@ ArmPlatformGetVirtualMemoryMap (
> >    VirtualMemoryTable[Index].Attributes =
> > ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
> >  #endif
> >
> > +#if (FixedPcdGet64 (PcdArmMaliDpBase) != 0)
> > +  // DP500/DP550/DP650 peripheral memory region
> > +  VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64
> > +(PcdArmMaliDpBase);
> > +  VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64
> > +(PcdArmMaliDpBase);
> > +  VirtualMemoryTable[Index].Length = FixedPcdGet32
> > +(PcdArmMaliDpMemoryRegionLength);
> > +  VirtualMemoryTable[Index].Attributes =
> > +ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
> > +#endif
> >    // Map sparse memory region if present
> >    if (HasSparseMemory) {
> >      VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
> > --
> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library
  2017-12-23 16:22   ` Ard Biesheuvel
@ 2018-01-09 18:21     ` Evan Lloyd
  2018-01-09 18:26       ` Ard Biesheuvel
  0 siblings, 1 reply; 57+ messages in thread
From: Evan Lloyd @ 2018-01-09 18:21 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Abraham, "ard.biesheuvel@linaro.org"@arm.com,
	"leif.lindholm@linaro.org"@arm.com,
	"Matteo.Carlini@arm.com"@arm.com,
	"nd@arm.com"@arm.com



> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 23 December 2017 16:23
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org; Arvind Chauhan <Arvind.Chauhan@arm.com>;
> Daniil Egranov <Daniil.Egranov@arm.com>; Thomas Abraham
> <thomas.abraham@arm.com>; "ard.biesheuvel@linaro.org"@arm.com;
> "leif.lindholm@linaro.org"@arm.com;
> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
> Subject: Re: [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD
> platform library
>
> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> > From: Girish Pathak <girish.pathak@arm.com>
> >
> > This change adds the HDLCD platform lib for the Juno plaform. This
> > library will be instantiated as a LcdPlatformLib to link with
> > LcdGraphicsOutputDxe for the Juno platform.
> >
> > HDLCD platform library depends on the Arm SCMI DXE driver for
> > communication with the SCP for clock setting. Therefore this change
> > also enables building of Arm SCMI DXE driver for the Juno platform.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Girish Pathak <girish.pathak@arm.com>
>
> Missing signoff?
[[Evan Lloyd]] Yes.  Oops.

>
> > ---
> >  Platform/ARM/JunoPkg/ArmJuno.dec                                 |   8 +
> >  Platform/ARM/JunoPkg/ArmJuno.dsc                                 |  29 +
> >  Platform/ARM/JunoPkg/ArmJuno.fdf                                 |  12 +-
> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf           |   5 +-
> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
> |  40 ++
> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c             |
> 18 +-
> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c      |
> 559 ++++++++++++++++++++
> >  7 files changed, 668 insertions(+), 3 deletions(-)
> >
> > diff --git a/Platform/ARM/JunoPkg/ArmJuno.dec
> > b/Platform/ARM/JunoPkg/ArmJuno.dec
> > index
> >
> b733480c3198d135df16ca024b5e85ff350e11c7..cd6710feb2faf0bd17b5ea
> 39a21d
> > be5406cd4ffd 100644
> > --- a/Platform/ARM/JunoPkg/ArmJuno.dec
> > +++ b/Platform/ARM/JunoPkg/ArmJuno.dec
> > @@ -53,3 +53,11 @@ [PcdsFixedAtBuild.common]
> >
> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase|0x2E000000|UINT64|0
> x00000025
> >
> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize|0x80|UINT32|0x00000
> 026
> >
> > +  # MaxMode must be one number higher than the actual max mode,  #
> > + i.e. for actual maximum mode 2, set the value to 3.
> > +  #
> > +  # Default value zero allows platform to enumerate maximum
> supported mode.
> > +  #
> > +  # For a list of mode numbers look in HdLcdArmJuno.c
> > +
> gArmJunoTokenSpaceGuid.PcdArmHdLcdMaxMode|0|UINT32|0x0000001
> 7
> > +
> > diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc
> > b/Platform/ARM/JunoPkg/ArmJuno.dsc
> > index
> >
> fe860956a4dc497cac52be70bab3657246a08bd0..9027c5b0728a6941f850
> 636b3bc3
> > 15fd33b867fb 100644
> > --- a/Platform/ARM/JunoPkg/ArmJuno.dsc
> > +++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
> > @@ -50,6 +50,11 @@ [LibraryClasses.common]
> >    # SCMI Mailbox Transport Layer
> >    ArmMtl|Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
> >
> > +!ifndef HEADLESS_PLATFORM
>
> Wouldn't it make more sense to add a macro ENABLE_HDLCD, rather than
> inverting the logic?

 [[Evan Lloyd]] We used this to correspond with the ACPI (FADT) terminology, where HEADLESS implies more than just no display (e.g. no keyboard or mouse).
It would be possible to insert another level to define ENABLE_HDLCD, ENABLE_KEYBOARD, and ENABLE_MOUSE when  HEADLESS_PLATFORM is not defined, but I'm not convinced that would improve clarity.
For mobile platforms (Juno, say) the default seems obvious, as a mobile without MMI is pretty pointless (unless you contemplate UEFI on IOT?).  For servers, less so, but the option is still available.  It also seems more natural to explicitly exclude support for hardware that is present, rather than defaulting to a crippled state.


>
> > +
> >
...
> > +  # SCMI Driver
> > +  ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf {
> > +    <LibraryClasses>
> > +
> BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
>
> I take it your trusted SRAM does not tolerate unaligned memcpy() because
> it is mapped as device memory. Couldn't you map it as non-cacheable
> memory instead? (I meant to ask in response to the other patch but I forgot)
>

 [[Evan Lloyd]]  As this is generic code we can't know what the platform SCP interface memory constraints might be, so we've gone for the safest option. (It might be fine for Juno, but future stuff is unknown.)  As far as I can tell, the only advantage of non-cacheable would be to permit unaligned access, which might give a small performance improvement.  My current guess is that the caller's protocol message structures are likely to be properly aligned anyway, so the benefit might be negligible.  The drawback would be that you need to add barriers.
The bottom line is, we'll change it if you see a significant gain, but there is a cost to re-jig and test.

>
> > +  }
> > +
...
> afb2db0050c65b0d1b2b69c9038e168755c152c1..baa5221cb906ed5d0774
> 14475da0
> > 06cf2e5cafc5 100644
> > --- a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
> > +++ b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
> > @@ -21,8 +21,10 @@
> >
...
> >
> > +  // Frame Buffer Memory
> > +#if (FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize) != 0)
>
> Please use a normal if()
[[Evan Lloyd]] Will do
>
...
> > diff --git
> > a/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
> > b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
> > new file mode 100644
> > index
> >
> 0000000000000000000000000000000000000000..72be0a39846fb0a78e
> bcf3248b6c
> > 51377adf4f73
> > --- /dev/null
> > +++
> b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
> > @@ -0,0 +1,559 @@
...
> > +
> > +    ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
> > +      ||  PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
>
> Please fix weird indentation
[[Evan Lloyd]] Will do
>
> > +   return EFI_UNSUPPORTED;
...
> > +
> > +  // Check if memory is already reserved for the frame buffer.
> > +#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)
>
> Please don't use CPP conditionals for control flow
[[Evan Lloyd]] Will do
>
...
> > --
> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library
  2018-01-09 18:21     ` Evan Lloyd
@ 2018-01-09 18:26       ` Ard Biesheuvel
  2018-01-10 11:45         ` Alexei Fedorov
  0 siblings, 1 reply; 57+ messages in thread
From: Ard Biesheuvel @ 2018-01-09 18:26 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: edk2-devel@lists.01.org, Arvind Chauhan, Daniil Egranov,
	Thomas Abraham, ard.biesheuvel@linaro.org@arm.com,
	leif.lindholm@linaro.org@arm.com, Matteo.Carlini@arm.com@arm.com,
	nd@arm.com@arm.com

On 9 January 2018 at 18:21, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
>
>
>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: 23 December 2017 16:23
>> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> Cc: edk2-devel@lists.01.org; Arvind Chauhan <Arvind.Chauhan@arm.com>;
>> Daniil Egranov <Daniil.Egranov@arm.com>; Thomas Abraham
>> <thomas.abraham@arm.com>; "ard.biesheuvel@linaro.org"@arm.com;
>> "leif.lindholm@linaro.org"@arm.com;
>> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
>> Subject: Re: [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD
>> platform library
>>
>> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
>> > From: Girish Pathak <girish.pathak@arm.com>
>> >
>> > This change adds the HDLCD platform lib for the Juno plaform. This
>> > library will be instantiated as a LcdPlatformLib to link with
>> > LcdGraphicsOutputDxe for the Juno platform.
>> >
>> > HDLCD platform library depends on the Arm SCMI DXE driver for
>> > communication with the SCP for clock setting. Therefore this change
>> > also enables building of Arm SCMI DXE driver for the Juno platform.
>> >
>> > Contributed-under: TianoCore Contribution Agreement 1.1
>> > Signed-off-by: Girish Pathak <girish.pathak@arm.com>
>>
>> Missing signoff?
> [[Evan Lloyd]] Yes.  Oops.
>
>>
>> > ---
>> >  Platform/ARM/JunoPkg/ArmJuno.dec                                 |   8 +
>> >  Platform/ARM/JunoPkg/ArmJuno.dsc                                 |  29 +
>> >  Platform/ARM/JunoPkg/ArmJuno.fdf                                 |  12 +-
>> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf           |   5 +-
>> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
>> |  40 ++
>> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c             |
>> 18 +-
>> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c      |
>> 559 ++++++++++++++++++++
>> >  7 files changed, 668 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/Platform/ARM/JunoPkg/ArmJuno.dec
>> > b/Platform/ARM/JunoPkg/ArmJuno.dec
>> > index
>> >
>> b733480c3198d135df16ca024b5e85ff350e11c7..cd6710feb2faf0bd17b5ea
>> 39a21d
>> > be5406cd4ffd 100644
>> > --- a/Platform/ARM/JunoPkg/ArmJuno.dec
>> > +++ b/Platform/ARM/JunoPkg/ArmJuno.dec
>> > @@ -53,3 +53,11 @@ [PcdsFixedAtBuild.common]
>> >
>> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase|0x2E000000|UINT64|0
>> x00000025
>> >
>> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize|0x80|UINT32|0x00000
>> 026
>> >
>> > +  # MaxMode must be one number higher than the actual max mode,  #
>> > + i.e. for actual maximum mode 2, set the value to 3.
>> > +  #
>> > +  # Default value zero allows platform to enumerate maximum
>> supported mode.
>> > +  #
>> > +  # For a list of mode numbers look in HdLcdArmJuno.c
>> > +
>> gArmJunoTokenSpaceGuid.PcdArmHdLcdMaxMode|0|UINT32|0x0000001
>> 7
>> > +
>> > diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > b/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > index
>> >
>> fe860956a4dc497cac52be70bab3657246a08bd0..9027c5b0728a6941f850
>> 636b3bc3
>> > 15fd33b867fb 100644
>> > --- a/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > +++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > @@ -50,6 +50,11 @@ [LibraryClasses.common]
>> >    # SCMI Mailbox Transport Layer
>> >    ArmMtl|Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
>> >
>> > +!ifndef HEADLESS_PLATFORM
>>
>> Wouldn't it make more sense to add a macro ENABLE_HDLCD, rather than
>> inverting the logic?
>
>  [[Evan Lloyd]] We used this to correspond with the ACPI (FADT) terminology, where HEADLESS implies more than just no display (e.g. no keyboard or mouse).
> It would be possible to insert another level to define ENABLE_HDLCD, ENABLE_KEYBOARD, and ENABLE_MOUSE when  HEADLESS_PLATFORM is not defined, but I'm not convinced that would improve clarity.
> For mobile platforms (Juno, say) the default seems obvious, as a mobile without MMI is pretty pointless (unless you contemplate UEFI on IOT?).  For servers, less so, but the option is still available.  It also seems more natural to explicitly exclude support for hardware that is present, rather than defaulting to a crippled state.
>
>

Fair enough.

>>
>> > +
>> >
> ...
>> > +  # SCMI Driver
>> > +  ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf {
>> > +    <LibraryClasses>
>> > +
>> BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
>>
>> I take it your trusted SRAM does not tolerate unaligned memcpy() because
>> it is mapped as device memory. Couldn't you map it as non-cacheable
>> memory instead? (I meant to ask in response to the other patch but I forgot)
>>
>
>  [[Evan Lloyd]]  As this is generic code we can't know what the platform SCP interface memory constraints might be, so we've gone for the safest option. (It might be fine for Juno, but future stuff is unknown.)  As far as I can tell, the only advantage of non-cacheable would be to permit unaligned access, which might give a small performance improvement.  My current guess is that the caller's protocol message structures are likely to be properly aligned anyway, so the benefit might be negligible.  The drawback would be that you need to add barriers.
> The bottom line is, we'll change it if you see a significant gain, but there is a cost to re-jig and test.
>

Well, the fact that you need to override the BaseMemoryLib
implementation is telling. This means the region is treated as memory
in the code, but mapped with device semantics. So this is not about
performance, but about the face that the UEFI spec stipulates that
unaligned access to memory are allowed on AArch64, and so if the
contents of these regions are dereferenced as memory, they should be
mapped as memory. If they are mapped as device, you should only use
MmioRead32/MmioWrite32 accessors. Your call.

>>
>> > +  }
>> > +
> ...
>> afb2db0050c65b0d1b2b69c9038e168755c152c1..baa5221cb906ed5d0774
>> 14475da0
>> > 06cf2e5cafc5 100644
>> > --- a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
>> > +++ b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
>> > @@ -21,8 +21,10 @@
>> >
> ...
>> >
>> > +  // Frame Buffer Memory
>> > +#if (FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize) != 0)
>>
>> Please use a normal if()
> [[Evan Lloyd]] Will do
>>
> ...
>> > diff --git
>> > a/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
>> > b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
>> > new file mode 100644
>> > index
>> >
>> 0000000000000000000000000000000000000000..72be0a39846fb0a78e
>> bcf3248b6c
>> > 51377adf4f73
>> > --- /dev/null
>> > +++
>> b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
>> > @@ -0,0 +1,559 @@
> ...
>> > +
>> > +    ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
>> > +      ||  PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
>>
>> Please fix weird indentation
> [[Evan Lloyd]] Will do
>>
>> > +   return EFI_UNSUPPORTED;
> ...
>> > +
>> > +  // Check if memory is already reserved for the frame buffer.
>> > +#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)
>>
>> Please don't use CPP conditionals for control flow
> [[Evan Lloyd]] Will do
>>
> ...
>> > --
>> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>> >
>
> IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library
  2018-01-09 18:26       ` Ard Biesheuvel
@ 2018-01-10 11:45         ` Alexei Fedorov
  2018-01-10 12:02           ` Ard Biesheuvel
  0 siblings, 1 reply; 57+ messages in thread
From: Alexei Fedorov @ 2018-01-10 11:45 UTC (permalink / raw)
  To: Ard Biesheuvel, Evan Lloyd
  Cc: Matteo.Carlini@arm.com@arm.com, leif.lindholm@linaro.org@arm.com,
	nd@arm.com@arm.com, edk2-devel@lists.01.org, Arvind Chauhan,
	ard.biesheuvel@linaro.org@arm.com, Thomas Abraham

Hi Ard,


You wrote

"Well, the fact that you need to override the BaseMemoryLib
implementation is telling. This means the region is treated as memory
in the code, but mapped with device semantics. So this is not about
performance, but about the face that the UEFI spec stipulates that
unaligned access to memory are allowed on AArch64, and so if the
contents of these regions are dereferenced as memory, they should be
mapped as memory. If they are mapped as device, you should only use
MmioRead32/MmioWrite32 accessors."


In that case could you comment on the following commits:

"The BaseMemoryLib has switch to use BaseMemoryLibOptDxe at OPP, but the flash module is device attributes and have to be alignment accessed. so we change the flash related drivers to use generic BaseMemoryLib which is alignment access. "


Hisilicon/D02: flash related drivers switch to use generic BaseMemoryLib:
https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D02/Pv660D02.dsc?id=e3c520596d9ebdc525f284a9da95f080af815ec9


Hisilicon/D03: flash related drivers switch to use generic BaseMemoryLib:
https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D03/D03.dsc?id=337713801cceb684326bfde22975310ca1bd0cc0


Hisilicon/D05: flash related drivers switch to use generic BaseMemoryLib:
https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D05/D05.dsc?id=0749464022407f11c0c6a46cb8eb293fc74ef236


Alexei.


________________________________
From: edk2-devel <edk2-devel-bounces@lists.01.org> on behalf of Ard Biesheuvel <ard.biesheuvel@linaro.org>
Sent: 09 January 2018 18:26:57
To: Evan Lloyd
Cc: Matteo.Carlini@arm.com@arm.com; leif.lindholm@linaro.org@arm.com; nd@arm.com@arm.com; edk2-devel@lists.01.org; Arvind Chauhan; ard.biesheuvel@linaro.org@arm.com; Thomas Abraham
Subject: Re: [edk2] [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library

On 9 January 2018 at 18:21, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
>
>
>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: 23 December 2017 16:23
>> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> Cc: edk2-devel@lists.01.org; Arvind Chauhan <Arvind.Chauhan@arm.com>;
>> Daniil Egranov <Daniil.Egranov@arm.com>; Thomas Abraham
>> <thomas.abraham@arm.com>; "ard.biesheuvel@linaro.org"@arm.com;
>> "leif.lindholm@linaro.org"@arm.com;
>> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
>> Subject: Re: [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD
>> platform library
>>
>> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
>> > From: Girish Pathak <girish.pathak@arm.com>
>> >
>> > This change adds the HDLCD platform lib for the Juno plaform. This
>> > library will be instantiated as a LcdPlatformLib to link with
>> > LcdGraphicsOutputDxe for the Juno platform.
>> >
>> > HDLCD platform library depends on the Arm SCMI DXE driver for
>> > communication with the SCP for clock setting. Therefore this change
>> > also enables building of Arm SCMI DXE driver for the Juno platform.
>> >
>> > Contributed-under: TianoCore Contribution Agreement 1.1
>> > Signed-off-by: Girish Pathak <girish.pathak@arm.com>
>>
>> Missing signoff?
> [[Evan Lloyd]] Yes.  Oops.
>
>>
>> > ---
>> >  Platform/ARM/JunoPkg/ArmJuno.dec                                 |   8 +
>> >  Platform/ARM/JunoPkg/ArmJuno.dsc                                 |  29 +
>> >  Platform/ARM/JunoPkg/ArmJuno.fdf                                 |  12 +-
>> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoLib.inf           |   5 +-
>> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJunoLib.inf
>> |  40 ++
>> >  Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c             |
>> 18 +-
>> >  Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c      |
>> 559 ++++++++++++++++++++
>> >  7 files changed, 668 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/Platform/ARM/JunoPkg/ArmJuno.dec
>> > b/Platform/ARM/JunoPkg/ArmJuno.dec
>> > index
>> >
>> b733480c3198d135df16ca024b5e85ff350e11c7..cd6710feb2faf0bd17b5ea
>> 39a21d
>> > be5406cd4ffd 100644
>> > --- a/Platform/ARM/JunoPkg/ArmJuno.dec
>> > +++ b/Platform/ARM/JunoPkg/ArmJuno.dec
>> > @@ -53,3 +53,11 @@ [PcdsFixedAtBuild.common]
>> >
>> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxBase|0x2E000000|UINT64|0
>> x00000025
>> >
>> gArmJunoTokenSpaceGuid.PcdArmMtlMailBoxSize|0x80|UINT32|0x00000
>> 026
>> >
>> > +  # MaxMode must be one number higher than the actual max mode,  #
>> > + i.e. for actual maximum mode 2, set the value to 3.
>> > +  #
>> > +  # Default value zero allows platform to enumerate maximum
>> supported mode.
>> > +  #
>> > +  # For a list of mode numbers look in HdLcdArmJuno.c
>> > +
>> gArmJunoTokenSpaceGuid.PcdArmHdLcdMaxMode|0|UINT32|0x0000001
>> 7
>> > +
>> > diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > b/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > index
>> >
>> fe860956a4dc497cac52be70bab3657246a08bd0..9027c5b0728a6941f850
>> 636b3bc3
>> > 15fd33b867fb 100644
>> > --- a/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > +++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
>> > @@ -50,6 +50,11 @@ [LibraryClasses.common]
>> >    # SCMI Mailbox Transport Layer
>> >    ArmMtl|Platform/ARM/JunoPkg/Library/ArmMtl/ArmMtl.inf
>> >
>> > +!ifndef HEADLESS_PLATFORM
>>
>> Wouldn't it make more sense to add a macro ENABLE_HDLCD, rather than
>> inverting the logic?
>
>  [[Evan Lloyd]] We used this to correspond with the ACPI (FADT) terminology, where HEADLESS implies more than just no display (e.g. no keyboard or mouse).
> It would be possible to insert another level to define ENABLE_HDLCD, ENABLE_KEYBOARD, and ENABLE_MOUSE when  HEADLESS_PLATFORM is not defined, but I'm not convinced that would improve clarity.
> For mobile platforms (Juno, say) the default seems obvious, as a mobile without MMI is pretty pointless (unless you contemplate UEFI on IOT?).  For servers, less so, but the option is still available.  It also seems more natural to explicitly exclude support for hardware that is present, rather than defaulting to a crippled state.
>
>

Fair enough.

>>
>> > +
>> >
> ...
>> > +  # SCMI Driver
>> > +  ArmPlatformPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf {
>> > +    <LibraryClasses>
>> > +
>> BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
>>
>> I take it your trusted SRAM does not tolerate unaligned memcpy() because
>> it is mapped as device memory. Couldn't you map it as non-cacheable
>> memory instead? (I meant to ask in response to the other patch but I forgot)
>>
>
>  [[Evan Lloyd]]  As this is generic code we can't know what the platform SCP interface memory constraints might be, so we've gone for the safest option. (It might be fine for Juno, but future stuff is unknown.)  As far as I can tell, the only advantage of non-cacheable would be to permit unaligned access, which might give a small performance improvement.  My current guess is that the caller's protocol message structures are likely to be properly aligned anyway, so the benefit might be negligible.  The drawback would be that you need to add barriers.
> The bottom line is, we'll change it if you see a significant gain, but there is a cost to re-jig and test.
>

Well, the fact that you need to override the BaseMemoryLib
implementation is telling. This means the region is treated as memory
in the code, but mapped with device semantics. So this is not about
performance, but about the face that the UEFI spec stipulates that
unaligned access to memory are allowed on AArch64, and so if the
contents of these regions are dereferenced as memory, they should be
mapped as memory. If they are mapped as device, you should only use
MmioRead32/MmioWrite32 accessors. Your call.

>>
>> > +  }
>> > +
> ...
>> afb2db0050c65b0d1b2b69c9038e168755c152c1..baa5221cb906ed5d0774
>> 14475da0
>> > 06cf2e5cafc5 100644
>> > --- a/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
>> > +++ b/Platform/ARM/JunoPkg/Library/ArmJunoLib/ArmJunoMem.c
>> > @@ -21,8 +21,10 @@
>> >
> ...
>> >
>> > +  // Frame Buffer Memory
>> > +#if (FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize) != 0)
>>
>> Please use a normal if()
> [[Evan Lloyd]] Will do
>>
> ...
>> > diff --git
>> > a/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
>> > b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
>> > new file mode 100644
>> > index
>> >
>> 0000000000000000000000000000000000000000..72be0a39846fb0a78e
>> bcf3248b6c
>> > 51377adf4f73
>> > --- /dev/null
>> > +++
>> b/Platform/ARM/JunoPkg/Library/HdLcdArmJunoLib/HdLcdArmJuno.c
>> > @@ -0,0 +1,559 @@
> ...
>> > +
>> > +    ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
>> > +      ||  PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
>>
>> Please fix weird indentation
> [[Evan Lloyd]] Will do
>>
>> > +   return EFI_UNSUPPORTED;
> ...
>> > +
>> > +  // Check if memory is already reserved for the frame buffer.
>> > +#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)
>>
>> Please don't use CPP conditionals for control flow
> [[Evan Lloyd]] Will do
>>
> ...
>> > --
>> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>> >
>
> IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library
  2018-01-10 11:45         ` Alexei Fedorov
@ 2018-01-10 12:02           ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2018-01-10 12:02 UTC (permalink / raw)
  To: Alexei Fedorov
  Cc: Evan Lloyd, Matteo.Carlini@arm.com@arm.com,
	leif.lindholm@linaro.org@arm.com, nd@arm.com@arm.com,
	edk2-devel@lists.01.org, Arvind Chauhan,
	ard.biesheuvel@linaro.org@arm.com, Thomas Abraham

On 10 January 2018 at 11:45, Alexei Fedorov <Alexei.Fedorov@arm.com> wrote:
> Hi Ard,
>
>
> You wrote
>
> "Well, the fact that you need to override the BaseMemoryLib
> implementation is telling. This means the region is treated as memory
> in the code, but mapped with device semantics. So this is not about
> performance, but about the face that the UEFI spec stipulates that
> unaligned access to memory are allowed on AArch64, and so if the
> contents of these regions are dereferenced as memory, they should be
> mapped as memory. If they are mapped as device, you should only use
> MmioRead32/MmioWrite32 accessors."
>
>
> In that case could you comment on the following commits:
>
> "The BaseMemoryLib has switch to use BaseMemoryLibOptDxe at OPP, but the
> flash module is device attributes and have to be alignment accessed. so we
> change the flash related drivers to use generic BaseMemoryLib which is
> alignment access. "
>
>
> Hisilicon/D02: flash related drivers switch to use generic BaseMemoryLib:
> https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D02/Pv660D02.dsc?id=e3c520596d9ebdc525f284a9da95f080af815ec9
>
>
> Hisilicon/D03: flash related drivers switch to use generic BaseMemoryLib:
> https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D03/D03.dsc?id=337713801cceb684326bfde22975310ca1bd0cc0
>
>
> Hisilicon/D05: flash related drivers switch to use generic BaseMemoryLib:
> https://git.linaro.org/uefi/OpenPlatformPkg.git/commit/Platforms/Hisilicon/D05/D05.dsc?id=0749464022407f11c0c6a46cb8eb293fc74ef236
>

NOR flash can only be mapped as device memory, because it switches
between array mode and command mode, and in the latter mode, we
require device semantics.

Ideally, we should be able to switch between cacheable and device
mappings in this case (because we also switch between modes), but this
is not possible when running under the OS, and VariableRuntimeDxe is a
DXE_RUNTIME_DRIVER type module.

In general, memory should not be mapped with device semantics and vice
versa. NOR flash is arguably a corner case, especially because the
generic variable driver is shared with x86 which doesn't care about
any of this, and so the code is quite sloppy when it comes to
dereferencing pointers that may point outside of memory.


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 15/18] ARM/VExpressPkg: New DP500/DP550/DP650 platform library.
  2018-01-08 18:51     ` Evan Lloyd
@ 2018-01-24 11:27       ` Alexei Fedorov
  2018-01-24 11:34         ` Ard Biesheuvel
  0 siblings, 1 reply; 57+ messages in thread
From: Alexei Fedorov @ 2018-01-24 11:27 UTC (permalink / raw)
  To: Evan Lloyd, Ard Biesheuvel
  Cc: "Matteo.Carlini@arm.com"@arm.com,
	"leif.lindholm@linaro.org"@arm.com,
	"nd@arm.com"@arm.com, edk2-devel@lists.01.org,
	Arvind Chauhan, "ard.biesheuvel@linaro.org"@arm.com,
	Thomas Abraham, Sami Mujawar, Mitch Ishihara

Hi Ard,


You wrote:


> > +  Status = gDS->SetMemorySpaceAttributes (
> > +                  *VramBaseAddress,
> > +                  *VramSize,
> > +                  EFI_MEMORY_WC
>
> Please add EFI_MEMORY_XP here
>


Setting EFI_MEMORY_XP causes assertion because  gDS->SetMemorySpaceAttributes() returns Unsupported in edk2\MdeModulePkg\Core\Dxe\Gcd\Gcd.c  with Status set at line #834:


      if ((Entry->Capabilities & Attributes) != Attributes) {

        //***AF
        DEBUG ((DEBUG_GCD, " @%d EFI_UNSUPPORTED: Capabilitie=0x%lX Attributes=0x%lX\n",
                __LINE__, Entry->Capabilities, Attributes));

        Status = EFI_UNSUPPORTED;
        goto Done;
      }

because Entry->Capabilities don't have EFI_MEMORY_XP set, see debug output below:


===================

 Framebuffer @0xF98A4000 0x4000000
GCD:SetMemorySpaceAttributes(Base=00000000F98A4000,Length=0000000004000000)
  Attributes  = 0000000000004002
 @834 EFI_UNSUPPORTED: Capabilities=0x800000000000000E Attributes=0x4002
  Status = Unsupported
GCDMemType Range                             Capabilities     Attributes
========== ================================= ================ ================
NonExist   0000000000000000-0000000007FFFFFF 0000000000000000 0000000000000000
MMIO       0000000008000000-000000000BFFFFFF C000000000000001 8000000000000001
NonExist   000000000C000000-000000001C16FFFF 0000000000000000 0000000000000000
MMIO       000000001C170000-000000001C170FFF C000000000000001 8000000000000001
NonExist   000000001C171000-000000004FFFFFFF 0000000000000000 0000000000000000
MMIO       0000000050000000-00000000501FFFFF C000000000000001 0000000000000001*
MMIO       0000000050200000-0000000057FFFFFF C000000000000001 0000000000000001
NonExist   0000000058000000-000000007FFFFFFF 0000000000000000 0000000000000000
SystemMem  0000000080000000-00000000FEFFFFFF 800000000000000E 0000000000000008*
NonExist   00000000FF000000-000000087FFFFFFF 0000000000000000 0000000000000000
SystemMem  0000000880000000-00000009FFFFFFFF 800000000000000E 0000000000000008*
NonExist   0000000A00000000-0000003FFFFFFFFF 0000000000000000 0000000000000000
MMIO       0000004000000000-00000040000FFFFF C000000000000001 0000000000000001*
MMIO       0000004000100000-00000040FFFFFFFF C000000000000001 0000000000000001
NonExist   0000004100000000-0000FFFFFFFFFFFF 0000000000000000 0000000000000000

ASSERT_EFI_ERROR (Status = Unsupported)
ASSERT [HdLcdGraphicsDxe] n:\edk2\ArmPlatformPkg\ArmJunoPkg\Library\HdLcdArmJunoLib\HdLcdArmJuno.c(254): !EFI_ERROR (Status)
===============

If  gDS->SetMemorySpaceAttributes() call is replaced with Cpu->SetMemoryAttributes(), attributes are set successfully with eXecute bit for frame buffer being cleared.


Alexei.

________________________________
From: edk2-devel <edk2-devel-bounces@lists.01.org> on behalf of Evan Lloyd <Evan.Lloyd@arm.com>
Sent: 08 January 2018 18:51:12
To: Ard Biesheuvel
Cc: "Matteo.Carlini@arm.com"@arm.com; "leif.lindholm@linaro.org"@arm.com; "nd@arm.com"@arm.com; edk2-devel@lists.01.org; Arvind Chauhan; "ard.biesheuvel@linaro.org"@arm.com; Thomas Abraham
Subject: Re: [edk2] [PATCH edk2-platforms v2 15/18] ARM/VExpressPkg: New DP500/DP550/DP650 platform library.



> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 23 December 2017 16:07
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org; Arvind Chauhan <Arvind.Chauhan@arm.com>;
> Daniil Egranov <Daniil.Egranov@arm.com>; Thomas Abraham
> <thomas.abraham@arm.com>; "ard.biesheuvel@linaro.org"@arm.com;
> "leif.lindholm@linaro.org"@arm.com;
> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
> Subject: Re: [PATCH edk2-platforms v2 15/18] ARM/VExpressPkg: New
> DP500/DP550/DP650 platform library.
>
> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> > From: Girish Pathak <girish.pathak at arm.com>
> >
...
> > +
> > +/* Internal helper function to allocate memory if memory is not
> > +already
> > +  reserved for framebuffer
> > +
> > +  @param[in]  VramSize          Requested framebuffer size in bytes.
> > +  @param[out] VramBaseAddress   Pointer to memory allocated for
> framebuffer.
> > +
> > +  @retval EFI_SUCCESS           Framebuffer memory allocated successfully.
> > +  @retval EFI_UNSUPPORTED       Allocated address wider than 40 bits.
> > +  @retval !EFI_SUCCESS          Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +GetVram (
> > +  IN  UINTN                 CONST  VramSize,
> > +  OUT EFI_PHYSICAL_ADDRESS *CONST  VramBaseAddress
> > +  )
> > +{
> > +  EFI_STATUS Status;
> > +
> > +  // Check if memory is already reserved for the framebuffer.
> > +#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)
> > +
>
> Please don't use CPP conditionals for control flow
>
> > +#if (!DP_VALID_BASE_ADDR (FixedPcdGet64
> > +(PcdArmLcdDdrFrameBufferBase))) #error ARM Mali DP framebuffer
> base address cannot be wider than 40 bits.
> > +#else
> > +  *VramBaseAddress =
> > +    (EFI_PHYSICAL_ADDRESS)FixedPcdGet64
> > +(PcdArmLcdDdrFrameBufferBase);
> > +
> > +  Status = EFI_SUCCESS;
> > +#endif
> > +
> > +#else
> > +  // If not already reserved, attempt to allocate the VRAM from the
> DRAM.
> > +  Status = gBS->AllocatePages (
> > +                  AllocateAnyPages,
> > +                  EfiBootServicesData,
> > +                  EFI_SIZE_TO_PAGES (*VramSize),
> > +                  VramBaseAddress
> > +                  );
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "ArmMaliDpLib: Failed to allocate
> framebuffer.\n"));
> > +    ASSERT (FALSE);
> > +    return Status;
> > +  }
> > +
> > +  // ARM Mali DP framebuffer base address can not be wider than 40 bits.
> > +  if (!DP_VALID_BASE_ADDR (*VramBaseAddress)) {
> > +    gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> (*VramSize));
> > +    ASSERT (DP_VALID_BASE_ADDR (*VramBaseAddress));
> > +    return EFI_UNSUPPORTED;
> > +  }
> > +
> > +  // Mark the VRAM as write-combining. The VRAM is inside the DRAM,
> > + which is  // cacheable, for ARM/AArch64 EFI_MEMORY_WC memory is
> actually uncached.
> > +  Status = gDS->SetMemorySpaceAttributes (
> > +                  *VramBaseAddress,
> > +                  *VramSize,
> > +                  EFI_MEMORY_WC
>
> Please add EFI_MEMORY_XP here
>

 [[Evan Lloyd]] We can do that, happily.  However, in looking at this we found that the UEFI spec has in "2.3.6 AArch64 Platforms", section "2.3.6.1 Memory types":
EFI_MEMORY_XP, ...                                                                             Not used or defined

Does that suggest we need a minor spec update?

> > +                  );
> > +  if (EFI_ERROR (Status)) {
> > +    ASSERT (FALSE);
> > +    gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> (*VramSize));
> > +  }
> > +#endif
> > +
> > +  return Status;
> > +}
> > +
> > +/** Allocate VRAM memory in DRAM for the framebuffer
> > +  (unless it is reserved already).
> > +
> > +  The allocated address can be used to set the framebuffer as a base
> > + buffer  address for any layer of the ARM Mali DP.
> > +
> > +  @param[out] VramBaseAddress     A pointer to the framebuffer
> address.
> > +  @param[out] VramSize            A pointer to the size of the frame
> > +                                  buffer in bytes
> > +
> > +  @retval EFI_SUCCESS             Frame buffer memory allocation success.
> > +  @retval EFI_UNSUPPORTED         Allocated address wider than 40 bits
> > +  @retval !EFI_SUCCESS            Other errors.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformGetVram (
> > +  OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> > +  OUT UINTN                * CONST VramSize
> > +  )
> > +{
> > +  ASSERT (VramBaseAddress != NULL);
> > +  ASSERT (VramSize != NULL);
> > +
> > +  // Set the VRAM size.
> > +  *VramSize = (UINTN)FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
> > +
> > +  return GetVram (*VramSize, VramBaseAddress); }
> > +
> > +/** Return total number of modes supported.
> > +
> > +  Note: Valid mode numbers are 0 to MaxMode - 1  See Section 12.9 of
> > + the UEFI Specification 2.7
> > +
> > +  @retval UINT32             Mode Number.
> > +**/
> > +UINT32
> > +LcdPlatformGetMaxMode (VOID)
> > +{
> > +  return  mMaxMode;
> > +}
> > +
> > +/** Set the requested display mode.
> > +
> > +  @param[in] ModeNumber            Mode Number.
> > +
> > +  @retval EFI_SUCCESS              Mode set successful.
> > +  @retval EFI_INVALID_PARAMETER    Requested mode not found.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformSetMode (
> > +  IN CONST UINT32 ModeNumber
> > +  )
> > +{
> > +
> > +  if (ModeNumber >= mMaxMode) {
> > +    ASSERT (ModeNumber < mMaxMode);
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  // On models, platform specific clock/mux settings are not required.
> > +  // Display controller specific settings for Mali DP are done in
> LcdSetMode.
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +/** Return information for the requested mode number.
> > +
> > +  @param[in]  ModeNumber          Mode Number.
> > +  @param[out] Info                Pointer for returned mode information
> > +                                  (on success).
> > +
> > +  @retval EFI_SUCCESS             Display mode information of the
> requested
> > +                                  mode returned successfully.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformQueryMode (
> > +  IN  CONST UINT32                                 ModeNumber,
> > +  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> > +  )
> > +{
> > +  ASSERT (ModeNumber < mMaxMode);
> > +  ASSERT (Info != NULL);
> > +
> > +  Info->Version = 0;
> > +  Info->HorizontalResolution =
> > + mDisplayModes[ModeNumber].Horizontal.Resolution;
> > +  Info->VerticalResolution =
> > + mDisplayModes[ModeNumber].Vertical.Resolution;
> > +  Info->PixelsPerScanLine =
> > + mDisplayModes[ModeNumber].Horizontal.Resolution;
> > +
> > +  Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +/** Return the display timing information for the requested mode
> number.
> > +
> > +  @param[in]  ModeNumber         Mode Number.
> > +
> > +  @param[out] Horizontal         Pointer to horizontal timing parameters.
> > +                                 (Resolution, Sync, Back porch, Front porch)
> > +  @param[out] Vertical           Pointer to vertical timing parameters.
> > +                                 (Resolution, Sync, Back porch, Front
> > + porch)
> > +
> > +  @retval EFI_SUCCESS             Display timing information of the
> requested
> > +                                  mode returned successfully.
> > +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformGetTimings (
> > +  IN  UINT32                ModeNumber,
> > +  OUT CONST SCAN_TIMINGS ** Horizontal,
> > +  OUT CONST SCAN_TIMINGS ** Vertical
> > +  )
> > +{
> > +  ASSERT (Horizontal != NULL);
> > +  ASSERT (Vertical != NULL);
> > +
> > +  if (ModeNumber >= mMaxMode) {
> > +    ASSERT (ModeNumber < mMaxMode);
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
> > +  *Vertical = &mDisplayModes[ModeNumber].Vertical;
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +/** Return bits per pixel information for a mode number.
> > +
> > +  @param[in]  ModeNumber          Mode Number.
> > +  @param[out] Bpp                 Pointer to value Bytes Per Pixel.
> > +
> > +  @retval EFI_SUCCESS             Bits per pixel information of the display
> > +                                  mode returned successfully.
> > +  @retval EFI_INVALID_PARAMETER   Requested mode not found.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformGetBpp (
> > +  IN  CONST UINT32    ModeNumber,
> > +  OUT LCD_BPP * CONST Bpp
> > +  )
> > +{
> > +  ASSERT (Bpp != NULL);
> > +  if (ModeNumber >= mMaxMode) {
> > +    // Check valid ModeNumber.
> > +    ASSERT (ModeNumber < mMaxMode);
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  *Bpp = LCD_BITS_PER_PIXEL_24;
> > +
> > +  return EFI_SUCCESS;
> > +}
> > diff --git
> >
> a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> >
> b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> > index
> >
> 1e8f3205312ebf30fa1666130bc944261384359a..f0b482f91a84d91ac9914
> c18b794
> > 1dd32ab8c8a7 100644
> > ---
> a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> > +++
> b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> > @@ -21,9 +21,10 @@
> >  #include <ArmPlatform.h>
> >
> >  #define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet64
> > (PcdArmLcdDdrFrameBufferBase) != 0) ? 1 : 0)
> > +#define DP_BASE_DESCRIPTOR      ((FixedPcdGet64
> (PcdArmMaliDpBase) != 0) ? 1 : 0)
> >
> >  // Number of Virtual Memory Map Descriptors -#define
> > MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 +
> FRAME_BUFFER_DESCRIPTOR)
> > +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 +
> > +FRAME_BUFFER_DESCRIPTOR + DP_BASE_DESCRIPTOR)
> >
> >  // DDR attributes
> >  #define DDR_ATTRIBUTES_CACHED
> ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
> > @@ -158,6 +159,13 @@ ArmPlatformGetVirtualMemoryMap (
> >    VirtualMemoryTable[Index].Attributes =
> > ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
> >  #endif
> >
> > +#if (FixedPcdGet64 (PcdArmMaliDpBase) != 0)
> > +  // DP500/DP550/DP650 peripheral memory region
> > +  VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64
> > +(PcdArmMaliDpBase);
> > +  VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64
> > +(PcdArmMaliDpBase);
> > +  VirtualMemoryTable[Index].Length = FixedPcdGet32
> > +(PcdArmMaliDpMemoryRegionLength);
> > +  VirtualMemoryTable[Index].Attributes =
> > +ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
> > +#endif
> >    // Map sparse memory region if present
> >    if (HasSparseMemory) {
> >      VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
> > --
> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 15/18] ARM/VExpressPkg: New DP500/DP550/DP650 platform library.
  2018-01-24 11:27       ` Alexei Fedorov
@ 2018-01-24 11:34         ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2018-01-24 11:34 UTC (permalink / raw)
  To: Alexei Fedorov
  Cc: Evan Lloyd, Matteo.Carlini@arm.com@arm.com,
	leif.lindholm@linaro.org@arm.com, nd@arm.com@arm.com,
	edk2-devel@lists.01.org, Arvind Chauhan,
	ard.biesheuvel@linaro.org@arm.com, Thomas Abraham, Sami Mujawar,
	Mitch Ishihara

On 24 January 2018 at 11:27, Alexei Fedorov <Alexei.Fedorov@arm.com> wrote:
> Hi Ard,
>
>
> You wrote:
>
>
>> > +  Status = gDS->SetMemorySpaceAttributes (
>> > +                  *VramBaseAddress,
>> > +                  *VramSize,
>> > +                  EFI_MEMORY_WC
>>
>> Please add EFI_MEMORY_XP here
>>
>
>
> Setting EFI_MEMORY_XP causes assertion because
> gDS->SetMemorySpaceAttributes() returns Unsupported in
> edk2\MdeModulePkg\Core\Dxe\Gcd\Gcd.c  with Status set at line #834:
>
>
>       if ((Entry->Capabilities & Attributes) != Attributes) {
>
>         //***AF
>         DEBUG ((DEBUG_GCD, " @%d EFI_UNSUPPORTED: Capabilitie=0x%lX
> Attributes=0x%lX\n",
>                 __LINE__, Entry->Capabilities, Attributes));
>
>         Status = EFI_UNSUPPORTED;
>         goto Done;
>       }
>
> because Entry->Capabilities don't have EFI_MEMORY_XP set, see debug output
> below:
>

<snip>

> If  gDS->SetMemorySpaceAttributes() call is replaced with
> Cpu->SetMemoryAttributes(), attributes are set successfully with eXecute bit
> for frame buffer being cleared.
>

Ugh. The GCD map conflates capabilities of the region (i.e., this
region can be configured as read-only by the MMU) with permissions
(i.e., the contents of this region should not be modified by the
program), which is why nobody bothers to set these attributes for the
GCD region. If you do set those bits in the GCD map, all allocations
carved out of it will be read-only and non-executable (because, hey,
why would you allocate writable or executable memory from a region
that can be configured as read-only or non-executable?).

In any case, your solution is the correct one: use the arch CPU
protocol directly instead (although there is something  in the PI spec
that bans it). Having an executable frame buffer is a much bigger deal
IMHO, especially when all other allocations are being locked down, and
so my preference is to switch to the arch CPU protocol here.

Thanks,
Ard.


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS
  2018-01-04 19:54           ` Ard Biesheuvel
@ 2018-02-28 20:27             ` Evan Lloyd
  2018-03-02 19:07               ` Ard Biesheuvel
  0 siblings, 1 reply; 57+ messages in thread
From: Evan Lloyd @ 2018-02-28 20:27 UTC (permalink / raw)
  To: Ard Biesheuvel, leif.lindholm@linaro.org
  Cc: Girish Pathak, Matteo Carlini, nd, edk2-devel@lists.01.org

Hi Leif, Ard.
Can I get you two argue out the pros and cons of the "ASSERT(FALSE)" debate, please.
(see https://lists.01.org/pipermail/edk2-devel/2018-January/019788.html)
For what it is worth, our (surprisingly unanimous) opinion is that, since the ASSERT is only there to help spot a problem, then the more information reported the better.  The only benefits of ASSERT(FALSE) would be a smaller debug image and minor efficiency improvement on the path to the crash.

Regards,
Evan

> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 04 January 2018 19:55
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: Girish Pathak <Girish.Pathak@arm.com>; Matteo Carlini
> <Matteo.Carlini@arm.com>; nd <nd@arm.com>; edk2-devel@lists.01.org;
> Thomas Abraham <thomas.abraham@arm.com>; Arvind Chauhan
> <Arvind.Chauhan@arm.com>; leif.lindholm@linaro.org
> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg:
> Add and update debug ASSERTS
> 
> On 4 January 2018 at 19:51, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> >
> >
> >> -----Original Message-----
> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> >> Sent: 04 January 2018 19:24
> >> To: Girish Pathak <Girish.Pathak@arm.com>
> >> Cc: Evan Lloyd <Evan.Lloyd@arm.com>; Matteo Carlini
> >> <Matteo.Carlini@arm.com>; nd <nd@arm.com>; edk2-
> devel@lists.01.org;
> >> Thomas Abraham <thomas.abraham@arm.com>; Arvind Chauhan
> >> <Arvind.Chauhan@arm.com>; leif.lindholm@linaro.org
> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg:
> >> Add and update debug ASSERTS
> >>
> >> On 4 January 2018 at 18:55, Girish Pathak <Girish.Pathak@arm.com>
> >> wrote:
> >> > Hi Ard,
> >> >
> >> >> -----Original Message-----
> >> >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On
> >> >> Behalf Of Ard Biesheuvel
> >> >> Sent: 23 December 2017 14:12
> >> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
> >> >> Cc: "Matteo.Carlini@arm.com"@arm.com;
> >> >> "leif.lindholm@linaro.org"@arm.com; "nd@arm.com"@arm.com;
> edk2-
> >> >> devel@lists.01.org; Thomas Abraham <thomas.abraham@arm.com>;
> >> Arvind
> >> >> Chauhan <Arvind.Chauhan@arm.com>;
> >> "ard.biesheuvel@linaro.org"@arm.com
> >> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18]
> ARM/VExpressPkg:
> >> >> Add and update debug ASSERTS
> >> >>
> >> >> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> >> >> > From: Girish Pathak <girish.pathak at arm.com>
> >> >> >
> >> >> > This change adds some debug assertions e.g to catch NULL pointer
> >> >> > errors missing in PL11Lcd and HdLcd platform libraries.
> >> >> >
> >> >> > Contributed-under: TianoCore Contribution Agreement 1.1
> >> >> > Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> >> >> > Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
> >> >> > ---
> >> >> >
> >> >>
> >>
> Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExp
> >> r
> >> >> ess.c       | 22 +++++++++++++++++-
> >> >> >
> >> >> >
> >> >>
> >>
> Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
> >> m
> >> >> VEx
> >> >> > press.c | 24 +++++++++++++++++++-
> >> >> >  2 files changed, 44 insertions(+), 2 deletions(-)
> >> >> >
> >> >> > diff --git
> >> >> >
> >> >>
> >>
> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
> >> x
> >> >> pres
> >> >> > s.c
> >> >> >
> >> >>
> >>
> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
> >> x
> >> >> pres
> >> >> > s.c index
> >> >> >
> >> >>
> >>
> 6afd764897f49c64490ce891682f99bb0f5d993b..a8fe8696da0653017ce9fa
> >> 6e4a
> >> >> 86
> >> >> > caf283bc04c9 100644
> >> >> > ---
> >> >> >
> >> >>
> >>
> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
> >> x
> >> >> pres
> >> >> > s.c
> >> >> > +++
> >> >>
> >>
> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
> >> x
> >> >> > +++ press.c
> >> >> > @@ -153,6 +153,9 @@ LcdPlatformGetVram (
> >> >> >    EFI_STATUS              Status;
> >> >> >    EFI_ALLOCATE_TYPE       AllocationType;
> >> >> >
> >> >> > +  ASSERT (VramBaseAddress != NULL);  ASSERT (VramSize != NULL);
> >> >> > +
> >> >> >    // Set the vram size
> >> >> >    *VramSize = LCD_VRAM_SIZE;
> >> >> >
> >> >> > @@ -171,6 +174,7 @@ LcdPlatformGetVram (
> >> >> >                    VramBaseAddress
> >> >> >                    );
> >> >> >    if (EFI_ERROR (Status)) {
> >> >> > +    ASSERT (FALSE);
> >> >> >      return Status;
> >> >> >    }
> >> >> >
> >> >> > @@ -181,8 +185,8 @@ LcdPlatformGetVram (
> >> >> >                    *VramSize,
> >> >> >                    EFI_MEMORY_WC
> >> >> >                    );
> >> >> > -  ASSERT_EFI_ERROR (Status);
> >> >> >    if (EFI_ERROR (Status)) {
> >> >> > +    ASSERT (FALSE);
> >> >>
> >> >> As in the sibling patch against EDK2, this patch makes it more
> >> >> difficult to figure out what went wrong when you hit the ASSERT.
> >> >> ASSERT_EFI_ERROR prints the value of Status, ASSERT(FALSE) only
> >> >> prints
> >> >> '0 != 1'
> >> >>
> >> >
> >> > This change(and other similar changes) is in response to review
> >> > comments on patch v1
> >> > https://lists.01.org/pipermail/edk2-devel/2017-October/015995.html
> >> >
> >> > with above reference, Can you please confirm if we should revert to
> >> > the
> >> patch v1 version ?
> >> >
> >>
> >> I guess Leif and I are in disagreement here. In particular, I think
> >> his comment
> >>
> >> """
> >> ASSERT (FALSE)?  (You already know Status is an EFI_ERROR, and a
> >> console message saying ASSERT (Status) is not getting you out of
> >> looking at the source code to find out what happened.) """
> >>
> >> is misguided, given that ASSERT_EFI_ERROR (Status) will actually
> >> print the value of Status to the debug console.
> >>
> >> However, the objections against putting function calls in ASSERT()s
> >> are
> >> justified: ASSERT() should not have side effects if its condition is
> >> met, and function calls may have side effects.
> >>
> >> I suppose we should wait for Leif to return on the 22nd before
> >> proceeding with the review.
> >> Apologies for the confusion, and for the delay.
> >
> >  [[Evan Lloyd]] An alternative might be for Girish to take the other route
> Leif suggested, and cache the condition in a variable.
> > That might be a slight overhead, and the (presumably BOOLEAN) variable
> may need careful naming, but...
> >
> 
> If we are going to use a boolean to record the result of the comparison, and
> ASSERT() on it in the if () block if the comparison is false, I don't see what
> the difference is with doing ASSERT (FALSE) directly.
> 
> 
> >>
> >>
> >>
> >> >> >      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> >> (*VramSize));
> >> >> >      return Status;
> >> >> >    }
> >> >> > @@ -221,6 +225,7 @@ LcdPlatformSetMode (
> >> >> >    EFI_STATUS            Status;
> >> >> >
> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> > +    ASSERT (FALSE);
> >> >>
> >> >> These are fine: the code itself explains adequately which
> >> >> condition triggered the ASSERT to fire.
> >> >>
> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >    }
> >> >> >
> >> >> > @@ -279,7 +284,10 @@ LcdPlatformQueryMode (
> >> >> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST
> Info
> >> >> >    )
> >> >> >  {
> >> >> > +  ASSERT (Info != NULL);
> >> >> > +
> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> > +    ASSERT (FALSE);
> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >    }
> >> >> >
> >> >> > @@ -343,7 +351,18 @@ LcdPlatformGetTimings (
> >> >> >    OUT UINT32 * CONST                            VFrontPorch
> >> >> >    )
> >> >> >  {
> >> >> > +  // One of the pointers is NULL  ASSERT (HRes != NULL);
> >> >> > + ASSERT (HSync != NULL);  ASSERT (HBackPorch != NULL);  ASSERT
> >> >> > + (HFrontPorch != NULL);  ASSERT (VRes != NULL);  ASSERT (VSync
> >> >> > + != NULL);  ASSERT (VBackPorch != NULL);  ASSERT (VFrontPorch
> >> >> > + != NULL);
> >> >> > +
> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> > +    ASSERT (FALSE);
> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >    }
> >> >> >
> >> >> > @@ -376,6 +395,7 @@ LcdPlatformGetBpp (
> >> >> >    )
> >> >> >  {
> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> > +    ASSERT (FALSE);
> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >    }
> >> >> >
> >> >> > diff --git
> >> >> >
> >> >>
> >>
> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
> >> Ar
> >> >> mV
> >> >> > Express.c
> >> >> >
> >> >>
> >>
> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
> >> Ar
> >> >> mV
> >> >> > Express.c index
> >> >> >
> >> >>
> >>
> 799fb3fc781ce04bb64cb1fa0b87f262a670ed78..fd4eea8f8e2397bc7d4ddf
> >> 4cfe
> >> >> 3d
> >> >> > cc97a5109edb 100644
> >> >> > ---
> >> >> >
> >> >>
> >>
> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
> >> Ar
> >> >> mV
> >> >> > Express.c
> >> >> > +++
> >> >>
> >>
> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
> >> >> > +++ ArmVExpress.c
> >> >> > @@ -205,6 +205,9 @@ LcdPlatformGetVram (
> >> >> >
> >> >> >    Status = EFI_SUCCESS;
> >> >> >
> >> >> > +  ASSERT (VramBaseAddress != NULL);  ASSERT (VramSize != NULL);
> >> >> > +
> >> >> >    // Is it on the motherboard or on the daughterboard?
> >> >> >    switch (PL111_CLCD_SITE) {
> >> >> >
> >> >> > @@ -225,6 +228,7 @@ LcdPlatformGetVram (
> >> >> >                      VramBaseAddress
> >> >> >                      );
> >> >> >      if (EFI_ERROR (Status)) {
> >> >> > +      ASSERT (FALSE);
> >> >> >        return Status;
> >> >> >      }
> >> >> >
> >> >> > @@ -235,8 +239,8 @@ LcdPlatformGetVram (
> >> >> >                      *VramSize,
> >> >> >                      EFI_MEMORY_WC
> >> >> >                      );
> >> >> > -    ASSERT_EFI_ERROR (Status);
> >> >> >      if (EFI_ERROR (Status)) {
> >> >> > +      ASSERT (FALSE);
> >> >> >        gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> >> >> (*VramSize));
> >> >> >        return Status;
> >> >> >      }
> >> >> > @@ -294,6 +298,7 @@ LcdPlatformSetMode (
> >> >> >    UINT32                SysId;
> >> >> >
> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> > +    ASSERT (FALSE);
> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >    }
> >> >> >
> >> >> > @@ -369,7 +374,10 @@ LcdPlatformQueryMode (
> >> >> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> >> >> >    )
> >> >> >  {
> >> >> > +  ASSERT (Info != NULL);
> >> >> > +
> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> > +    ASSERT (FALSE);
> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >    }
> >> >> >
> >> >> > @@ -433,7 +441,18 @@ LcdPlatformGetTimings (
> >> >> >    OUT UINT32 * CONST                      VFrontPorch
> >> >> >    )
> >> >> >  {
> >> >> > +  // One of the pointers is NULL  ASSERT (HRes != NULL);
> >> >> > + ASSERT (HSync != NULL);  ASSERT (HBackPorch != NULL);  ASSERT
> >> >> > + (HFrontPorch != NULL);  ASSERT (VRes != NULL);  ASSERT (VSync
> >> >> > + != NULL);  ASSERT (VBackPorch != NULL);  ASSERT (VFrontPorch
> >> >> > + != NULL);
> >> >> > +
> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> > +    ASSERT (FALSE);
> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >    }
> >> >> >
> >> >> > @@ -465,7 +484,10 @@ LcdPlatformGetBpp (
> >> >> >    OUT LCD_BPP * CONST                     Bpp
> >> >> >    )
> >> >> >  {
> >> >> > +  ASSERT (Bpp != NULL);
> >> >> > +
> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> > +    ASSERT (FALSE);
> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >    }
> >> >> >
> >> >> > --
> >> >> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >> >> >
> >> >> > _______________________________________________
> >> >> > edk2-devel mailing list
> >> >> > edk2-devel@lists.01.org
> >> >> > https://lists.01.org/mailman/listinfo/edk2-devel
> >> >> _______________________________________________
> >> >> edk2-devel mailing list
> >> >> edk2-devel@lists.01.org
> >> >> https://lists.01.org/mailman/listinfo/edk2-devel

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS
  2018-02-28 20:27             ` Evan Lloyd
@ 2018-03-02 19:07               ` Ard Biesheuvel
  2018-03-05 15:08                 ` Evan Lloyd
  0 siblings, 1 reply; 57+ messages in thread
From: Ard Biesheuvel @ 2018-03-02 19:07 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: leif.lindholm@linaro.org, Girish Pathak, Matteo Carlini, nd,
	edk2-devel@lists.01.org

On 28 February 2018 at 20:27, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> Hi Leif, Ard.
> Can I get you two argue out the pros and cons of the "ASSERT(FALSE)" debate, please.

I can argue the cons if you like. For the pros, you'll have to wait
for Leif to return from holiday (in a week or two AFAIK)

> (see https://lists.01.org/pipermail/edk2-devel/2018-January/019788.html)
> For what it is worth, our (surprisingly unanimous) opinion is that, since the ASSERT is only there to help spot a problem, then the more information reported the better.  The only benefits of ASSERT(FALSE) would be a smaller debug image and minor efficiency improvement on the path to the crash.
>
> Regards,
> Evan
>
>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: 04 January 2018 19:55
>> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> Cc: Girish Pathak <Girish.Pathak@arm.com>; Matteo Carlini
>> <Matteo.Carlini@arm.com>; nd <nd@arm.com>; edk2-devel@lists.01.org;
>> Thomas Abraham <thomas.abraham@arm.com>; Arvind Chauhan
>> <Arvind.Chauhan@arm.com>; leif.lindholm@linaro.org
>> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg:
>> Add and update debug ASSERTS
>>
>> On 4 January 2018 at 19:51, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
>> >
>> >
>> >> -----Original Message-----
>> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> >> Sent: 04 January 2018 19:24
>> >> To: Girish Pathak <Girish.Pathak@arm.com>
>> >> Cc: Evan Lloyd <Evan.Lloyd@arm.com>; Matteo Carlini
>> >> <Matteo.Carlini@arm.com>; nd <nd@arm.com>; edk2-
>> devel@lists.01.org;
>> >> Thomas Abraham <thomas.abraham@arm.com>; Arvind Chauhan
>> >> <Arvind.Chauhan@arm.com>; leif.lindholm@linaro.org
>> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg:
>> >> Add and update debug ASSERTS
>> >>
>> >> On 4 January 2018 at 18:55, Girish Pathak <Girish.Pathak@arm.com>
>> >> wrote:
>> >> > Hi Ard,
>> >> >
>> >> >> -----Original Message-----
>> >> >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On
>> >> >> Behalf Of Ard Biesheuvel
>> >> >> Sent: 23 December 2017 14:12
>> >> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> >> >> Cc: "Matteo.Carlini@arm.com"@arm.com;
>> >> >> "leif.lindholm@linaro.org"@arm.com; "nd@arm.com"@arm.com;
>> edk2-
>> >> >> devel@lists.01.org; Thomas Abraham <thomas.abraham@arm.com>;
>> >> Arvind
>> >> >> Chauhan <Arvind.Chauhan@arm.com>;
>> >> "ard.biesheuvel@linaro.org"@arm.com
>> >> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18]
>> ARM/VExpressPkg:
>> >> >> Add and update debug ASSERTS
>> >> >>
>> >> >> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
>> >> >> > From: Girish Pathak <girish.pathak at arm.com>
>> >> >> >
>> >> >> > This change adds some debug assertions e.g to catch NULL pointer
>> >> >> > errors missing in PL11Lcd and HdLcd platform libraries.
>> >> >> >
>> >> >> > Contributed-under: TianoCore Contribution Agreement 1.1
>> >> >> > Signed-off-by: Girish Pathak <girish.pathak@arm.com>
>> >> >> > Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
>> >> >> > ---
>> >> >> >
>> >> >>
>> >>
>> Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExp
>> >> r
>> >> >> ess.c       | 22 +++++++++++++++++-
>> >> >> >
>> >> >> >
>> >> >>
>> >>
>> Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
>> >> m
>> >> >> VEx
>> >> >> > press.c | 24 +++++++++++++++++++-
>> >> >> >  2 files changed, 44 insertions(+), 2 deletions(-)
>> >> >> >
>> >> >> > diff --git
>> >> >> >
>> >> >>
>> >>
>> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
>> >> x
>> >> >> pres
>> >> >> > s.c
>> >> >> >
>> >> >>
>> >>
>> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
>> >> x
>> >> >> pres
>> >> >> > s.c index
>> >> >> >
>> >> >>
>> >>
>> 6afd764897f49c64490ce891682f99bb0f5d993b..a8fe8696da0653017ce9fa
>> >> 6e4a
>> >> >> 86
>> >> >> > caf283bc04c9 100644
>> >> >> > ---
>> >> >> >
>> >> >>
>> >>
>> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
>> >> x
>> >> >> pres
>> >> >> > s.c
>> >> >> > +++
>> >> >>
>> >>
>> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
>> >> x
>> >> >> > +++ press.c
>> >> >> > @@ -153,6 +153,9 @@ LcdPlatformGetVram (
>> >> >> >    EFI_STATUS              Status;
>> >> >> >    EFI_ALLOCATE_TYPE       AllocationType;
>> >> >> >
>> >> >> > +  ASSERT (VramBaseAddress != NULL);  ASSERT (VramSize != NULL);
>> >> >> > +
>> >> >> >    // Set the vram size
>> >> >> >    *VramSize = LCD_VRAM_SIZE;
>> >> >> >
>> >> >> > @@ -171,6 +174,7 @@ LcdPlatformGetVram (
>> >> >> >                    VramBaseAddress
>> >> >> >                    );
>> >> >> >    if (EFI_ERROR (Status)) {
>> >> >> > +    ASSERT (FALSE);
>> >> >> >      return Status;
>> >> >> >    }
>> >> >> >
>> >> >> > @@ -181,8 +185,8 @@ LcdPlatformGetVram (
>> >> >> >                    *VramSize,
>> >> >> >                    EFI_MEMORY_WC
>> >> >> >                    );
>> >> >> > -  ASSERT_EFI_ERROR (Status);
>> >> >> >    if (EFI_ERROR (Status)) {
>> >> >> > +    ASSERT (FALSE);
>> >> >>
>> >> >> As in the sibling patch against EDK2, this patch makes it more
>> >> >> difficult to figure out what went wrong when you hit the ASSERT.
>> >> >> ASSERT_EFI_ERROR prints the value of Status, ASSERT(FALSE) only
>> >> >> prints
>> >> >> '0 != 1'
>> >> >>
>> >> >
>> >> > This change(and other similar changes) is in response to review
>> >> > comments on patch v1
>> >> > https://lists.01.org/pipermail/edk2-devel/2017-October/015995.html
>> >> >
>> >> > with above reference, Can you please confirm if we should revert to
>> >> > the
>> >> patch v1 version ?
>> >> >
>> >>
>> >> I guess Leif and I are in disagreement here. In particular, I think
>> >> his comment
>> >>
>> >> """
>> >> ASSERT (FALSE)?  (You already know Status is an EFI_ERROR, and a
>> >> console message saying ASSERT (Status) is not getting you out of
>> >> looking at the source code to find out what happened.) """
>> >>
>> >> is misguided, given that ASSERT_EFI_ERROR (Status) will actually
>> >> print the value of Status to the debug console.
>> >>
>> >> However, the objections against putting function calls in ASSERT()s
>> >> are
>> >> justified: ASSERT() should not have side effects if its condition is
>> >> met, and function calls may have side effects.
>> >>
>> >> I suppose we should wait for Leif to return on the 22nd before
>> >> proceeding with the review.
>> >> Apologies for the confusion, and for the delay.
>> >
>> >  [[Evan Lloyd]] An alternative might be for Girish to take the other route
>> Leif suggested, and cache the condition in a variable.
>> > That might be a slight overhead, and the (presumably BOOLEAN) variable
>> may need careful naming, but...
>> >
>>
>> If we are going to use a boolean to record the result of the comparison, and
>> ASSERT() on it in the if () block if the comparison is false, I don't see what
>> the difference is with doing ASSERT (FALSE) directly.
>>
>>
>> >>
>> >>
>> >>
>> >> >> >      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
>> >> (*VramSize));
>> >> >> >      return Status;
>> >> >> >    }
>> >> >> > @@ -221,6 +225,7 @@ LcdPlatformSetMode (
>> >> >> >    EFI_STATUS            Status;
>> >> >> >
>> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> > +    ASSERT (FALSE);
>> >> >>
>> >> >> These are fine: the code itself explains adequately which
>> >> >> condition triggered the ASSERT to fire.
>> >> >>
>> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >    }
>> >> >> >
>> >> >> > @@ -279,7 +284,10 @@ LcdPlatformQueryMode (
>> >> >> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST
>> Info
>> >> >> >    )
>> >> >> >  {
>> >> >> > +  ASSERT (Info != NULL);
>> >> >> > +
>> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> > +    ASSERT (FALSE);
>> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >    }
>> >> >> >
>> >> >> > @@ -343,7 +351,18 @@ LcdPlatformGetTimings (
>> >> >> >    OUT UINT32 * CONST                            VFrontPorch
>> >> >> >    )
>> >> >> >  {
>> >> >> > +  // One of the pointers is NULL  ASSERT (HRes != NULL);
>> >> >> > + ASSERT (HSync != NULL);  ASSERT (HBackPorch != NULL);  ASSERT
>> >> >> > + (HFrontPorch != NULL);  ASSERT (VRes != NULL);  ASSERT (VSync
>> >> >> > + != NULL);  ASSERT (VBackPorch != NULL);  ASSERT (VFrontPorch
>> >> >> > + != NULL);
>> >> >> > +
>> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> > +    ASSERT (FALSE);
>> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >    }
>> >> >> >
>> >> >> > @@ -376,6 +395,7 @@ LcdPlatformGetBpp (
>> >> >> >    )
>> >> >> >  {
>> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> > +    ASSERT (FALSE);
>> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >    }
>> >> >> >
>> >> >> > diff --git
>> >> >> >
>> >> >>
>> >>
>> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
>> >> Ar
>> >> >> mV
>> >> >> > Express.c
>> >> >> >
>> >> >>
>> >>
>> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
>> >> Ar
>> >> >> mV
>> >> >> > Express.c index
>> >> >> >
>> >> >>
>> >>
>> 799fb3fc781ce04bb64cb1fa0b87f262a670ed78..fd4eea8f8e2397bc7d4ddf
>> >> 4cfe
>> >> >> 3d
>> >> >> > cc97a5109edb 100644
>> >> >> > ---
>> >> >> >
>> >> >>
>> >>
>> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
>> >> Ar
>> >> >> mV
>> >> >> > Express.c
>> >> >> > +++
>> >> >>
>> >>
>> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
>> >> >> > +++ ArmVExpress.c
>> >> >> > @@ -205,6 +205,9 @@ LcdPlatformGetVram (
>> >> >> >
>> >> >> >    Status = EFI_SUCCESS;
>> >> >> >
>> >> >> > +  ASSERT (VramBaseAddress != NULL);  ASSERT (VramSize != NULL);
>> >> >> > +
>> >> >> >    // Is it on the motherboard or on the daughterboard?
>> >> >> >    switch (PL111_CLCD_SITE) {
>> >> >> >
>> >> >> > @@ -225,6 +228,7 @@ LcdPlatformGetVram (
>> >> >> >                      VramBaseAddress
>> >> >> >                      );
>> >> >> >      if (EFI_ERROR (Status)) {
>> >> >> > +      ASSERT (FALSE);
>> >> >> >        return Status;
>> >> >> >      }
>> >> >> >
>> >> >> > @@ -235,8 +239,8 @@ LcdPlatformGetVram (
>> >> >> >                      *VramSize,
>> >> >> >                      EFI_MEMORY_WC
>> >> >> >                      );
>> >> >> > -    ASSERT_EFI_ERROR (Status);
>> >> >> >      if (EFI_ERROR (Status)) {
>> >> >> > +      ASSERT (FALSE);
>> >> >> >        gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
>> >> >> (*VramSize));
>> >> >> >        return Status;
>> >> >> >      }
>> >> >> > @@ -294,6 +298,7 @@ LcdPlatformSetMode (
>> >> >> >    UINT32                SysId;
>> >> >> >
>> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> > +    ASSERT (FALSE);
>> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >    }
>> >> >> >
>> >> >> > @@ -369,7 +374,10 @@ LcdPlatformQueryMode (
>> >> >> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
>> >> >> >    )
>> >> >> >  {
>> >> >> > +  ASSERT (Info != NULL);
>> >> >> > +
>> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> > +    ASSERT (FALSE);
>> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >    }
>> >> >> >
>> >> >> > @@ -433,7 +441,18 @@ LcdPlatformGetTimings (
>> >> >> >    OUT UINT32 * CONST                      VFrontPorch
>> >> >> >    )
>> >> >> >  {
>> >> >> > +  // One of the pointers is NULL  ASSERT (HRes != NULL);
>> >> >> > + ASSERT (HSync != NULL);  ASSERT (HBackPorch != NULL);  ASSERT
>> >> >> > + (HFrontPorch != NULL);  ASSERT (VRes != NULL);  ASSERT (VSync
>> >> >> > + != NULL);  ASSERT (VBackPorch != NULL);  ASSERT (VFrontPorch
>> >> >> > + != NULL);
>> >> >> > +
>> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> > +    ASSERT (FALSE);
>> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >    }
>> >> >> >
>> >> >> > @@ -465,7 +484,10 @@ LcdPlatformGetBpp (
>> >> >> >    OUT LCD_BPP * CONST                     Bpp
>> >> >> >    )
>> >> >> >  {
>> >> >> > +  ASSERT (Bpp != NULL);
>> >> >> > +
>> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> > +    ASSERT (FALSE);
>> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >    }
>> >> >> >
>> >> >> > --
>> >> >> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>> >> >> >
>> >> >> > _______________________________________________
>> >> >> > edk2-devel mailing list
>> >> >> > edk2-devel@lists.01.org
>> >> >> > https://lists.01.org/mailman/listinfo/edk2-devel
>> >> >> _______________________________________________
>> >> >> edk2-devel mailing list
>> >> >> edk2-devel@lists.01.org
>> >> >> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS
  2018-03-02 19:07               ` Ard Biesheuvel
@ 2018-03-05 15:08                 ` Evan Lloyd
  2018-03-06 11:16                   ` Ard Biesheuvel
  0 siblings, 1 reply; 57+ messages in thread
From: Evan Lloyd @ 2018-03-05 15:08 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: leif.lindholm@linaro.org, Girish Pathak, Matteo Carlini, nd,
	edk2-devel@lists.01.org

In that case, would you be happy to take Girish's patches with the ASSERTs done your (our) way?
Leif can fulminate about it when he gets back, if he really feels that strongly.
I suspect, though, that Leif is capable of being reasonable if pressed (and offered beer at Plugfest).

Regards,
Evan

> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 02 March 2018 19:07
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: leif.lindholm@linaro.org; Girish Pathak <Girish.Pathak@arm.com>;
> Matteo Carlini <Matteo.Carlini@arm.com>; nd <nd@arm.com>; edk2-
> devel@lists.01.org
> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg:
> Add and update debug ASSERTS
> 
> On 28 February 2018 at 20:27, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> > Hi Leif, Ard.
> > Can I get you two argue out the pros and cons of the "ASSERT(FALSE)"
> debate, please.
> 
> I can argue the cons if you like. For the pros, you'll have to wait for Leif to
> return from holiday (in a week or two AFAIK)
> 
> > (see
> > https://lists.01.org/pipermail/edk2-devel/2018-January/019788.html)
> > For what it is worth, our (surprisingly unanimous) opinion is that, since
> the ASSERT is only there to help spot a problem, then the more information
> reported the better.  The only benefits of ASSERT(FALSE) would be a smaller
> debug image and minor efficiency improvement on the path to the crash.
> >
> > Regards,
> > Evan
> >
> >> -----Original Message-----
> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> >> Sent: 04 January 2018 19:55
> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
> >> Cc: Girish Pathak <Girish.Pathak@arm.com>; Matteo Carlini
> >> <Matteo.Carlini@arm.com>; nd <nd@arm.com>; edk2-
> devel@lists.01.org;
> >> Thomas Abraham <thomas.abraham@arm.com>; Arvind Chauhan
> >> <Arvind.Chauhan@arm.com>; leif.lindholm@linaro.org
> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg:
> >> Add and update debug ASSERTS
> >>
> >> On 4 January 2018 at 19:51, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> >> >
> >> >
> >> >> -----Original Message-----
> >> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> >> >> Sent: 04 January 2018 19:24
> >> >> To: Girish Pathak <Girish.Pathak@arm.com>
> >> >> Cc: Evan Lloyd <Evan.Lloyd@arm.com>; Matteo Carlini
> >> >> <Matteo.Carlini@arm.com>; nd <nd@arm.com>; edk2-
> >> devel@lists.01.org;
> >> >> Thomas Abraham <thomas.abraham@arm.com>; Arvind Chauhan
> >> >> <Arvind.Chauhan@arm.com>; leif.lindholm@linaro.org
> >> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18]
> ARM/VExpressPkg:
> >> >> Add and update debug ASSERTS
> >> >>
> >> >> On 4 January 2018 at 18:55, Girish Pathak <Girish.Pathak@arm.com>
> >> >> wrote:
> >> >> > Hi Ard,
> >> >> >
> >> >> >> -----Original Message-----
> >> >> >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On
> >> >> >> Behalf Of Ard Biesheuvel
> >> >> >> Sent: 23 December 2017 14:12
> >> >> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
> >> >> >> Cc: "Matteo.Carlini@arm.com"@arm.com;
> >> >> >> "leif.lindholm@linaro.org"@arm.com; "nd@arm.com"@arm.com;
> >> edk2-
> >> >> >> devel@lists.01.org; Thomas Abraham
> <thomas.abraham@arm.com>;
> >> >> Arvind
> >> >> >> Chauhan <Arvind.Chauhan@arm.com>;
> >> >> "ard.biesheuvel@linaro.org"@arm.com
> >> >> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18]
> >> ARM/VExpressPkg:
> >> >> >> Add and update debug ASSERTS
> >> >> >>
> >> >> >> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> >> >> >> > From: Girish Pathak <girish.pathak at arm.com>
> >> >> >> >
> >> >> >> > This change adds some debug assertions e.g to catch NULL
> >> >> >> > pointer errors missing in PL11Lcd and HdLcd platform libraries.
> >> >> >> >
> >> >> >> > Contributed-under: TianoCore Contribution Agreement 1.1
> >> >> >> > Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> >> >> >> > Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
> >> >> >> > ---
> >> >> >> >
> >> >> >>
> >> >>
> >>
> Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExp
> >> >> r
> >> >> >> ess.c       | 22 +++++++++++++++++-
> >> >> >> >
> >> >> >> >
> >> >> >>
> >> >>
> >>
> Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
> >> >> m
> >> >> >> VEx
> >> >> >> > press.c | 24 +++++++++++++++++++-
> >> >> >> >  2 files changed, 44 insertions(+), 2 deletions(-)
> >> >> >> >
> >> >> >> > diff --git
> >> >> >> >
> >> >> >>
> >> >>
> >>
> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
> >> >> x
> >> >> >> pres
> >> >> >> > s.c
> >> >> >> >
> >> >> >>
> >> >>
> >>
> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
> >> >> x
> >> >> >> pres
> >> >> >> > s.c index
> >> >> >> >
> >> >> >>
> >> >>
> >>
> 6afd764897f49c64490ce891682f99bb0f5d993b..a8fe8696da0653017ce9fa
> >> >> 6e4a
> >> >> >> 86
> >> >> >> > caf283bc04c9 100644
> >> >> >> > ---
> >> >> >> >
> >> >> >>
> >> >>
> >>
> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
> >> >> x
> >> >> >> pres
> >> >> >> > s.c
> >> >> >> > +++
> >> >> >>
> >> >>
> >>
> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
> >> >> x
> >> >> >> > +++ press.c
> >> >> >> > @@ -153,6 +153,9 @@ LcdPlatformGetVram (
> >> >> >> >    EFI_STATUS              Status;
> >> >> >> >    EFI_ALLOCATE_TYPE       AllocationType;
> >> >> >> >
> >> >> >> > +  ASSERT (VramBaseAddress != NULL);  ASSERT (VramSize !=
> >> >> >> > + NULL);
> >> >> >> > +
> >> >> >> >    // Set the vram size
> >> >> >> >    *VramSize = LCD_VRAM_SIZE;
> >> >> >> >
> >> >> >> > @@ -171,6 +174,7 @@ LcdPlatformGetVram (
> >> >> >> >                    VramBaseAddress
> >> >> >> >                    );
> >> >> >> >    if (EFI_ERROR (Status)) {
> >> >> >> > +    ASSERT (FALSE);
> >> >> >> >      return Status;
> >> >> >> >    }
> >> >> >> >
> >> >> >> > @@ -181,8 +185,8 @@ LcdPlatformGetVram (
> >> >> >> >                    *VramSize,
> >> >> >> >                    EFI_MEMORY_WC
> >> >> >> >                    );
> >> >> >> > -  ASSERT_EFI_ERROR (Status);
> >> >> >> >    if (EFI_ERROR (Status)) {
> >> >> >> > +    ASSERT (FALSE);
> >> >> >>
> >> >> >> As in the sibling patch against EDK2, this patch makes it more
> >> >> >> difficult to figure out what went wrong when you hit the ASSERT.
> >> >> >> ASSERT_EFI_ERROR prints the value of Status, ASSERT(FALSE) only
> >> >> >> prints
> >> >> >> '0 != 1'
> >> >> >>
> >> >> >
> >> >> > This change(and other similar changes) is in response to review
> >> >> > comments on patch v1
> >> >> > https://lists.01.org/pipermail/edk2-devel/2017-
> October/015995.ht
> >> >> > ml
> >> >> >
> >> >> > with above reference, Can you please confirm if we should revert
> >> >> > to the
> >> >> patch v1 version ?
> >> >> >
> >> >>
> >> >> I guess Leif and I are in disagreement here. In particular, I
> >> >> think his comment
> >> >>
> >> >> """
> >> >> ASSERT (FALSE)?  (You already know Status is an EFI_ERROR, and a
> >> >> console message saying ASSERT (Status) is not getting you out of
> >> >> looking at the source code to find out what happened.) """
> >> >>
> >> >> is misguided, given that ASSERT_EFI_ERROR (Status) will actually
> >> >> print the value of Status to the debug console.
> >> >>
> >> >> However, the objections against putting function calls in
> >> >> ASSERT()s are
> >> >> justified: ASSERT() should not have side effects if its condition
> >> >> is met, and function calls may have side effects.
> >> >>
> >> >> I suppose we should wait for Leif to return on the 22nd before
> >> >> proceeding with the review.
> >> >> Apologies for the confusion, and for the delay.
> >> >
> >> >  [[Evan Lloyd]] An alternative might be for Girish to take the
> >> > other route
> >> Leif suggested, and cache the condition in a variable.
> >> > That might be a slight overhead, and the (presumably BOOLEAN)
> >> > variable
> >> may need careful naming, but...
> >> >
> >>
> >> If we are going to use a boolean to record the result of the
> >> comparison, and
> >> ASSERT() on it in the if () block if the comparison is false, I don't
> >> see what the difference is with doing ASSERT (FALSE) directly.
> >>
> >>
> >> >>
> >> >>
> >> >>
> >> >> >> >      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> >> >> (*VramSize));
> >> >> >> >      return Status;
> >> >> >> >    }
> >> >> >> > @@ -221,6 +225,7 @@ LcdPlatformSetMode (
> >> >> >> >    EFI_STATUS            Status;
> >> >> >> >
> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> >> > +    ASSERT (FALSE);
> >> >> >>
> >> >> >> These are fine: the code itself explains adequately which
> >> >> >> condition triggered the ASSERT to fire.
> >> >> >>
> >> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >> >    }
> >> >> >> >
> >> >> >> > @@ -279,7 +284,10 @@ LcdPlatformQueryMode (
> >> >> >> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST
> >> Info
> >> >> >> >    )
> >> >> >> >  {
> >> >> >> > +  ASSERT (Info != NULL);
> >> >> >> > +
> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> >> > +    ASSERT (FALSE);
> >> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >> >    }
> >> >> >> >
> >> >> >> > @@ -343,7 +351,18 @@ LcdPlatformGetTimings (
> >> >> >> >    OUT UINT32 * CONST                            VFrontPorch
> >> >> >> >    )
> >> >> >> >  {
> >> >> >> > +  // One of the pointers is NULL  ASSERT (HRes != NULL);
> >> >> >> > + ASSERT (HSync != NULL);  ASSERT (HBackPorch != NULL);
> >> >> >> > + ASSERT (HFrontPorch != NULL);  ASSERT (VRes != NULL);
> >> >> >> > + ASSERT (VSync != NULL);  ASSERT (VBackPorch != NULL);
> >> >> >> > + ASSERT (VFrontPorch != NULL);
> >> >> >> > +
> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> >> > +    ASSERT (FALSE);
> >> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >> >    }
> >> >> >> >
> >> >> >> > @@ -376,6 +395,7 @@ LcdPlatformGetBpp (
> >> >> >> >    )
> >> >> >> >  {
> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> >> > +    ASSERT (FALSE);
> >> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >> >    }
> >> >> >> >
> >> >> >> > diff --git
> >> >> >> >
> >> >> >>
> >> >>
> >>
> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
> >> >> Ar
> >> >> >> mV
> >> >> >> > Express.c
> >> >> >> >
> >> >> >>
> >> >>
> >>
> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
> >> >> Ar
> >> >> >> mV
> >> >> >> > Express.c index
> >> >> >> >
> >> >> >>
> >> >>
> >>
> 799fb3fc781ce04bb64cb1fa0b87f262a670ed78..fd4eea8f8e2397bc7d4ddf
> >> >> 4cfe
> >> >> >> 3d
> >> >> >> > cc97a5109edb 100644
> >> >> >> > ---
> >> >> >> >
> >> >> >>
> >> >>
> >>
> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
> >> >> Ar
> >> >> >> mV
> >> >> >> > Express.c
> >> >> >> > +++
> >> >> >>
> >> >>
> >>
> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
> >> >> >> > +++ ArmVExpress.c
> >> >> >> > @@ -205,6 +205,9 @@ LcdPlatformGetVram (
> >> >> >> >
> >> >> >> >    Status = EFI_SUCCESS;
> >> >> >> >
> >> >> >> > +  ASSERT (VramBaseAddress != NULL);  ASSERT (VramSize !=
> >> >> >> > + NULL);
> >> >> >> > +
> >> >> >> >    // Is it on the motherboard or on the daughterboard?
> >> >> >> >    switch (PL111_CLCD_SITE) {
> >> >> >> >
> >> >> >> > @@ -225,6 +228,7 @@ LcdPlatformGetVram (
> >> >> >> >                      VramBaseAddress
> >> >> >> >                      );
> >> >> >> >      if (EFI_ERROR (Status)) {
> >> >> >> > +      ASSERT (FALSE);
> >> >> >> >        return Status;
> >> >> >> >      }
> >> >> >> >
> >> >> >> > @@ -235,8 +239,8 @@ LcdPlatformGetVram (
> >> >> >> >                      *VramSize,
> >> >> >> >                      EFI_MEMORY_WC
> >> >> >> >                      );
> >> >> >> > -    ASSERT_EFI_ERROR (Status);
> >> >> >> >      if (EFI_ERROR (Status)) {
> >> >> >> > +      ASSERT (FALSE);
> >> >> >> >        gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> >> >> >> (*VramSize));
> >> >> >> >        return Status;
> >> >> >> >      }
> >> >> >> > @@ -294,6 +298,7 @@ LcdPlatformSetMode (
> >> >> >> >    UINT32                SysId;
> >> >> >> >
> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> >> > +    ASSERT (FALSE);
> >> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >> >    }
> >> >> >> >
> >> >> >> > @@ -369,7 +374,10 @@ LcdPlatformQueryMode (
> >> >> >> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST
> Info
> >> >> >> >    )
> >> >> >> >  {
> >> >> >> > +  ASSERT (Info != NULL);
> >> >> >> > +
> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> >> > +    ASSERT (FALSE);
> >> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >> >    }
> >> >> >> >
> >> >> >> > @@ -433,7 +441,18 @@ LcdPlatformGetTimings (
> >> >> >> >    OUT UINT32 * CONST                      VFrontPorch
> >> >> >> >    )
> >> >> >> >  {
> >> >> >> > +  // One of the pointers is NULL  ASSERT (HRes != NULL);
> >> >> >> > + ASSERT (HSync != NULL);  ASSERT (HBackPorch != NULL);
> >> >> >> > + ASSERT (HFrontPorch != NULL);  ASSERT (VRes != NULL);
> >> >> >> > + ASSERT (VSync != NULL);  ASSERT (VBackPorch != NULL);
> >> >> >> > + ASSERT (VFrontPorch != NULL);
> >> >> >> > +
> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> >> > +    ASSERT (FALSE);
> >> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >> >    }
> >> >> >> >
> >> >> >> > @@ -465,7 +484,10 @@ LcdPlatformGetBpp (
> >> >> >> >    OUT LCD_BPP * CONST                     Bpp
> >> >> >> >    )
> >> >> >> >  {
> >> >> >> > +  ASSERT (Bpp != NULL);
> >> >> >> > +
> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> >> >> > +    ASSERT (FALSE);
> >> >> >> >      return EFI_INVALID_PARAMETER;
> >> >> >> >    }
> >> >> >> >
> >> >> >> > --
> >> >> >> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >> >> >> >
> >> >> >> > _______________________________________________
> >> >> >> > edk2-devel mailing list
> >> >> >> > edk2-devel@lists.01.org
> >> >> >> > https://lists.01.org/mailman/listinfo/edk2-devel
> >> >> >> _______________________________________________
> >> >> >> edk2-devel mailing list
> >> >> >> edk2-devel@lists.01.org
> >> >> >> https://lists.01.org/mailman/listinfo/edk2-devel

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS
  2018-03-05 15:08                 ` Evan Lloyd
@ 2018-03-06 11:16                   ` Ard Biesheuvel
  0 siblings, 0 replies; 57+ messages in thread
From: Ard Biesheuvel @ 2018-03-06 11:16 UTC (permalink / raw)
  To: Evan Lloyd
  Cc: leif.lindholm@linaro.org, Girish Pathak, Matteo Carlini, nd,
	edk2-devel@lists.01.org

On 5 March 2018 at 15:08, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> In that case, would you be happy to take Girish's patches with the ASSERTs done your (our) way?
> Leif can fulminate about it when he gets back, if he really feels that strongly.

Why? Because it is almost the end of the quarter? Can't it wait?

> I suspect, though, that Leif is capable of being reasonable if pressed (and offered beer at Plugfest).
>

I am not going to push something I know Leif disapproves of in its
current form in his absence, sorry.

>
>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: 02 March 2018 19:07
>> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> Cc: leif.lindholm@linaro.org; Girish Pathak <Girish.Pathak@arm.com>;
>> Matteo Carlini <Matteo.Carlini@arm.com>; nd <nd@arm.com>; edk2-
>> devel@lists.01.org
>> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg:
>> Add and update debug ASSERTS
>>
>> On 28 February 2018 at 20:27, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
>> > Hi Leif, Ard.
>> > Can I get you two argue out the pros and cons of the "ASSERT(FALSE)"
>> debate, please.
>>
>> I can argue the cons if you like. For the pros, you'll have to wait for Leif to
>> return from holiday (in a week or two AFAIK)
>>
>> > (see
>> > https://lists.01.org/pipermail/edk2-devel/2018-January/019788.html)
>> > For what it is worth, our (surprisingly unanimous) opinion is that, since
>> the ASSERT is only there to help spot a problem, then the more information
>> reported the better.  The only benefits of ASSERT(FALSE) would be a smaller
>> debug image and minor efficiency improvement on the path to the crash.
>> >
>> > Regards,
>> > Evan
>> >
>> >> -----Original Message-----
>> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> >> Sent: 04 January 2018 19:55
>> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> >> Cc: Girish Pathak <Girish.Pathak@arm.com>; Matteo Carlini
>> >> <Matteo.Carlini@arm.com>; nd <nd@arm.com>; edk2-
>> devel@lists.01.org;
>> >> Thomas Abraham <thomas.abraham@arm.com>; Arvind Chauhan
>> >> <Arvind.Chauhan@arm.com>; leif.lindholm@linaro.org
>> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg:
>> >> Add and update debug ASSERTS
>> >>
>> >> On 4 January 2018 at 19:51, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
>> >> >
>> >> >
>> >> >> -----Original Message-----
>> >> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> >> >> Sent: 04 January 2018 19:24
>> >> >> To: Girish Pathak <Girish.Pathak@arm.com>
>> >> >> Cc: Evan Lloyd <Evan.Lloyd@arm.com>; Matteo Carlini
>> >> >> <Matteo.Carlini@arm.com>; nd <nd@arm.com>; edk2-
>> >> devel@lists.01.org;
>> >> >> Thomas Abraham <thomas.abraham@arm.com>; Arvind Chauhan
>> >> >> <Arvind.Chauhan@arm.com>; leif.lindholm@linaro.org
>> >> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18]
>> ARM/VExpressPkg:
>> >> >> Add and update debug ASSERTS
>> >> >>
>> >> >> On 4 January 2018 at 18:55, Girish Pathak <Girish.Pathak@arm.com>
>> >> >> wrote:
>> >> >> > Hi Ard,
>> >> >> >
>> >> >> >> -----Original Message-----
>> >> >> >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On
>> >> >> >> Behalf Of Ard Biesheuvel
>> >> >> >> Sent: 23 December 2017 14:12
>> >> >> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> >> >> >> Cc: "Matteo.Carlini@arm.com"@arm.com;
>> >> >> >> "leif.lindholm@linaro.org"@arm.com; "nd@arm.com"@arm.com;
>> >> edk2-
>> >> >> >> devel@lists.01.org; Thomas Abraham
>> <thomas.abraham@arm.com>;
>> >> >> Arvind
>> >> >> >> Chauhan <Arvind.Chauhan@arm.com>;
>> >> >> "ard.biesheuvel@linaro.org"@arm.com
>> >> >> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18]
>> >> ARM/VExpressPkg:
>> >> >> >> Add and update debug ASSERTS
>> >> >> >>
>> >> >> >> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
>> >> >> >> > From: Girish Pathak <girish.pathak at arm.com>
>> >> >> >> >
>> >> >> >> > This change adds some debug assertions e.g to catch NULL
>> >> >> >> > pointer errors missing in PL11Lcd and HdLcd platform libraries.
>> >> >> >> >
>> >> >> >> > Contributed-under: TianoCore Contribution Agreement 1.1
>> >> >> >> > Signed-off-by: Girish Pathak <girish.pathak@arm.com>
>> >> >> >> > Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
>> >> >> >> > ---
>> >> >> >> >
>> >> >> >>
>> >> >>
>> >>
>> Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExp
>> >> >> r
>> >> >> >> ess.c       | 22 +++++++++++++++++-
>> >> >> >> >
>> >> >> >> >
>> >> >> >>
>> >> >>
>> >>
>> Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdAr
>> >> >> m
>> >> >> >> VEx
>> >> >> >> > press.c | 24 +++++++++++++++++++-
>> >> >> >> >  2 files changed, 44 insertions(+), 2 deletions(-)
>> >> >> >> >
>> >> >> >> > diff --git
>> >> >> >> >
>> >> >> >>
>> >> >>
>> >>
>> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
>> >> >> x
>> >> >> >> pres
>> >> >> >> > s.c
>> >> >> >> >
>> >> >> >>
>> >> >>
>> >>
>> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
>> >> >> x
>> >> >> >> pres
>> >> >> >> > s.c index
>> >> >> >> >
>> >> >> >>
>> >> >>
>> >>
>> 6afd764897f49c64490ce891682f99bb0f5d993b..a8fe8696da0653017ce9fa
>> >> >> 6e4a
>> >> >> >> 86
>> >> >> >> > caf283bc04c9 100644
>> >> >> >> > ---
>> >> >> >> >
>> >> >> >>
>> >> >>
>> >>
>> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
>> >> >> x
>> >> >> >> pres
>> >> >> >> > s.c
>> >> >> >> > +++
>> >> >> >>
>> >> >>
>> >>
>> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVE
>> >> >> x
>> >> >> >> > +++ press.c
>> >> >> >> > @@ -153,6 +153,9 @@ LcdPlatformGetVram (
>> >> >> >> >    EFI_STATUS              Status;
>> >> >> >> >    EFI_ALLOCATE_TYPE       AllocationType;
>> >> >> >> >
>> >> >> >> > +  ASSERT (VramBaseAddress != NULL);  ASSERT (VramSize !=
>> >> >> >> > + NULL);
>> >> >> >> > +
>> >> >> >> >    // Set the vram size
>> >> >> >> >    *VramSize = LCD_VRAM_SIZE;
>> >> >> >> >
>> >> >> >> > @@ -171,6 +174,7 @@ LcdPlatformGetVram (
>> >> >> >> >                    VramBaseAddress
>> >> >> >> >                    );
>> >> >> >> >    if (EFI_ERROR (Status)) {
>> >> >> >> > +    ASSERT (FALSE);
>> >> >> >> >      return Status;
>> >> >> >> >    }
>> >> >> >> >
>> >> >> >> > @@ -181,8 +185,8 @@ LcdPlatformGetVram (
>> >> >> >> >                    *VramSize,
>> >> >> >> >                    EFI_MEMORY_WC
>> >> >> >> >                    );
>> >> >> >> > -  ASSERT_EFI_ERROR (Status);
>> >> >> >> >    if (EFI_ERROR (Status)) {
>> >> >> >> > +    ASSERT (FALSE);
>> >> >> >>
>> >> >> >> As in the sibling patch against EDK2, this patch makes it more
>> >> >> >> difficult to figure out what went wrong when you hit the ASSERT.
>> >> >> >> ASSERT_EFI_ERROR prints the value of Status, ASSERT(FALSE) only
>> >> >> >> prints
>> >> >> >> '0 != 1'
>> >> >> >>
>> >> >> >
>> >> >> > This change(and other similar changes) is in response to review
>> >> >> > comments on patch v1
>> >> >> > https://lists.01.org/pipermail/edk2-devel/2017-
>> October/015995.ht
>> >> >> > ml
>> >> >> >
>> >> >> > with above reference, Can you please confirm if we should revert
>> >> >> > to the
>> >> >> patch v1 version ?
>> >> >> >
>> >> >>
>> >> >> I guess Leif and I are in disagreement here. In particular, I
>> >> >> think his comment
>> >> >>
>> >> >> """
>> >> >> ASSERT (FALSE)?  (You already know Status is an EFI_ERROR, and a
>> >> >> console message saying ASSERT (Status) is not getting you out of
>> >> >> looking at the source code to find out what happened.) """
>> >> >>
>> >> >> is misguided, given that ASSERT_EFI_ERROR (Status) will actually
>> >> >> print the value of Status to the debug console.
>> >> >>
>> >> >> However, the objections against putting function calls in
>> >> >> ASSERT()s are
>> >> >> justified: ASSERT() should not have side effects if its condition
>> >> >> is met, and function calls may have side effects.
>> >> >>
>> >> >> I suppose we should wait for Leif to return on the 22nd before
>> >> >> proceeding with the review.
>> >> >> Apologies for the confusion, and for the delay.
>> >> >
>> >> >  [[Evan Lloyd]] An alternative might be for Girish to take the
>> >> > other route
>> >> Leif suggested, and cache the condition in a variable.
>> >> > That might be a slight overhead, and the (presumably BOOLEAN)
>> >> > variable
>> >> may need careful naming, but...
>> >> >
>> >>
>> >> If we are going to use a boolean to record the result of the
>> >> comparison, and
>> >> ASSERT() on it in the if () block if the comparison is false, I don't
>> >> see what the difference is with doing ASSERT (FALSE) directly.
>> >>
>> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> >> >      gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
>> >> >> (*VramSize));
>> >> >> >> >      return Status;
>> >> >> >> >    }
>> >> >> >> > @@ -221,6 +225,7 @@ LcdPlatformSetMode (
>> >> >> >> >    EFI_STATUS            Status;
>> >> >> >> >
>> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> >> > +    ASSERT (FALSE);
>> >> >> >>
>> >> >> >> These are fine: the code itself explains adequately which
>> >> >> >> condition triggered the ASSERT to fire.
>> >> >> >>
>> >> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >> >    }
>> >> >> >> >
>> >> >> >> > @@ -279,7 +284,10 @@ LcdPlatformQueryMode (
>> >> >> >> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST
>> >> Info
>> >> >> >> >    )
>> >> >> >> >  {
>> >> >> >> > +  ASSERT (Info != NULL);
>> >> >> >> > +
>> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> >> > +    ASSERT (FALSE);
>> >> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >> >    }
>> >> >> >> >
>> >> >> >> > @@ -343,7 +351,18 @@ LcdPlatformGetTimings (
>> >> >> >> >    OUT UINT32 * CONST                            VFrontPorch
>> >> >> >> >    )
>> >> >> >> >  {
>> >> >> >> > +  // One of the pointers is NULL  ASSERT (HRes != NULL);
>> >> >> >> > + ASSERT (HSync != NULL);  ASSERT (HBackPorch != NULL);
>> >> >> >> > + ASSERT (HFrontPorch != NULL);  ASSERT (VRes != NULL);
>> >> >> >> > + ASSERT (VSync != NULL);  ASSERT (VBackPorch != NULL);
>> >> >> >> > + ASSERT (VFrontPorch != NULL);
>> >> >> >> > +
>> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> >> > +    ASSERT (FALSE);
>> >> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >> >    }
>> >> >> >> >
>> >> >> >> > @@ -376,6 +395,7 @@ LcdPlatformGetBpp (
>> >> >> >> >    )
>> >> >> >> >  {
>> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> >> > +    ASSERT (FALSE);
>> >> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >> >    }
>> >> >> >> >
>> >> >> >> > diff --git
>> >> >> >> >
>> >> >> >>
>> >> >>
>> >>
>> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
>> >> >> Ar
>> >> >> >> mV
>> >> >> >> > Express.c
>> >> >> >> >
>> >> >> >>
>> >> >>
>> >>
>> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
>> >> >> Ar
>> >> >> >> mV
>> >> >> >> > Express.c index
>> >> >> >> >
>> >> >> >>
>> >> >>
>> >>
>> 799fb3fc781ce04bb64cb1fa0b87f262a670ed78..fd4eea8f8e2397bc7d4ddf
>> >> >> 4cfe
>> >> >> >> 3d
>> >> >> >> > cc97a5109edb 100644
>> >> >> >> > ---
>> >> >> >> >
>> >> >> >>
>> >> >>
>> >>
>> a/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
>> >> >> Ar
>> >> >> >> mV
>> >> >> >> > Express.c
>> >> >> >> > +++
>> >> >> >>
>> >> >>
>> >>
>> b/Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd
>> >> >> >> > +++ ArmVExpress.c
>> >> >> >> > @@ -205,6 +205,9 @@ LcdPlatformGetVram (
>> >> >> >> >
>> >> >> >> >    Status = EFI_SUCCESS;
>> >> >> >> >
>> >> >> >> > +  ASSERT (VramBaseAddress != NULL);  ASSERT (VramSize !=
>> >> >> >> > + NULL);
>> >> >> >> > +
>> >> >> >> >    // Is it on the motherboard or on the daughterboard?
>> >> >> >> >    switch (PL111_CLCD_SITE) {
>> >> >> >> >
>> >> >> >> > @@ -225,6 +228,7 @@ LcdPlatformGetVram (
>> >> >> >> >                      VramBaseAddress
>> >> >> >> >                      );
>> >> >> >> >      if (EFI_ERROR (Status)) {
>> >> >> >> > +      ASSERT (FALSE);
>> >> >> >> >        return Status;
>> >> >> >> >      }
>> >> >> >> >
>> >> >> >> > @@ -235,8 +239,8 @@ LcdPlatformGetVram (
>> >> >> >> >                      *VramSize,
>> >> >> >> >                      EFI_MEMORY_WC
>> >> >> >> >                      );
>> >> >> >> > -    ASSERT_EFI_ERROR (Status);
>> >> >> >> >      if (EFI_ERROR (Status)) {
>> >> >> >> > +      ASSERT (FALSE);
>> >> >> >> >        gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
>> >> >> >> (*VramSize));
>> >> >> >> >        return Status;
>> >> >> >> >      }
>> >> >> >> > @@ -294,6 +298,7 @@ LcdPlatformSetMode (
>> >> >> >> >    UINT32                SysId;
>> >> >> >> >
>> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> >> > +    ASSERT (FALSE);
>> >> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >> >    }
>> >> >> >> >
>> >> >> >> > @@ -369,7 +374,10 @@ LcdPlatformQueryMode (
>> >> >> >> >    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST
>> Info
>> >> >> >> >    )
>> >> >> >> >  {
>> >> >> >> > +  ASSERT (Info != NULL);
>> >> >> >> > +
>> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> >> > +    ASSERT (FALSE);
>> >> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >> >    }
>> >> >> >> >
>> >> >> >> > @@ -433,7 +441,18 @@ LcdPlatformGetTimings (
>> >> >> >> >    OUT UINT32 * CONST                      VFrontPorch
>> >> >> >> >    )
>> >> >> >> >  {
>> >> >> >> > +  // One of the pointers is NULL  ASSERT (HRes != NULL);
>> >> >> >> > + ASSERT (HSync != NULL);  ASSERT (HBackPorch != NULL);
>> >> >> >> > + ASSERT (HFrontPorch != NULL);  ASSERT (VRes != NULL);
>> >> >> >> > + ASSERT (VSync != NULL);  ASSERT (VBackPorch != NULL);
>> >> >> >> > + ASSERT (VFrontPorch != NULL);
>> >> >> >> > +
>> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> >> > +    ASSERT (FALSE);
>> >> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >> >    }
>> >> >> >> >
>> >> >> >> > @@ -465,7 +484,10 @@ LcdPlatformGetBpp (
>> >> >> >> >    OUT LCD_BPP * CONST                     Bpp
>> >> >> >> >    )
>> >> >> >> >  {
>> >> >> >> > +  ASSERT (Bpp != NULL);
>> >> >> >> > +
>> >> >> >> >    if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> >> >> >> > +    ASSERT (FALSE);
>> >> >> >> >      return EFI_INVALID_PARAMETER;
>> >> >> >> >    }
>> >> >> >> >
>> >> >> >> > --
>> >> >> >> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>> >> >> >> >
>> >> >> >> > _______________________________________________
>> >> >> >> > edk2-devel mailing list
>> >> >> >> > edk2-devel@lists.01.org
>> >> >> >> > https://lists.01.org/mailman/listinfo/edk2-devel
>> >> >> >> _______________________________________________
>> >> >> >> edk2-devel mailing list
>> >> >> >> edk2-devel@lists.01.org
>> >> >> >> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS
  2018-01-04 19:24       ` Ard Biesheuvel
  2018-01-04 19:51         ` Evan Lloyd
@ 2018-03-14 12:24         ` Leif Lindholm
  2018-03-14 12:35           ` Ard Biesheuvel
  1 sibling, 1 reply; 57+ messages in thread
From: Leif Lindholm @ 2018-03-14 12:24 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Girish Pathak, Evan Lloyd, Matteo Carlini, nd,
	edk2-devel@lists.01.org, Thomas Abraham, Arvind Chauhan

On Thu, Jan 04, 2018 at 07:24:20PM +0000, Ard Biesheuvel wrote:
> On 4 January 2018 at 18:55, Girish Pathak <Girish.Pathak@arm.com> wrote:
> > Hi Ard,
> >
> >> -----Original Message-----
> >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> >> Ard Biesheuvel
> >> Sent: 23 December 2017 14:12
> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
> >> Cc: "Matteo.Carlini@arm.com"@arm.com;
> >> "leif.lindholm@linaro.org"@arm.com; "nd@arm.com"@arm.com; edk2-
> >> devel@lists.01.org; Thomas Abraham <thomas.abraham@arm.com>; Arvind
> >> Chauhan <Arvind.Chauhan@arm.com>;
> >> "ard.biesheuvel@linaro.org"@arm.com
> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add
> >> and update debug ASSERTS
> >>
> >> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
> >> > From: Girish Pathak <girish.pathak at arm.com>
> >> >
> >> > This change adds some debug assertions e.g to catch NULL pointer
> >> > errors missing in PL11Lcd and HdLcd platform libraries.
> >> >
> >> > Contributed-under: TianoCore Contribution Agreement 1.1
> >> > Signed-off-by: Girish Pathak <girish.pathak@arm.com>
> >> > Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
> >> > ---
> >> >
> >> Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpr
> >> ess.c       | 22 +++++++++++++++++-
> >> >
> >> >
> >> Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArm
> >> VEx
> >> > press.c | 24 +++++++++++++++++++-
> >> >  2 files changed, 44 insertions(+), 2 deletions(-)
> >> >
> >> > diff --git
> >> >
> >> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
> >> pres
> >> > s.c
> >> >
> >> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
> >> pres
> >> > s.c index
> >> >
> >> 6afd764897f49c64490ce891682f99bb0f5d993b..a8fe8696da0653017ce9fa6e4a
> >> 86
> >> > caf283bc04c9 100644
> >> > ---
> >> >
> >> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
> >> pres
> >> > s.c
> >> > +++
> >> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
> >> > +++ press.c
> >> > @@ -153,6 +153,9 @@ LcdPlatformGetVram (
> >> >    EFI_STATUS              Status;
> >> >    EFI_ALLOCATE_TYPE       AllocationType;
> >> >
> >> > +  ASSERT (VramBaseAddress != NULL);
> >> > +  ASSERT (VramSize != NULL);
> >> > +
> >> >    // Set the vram size
> >> >    *VramSize = LCD_VRAM_SIZE;
> >> >
> >> > @@ -171,6 +174,7 @@ LcdPlatformGetVram (
> >> >                    VramBaseAddress
> >> >                    );
> >> >    if (EFI_ERROR (Status)) {
> >> > +    ASSERT (FALSE);
> >> >      return Status;
> >> >    }
> >> >
> >> > @@ -181,8 +185,8 @@ LcdPlatformGetVram (
> >> >                    *VramSize,
> >> >                    EFI_MEMORY_WC
> >> >                    );
> >> > -  ASSERT_EFI_ERROR (Status);
> >> >    if (EFI_ERROR (Status)) {
> >> > +    ASSERT (FALSE);
> >>
> >> As in the sibling patch against EDK2, this patch makes it more difficult to
> >> figure out what went wrong when you hit the ASSERT.
> >> ASSERT_EFI_ERROR prints the value of Status, ASSERT(FALSE) only prints
> >> '0 != 1'
> >>
> >
> > This change(and other similar changes) is in response to review comments on patch v1
> > https://lists.01.org/pipermail/edk2-devel/2017-October/015995.html
> >
> > with above reference, Can you please confirm if we should revert to the patch v1 version ?
> >
> 
> I guess Leif and I are in disagreement here. In particular, I think
> his comment
> 
> """
> ASSERT (FALSE)?  (You already know Status is an EFI_ERROR, and a
> console message saying ASSERT (Status) is not getting you out of
> looking at the source code to find out what happened.)
> """
> 
> is misguided, given that ASSERT_EFI_ERROR (Status) will actually print
> the value of Status to the debug console.

I don't have a strong enough opinion on this that it should be
listened to if you both agree.

It's just the "if error, then assert if error" that breaks up the
parsing flow for me. Could it make sense to use ASSERT_RETURN_ERROR
instead?

So
      if (EFI_ERROR (Status)) {
        ASSERT_RETURN_ERROR (Status);
      }

> However, the objections against putting function calls in ASSERT()s
> are justified: ASSERT() should not have side effects if its condition
> is met, and function calls may have side effects.
> 
> I suppose we should wait for Leif to return on the 22nd before
> proceeding with the review.
> Apologies for the confusion, and for the delay.

Apologies for the even more ridicilous delay.
Err, I need to stop taking holidays or something.

Don't worry, I won't have another one for a couple of weeks :]
First Linaro Connect, then Plugfest.

/
    Leif


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS
  2018-03-14 12:24         ` Leif Lindholm
@ 2018-03-14 12:35           ` Ard Biesheuvel
  2018-03-14 12:39             ` Leif Lindholm
  0 siblings, 1 reply; 57+ messages in thread
From: Ard Biesheuvel @ 2018-03-14 12:35 UTC (permalink / raw)
  To: Leif Lindholm
  Cc: Girish Pathak, Evan Lloyd, Matteo Carlini, nd,
	edk2-devel@lists.01.org, Thomas Abraham, Arvind Chauhan

On 14 March 2018 at 12:24, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Thu, Jan 04, 2018 at 07:24:20PM +0000, Ard Biesheuvel wrote:
>> On 4 January 2018 at 18:55, Girish Pathak <Girish.Pathak@arm.com> wrote:
>> > Hi Ard,
>> >
>> >> -----Original Message-----
>> >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>> >> Ard Biesheuvel
>> >> Sent: 23 December 2017 14:12
>> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> >> Cc: "Matteo.Carlini@arm.com"@arm.com;
>> >> "leif.lindholm@linaro.org"@arm.com; "nd@arm.com"@arm.com; edk2-
>> >> devel@lists.01.org; Thomas Abraham <thomas.abraham@arm.com>; Arvind
>> >> Chauhan <Arvind.Chauhan@arm.com>;
>> >> "ard.biesheuvel@linaro.org"@arm.com
>> >> Subject: Re: [edk2] [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add
>> >> and update debug ASSERTS
>> >>
>> >> On 22 December 2017 at 19:08,  <evan.lloyd@arm.com> wrote:
>> >> > From: Girish Pathak <girish.pathak at arm.com>
>> >> >
>> >> > This change adds some debug assertions e.g to catch NULL pointer
>> >> > errors missing in PL11Lcd and HdLcd platform libraries.
>> >> >
>> >> > Contributed-under: TianoCore Contribution Agreement 1.1
>> >> > Signed-off-by: Girish Pathak <girish.pathak@arm.com>
>> >> > Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
>> >> > ---
>> >> >
>> >> Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpr
>> >> ess.c       | 22 +++++++++++++++++-
>> >> >
>> >> >
>> >> Platform/ARM/VExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArm
>> >> VEx
>> >> > press.c | 24 +++++++++++++++++++-
>> >> >  2 files changed, 44 insertions(+), 2 deletions(-)
>> >> >
>> >> > diff --git
>> >> >
>> >> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
>> >> pres
>> >> > s.c
>> >> >
>> >> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
>> >> pres
>> >> > s.c index
>> >> >
>> >> 6afd764897f49c64490ce891682f99bb0f5d993b..a8fe8696da0653017ce9fa6e4a
>> >> 86
>> >> > caf283bc04c9 100644
>> >> > ---
>> >> >
>> >> a/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
>> >> pres
>> >> > s.c
>> >> > +++
>> >> b/Platform/ARM/VExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx
>> >> > +++ press.c
>> >> > @@ -153,6 +153,9 @@ LcdPlatformGetVram (
>> >> >    EFI_STATUS              Status;
>> >> >    EFI_ALLOCATE_TYPE       AllocationType;
>> >> >
>> >> > +  ASSERT (VramBaseAddress != NULL);
>> >> > +  ASSERT (VramSize != NULL);
>> >> > +
>> >> >    // Set the vram size
>> >> >    *VramSize = LCD_VRAM_SIZE;
>> >> >
>> >> > @@ -171,6 +174,7 @@ LcdPlatformGetVram (
>> >> >                    VramBaseAddress
>> >> >                    );
>> >> >    if (EFI_ERROR (Status)) {
>> >> > +    ASSERT (FALSE);
>> >> >      return Status;
>> >> >    }
>> >> >
>> >> > @@ -181,8 +185,8 @@ LcdPlatformGetVram (
>> >> >                    *VramSize,
>> >> >                    EFI_MEMORY_WC
>> >> >                    );
>> >> > -  ASSERT_EFI_ERROR (Status);
>> >> >    if (EFI_ERROR (Status)) {
>> >> > +    ASSERT (FALSE);
>> >>
>> >> As in the sibling patch against EDK2, this patch makes it more difficult to
>> >> figure out what went wrong when you hit the ASSERT.
>> >> ASSERT_EFI_ERROR prints the value of Status, ASSERT(FALSE) only prints
>> >> '0 != 1'
>> >>
>> >
>> > This change(and other similar changes) is in response to review comments on patch v1
>> > https://lists.01.org/pipermail/edk2-devel/2017-October/015995.html
>> >
>> > with above reference, Can you please confirm if we should revert to the patch v1 version ?
>> >
>>
>> I guess Leif and I are in disagreement here. In particular, I think
>> his comment
>>
>> """
>> ASSERT (FALSE)?  (You already know Status is an EFI_ERROR, and a
>> console message saying ASSERT (Status) is not getting you out of
>> looking at the source code to find out what happened.)
>> """
>>
>> is misguided, given that ASSERT_EFI_ERROR (Status) will actually print
>> the value of Status to the debug console.
>
> I don't have a strong enough opinion on this that it should be
> listened to if you both agree.
>
> It's just the "if error, then assert if error" that breaks up the
> parsing flow for me. Could it make sense to use ASSERT_RETURN_ERROR
> instead?
>
> So
>       if (EFI_ERROR (Status)) {
>         ASSERT_RETURN_ERROR (Status);
>       }
>

Do you mean using ASSERT_RETURN_ERROR() rather than ASSERT_EFI_ERROR()?

That doesn't make sense: the former is for RETURN_STATUS type
variables and the latter for EFI_STATUS

>> However, the objections against putting function calls in ASSERT()s
>> are justified: ASSERT() should not have side effects if its condition
>> is met, and function calls may have side effects.
>>
>> I suppose we should wait for Leif to return on the 22nd before
>> proceeding with the review.
>> Apologies for the confusion, and for the delay.
>
> Apologies for the even more ridicilous delay.
> Err, I need to stop taking holidays or something.
>
> Don't worry, I won't have another one for a couple of weeks :]
> First Linaro Connect, then Plugfest.
>
> /
>     Leif


^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS
  2018-03-14 12:35           ` Ard Biesheuvel
@ 2018-03-14 12:39             ` Leif Lindholm
  0 siblings, 0 replies; 57+ messages in thread
From: Leif Lindholm @ 2018-03-14 12:39 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Girish Pathak, Evan Lloyd, Matteo Carlini, nd,
	edk2-devel@lists.01.org, Thomas Abraham, Arvind Chauhan

On Wed, Mar 14, 2018 at 12:35:03PM +0000, Ard Biesheuvel wrote:
> >> I guess Leif and I are in disagreement here. In particular, I think
> >> his comment
> >>
> >> """
> >> ASSERT (FALSE)?  (You already know Status is an EFI_ERROR, and a
> >> console message saying ASSERT (Status) is not getting you out of
> >> looking at the source code to find out what happened.)
> >> """
> >>
> >> is misguided, given that ASSERT_EFI_ERROR (Status) will actually print
> >> the value of Status to the debug console.
> >
> > I don't have a strong enough opinion on this that it should be
> > listened to if you both agree.
> >
> > It's just the "if error, then assert if error" that breaks up the
> > parsing flow for me. Could it make sense to use ASSERT_RETURN_ERROR
> > instead?
> >
> > So
> >       if (EFI_ERROR (Status)) {
> >         ASSERT_RETURN_ERROR (Status);
> >       }
> >
> 
> Do you mean using ASSERT_RETURN_ERROR() rather than ASSERT_EFI_ERROR()?

Yes.

> That doesn't make sense: the former is for RETURN_STATUS type
> variables and the latter for EFI_STATUS

Right, of course.
Makes the text look nicer though :)

Anyway, I'm OK with the original version.
Just wish we had a less redundant-looking way to describe this.

/
    Leif


^ permalink raw reply	[flat|nested] 57+ messages in thread

end of thread, other threads:[~2018-03-14 12:33 UTC | newest]

Thread overview: 57+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-22 19:08 [PATCH edk2-platforms v2 00/18] ARM: Update GOP evan.lloyd
2017-12-22 19:08 ` [PATCH edk2-platforms v2 01/18] ARM/VExpressPkg: Fix MODULE_TYPE of HDLCD/PL111 platform libraries evan.lloyd
2017-12-22 19:08 ` [PATCH edk2-platforms v2 02/18] ARM/VExpressPkg: Tidy HDLCD and PL11LCD platform Lib: Coding standard evan.lloyd
2017-12-23 14:07   ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 03/18] ARM/VExpressPkg: Tidy HdLcd/PL111Lcd code: Updated comments evan.lloyd
2017-12-23 14:08   ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 04/18] ARM/VExpressPkg: Remove unused PcdPL111LcdMaxMode from HDLCD inf evan.lloyd
2017-12-23 14:08   ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 05/18] ARM/VExpressPkg: PL111 and HDLCD: add const qualifier evan.lloyd
2017-12-23 14:09   ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 06/18] ARM/VExpressPkg: Add and update debug ASSERTS evan.lloyd
2017-12-23 14:12   ` Ard Biesheuvel
2018-01-04 18:55     ` Girish Pathak
2018-01-04 19:24       ` Ard Biesheuvel
2018-01-04 19:51         ` Evan Lloyd
2018-01-04 19:54           ` Ard Biesheuvel
2018-02-28 20:27             ` Evan Lloyd
2018-03-02 19:07               ` Ard Biesheuvel
2018-03-05 15:08                 ` Evan Lloyd
2018-03-06 11:16                   ` Ard Biesheuvel
2018-03-14 12:24         ` Leif Lindholm
2018-03-14 12:35           ` Ard Biesheuvel
2018-03-14 12:39             ` Leif Lindholm
2017-12-22 19:08 ` [PATCH edk2-platforms v2 07/18] ARM/VExpressPkg: PL111LcdArmVExpressLib: Minor code cleanup evan.lloyd
2017-12-23 14:13   ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 08/18] ARM/VExpressPkg: PL111 and HDLCD: Use FixedPcdGet32 evan.lloyd
2017-12-23 14:14   ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 09/18] ARM/VExpressPkg: PL11LcdArmVExpressLib: Improvement conditional evan.lloyd
2017-12-23 14:16   ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 10/18] ARM/VExpressPkg: HdLcdArmVExpressLib: Remove status check EFI_TIMEOUT evan.lloyd
2017-12-23 14:16   ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 11/18] ARM/VExpressPkg: HdLcdArmVExpressLib: Remove redundant Bpp evan.lloyd
2017-12-23 14:17   ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 12/18] ARM/VExpressPkg: Redefine LcdPlatformGetTimings function evan.lloyd
2017-12-23 14:18   ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 13/18] ARM/VExpressPkg: PL111 and HDLCD: Add PCD to select pixel format evan.lloyd
2017-12-23 16:00   ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 14/18] ARM/VExpressPkg: Reserving framebuffer at build evan.lloyd
2017-12-23 16:02   ` Ard Biesheuvel
2018-01-03 11:04     ` Evan Lloyd
2017-12-22 19:08 ` [PATCH edk2-platforms v2 15/18] ARM/VExpressPkg: New DP500/DP550/DP650 platform library evan.lloyd
2017-12-23 16:07   ` Ard Biesheuvel
2018-01-08 18:51     ` Evan Lloyd
2018-01-24 11:27       ` Alexei Fedorov
2018-01-24 11:34         ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 16/18] ARM/JunoPkg: Mapping Non-Trused SRAM as device memory evan.lloyd
2017-12-23 16:08   ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 17/18] ARM/JunoPkg: Adding SCMI MTL library evan.lloyd
2017-12-23 16:12   ` Ard Biesheuvel
2017-12-22 19:08 ` [PATCH edk2-platforms v2 18/18] ARM/JunoPkg: Add HDLCD platform library evan.lloyd
2017-12-23 16:22   ` Ard Biesheuvel
2018-01-09 18:21     ` Evan Lloyd
2018-01-09 18:26       ` Ard Biesheuvel
2018-01-10 11:45         ` Alexei Fedorov
2018-01-10 12:02           ` Ard Biesheuvel
2017-12-22 19:29 ` [PATCH edk2-platforms v2 00/18] ARM: Update GOP Ard Biesheuvel
2018-01-02 10:28   ` Evan Lloyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox