[edk2] [PATCH v6 edk2-platforms 6/6] Platform/HiKey: enable virtual keyboard

2018-05-23 Thread Haojian Zhuang
Enable virtual keyboard on HiKey platform. It detects the pattern
in memory and GPIO pin setting, and simulates them into virtual
key.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKey.dsc |  5 ++
 Platform/Hisilicon/HiKey/HiKey.fdf |  5 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf |  5 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h   |  5 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c   | 93 
 5 files changed, 113 insertions(+)

diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
b/Platform/Hisilicon/HiKey/HiKey.dsc
index 5cc4ff27f01b..83dd68a820b1 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -192,6 +192,11 @@ [Components.common]
   Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf 
b/Platform/Hisilicon/HiKey/HiKey.fdf
index 39020d27dbcd..2bca7232b6e5 100644
--- a/Platform/Hisilicon/HiKey/HiKey.fdf
+++ b/Platform/Hisilicon/HiKey/HiKey.fdf
@@ -123,6 +123,11 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
index 34734391b45a..41aa7f8081ed 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
@@ -28,11 +28,16 @@ [Packages]
   MdePkg/MdePkg.dec
 
 [LibraryClasses]
+  CacheMaintenanceLib
   DebugLib
   IoLib
   UefiLib
   UefiDriverEntryPoint
 
+[Protocols]
+  gEmbeddedGpioProtocolGuid
+  gPlatformVirtualKeyboardProtocolGuid
+
 [Guids]
   gEfiEndOfDxeEventGroupGuid
 
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
index 07f9ae6a949a..3d608183fa58 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
@@ -15,10 +15,15 @@
 #ifndef __HIKEYDXE_H__
 #define __HIKEYDXE_H__
 
+#include 
 #include 
 #include 
+#include 
 #include 
 
+#include 
+#include 
+
 #include 
 #include 
 
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
index b812f8bd483d..afd2f050896a 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
@@ -43,6 +43,8 @@ UartInit (
   MmioWrite32 (PMUSSI_ONOFF8_REG, Val);
 }
 
+STATIC EMBEDDED_GPIO*mGpio;
+
 STATIC
 VOID
 MtcmosInit (
@@ -87,6 +89,90 @@ HiKeyInitPeripherals (
 
 EFI_STATUS
 EFIAPI
+VirtualKeyboardRegister (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  Status = gBS->LocateProtocol (
+  ,
+  NULL,
+  (VOID **) 
+  );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardReset (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  if (mGpio == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  Status = mGpio->Set (mGpio, DETECT_J15_FASTBOOT, GPIO_MODE_INPUT);
+  return Status;
+}
+
+BOOLEAN
+EFIAPI
+VirtualKeyboardQuery (
+  IN VIRTUAL_KBD_KEY *VirtualKey
+  )
+{
+  EFI_STATUS   Status;
+  UINTNValue = 0;
+
+  if ((VirtualKey == NULL) || (mGpio == NULL)) {
+return FALSE;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+goto Done;
+  } else {
+Status = mGpio->Get (mGpio, DETECT_J15_FASTBOOT, );
+if (EFI_ERROR (Status) || (Value != 0)) {
+  return FALSE;
+}
+  }
+Done:
+  VirtualKey->Signature = VIRTUAL_KEYBOARD_KEY_SIGNATURE;
+  VirtualKey->Key.ScanCode = SCAN_NULL;
+  VirtualKey->Key.UnicodeChar = L'f';
+  return TRUE;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardClear (
+  IN VIRTUAL_KBD_KEY*VirtualKey
+  )
+{
+  if (VirtualKey == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+MmioWrite32 (ADB_REBOOT_ADDRESS, ADB_REBOOT_NONE);
+WriteBackInvalidateDataCacheRange ((VOID *)ADB_REBOOT_ADDRESS, 4);
+  }
+  return EFI_SUCCESS;
+}
+
+PLATFORM_VIRTUAL_KBD_PROTOCOL mVirtualKeyboard = {
+  VirtualKeyboardRegister,
+  VirtualKeyboardReset,
+  VirtualKeyboardQuery,
+  VirtualKeyboardClear
+};
+
+EFI_STATUS
+EFIAPI
 HiKeyEntryPoint (
   IN EFI_HANDLE ImageHandle,
   IN EFI_SYSTEM_TABLE   *SystemTable
@@ 

[edk2] [PATCH v6 edk2-platforms 4/6] Platform/Hisilicon/HiKey: add gpio platform driver

2018-05-23 Thread Haojian Zhuang
Add gpio platform driver to enable GPIO in HiKey platform.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf | 36 ++
 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c   | 74 

 2 files changed, 110 insertions(+)

diff --git a/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
new file mode 100644
index ..2791b9f44cad
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
@@ -0,0 +1,36 @@
+#
+#  Copyright (c) 2018, Linaro. 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= 0x0001001a
+  BASE_NAME  = HiKeyGpio
+  FILE_GUID  = b51a851c-7bf7-463f-b261-cfb158b7f699
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= HiKeyGpioEntryPoint
+
+[Sources.common]
+  HiKeyGpioDxe.c
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gPlatformGpioProtocolGuid
+
+[Depex]
+  TRUE
diff --git a/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
new file mode 100644
index ..be535f8f1903
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
@@ -0,0 +1,74 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro. 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 
+
+#include 
+
+GPIO_CONTROLLER gGpioDevice[] = {
+  //
+  // { base address, gpio index, gpio count }
+  //
+  { 0xf8011000, 0, 8 },// GPIO0
+  { 0xf8012000, 8, 8 },// GPIO1
+  { 0xf8013000, 16, 8 },   // GPIO2
+  { 0xf8014000, 24, 8 },   // GPIO3
+  { 0xf702, 32, 8 },   // GPIO4
+  { 0xf7021000, 40, 8 },   // GPIO5
+  { 0xf7022000, 48, 8 },   // GPIO6
+  { 0xf7023000, 56, 8 },   // GPIO7
+  { 0xf7024000, 64, 8 },   // GPIO8
+  { 0xf7025000, 72, 8 },   // GPIO9
+  { 0xf7026000, 80, 8 },   // GPIO10
+  { 0xf7027000, 88, 8 },   // GPIO11
+  { 0xf7028000, 96, 8 },   // GPIO12
+  { 0xf7029000, 104, 8 },  // GPIO13
+  { 0xf702a000, 112, 8 },  // GPIO14
+  { 0xf702b000, 120, 8 },  // GPIO15
+  { 0xf702c000, 128, 8 },  // GPIO16
+  { 0xf702d000, 136, 8 },  // GPIO17
+  { 0xf702e000, 144, 8 },  // GPIO18
+  { 0xf702f000, 152, 8 }   // GPIO19
+};
+
+PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
+  //
+  // { global gpio count, gpio controller counter, GPIO_CONTROLLER }
+  //
+  160, 20, gGpioDevice
+};
+
+EFI_STATUS
+EFIAPI
+HiKeyGpioEntryPoint (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  EFI_HANDLE  Handle;
+
+  // Install the Embedded Platform GPIO Protocol onto a new handle
+  Handle = NULL;
+  Status = gBS->InstallMultipleProtocolInterfaces(
+  ,
+  , ,
+  NULL
+ );
+  if (EFI_ERROR(Status)) {
+Status = EFI_OUT_OF_RESOURCES;
+  }
+
+  return Status;
+}
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v6 edk2-platforms 5/6] Platform/HiKey: do basic initialization on hikey

2018-05-23 Thread Haojian Zhuang
Do some basic initialization on HiKey platform, such as pin
setting, regulators and making peripherals out of reset mode.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKey.dsc|   3 +
 Platform/Hisilicon/HiKey/HiKey.fdf|   3 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf|  40 
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h  |  31 ++
 Silicon/Hisilicon/Hi6220/Include/Hi6220.h |   6 ++
 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h |  50 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c  | 102 
 7 files changed, 235 insertions(+)

diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
b/Platform/Hisilicon/HiKey/HiKey.dsc
index 5c1604d7f689..5cc4ff27f01b 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -189,8 +189,11 @@ [Components.common]
   #
   # GPIO
   #
+  Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+
   #
   # MMC/SD
   #
diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf 
b/Platform/Hisilicon/HiKey/HiKey.fdf
index 2a5c5a4d6e79..39020d27dbcd 100644
--- a/Platform/Hisilicon/HiKey/HiKey.fdf
+++ b/Platform/Hisilicon/HiKey/HiKey.fdf
@@ -120,8 +120,11 @@ [FV.FvMain]
   #
   # GPIO
   #
+  INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+
   #
   # Multimedia Card Interface
   #
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
new file mode 100644
index ..34734391b45a
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
@@ -0,0 +1,40 @@
+#
+#  Copyright (c) 2013 - 2014, ARM Ltd. All rights reserved.
+#  Copyright (c) 2018, Linaro 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.
+#
+
+[Defines]
+  INF_VERSION= 0x0001001a
+  BASE_NAME  = HiKeyDxe
+  FILE_GUID  = f567684b-1089-4214-8881-d64b20cbda2f
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= HiKeyEntryPoint
+
+[Sources.common]
+  HiKeyDxe.c
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  IoLib
+  UefiLib
+  UefiDriverEntryPoint
+
+[Guids]
+  gEfiEndOfDxeEventGroupGuid
+
+[Depex]
+  TRUE
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
new file mode 100644
index ..07f9ae6a949a
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
@@ -0,0 +1,31 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro 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.
+*
+**/
+
+#ifndef __HIKEYDXE_H__
+#define __HIKEYDXE_H__
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define DETECT_J15_FASTBOOT  24   // GPIO3_0
+
+#define ADB_REBOOT_ADDRESS   0x05F01000
+#define ADB_REBOOT_BOOTLOADER0x77665500
+#define ADB_REBOOT_NONE  0x77665501
+
+#endif /* __HIKEYDXE_H__ */
diff --git a/Silicon/Hisilicon/Hi6220/Include/Hi6220.h 
b/Silicon/Hisilicon/Hi6220/Include/Hi6220.h
index 203424adfc8b..9b2508955772 100644
--- a/Silicon/Hisilicon/Hi6220/Include/Hi6220.h
+++ b/Silicon/Hisilicon/Hi6220/Include/Hi6220.h
@@ -23,6 +23,12 @@
 #define HI6220_PERIPH_BASE  0xF400
 #define HI6220_PERIPH_SZ0x0580
 
+#define IOMG_BASE   0xF701
+#define IOMG_080_REG(IOMG_BASE + 0x140)
+
+#define IOCG_BASE   0xF7010800
+#define IOCG_084_REG(IOCG_BASE + 0x150)
+
 #define PERI_CTRL_BASE  0xF703
 #define 

[edk2] [PATCH v6 edk2-platforms 2/6] Platform/HiKey960: do basic initialization

2018-05-23 Thread Haojian Zhuang
Do some basic initliazation on peripherals, such as pins and
regulators.

The hardcoding code is taken from non-open reference code.
Can't fix it for lack of documents.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Silicon/Hisilicon/Hi3660/Hi3660.dec |  32 
 Platform/Hisilicon/HiKey960/HiKey960.dsc|   2 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf|   2 +
 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  47 +
 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   |  37 
 Silicon/Hisilicon/Hi3660/Include/Hi3660.h   | 195 
+++
 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 198 

 7 files changed, 513 insertions(+)

diff --git a/Silicon/Hisilicon/Hi3660/Hi3660.dec 
b/Silicon/Hisilicon/Hi3660/Hi3660.dec
new file mode 100644
index ..72de61e0635c
--- /dev/null
+++ b/Silicon/Hisilicon/Hi3660/Hi3660.dec
@@ -0,0 +1,32 @@
+#
+#  Copyright (c) 2018, Linaro 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]
+  DEC_SPECIFICATION  = 0x0001001a
+  PACKAGE_NAME   = Hi3660
+  PACKAGE_GUID   = e457ba7c-faba-4dea-b274-f5962d016c79
+  PACKAGE_VERSION= 0.1
+
+
+#
+# Include Section - list of Include Paths that are provided by this package.
+#   Comments are used for Keywords and Module Types.
+#
+# Supported Module Types:
+#  BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER 
DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
+#
+
+[Includes.common]
+  Include# Root include for the package
+
+[Guids.common]
+  gHi3660TokenSpaceGuid  =  { 0x4abc73fa, 0x8a49, 0x4d2c, { 0x95, 0x44, 
0x17, 0x87, 0x29, 0x06, 0x20, 0xb4 } }
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 3da1b8556321..6cc1c1edf453 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -182,6 +182,8 @@ [Components.common]
   Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
+
   #
   # USB Host Support
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index 162dbaaf2646..b7d70b010598 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -123,6 +123,8 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
+
   #
   # USB Host Support
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
new file mode 100644
index ..a1a7d005ce8b
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
@@ -0,0 +1,47 @@
+#
+#  Copyright (c) 2018, Linaro 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= 0x0001001a
+  BASE_NAME  = HiKey960Dxe
+  FILE_GUID  = 6d824b2c-640e-4643-b9f2-9c09e8bff429
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= HiKey960EntryPoint
+
+[Sources.common]
+  HiKey960Dxe.c
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+  Silicon/Hisilicon/Hi3660/Hi3660.dec
+
+[LibraryClasses]
+  BaseMemoryLib
+  CacheMaintenanceLib
+  DxeServicesTableLib
+  IoLib
+  PcdLib
+  TimerLib
+  UefiDriverEntryPoint
+  UefiLib
+
+[Protocols]
+  

[edk2] [PATCH v6 edk2-platforms 1/6] Platform/Hisilicon/HiKey960: add gpio platform driver

2018-05-23 Thread Haojian Zhuang
Add gpio platform driver to enable GPIO in HiKey960 platform.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc|  1 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf|  1 +
 Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf | 35 +
 Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c   | 83 

 4 files changed, 120 insertions(+)

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 36f43956ab40..3da1b8556321 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -179,6 +179,7 @@ [Components.common]
   #
   # GPIO
   #
+  Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index 655032a36c53..162dbaaf2646 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -120,6 +120,7 @@ [FV.FvMain]
   #
   # GPIO
   #
+  INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf 
b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
new file mode 100644
index ..5ea3747321d8
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
@@ -0,0 +1,35 @@
+#
+#  Copyright (c) 2018, Linaro. 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= 0x0001001a
+  BASE_NAME  = HiKey960GpioDxe
+  FILE_GUID  = 6aa12592-7e36-4aec-acf8-2ac2fd13815c
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= HiKey960GpioEntryPoint
+
+[Sources]
+  HiKey960GpioDxe.c
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  UefiDriverEntryPoint
+
+[Protocols]
+  gPlatformGpioProtocolGuid
+
+[Depex]
+  TRUE
diff --git a/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
new file mode 100644
index ..b196455072cc
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
@@ -0,0 +1,83 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro. 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 
+
+#include 
+
+GPIO_CONTROLLER gGpioDevice[] = {
+  //
+  // { base address, gpio index, gpio count }
+  //
+  { 0xe8a0b000, 0, 8 },// GPIO0
+  { 0xe8a0c000, 8, 8 },// GPIO1
+  { 0xe8a0d000, 16, 8 },   // GPIO2
+  { 0xe8a0e000, 24, 8 },   // GPIO3
+  { 0xe8a0f000, 32, 8 },   // GPIO4
+  { 0xe8a1, 40, 8 },   // GPIO5
+  { 0xe8a11000, 48, 8 },   // GPIO6
+  { 0xe8a12000, 56, 8 },   // GPIO7
+  { 0xe8a13000, 64, 8 },   // GPIO8
+  { 0xe8a14000, 72, 8 },   // GPIO9
+  { 0xe8a15000, 80, 8 },   // GPIO10
+  { 0xe8a16000, 88, 8 },   // GPIO11
+  { 0xe8a17000, 96, 8 },   // GPIO12
+  { 0xe8a18000, 104, 8 },  // GPIO13
+  { 0xe8a19000, 112, 8 },  // GPIO14
+  { 0xe8a1a000, 120, 8 },  // GPIO15
+  { 0xe8a1b000, 128, 8 },  // GPIO16
+  { 0xe8a1c000, 136, 8 },  // GPIO17
+  { 0xff3b4000, 144, 8 },  // GPIO18
+  { 0xff3b5000, 152, 8 },  // GPIO19
+  { 0xe8a1f000, 160, 8 },  // GPIO20
+  { 0xe8a2, 168, 8 },  // GPIO21
+  { 0xfff0b000, 176, 8 },  // GPIO22
+  { 0xfff0c000, 184, 8 },  // GPIO23
+  { 0xfff0d000, 192, 8 },  // GPIO24
+  { 0xfff0e000, 200, 8 },  // GPIO25
+  { 0xfff0f000, 208, 8 },  // GPIO26
+  { 0xfff1, 216, 8 },  // GPIO27
+  { 0xfff1d000, 224, 8 },  // GPIO28
+};
+
+PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
+  //
+  // { global gpio count, gpio controller count, 

[edk2] [PATCH v6 edk2-platforms 0/6] enable virtual keyboards

2018-05-23 Thread Haojian Zhuang
Changelog:
v6:
  * Append missing HiKey960Gpio files in v5.
v5:
  * Remove unused functions and definitions.
  * Add commit comments for hardcoding values.
v4:
  * Fix hard-coding value.
  * Remove unused functions.
v3:
  * Remove ADC and boardid, since it's not really used yet.
  * Add more comments.
v2:
  * Split HiKeyDxe & HiKey960Dxe into smaller patches.
  * Replace hardcoding register with macro.
v1:
  * Enable GPIO driver.
  * Enable virtual keyboard driver.

Haojian Zhuang (6):
  Platform/Hisilicon/HiKey960: add gpio platform driver
  Platform/HiKey960: do basic initialization
  Platform/HiKey960: enable virtual keyboard
  Platform/Hisilicon/HiKey: add gpio platform driver
  Platform/HiKey: do basic initialization on hikey
  Platform/HiKey: enable virtual keyboard

 Silicon/Hisilicon/Hi3660/Hi3660.dec |  32 +++
 Platform/Hisilicon/HiKey/HiKey.dsc  |   8 +
 Platform/Hisilicon/HiKey960/HiKey960.dsc|   8 +
 Platform/Hisilicon/HiKey/HiKey.fdf  |   8 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf|   8 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf  |  45 +++
 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf  |  36 +++
 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  48 
 Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf |  35 +++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h|  36 +++
 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   |  47 
 Silicon/Hisilicon/Hi3660/Include/Hi3660.h   | 195 
+
 Silicon/Hisilicon/Hi6220/Include/Hi6220.h   |   6 +
 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h   |  50 
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c| 195 
+
 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c|  74 +
 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 295 

 Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c   |  83 ++
 18 files changed, 1209 insertions(+)
 create mode 100644 Silicon/Hisilicon/Hi3660/Hi3660.dec
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hi3660.h
 create mode 100644 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v6 edk2-platforms 3/6] Platform/HiKey960: enable virtual keyboard

2018-05-23 Thread Haojian Zhuang
Enable virtual keyboard on HiKey960 platform. It checks two
conditions, such as pattern in memory and GPIO pin setting.
Since code is ported from non-open

The hardcoding code is taken from non-open reference code.
Can't fix it for lack of documents.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc|  5 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf|  5 +
 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  1 +
 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   | 10 ++
 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 97 

 5 files changed, 118 insertions(+)

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 6cc1c1edf453..79e68754976d 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -182,6 +182,11 @@ [Components.common]
   Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index b7d70b010598..d65f77878575 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -123,6 +123,11 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
index a1a7d005ce8b..46a9a5803e3d 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
@@ -39,6 +39,7 @@ [LibraryClasses]
 
 [Protocols]
   gEmbeddedGpioProtocolGuid
+  gPlatformVirtualKeyboardProtocolGuid
 
 [Guids]
   gEfiEndOfDxeEventGroupGuid
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
index 9a4c66f42c50..211eea55aa54 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
@@ -21,6 +21,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -29,6 +30,15 @@
 #include 
 #include 
 
+#include 
+#include 
+
+#define ADB_REBOOT_ADDRESS   0x3210
+#define ADB_REBOOT_BOOTLOADER0x77665500
+#define ADB_REBOOT_NONE  0x77665501
+
+#define DETECT_SW_FASTBOOT   68// GPIO8_4
+
 enum {
   BOOT_MODE_RECOVERY  = 0,
   BOOT_MODE_MASK = 1,
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
index 7c1705241e88..7ff2f118128d 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
@@ -14,6 +14,8 @@
 
 #include "HiKey960Dxe.h"
 
+STATIC EMBEDDED_GPIO   *mGpio;
+
 STATIC
 VOID
 InitSdCard (
@@ -166,6 +168,94 @@ OnEndOfDxe (
 
 EFI_STATUS
 EFIAPI
+VirtualKeyboardRegister (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  Status = gBS->LocateProtocol (
+  ,
+  NULL,
+  (VOID **) 
+  );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardReset (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  if (mGpio == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  //
+  // Configure GPIO68 as GPIO function
+  //
+  MmioWrite32 (0xe896c108, 0);
+  Status = mGpio->Set (mGpio, DETECT_SW_FASTBOOT, GPIO_MODE_INPUT);
+  return Status;
+}
+
+BOOLEAN
+EFIAPI
+VirtualKeyboardQuery (
+  IN VIRTUAL_KBD_KEY *VirtualKey
+  )
+{
+  EFI_STATUS   Status;
+  UINTNValue = 0;
+
+  if ((VirtualKey == NULL) || (mGpio == NULL)) {
+return FALSE;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+goto Done;
+  } else {
+Status = mGpio->Get (mGpio, DETECT_SW_FASTBOOT, );
+if (EFI_ERROR (Status) || (Value != 0)) {
+  return FALSE;
+}
+  }
+Done:
+  VirtualKey->Signature = VIRTUAL_KEYBOARD_KEY_SIGNATURE;
+  VirtualKey->Key.ScanCode = SCAN_NULL;
+  VirtualKey->Key.UnicodeChar = L'f';
+  return TRUE;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardClear (
+  IN VIRTUAL_KBD_KEY*VirtualKey
+  )
+{
+  if (VirtualKey == NULL) {
+

[edk2] [PATCH v2 7/7] OvmfPkg/Virtio10Dxe: convert to PciCapLib

2018-05-23 Thread Laszlo Ersek
Replace the manual capability list parsing in OvmfPkg/Virtio10Dxe with
PciCapLib and PciCapPciIoLib API calls.

The VIRTIO_PCI_CAP_LINK structure type is now superfluous. (Well, it
always has been; we should have used EFI_PCI_CAPABILITY_HDR.)

Also, EFI_PCI_CAPABILITY_VENDOR_HDR is now included at the front of
VIRTIO_PCI_CAP. No driver other than Virtio10Dxe relies on VIRTIO_PCI_CAP.

Cc: Ard Biesheuvel 
Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek 
---

Notes:
v2:
- no changes

 OvmfPkg/Virtio10Dxe/Virtio10.inf|   2 +
 OvmfPkg/Include/IndustryStandard/Virtio10.h |   7 +-
 OvmfPkg/Virtio10Dxe/Virtio10.c  | 135 +++-
 3 files changed, 52 insertions(+), 92 deletions(-)

diff --git a/OvmfPkg/Virtio10Dxe/Virtio10.inf b/OvmfPkg/Virtio10Dxe/Virtio10.inf
index c4ef15d94bfc..db0cb1189a29 100644
--- a/OvmfPkg/Virtio10Dxe/Virtio10.inf
+++ b/OvmfPkg/Virtio10Dxe/Virtio10.inf
@@ -32,6 +32,8 @@ [LibraryClasses]
   BaseMemoryLib
   DebugLib
   MemoryAllocationLib
+  PciCapLib
+  PciCapPciIoLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
   UefiLib
diff --git a/OvmfPkg/Include/IndustryStandard/Virtio10.h 
b/OvmfPkg/Include/IndustryStandard/Virtio10.h
index c5efb5cfcb8a..7d51aa36b326 100644
--- a/OvmfPkg/Include/IndustryStandard/Virtio10.h
+++ b/OvmfPkg/Include/IndustryStandard/Virtio10.h
@@ -16,6 +16,7 @@
 #ifndef _VIRTIO_1_0_H_
 #define _VIRTIO_1_0_H_
 
+#include 
 #include 
 
 //
@@ -29,11 +30,7 @@
 //
 #pragma pack (1)
 typedef struct {
-  UINT8 CapId;   // Capability identifier (generic)
-  UINT8 CapNext; // Link to next capability (generic)
-} VIRTIO_PCI_CAP_LINK;
-
-typedef struct {
+  EFI_PCI_CAPABILITY_VENDOR_HDR VendorHdr;
   UINT8  ConfigType; // Identifies the specific VirtIo 1.0 config structure
   UINT8  Bar;// The BAR that contains the structure
   UINT8  Padding[3];
diff --git a/OvmfPkg/Virtio10Dxe/Virtio10.c b/OvmfPkg/Virtio10Dxe/Virtio10.c
index e9b50b6e437b..9ebb72c76bfd 100644
--- a/OvmfPkg/Virtio10Dxe/Virtio10.c
+++ b/OvmfPkg/Virtio10Dxe/Virtio10.c
@@ -21,6 +21,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -184,48 +186,6 @@ GetBarType (
 }
 
 
-/**
-  Read a slice from PCI config space at the given offset, then advance the
-  offset.
-
-  @param [in] PciIo   The EFI_PCI_IO_PROTOCOL instance that represents the
-  device.
-
-  @param [in,out] Offset  On input, the offset in PCI config space to start
-  reading from. On output, the offset of the first byte
-  that was not read. On error, Offset is not modified.
-
-  @param [in] SizeThe number of bytes to read.
-
-  @param [out]Buffer  On output, the bytes read from PCI config space are
-  stored in this object.
-
-  @retval EFI_SUCCESS  Size bytes have been transferred from PCI config space
-   (from Offset) to Buffer, and Offset has been incremented
-   by Size.
-
-  @return  Error codes from PciIo->Pci.Read().
-**/
-STATIC
-EFI_STATUS
-ReadConfigSpace (
-  IN EFI_PCI_IO_PROTOCOL *PciIo,
-  IN OUT UINT32  *Offset,
-  IN UINTN   Size,
- OUT VOID*Buffer
-  )
-{
-  EFI_STATUS Status;
-
-  Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, *Offset, Size, Buffer);
-  if (EFI_ERROR (Status)) {
-return Status;
-  }
-  *Offset += (UINT32)Size;
-  return EFI_SUCCESS;
-}
-
-
 /*
   Traverse the PCI capabilities list of a virtio-1.0 device, and capture the
   locations of the interesting virtio-1.0 register blocks.
@@ -239,57 +199,51 @@ ReadConfigSpace (
 will have been updated from the PCI
 capabilities found.
 
-  @param[in] CapabilityPtr  The offset of the first capability in PCI
-config space, taken from the standard PCI
-device header.
-
   @retval EFI_SUCCESS  Traversal successful.
 
-  @return  Error codes from the ReadConfigSpace() and GetBarType()
-   helper functions.
+  @return  Error codes from PciCapPciIoLib, PciCapLib, and the
+   GetBarType() helper function.
 */
 STATIC
 EFI_STATUS
 ParseCapabilities (
-  IN OUT VIRTIO_1_0_DEV *Device,
-  IN UINT8  CapabilityPtr
+  IN OUT VIRTIO_1_0_DEV *Device
   )
 {
-  UINT32  Offset;
-  VIRTIO_PCI_CAP_LINK CapLink;
+  EFI_STATUS   Status;
+  PCI_CAP_DEV  *PciDevice;
+  PCI_CAP_LIST *CapList;
+  UINT16   VendorInstance;
+  PCI_CAP  *VendorCap;
 
-  for (Offset = CapabilityPtr & 0xFC;
-   Offset > 0;
-   Offset = CapLink.CapNext & 0xFC
-   ) {
-EFI_STATUSStatus;
+  Status = PciCapPciIoDeviceInit (Device->PciIo, );
+  

[edk2] [PATCH v2 6/7] OvmfPkg/PciHotPlugInitDxe: convert to PciCapLib

2018-05-23 Thread Laszlo Ersek
Replace the manual capability list parsing in OvmfPkg/PciHotPlugInitDxe
with PciCapLib and PciCapPciSegmentLib API calls.

Cc: Ard Biesheuvel 
Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek 
---

Notes:
v2:
- no changes

 OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf |   5 +
 OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c   | 267 +++-
 2 files changed, 102 insertions(+), 170 deletions(-)

diff --git a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf 
b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
index 38043986eb67..cc2b60d44263 100644
--- a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
+++ b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
@@ -35,6 +35,8 @@ [LibraryClasses]
   DebugLib
   DevicePathLib
   MemoryAllocationLib
+  PciCapLib
+  PciCapPciSegmentLib
   PciLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
@@ -42,5 +44,8 @@ [LibraryClasses]
 [Protocols]
   gEfiPciHotPlugInitProtocolGuid ## ALWAYS_PRODUCES
 
+[Pcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId ## CONSUMES
+
 [Depex]
   TRUE
diff --git a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c 
b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c
index 177e1a62120d..3449796878ef 100644
--- a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c
+++ b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c
@@ -14,6 +14,7 @@
 **/
 
 #include 
+#include 
 #include 
 
 #include 
@@ -21,12 +22,20 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
 #include 
 #include 
 
+//
+// TRUE if the PCI platform supports extended config space, FALSE otherwise.
+//
+STATIC BOOLEAN mPciExtConfSpaceSupported;
+
+
 //
 // The protocol interface this driver produces.
 //
@@ -248,91 +257,11 @@ HighBitSetRoundUp64 (
 }
 
 
-/**
-  Read a slice from conventional PCI config space at the given offset, then
-  advance the offset.
-
-  @param[in] PciAddress  The address of the PCI Device -- Bus, Device, Function
- -- in UEFI (not PciLib) encoding.
-
-  @param[in,out] Offset  On input, the offset in conventional PCI config space
- to start reading from. On output, the offset of the
- first byte that was not read.
-
-  @param[in] SizeThe number of bytes to read.
-
-  @param[out] Buffer On output, the bytes read from PCI config space are
- stored in this object.
-**/
-STATIC
-VOID
-ReadConfigSpace (
-  IN CONST EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS *PciAddress,
-  IN OUT UINT8 *Offset,
-  IN UINT8 Size,
-  OUTVOID  *Buffer
-  )
-{
-  PciReadBuffer (
-PCI_LIB_ADDRESS (
-  PciAddress->Bus,
-  PciAddress->Device,
-  PciAddress->Function,
-  *Offset
-  ),
-Size,
-Buffer
-);
-  *Offset += Size;
-}
-
-
-/**
-  Convenience wrapper macro for ReadConfigSpace().
-
-  Given the following conditions:
-
-  - HeaderField is the first field in the structure pointed-to by Struct,
-
-  - Struct->HeaderField has been populated from the conventional PCI config
-space of the PCI device identified by PciAddress,
-
-  - *Offset points one past HeaderField in the conventional PCI config space of
-the PCI device identified by PciAddress,
-
-  populate the rest of *Struct from conventional PCI config space, starting at
-  *Offset. Finally, increment *Offset so that it point one past *Struct.
-
-  @param[in] PciAddress  The address of the PCI Device -- Bus, Device, Function
- -- in UEFI (not PciLib) encoding. Type: pointer to
- CONST EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS.
-
-  @param[in,out] Offset  On input, the offset in conventional PCI config space
- to start reading from; one past Struct->HeaderField.
- On output, the offset of the first byte that was not
- read; one past *Struct. Type: pointer to UINT8.
-
-  @param[out] Struct The structure to complete. Type: pointer to structure
- object.
-
-  @param[in] HeaderField The name of the first field in *Struct, after which
- *Struct should be populated. Type: structure member
- identifier.
-**/
-#define COMPLETE_CONFIG_SPACE_STRUCT(PciAddress, Offset, Struct, HeaderField) \
-  ReadConfigSpace (   \
-(PciAddress), \
-(Offset), \
-(UINT8)(sizeof *(Struct) - sizeof ((Struct)->HeaderField)),   \
-&((Struct)->HeaderField) + 1  \
-)
-
-
 /**
   Look 

[edk2] [PATCH v2 3/7] OvmfPkg: introduce PciCapPciIoLib

2018-05-23 Thread Laszlo Ersek
Add a library class, and a UEFI_DRIVER lib instance, that are layered on
top of PciCapLib, and allow clients to plug an EFI_PCI_IO_PROTOCOL backend
into PciCapLib, for config space access.

(Side note:

Although the UEFI spec says that EFI_PCI_IO_PROTOCOL_CONFIG() returns
EFI_UNSUPPORTED if "[t]he address range specified by Offset, Width, and
Count is not valid for the PCI configuration header of the PCI
controller", this patch doesn't directly document the EFI_UNSUPPORTED
error code, for ProtoDevTransferConfig() and its callers
ProtoDevReadConfig() and ProtoDevWriteConfig(). Instead, the patch refers
to "unspecified error codes". The reason is that in edk2, the
PciIoConfigRead() and PciIoConfigWrite() functions [1] can also return
EFI_INVALID_PARAMETER for the above situation.

Namely, PciIoConfigRead() and PciIoConfigWrite() first call
PciIoVerifyConfigAccess(), which indeed produces the standard
EFI_UNSUPPORTED error code, if the device's config space is exceeded.
However, if PciIoVerifyConfigAccess() passes, and we reach
RootBridgeIoPciRead() and RootBridgeIoPciWrite() [2], then
RootBridgeIoCheckParameter() can still fail, e.g. if the root bridge
doesn't support extended config space (see commit 014b472053ae3).

For all kinds of Limit violations in IO, MMIO, and config space,
RootBridgeIoCheckParameter() returns EFI_INVALID_PARAMETER, not
EFI_UNSUPPORTED. That error code is then propagated up to, and out of,
PciIoConfigRead() and PciIoConfigWrite().

[1] MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
[2] MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c
)

Cc: Ard Biesheuvel 
Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek 
---

Notes:
v2:
- move library from MdePkg to OvmfPkg, for initial introduction

 OvmfPkg/OvmfPkg.dec   |   5 +
 OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf |  36 +++
 OvmfPkg/Include/Library/PciCapPciIoLib.h  |  58 +
 OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.h   |  44 
 OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.c   | 243 

 5 files changed, 386 insertions(+)

diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index fbec1cfe4a8e..dc5597db4136 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -35,6 +35,11 @@ [LibraryClasses]
   #  config space.
   PciCapLib|Include/Library/PciCapLib.h
 
+  ##  @libraryclass  Layered on top of PciCapLib, allows clients to plug an
+  #  EFI_PCI_IO_PROTOCOL backend into PciCapLib, for config
+  #  space access.
+  PciCapPciIoLib|Include/Library/PciCapPciIoLib.h
+
   ##  @libraryclass  Layered on top of PciCapLib, allows clients to plug a
   #  PciSegmentLib backend into PciCapLib, for config space
   #  access.
diff --git a/OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf 
b/OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf
new file mode 100644
index ..2e14acb0ab75
--- /dev/null
+++ b/OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf
@@ -0,0 +1,36 @@
+## @file
+# Plug an EFI_PCI_IO_PROTOCOL backend into PciCapLib, for config space access.
+#
+# Copyright (C) 2018, Red Hat, Inc.
+#
+# 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= 1.27
+  BASE_NAME  = UefiPciCapPciIoLib
+  FILE_GUID  = 4102F4FE-DA10-4F0F-AC18-4982ED506154
+  MODULE_TYPE= UEFI_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = PciCapPciIoLib
+
+[Sources]
+  UefiPciCapPciIoLib.h
+  UefiPciCapPciIoLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+  DebugLib
+  MemoryAllocationLib
+
+[Protocols]
+  gEfiPciIoProtocolGuid ## CONSUMES
diff --git a/OvmfPkg/Include/Library/PciCapPciIoLib.h 
b/OvmfPkg/Include/Library/PciCapPciIoLib.h
new file mode 100644
index ..553715fd5080
--- /dev/null
+++ b/OvmfPkg/Include/Library/PciCapPciIoLib.h
@@ -0,0 +1,58 @@
+/** @file
+  Library class layered on top of PciCapLib that allows clients to plug an
+  EFI_PCI_IO_PROTOCOL backend into PciCapLib, for config space access.
+
+  Copyright (C) 2018, Red Hat, Inc.
+
+  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 

[edk2] [PATCH v2 4/7] OvmfPkg: resolve PciCapLib, PciCapPciSegmentLib, PciCapPciIoLib

2018-05-23 Thread Laszlo Ersek
Resolve the PciCapLib, PciCapPciSegmentLib, and PciCapPciIoLib classes to
their single respective instances. Later patches will use these lib
classes in OvmfPkg drivers.

Cc: Ard Biesheuvel 
Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek 
---

Notes:
v2:
- update references from MdePkg to OvmfPkg

 OvmfPkg/OvmfPkgIa32.dsc| 3 +++
 OvmfPkg/OvmfPkgIa32X64.dsc | 3 +++
 OvmfPkg/OvmfPkgX64.dsc | 3 +++
 3 files changed, 9 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 251434a9ff7c..a2c995b910cd 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -127,6 +127,9 @@ [LibraryClasses]
   PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
   PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
   PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
+  PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
+  
PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf
+  PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf
   
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
   SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index ce247a59d61a..bc7db229d2d9 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -132,6 +132,9 @@ [LibraryClasses]
   PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
   PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
   PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
+  PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
+  
PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf
+  PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf
   
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
   SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 67f7e155ee3e..0767b34d1877 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -132,6 +132,9 @@ [LibraryClasses]
   PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
   PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
   PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
+  PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
+  
PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf
+  PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf
   
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
   SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf
-- 
2.14.1.3.gb7cf6e02401b


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 5/7] ArmVirtPkg: resolve PciCapLib, PciCapPciSegmentLib, PciCapPciIoLib

2018-05-23 Thread Laszlo Ersek
Resolve the PciCapLib, PciCapPciSegmentLib, and PciCapPciIoLib classes to
their single respective instances under OvmfPkg. Later patches will use
those lib classes in OvmfPkg drivers, some of which are included in
ArmVirt platforms.

Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek 
---

Notes:
v2:
- update references from MdePkg to OvmfPkg

 ArmVirtPkg/ArmVirt.dsc.inc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 35bccb3dc1f4..766e4f598a07 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -131,6 +131,9 @@ [LibraryClasses.common]
   # PCI Libraries
   PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
   
PciExpressLib|ArmVirtPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf
+  PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
+  
PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf
+  PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf
 
   # USB Libraries
   UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
-- 
2.14.1.3.gb7cf6e02401b


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2 1/7] OvmfPkg: introduce PciCapLib

2018-05-23 Thread Laszlo Ersek
Add a library class, and a BASE lib instance, to work more easily with PCI
capabilities in PCI config space. Functions are provided to parse
capabilities lists, and to locate, describe, read and write capabilities.
PCI config space access is abstracted away.

Cc: Ard Biesheuvel 
Cc: Jordan Justen 
Suggested-by: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek 
---

Notes:
v2:
- move library from MdePkg to OvmfPkg, for initial introduction

 OvmfPkg/OvmfPkg.dec |4 +
 OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf |   38 +
 OvmfPkg/Include/Library/PciCapLib.h |  429 +
 OvmfPkg/Library/BasePciCapLib/BasePciCapLib.h   |   60 ++
 OvmfPkg/Library/BasePciCapLib/BasePciCapLib.c   | 1007 
 5 files changed, 1538 insertions(+)

diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index c01a2ca7219a..74818a2e2a19 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -31,6 +31,10 @@ [LibraryClasses]
   #
   NvVarsFileLib|Include/Library/NvVarsFileLib.h
 
+  ##  @libraryclass  Provides services to work with PCI capabilities in PCI
+  #  config space.
+  PciCapLib|Include/Library/PciCapLib.h
+
   ##  @libraryclass  Access QEMU's firmware configuration interface
   #
   QemuFwCfgLib|Include/Library/QemuFwCfgLib.h
diff --git a/OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf 
b/OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
new file mode 100644
index ..9a7428a589c2
--- /dev/null
+++ b/OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
@@ -0,0 +1,38 @@
+## @file
+# Work with PCI capabilities in PCI config space.
+#
+# Provides functions to parse capabilities lists, and to locate, describe, read
+# and write capabilities. PCI config space access is abstracted away.
+#
+# Copyright (C) 2018, Red Hat, Inc.
+#
+# 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= 1.27
+  BASE_NAME  = BasePciCapLib
+  FILE_GUID  = 6957540D-F7B5-4D5B-BEE4-FC14114DCD3C
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = PciCapLib
+
+[Sources]
+  BasePciCapLib.h
+  BasePciCapLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+  BaseMemoryLib
+  DebugLib
+  MemoryAllocationLib
+  OrderedCollectionLib
diff --git a/OvmfPkg/Include/Library/PciCapLib.h 
b/OvmfPkg/Include/Library/PciCapLib.h
new file mode 100644
index ..22a1ad624bd3
--- /dev/null
+++ b/OvmfPkg/Include/Library/PciCapLib.h
@@ -0,0 +1,429 @@
+/** @file
+  Library class to work with PCI capabilities in PCI config space.
+
+  Provides functions to parse capabilities lists, and to locate, describe, read
+  and write capabilities. PCI config space access is abstracted away.
+
+  Copyright (C) 2018, Red Hat, Inc.
+
+  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.
+**/
+
+#ifndef __PCI_CAP_LIB_H__
+#define __PCI_CAP_LIB_H__
+
+#include 
+
+//
+// Base structure for representing a PCI device -- down to the PCI function
+// level -- for the purposes of this library class. This is a forward
+// declaration that is completed below. Concrete implementations are supposed
+// to inherit and extend this type.
+//
+typedef struct PCI_CAP_DEV PCI_CAP_DEV;
+
+/**
+  Read the config space of a given PCI device (both normal and extended).
+
+  PCI_CAP_DEV_READ_CONFIG performs as few config space accesses as possible
+  (without attempting 64-bit wide accesses).
+
+  PCI_CAP_DEV_READ_CONFIG returns an unspecified error if accessing Size bytes
+  from SourceOffset exceeds the config space limit of the PCI device. Fewer
+  than Size bytes may have been read in this case.
+
+  @param[in] PciDevice   Implementation-specific unique representation
+ of the PCI device in the PCI hierarchy.
+
+  @param[in] SourceOffsetSource offset in the config space of the PCI
+ device to start reading from.
+
+  @param[out] DestinationBuffer  Buffer to store the read data to.
+
+  @param[in] SizeThe number of bytes to transfer.
+
+  

[edk2] [PATCH v2 2/7] OvmfPkg: introduce PciCapPciSegmentLib

2018-05-23 Thread Laszlo Ersek
Add a library class, and a BASE lib instance, that are layered on top of
PciCapLib, and allow clients to plug a PciSegmentLib backend into
PciCapLib, for config space access.

(Side note:

The "MaxDomain" parameter is provided because, in practice, platforms
exist where a PCI Express device may show up on a root bridge such that
the root bridge doesn't support access to extended config space. Earlier
the same issue was handled for MdeModulePkg/PciHostBridgeDxe in commit
014b472053ae3. However, that solution does not apply to the PciSegmentLib
class, because:

(1) The config space accessor functions of the PciSegmentLib class, such
as PciSegmentReadBuffer(), have no way of informing the caller whether
access to extended config space actually succeeds.

(For example, in the UefiPciSegmentLibPciRootBridgeIo instace, which
could in theory benefit from commit 014b472053ae3, the
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Pci.Read() status code is explicitly
ignored, because there's no way for the lib instance to propagate it
to the PciSegmentLib caller. If the
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Pci.Read() call fails, then
DxePciSegmentLibPciRootBridgeIoReadWorker() returns Data with
indeterminate value.)

(2) There is no *general* way for any firmware platform to provide, or
use, a PciSegmentLib instance in which access to extended config space
always succeeds.

In brief, on a platform where config space may be limited to 256 bytes,
access to extended config space through PciSegmentLib may invoke undefined
behavior; therefore PciCapPciSegmentLib must give platforms a way to
prevent such access.)

Cc: Ard Biesheuvel 
Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek 
---

Notes:
v2:
- move library from MdePkg to OvmfPkg, for initial introduction

 OvmfPkg/OvmfPkg.dec |   5 +
 OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf |  35 +++
 OvmfPkg/Include/Library/PciCapPciSegmentLib.h   |  82 
+++
 OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.h   |  47 
 OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c   | 226 

 5 files changed, 395 insertions(+)

diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index 74818a2e2a19..fbec1cfe4a8e 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -35,6 +35,11 @@ [LibraryClasses]
   #  config space.
   PciCapLib|Include/Library/PciCapLib.h
 
+  ##  @libraryclass  Layered on top of PciCapLib, allows clients to plug a
+  #  PciSegmentLib backend into PciCapLib, for config space
+  #  access.
+  PciCapPciSegmentLib|Include/Library/PciCapPciSegmentLib.h
+
   ##  @libraryclass  Access QEMU's firmware configuration interface
   #
   QemuFwCfgLib|Include/Library/QemuFwCfgLib.h
diff --git 
a/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf 
b/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf
new file mode 100644
index ..e3cf5de49b15
--- /dev/null
+++ b/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf
@@ -0,0 +1,35 @@
+## @file
+# Plug a PciSegmentLib backend into PciCapLib, for config space access.
+#
+# Copyright (C) 2018, Red Hat, Inc.
+#
+# 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= 1.27
+  BASE_NAME  = BasePciCapPciSegmentLib
+  FILE_GUID  = ED011855-AA31-43B9-ACC0-BF45A05C5985
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = PciCapPciSegmentLib
+
+[Sources]
+  BasePciCapPciSegmentLib.h
+  BasePciCapPciSegmentLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  MemoryAllocationLib
+  PciSegmentLib
diff --git a/OvmfPkg/Include/Library/PciCapPciSegmentLib.h 
b/OvmfPkg/Include/Library/PciCapPciSegmentLib.h
new file mode 100644
index ..6b6930288d16
--- /dev/null
+++ b/OvmfPkg/Include/Library/PciCapPciSegmentLib.h
@@ -0,0 +1,82 @@
+/** @file
+  Library class layered on top of PciCapLib that allows clients to plug a
+  PciSegmentLib backend into PciCapLib, for config space access.
+
+  Copyright (C) 2018, Red Hat, Inc.
+
+  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
+  

[edk2] [PATCH v2 0/7] OvmfPkg, ArmVirtPkg: add and use PCI(E) Capabilities Library

2018-05-23 Thread Laszlo Ersek
Repo:   https://github.com/lersek/edk2.git
Branch: pci_cap_v2

In v2, the new libs are initially introduced under OvmfPkg, rather than
MdePkg. v1 was posted at
<20180504213637.11266-1-lersek@redhat.com">http://mid.mail-archive.com/20180504213637.11266-1-lersek@redhat.com>.

Cc: Ard Biesheuvel 
Cc: Jordan Justen 

Thanks,
Laszlo

Laszlo Ersek (7):
  OvmfPkg: introduce PciCapLib
  OvmfPkg: introduce PciCapPciSegmentLib
  OvmfPkg: introduce PciCapPciIoLib
  OvmfPkg: resolve PciCapLib, PciCapPciSegmentLib, PciCapPciIoLib
  ArmVirtPkg: resolve PciCapLib, PciCapPciSegmentLib, PciCapPciIoLib
  OvmfPkg/PciHotPlugInitDxe: convert to PciCapLib
  OvmfPkg/Virtio10Dxe: convert to PciCapLib

 ArmVirtPkg/ArmVirt.dsc.inc  |3 +
 OvmfPkg/Include/IndustryStandard/Virtio10.h |7 +-
 OvmfPkg/Include/Library/PciCapLib.h |  429 
+
 OvmfPkg/Include/Library/PciCapPciIoLib.h|   58 ++
 OvmfPkg/Include/Library/PciCapPciSegmentLib.h   |   82 ++
 OvmfPkg/Library/BasePciCapLib/BasePciCapLib.c   | 1007 

 OvmfPkg/Library/BasePciCapLib/BasePciCapLib.h   |   60 ++
 OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf |   38 +
 OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c   |  226 
+
 OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.h   |   47 +
 OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf |   35 +
 OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.c |  243 
+
 OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.h |   44 +
 OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf   |   36 +
 OvmfPkg/OvmfPkg.dec |   14 +
 OvmfPkg/OvmfPkgIa32.dsc |3 +
 OvmfPkg/OvmfPkgIa32X64.dsc  |3 +
 OvmfPkg/OvmfPkgX64.dsc  |3 +
 OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c  |  267 
++
 OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf|5 +
 OvmfPkg/Virtio10Dxe/Virtio10.c  |  135 +--
 OvmfPkg/Virtio10Dxe/Virtio10.inf|2 +
 22 files changed, 2485 insertions(+), 262 deletions(-)
 create mode 100644 OvmfPkg/Include/Library/PciCapLib.h
 create mode 100644 OvmfPkg/Include/Library/PciCapPciIoLib.h
 create mode 100644 OvmfPkg/Include/Library/PciCapPciSegmentLib.h
 create mode 100644 OvmfPkg/Library/BasePciCapLib/BasePciCapLib.c
 create mode 100644 OvmfPkg/Library/BasePciCapLib/BasePciCapLib.h
 create mode 100644 OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
 create mode 100644 
OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c
 create mode 100644 
OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.h
 create mode 100644 
OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf
 create mode 100644 OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.c
 create mode 100644 OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.h
 create mode 100644 OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf

-- 
2.14.1.3.gb7cf6e02401b

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS

2018-05-23 Thread Laszlo Ersek
On 05/23/18 16:21, Gao, Liming wrote:
> Laszlo:
>   I agree to add this change first in tools_def.txt. Then, update IA32/X64 
> arch when there is a real request. For long term, I prefer to file a BZ for 
> GccBase.lds / tools_def.template, to discard or strip .eh_frame under GCC.
> 
>   Reviewed-by: Liming Gao 

Thanks! I've pushed this patch now as commit cbf00651eda6, and filed
.

Cheers,
Laszlo


>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
>> Laszlo Ersek
>> Sent: Tuesday, May 22, 2018 5:30 PM
>> To: Leif Lindholm 
>> Cc: Ard Biesheuvel ; edk2-devel-01 
>> ; Gao, Liming ;
>> pjo...@redhat.com; Cole Robinson ; Paolo Bonzini 
>> ; Danilo C. L. de Paula
>> 
>> Subject: Re: [edk2] [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to 
>> GCC_AARCH64_CC_FLAGS
>>
>> On 05/21/18 12:30, Leif Lindholm wrote:
>>> On Fri, May 18, 2018 at 08:23:01PM +0200, Laszlo Ersek wrote:
 The ElfConvert routines in GenFw don't handle the ".eh_frame" ELF section
 emitted by gcc. For this reason, Leif disabled the generation of that
 section for AARCH64 with "-fno-asynchronous-unwind-tables" in commit
 28e80befa4fe [1], and Ard did the same for IA32 and X64 in commit
 26ecc55c027d [2]. (The CLANG38 toolchain received the same flag at its
 inception, in commit 6f756db5ea05 [3].)

 However, ".eh_frame" is back now; in upstream gcc commit 9cbee213b579 [4]
 (part of tag "gcc-8_1_0-release"), both "-fasynchronous-unwind-tables" and
 "-funwind-tables" were made the default for AARCH64. (The patch author
 described the effects on the gcc mailing list [5].) We have to counter the
 latter flag with "-fno-unwind-tables", otherwise GenFw chokes on
 ".eh_frame" again (triggered for example on Fedora 28).

 "-f[no-]unwind-tables" goes back to at least gcc-4.4 [6], so it's safe to
 add to GCC_AARCH64_CC_FLAGS.
>>>
>>> I'm not against this patch (which fixes a real problem), but would
>>> it be possible to take the opposite approach, as Peter Jones did for
>>> GRUB when the same issue hit there?:
>>>
>>> http://lists.gnu.org/archive/html/grub-devel/2018-02/msg00095.html
>>>
>>> I.e., rather than keep adding flags when new "special" sections are
>>> added by toolchains, explicitly filter those out as part of the link
>>> step.
>>
>> I guess this could be implemented in two places in BaseTools:
>>
>> (1) In GenFw / ElfConvert. I'm afraid that's beyond my binutils-fu at
>> the moment.
>>
>> (2) In "BaseTools/Scripts/GccBase.lds". This is similarly beyond my
>> binutils-fu, but at least I can make more comments on it:
>>
>> We already discard a good number of sections, but we keep (and realign)
>> "eh_frame". From Ard's commit message 26ecc55c027d, I believe the idea
>> here was to "retain the .eh_frame data for external debugging", and then
>> strip it with "objcopy -R .eh_frame" finally (see
>> [Dynamic-Library-File],  in
>> "BaseTools/Conf/build_rule.template").
>>
>> However, in practice we stub out objcopy (see under "GCC Common" in
>> "BaseTools/Conf/tools_def.template"), and then we must prevent the
>> generation of .eh_frame in the first place.
>>
>> Rather than adding "-fno-unwind-tables", I considered moving .eh_frame
>> to /DISCARD/, or else turning $(OBJCOPY) into the real thing. However,
>> that would affect more targets than just AARCH64/GCC, and I really
>> didn't (don't) remember why we have this redundancy with "objcopy -R
>> .eh_frame" vs. "-no-fasynchronous-unwind-tables". The latest practice
>> seemed to be "add more -fno-..." (see the commits I referenced above),
>> so I went with that.
>>
>>
>> I suggest we push this patch now, plus I could:
>>
>> - submit a followup for IA32/X64, if that's deemed best,
>> - file a BZ for GenFw / ElfConvert about the programmatic relocation
>>   filtering,
>> - file a BZ for GccBase.lds / tools_def.template, to discard or strip
>>   .eh_frame under GCC.
>>
>> Thanks
>> Laszlo
>> ___
>> 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
> 

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v5 5/6] Platform/HiKey: do basic initialization on hikey

2018-05-23 Thread Haojian Zhuang
Do some basic initialization on HiKey platform, such as pin
setting, regulators and making peripherals out of reset mode.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKey.dsc|   3 +
 Platform/Hisilicon/HiKey/HiKey.fdf|   3 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c  | 102 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h  |  31 +++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf|  40 +
 Silicon/Hisilicon/Hi6220/Include/Hi6220.h |   6 ++
 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h |  50 +++
 7 files changed, 235 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 create mode 100644 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h

diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
b/Platform/Hisilicon/HiKey/HiKey.dsc
index 5c1604d7f689..5cc4ff27f01b 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -189,8 +189,11 @@ [Components.common]
   #
   # GPIO
   #
+  Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+
   #
   # MMC/SD
   #
diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf 
b/Platform/Hisilicon/HiKey/HiKey.fdf
index 2a5c5a4d6e79..39020d27dbcd 100644
--- a/Platform/Hisilicon/HiKey/HiKey.fdf
+++ b/Platform/Hisilicon/HiKey/HiKey.fdf
@@ -120,8 +120,11 @@ [FV.FvMain]
   #
   # GPIO
   #
+  INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+
   #
   # Multimedia Card Interface
   #
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
new file mode 100644
index ..b812f8bd483d
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
@@ -0,0 +1,102 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro 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 "HiKeyDxe.h"
+
+STATIC
+VOID
+UartInit (
+  IN VOID
+  )
+{
+  UINT32 Val;
+
+  /* make UART1 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART1);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART1);
+  /* make UART2 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART2);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART2);
+  /* make UART3 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART3);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART3);
+  /* make UART4 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART4);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART4);
+
+  /* make DW_MMC2 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS0, PERIPH_RST0_MMC2);
+
+  /* enable clock for BT/WIFI */
+  Val = MmioRead32 (PMUSSI_ONOFF8_REG) | PMUSSI_ONOFF8_EN_32KB;
+  MmioWrite32 (PMUSSI_ONOFF8_REG, Val);
+}
+
+STATIC
+VOID
+MtcmosInit (
+  IN VOID
+  )
+{
+  UINT32 Data;
+
+  /* enable MTCMOS for GPU */
+  MmioWrite32 (AO_CTRL_BASE + SC_PW_MTCMOS_EN0, PW_EN0_G3D);
+  do {
+Data = MmioRead32 (AO_CTRL_BASE + SC_PW_MTCMOS_ACK_STAT0);
+  } while ((Data & PW_EN0_G3D) == 0);
+}
+
+EFI_STATUS
+HiKeyInitPeripherals (
+  IN VOID
+  )
+{
+  UINT32 Data, Bits;
+
+  /* make I2C0/I2C1/I2C2/SPI0 out of reset */
+  Bits = PERIPH_RST3_I2C0 | PERIPH_RST3_I2C1 | PERIPH_RST3_I2C2 | \
+ PERIPH_RST3_SSP;
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, Bits);
+
+  do {
+Data = MmioRead32 (PERI_CTRL_BASE + SC_PERIPH_RSTSTAT3);
+  } while (Data & Bits);
+
+  UartInit ();
+  /* MTCMOS -- Multi-threshold CMOS */
+  MtcmosInit ();
+
+  /* Set DETECT_J15_FASTBOOT (GPIO24) pin as GPIO function */
+  MmioWrite32 (IOCG_084_REG, 0);/* configure GPIO24 as nopull */
+  MmioWrite32 (IOMG_080_REG, 0);/* configure GPIO24 as GPIO */
+
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+HiKeyEntryPoint (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUSStatus;
+
+  Status = 

[edk2] [PATCH edk2-platforms v5 3/6] Platform/HiKey960: enable virtual keyboard

2018-05-23 Thread Haojian Zhuang
Enable virtual keyboard on HiKey960 platform. It checks two
conditions, such as pattern in memory and GPIO pin setting.
Since code is ported from non-open

The hardcoding code is taken from non-open reference code.
Can't fix it for lack of documents.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |  5 ++
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |  5 ++
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 97 ++
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   | 10 +++
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  1 +
 5 files changed, 118 insertions(+)

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 6cc1c1edf453..79e68754976d 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -182,6 +182,11 @@ [Components.common]
   Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index b7d70b010598..d65f77878575 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -123,6 +123,11 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
index 7c1705241e88..7ff2f118128d 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
@@ -14,6 +14,8 @@
 
 #include "HiKey960Dxe.h"
 
+STATIC EMBEDDED_GPIO   *mGpio;
+
 STATIC
 VOID
 InitSdCard (
@@ -166,6 +168,94 @@ OnEndOfDxe (
 
 EFI_STATUS
 EFIAPI
+VirtualKeyboardRegister (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  Status = gBS->LocateProtocol (
+  ,
+  NULL,
+  (VOID **) 
+  );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardReset (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  if (mGpio == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  //
+  // Configure GPIO68 as GPIO function
+  //
+  MmioWrite32 (0xe896c108, 0);
+  Status = mGpio->Set (mGpio, DETECT_SW_FASTBOOT, GPIO_MODE_INPUT);
+  return Status;
+}
+
+BOOLEAN
+EFIAPI
+VirtualKeyboardQuery (
+  IN VIRTUAL_KBD_KEY *VirtualKey
+  )
+{
+  EFI_STATUS   Status;
+  UINTNValue = 0;
+
+  if ((VirtualKey == NULL) || (mGpio == NULL)) {
+return FALSE;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+goto Done;
+  } else {
+Status = mGpio->Get (mGpio, DETECT_SW_FASTBOOT, );
+if (EFI_ERROR (Status) || (Value != 0)) {
+  return FALSE;
+}
+  }
+Done:
+  VirtualKey->Signature = VIRTUAL_KEYBOARD_KEY_SIGNATURE;
+  VirtualKey->Key.ScanCode = SCAN_NULL;
+  VirtualKey->Key.UnicodeChar = L'f';
+  return TRUE;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardClear (
+  IN VIRTUAL_KBD_KEY*VirtualKey
+  )
+{
+  if (VirtualKey == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+MmioWrite32 (ADB_REBOOT_ADDRESS, ADB_REBOOT_NONE);
+WriteBackInvalidateDataCacheRange ((VOID *)ADB_REBOOT_ADDRESS, 4);
+  }
+  return EFI_SUCCESS;
+}
+
+PLATFORM_VIRTUAL_KBD_PROTOCOL mVirtualKeyboard = {
+  VirtualKeyboardRegister,
+  VirtualKeyboardReset,
+  VirtualKeyboardQuery,
+  VirtualKeyboardClear
+};
+
+EFI_STATUS
+EFIAPI
 HiKey960EntryPoint (
   IN EFI_HANDLE ImageHandle,
   IN EFI_SYSTEM_TABLE   *SystemTable
@@ -194,5 +284,12 @@ HiKey960EntryPoint (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+
+  Status = gBS->InstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  
+  );
   return Status;
 }
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
index 9a4c66f42c50..211eea55aa54 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
@@ -21,6 +21,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

[edk2] [PATCH v5 0/6] enable virtual keyboard

2018-05-23 Thread Haojian Zhuang
Changelog:
v5:
  * Remove unused functions and definitions.
  * Add commit comments for hardcoding values.
v4:
  * Fix hard-coding value.
  * Remove unused functions.
v3:
  * Remove ADC and boardid, since it's not really used yet.
  * Add more comments.
v2:
  * Split HiKeyDxe & HiKey960Dxe into smaller patches.
  * Replace hardcoding register with macro.
v1:
  * Enable GPIO driver.
  * Enable virtual keyboard driver.

Haojian Zhuang (6):
  Platform/Hisilicon/HiKey960: add gpio platform driver
  Platform/HiKey960: do basic initialization
  Platform/HiKey960: enable virtual keyboard
  Platform/Hisilicon/HiKey: add gpio platform driver
  Platform/HiKey: do basic initialization on hikey
  Platform/HiKey: enable virtual keyboard

 Platform/Hisilicon/HiKey/HiKey.dsc |   8 +
 Platform/Hisilicon/HiKey/HiKey.fdf |   8 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c   | 195 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h   |  36 +++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf |  45 
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c|  74 ++
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf  |  36 +++
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |   8 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |   8 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 295 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   |  47 
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  48 
 Silicon/Hisilicon/Hi3660/Hi3660.dec|  32 +++
 Silicon/Hisilicon/Hi3660/Include/Hi3660.h  | 195 ++
 Silicon/Hisilicon/Hi6220/Include/Hi6220.h  |   6 +
 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h  |  50 
 16 files changed, 1091 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 create mode 100644 Silicon/Hisilicon/Hi3660/Hi3660.dec
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hi3660.h
 create mode 100644 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v5 4/6] Platform/Hisilicon/HiKey: add gpio platform driver

2018-05-23 Thread Haojian Zhuang
Add gpio platform driver to enable GPIO in HiKey platform.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
Reviewed-by: Leif Lindholm 
---
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c| 74 ++
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf  | 36 +++
 2 files changed, 110 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf

diff --git a/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
new file mode 100644
index ..be535f8f1903
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
@@ -0,0 +1,74 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro. 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 
+
+#include 
+
+GPIO_CONTROLLER gGpioDevice[] = {
+  //
+  // { base address, gpio index, gpio count }
+  //
+  { 0xf8011000, 0, 8 },// GPIO0
+  { 0xf8012000, 8, 8 },// GPIO1
+  { 0xf8013000, 16, 8 },   // GPIO2
+  { 0xf8014000, 24, 8 },   // GPIO3
+  { 0xf702, 32, 8 },   // GPIO4
+  { 0xf7021000, 40, 8 },   // GPIO5
+  { 0xf7022000, 48, 8 },   // GPIO6
+  { 0xf7023000, 56, 8 },   // GPIO7
+  { 0xf7024000, 64, 8 },   // GPIO8
+  { 0xf7025000, 72, 8 },   // GPIO9
+  { 0xf7026000, 80, 8 },   // GPIO10
+  { 0xf7027000, 88, 8 },   // GPIO11
+  { 0xf7028000, 96, 8 },   // GPIO12
+  { 0xf7029000, 104, 8 },  // GPIO13
+  { 0xf702a000, 112, 8 },  // GPIO14
+  { 0xf702b000, 120, 8 },  // GPIO15
+  { 0xf702c000, 128, 8 },  // GPIO16
+  { 0xf702d000, 136, 8 },  // GPIO17
+  { 0xf702e000, 144, 8 },  // GPIO18
+  { 0xf702f000, 152, 8 }   // GPIO19
+};
+
+PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
+  //
+  // { global gpio count, gpio controller counter, GPIO_CONTROLLER }
+  //
+  160, 20, gGpioDevice
+};
+
+EFI_STATUS
+EFIAPI
+HiKeyGpioEntryPoint (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  EFI_HANDLE  Handle;
+
+  // Install the Embedded Platform GPIO Protocol onto a new handle
+  Handle = NULL;
+  Status = gBS->InstallMultipleProtocolInterfaces(
+  ,
+  , ,
+  NULL
+ );
+  if (EFI_ERROR(Status)) {
+Status = EFI_OUT_OF_RESOURCES;
+  }
+
+  return Status;
+}
diff --git a/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
new file mode 100644
index ..2791b9f44cad
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
@@ -0,0 +1,36 @@
+#
+#  Copyright (c) 2018, Linaro. 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= 0x0001001a
+  BASE_NAME  = HiKeyGpio
+  FILE_GUID  = b51a851c-7bf7-463f-b261-cfb158b7f699
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= HiKeyGpioEntryPoint
+
+[Sources.common]
+  HiKeyGpioDxe.c
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gPlatformGpioProtocolGuid
+
+[Depex]
+  TRUE
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v5 1/6] Platform/Hisilicon/HiKey960: add gpio platform driver

2018-05-23 Thread Haojian Zhuang
Add gpio platform driver to enable GPIO in HiKey960 platform.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc | 1 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf | 1 +
 2 files changed, 2 insertions(+)

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 36f43956ab40..3da1b8556321 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -179,6 +179,7 @@ [Components.common]
   #
   # GPIO
   #
+  Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index 655032a36c53..162dbaaf2646 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -120,6 +120,7 @@ [FV.FvMain]
   #
   # GPIO
   #
+  INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
   #
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v5 2/6] Platform/HiKey960: do basic initialization

2018-05-23 Thread Haojian Zhuang
Do some basic initliazation on peripherals, such as pins and
regulators.

The hardcoding code is taken from non-open reference code.
Can't fix it for lack of documents.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |   2 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |   2 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 198 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   |  37 
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  47 +
 Silicon/Hisilicon/Hi3660/Hi3660.dec|  32 
 Silicon/Hisilicon/Hi3660/Include/Hi3660.h  | 195 
 7 files changed, 513 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 create mode 100644 Silicon/Hisilicon/Hi3660/Hi3660.dec
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hi3660.h

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 3da1b8556321..6cc1c1edf453 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -182,6 +182,8 @@ [Components.common]
   Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
+
   #
   # USB Host Support
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index 162dbaaf2646..b7d70b010598 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -123,6 +123,8 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
+
   #
   # USB Host Support
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
new file mode 100644
index ..7c1705241e88
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
@@ -0,0 +1,198 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro 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 "HiKey960Dxe.h"
+
+STATIC
+VOID
+InitSdCard (
+  IN VOID
+  )
+{
+  UINT32Data;
+
+  //
+  // LDO16
+  // 000: 1.75V, 001: 1.8V, 010: 2.4V, 011: 2.6V, 100: 2.7V,
+  // 101: 2.85V, 110: 2.95V, 111: 3.0V.
+  //
+  Data = MmioRead32 (PMIC_LDO16_VSET_REG) & LDO16_VSET_MASK;
+  Data |= 6;
+  MmioWrite32 (PMIC_LDO16_VSET_REG, Data);
+  MmioOr32 (PMIC_LDO16_ONOFF_ECO_REG, LDO16_ONOFF_ECO_LDO16_ENABLE);
+  //
+  // wait regulator stable
+  //
+  MicroSecondDelay (100);
+
+  //
+  // LDO9
+  // 000: 1.75V, 001: 1.8V, 010: 1.825V, 011: 2.8V, 100: 2.85V,
+  // 101: 2.95V, 110: 3.0V, 111: 3.3V.
+  //
+  Data = MmioRead32 (PMIC_LDO9_VSET_REG) & LDO9_VSET_MASK;
+  Data |= 5;
+  MmioWrite32 (PMIC_LDO9_VSET_REG, Data);
+  MmioOr32 (PMU_REG_BASE + (0x6a << 2), 2);
+  //
+  // wait regulator stable
+  //
+  MicroSecondDelay (100);
+
+  //
+  // GPIO203
+  //
+  MmioWrite32 (IOMG_AO_REG_BASE + (24 << 2), 0); // GPIO function
+
+  //
+  // SD pinmux
+  //
+  MmioWrite32 (IOMG_MMC0_000_REG, IOMG_FUNC1); // SD_CLK
+  MmioWrite32 (IOMG_MMC0_001_REG, IOMG_FUNC1); // SD_CMD
+  MmioWrite32 (IOMG_MMC0_002_REG, IOMG_FUNC1); // SD_DATA0
+  MmioWrite32 (IOMG_MMC0_003_REG, IOMG_FUNC1); // SD_DATA1
+  MmioWrite32 (IOMG_MMC0_004_REG, IOMG_FUNC1); // SD_DATA2
+  MmioWrite32 (IOMG_MMC0_005_REG, IOMG_FUNC1); // SD_DATA3
+  MmioWrite32 (IOCG_MMC0_000_REG, IOCG_DRIVE (15)); // SD_CLK float with 32mA
+  MmioWrite32 (IOCG_MMC0_001_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_CMD
+  MmioWrite32 (IOCG_MMC0_002_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_DATA0
+  MmioWrite32 (IOCG_MMC0_003_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_DATA1
+  MmioWrite32 (IOCG_MMC0_004_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_DATA2
+  MmioWrite32 (IOCG_MMC0_005_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_DATA3
+
+  //
+  // SC_SEL_SD:
+  //   0xx: 3.2MHz, 100: PPLL0, 101: PPLL1, 11x: PPLL2.
+  // SC_DIV_SD:
+  //   divider = value + 1
+  //
+  do {
+MmioOr32 (
+  CRG_CLKDIV4,
+  CLKDIV4_SC_SEL_SD (7) |

[edk2] [PATCH edk2-platforms v5 6/6] Platform/HiKey: enable virtual keyboard

2018-05-23 Thread Haojian Zhuang
Enable virtual keyboard on HiKey platform. It detects the pattern
in memory and GPIO pin setting, and simulates them into virtual
key.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKey.dsc |  5 ++
 Platform/Hisilicon/HiKey/HiKey.fdf |  5 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c   | 93 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h   |  5 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf |  5 ++
 5 files changed, 113 insertions(+)

diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
b/Platform/Hisilicon/HiKey/HiKey.dsc
index 5cc4ff27f01b..83dd68a820b1 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -192,6 +192,11 @@ [Components.common]
   Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf 
b/Platform/Hisilicon/HiKey/HiKey.fdf
index 39020d27dbcd..2bca7232b6e5 100644
--- a/Platform/Hisilicon/HiKey/HiKey.fdf
+++ b/Platform/Hisilicon/HiKey/HiKey.fdf
@@ -123,6 +123,11 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
index b812f8bd483d..afd2f050896a 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
@@ -43,6 +43,8 @@ UartInit (
   MmioWrite32 (PMUSSI_ONOFF8_REG, Val);
 }
 
+STATIC EMBEDDED_GPIO*mGpio;
+
 STATIC
 VOID
 MtcmosInit (
@@ -87,6 +89,90 @@ HiKeyInitPeripherals (
 
 EFI_STATUS
 EFIAPI
+VirtualKeyboardRegister (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  Status = gBS->LocateProtocol (
+  ,
+  NULL,
+  (VOID **) 
+  );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardReset (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  if (mGpio == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  Status = mGpio->Set (mGpio, DETECT_J15_FASTBOOT, GPIO_MODE_INPUT);
+  return Status;
+}
+
+BOOLEAN
+EFIAPI
+VirtualKeyboardQuery (
+  IN VIRTUAL_KBD_KEY *VirtualKey
+  )
+{
+  EFI_STATUS   Status;
+  UINTNValue = 0;
+
+  if ((VirtualKey == NULL) || (mGpio == NULL)) {
+return FALSE;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+goto Done;
+  } else {
+Status = mGpio->Get (mGpio, DETECT_J15_FASTBOOT, );
+if (EFI_ERROR (Status) || (Value != 0)) {
+  return FALSE;
+}
+  }
+Done:
+  VirtualKey->Signature = VIRTUAL_KEYBOARD_KEY_SIGNATURE;
+  VirtualKey->Key.ScanCode = SCAN_NULL;
+  VirtualKey->Key.UnicodeChar = L'f';
+  return TRUE;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardClear (
+  IN VIRTUAL_KBD_KEY*VirtualKey
+  )
+{
+  if (VirtualKey == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+MmioWrite32 (ADB_REBOOT_ADDRESS, ADB_REBOOT_NONE);
+WriteBackInvalidateDataCacheRange ((VOID *)ADB_REBOOT_ADDRESS, 4);
+  }
+  return EFI_SUCCESS;
+}
+
+PLATFORM_VIRTUAL_KBD_PROTOCOL mVirtualKeyboard = {
+  VirtualKeyboardRegister,
+  VirtualKeyboardReset,
+  VirtualKeyboardQuery,
+  VirtualKeyboardClear
+};
+
+EFI_STATUS
+EFIAPI
 HiKeyEntryPoint (
   IN EFI_HANDLE ImageHandle,
   IN EFI_SYSTEM_TABLE   *SystemTable
@@ -98,5 +184,12 @@ HiKeyEntryPoint (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+
+  Status = gBS->InstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  
+  );
   return Status;
 }
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
index 07f9ae6a949a..3d608183fa58 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
@@ -15,10 +15,15 @@
 #ifndef __HIKEYDXE_H__
 #define __HIKEYDXE_H__
 
+#include 
 #include 
 #include 
+#include 
 #include 
 
+#include 
+#include 
+
 #include 
 #include 
 
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
index 34734391b45a..41aa7f8081ed 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+++ 

Re: [edk2] [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS

2018-05-23 Thread Gao, Liming
Laszlo:
  I agree to add this change first in tools_def.txt. Then, update IA32/X64 arch 
when there is a real request. For long term, I prefer to file a BZ for 
GccBase.lds / tools_def.template, to discard or strip .eh_frame under GCC.

  Reviewed-by: Liming Gao 

Thanks
Liming
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Laszlo 
> Ersek
> Sent: Tuesday, May 22, 2018 5:30 PM
> To: Leif Lindholm 
> Cc: Ard Biesheuvel ; edk2-devel-01 
> ; Gao, Liming ;
> pjo...@redhat.com; Cole Robinson ; Paolo Bonzini 
> ; Danilo C. L. de Paula
> 
> Subject: Re: [edk2] [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to 
> GCC_AARCH64_CC_FLAGS
> 
> On 05/21/18 12:30, Leif Lindholm wrote:
> > On Fri, May 18, 2018 at 08:23:01PM +0200, Laszlo Ersek wrote:
> >> The ElfConvert routines in GenFw don't handle the ".eh_frame" ELF section
> >> emitted by gcc. For this reason, Leif disabled the generation of that
> >> section for AARCH64 with "-fno-asynchronous-unwind-tables" in commit
> >> 28e80befa4fe [1], and Ard did the same for IA32 and X64 in commit
> >> 26ecc55c027d [2]. (The CLANG38 toolchain received the same flag at its
> >> inception, in commit 6f756db5ea05 [3].)
> >>
> >> However, ".eh_frame" is back now; in upstream gcc commit 9cbee213b579 [4]
> >> (part of tag "gcc-8_1_0-release"), both "-fasynchronous-unwind-tables" and
> >> "-funwind-tables" were made the default for AARCH64. (The patch author
> >> described the effects on the gcc mailing list [5].) We have to counter the
> >> latter flag with "-fno-unwind-tables", otherwise GenFw chokes on
> >> ".eh_frame" again (triggered for example on Fedora 28).
> >>
> >> "-f[no-]unwind-tables" goes back to at least gcc-4.4 [6], so it's safe to
> >> add to GCC_AARCH64_CC_FLAGS.
> >
> > I'm not against this patch (which fixes a real problem), but would
> > it be possible to take the opposite approach, as Peter Jones did for
> > GRUB when the same issue hit there?:
> >
> > http://lists.gnu.org/archive/html/grub-devel/2018-02/msg00095.html
> >
> > I.e., rather than keep adding flags when new "special" sections are
> > added by toolchains, explicitly filter those out as part of the link
> > step.
> 
> I guess this could be implemented in two places in BaseTools:
> 
> (1) In GenFw / ElfConvert. I'm afraid that's beyond my binutils-fu at
> the moment.
> 
> (2) In "BaseTools/Scripts/GccBase.lds". This is similarly beyond my
> binutils-fu, but at least I can make more comments on it:
> 
> We already discard a good number of sections, but we keep (and realign)
> "eh_frame". From Ard's commit message 26ecc55c027d, I believe the idea
> here was to "retain the .eh_frame data for external debugging", and then
> strip it with "objcopy -R .eh_frame" finally (see
> [Dynamic-Library-File],  in
> "BaseTools/Conf/build_rule.template").
> 
> However, in practice we stub out objcopy (see under "GCC Common" in
> "BaseTools/Conf/tools_def.template"), and then we must prevent the
> generation of .eh_frame in the first place.
> 
> Rather than adding "-fno-unwind-tables", I considered moving .eh_frame
> to /DISCARD/, or else turning $(OBJCOPY) into the real thing. However,
> that would affect more targets than just AARCH64/GCC, and I really
> didn't (don't) remember why we have this redundancy with "objcopy -R
> .eh_frame" vs. "-no-fasynchronous-unwind-tables". The latest practice
> seemed to be "add more -fno-..." (see the commits I referenced above),
> so I went with that.
> 
> 
> I suggest we push this patch now, plus I could:
> 
> - submit a followup for IA32/X64, if that's deemed best,
> - file a BZ for GenFw / ElfConvert about the programmatic relocation
>   filtering,
> - file a BZ for GccBase.lds / tools_def.template, to discard or strip
>   .eh_frame under GCC.
> 
> Thanks
> Laszlo
> ___
> 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


[edk2] [PATCH edk2-platforms 4/4] Silicon/Socionext/SynQuacerPciHostBridgeLib: DEPEX on variable protocol

2018-05-23 Thread Ard Biesheuvel
As discussed on-list [0], dynamic HII PCDs are backed by EFI variables,
but having PcdDxe DEPEXing on gEfiVariableArchProtocolGuid in general
is too restrictive, and so it is up to the platforms themselves to
DEPEX on gEfiVariableArchProtocolGuid in modules that use PCDs that
the platform may declare as dynamic HII. This also applies to the PCD
gSynQuacerTokenSpaceGuid.PcdPlatformSettings on the SynQuacer platform,
which is used by its PciHostBridgeLib implementation. So add the DEPEX
to make this dependency explicit.

[0] https://lists.01.org/pipermail/edk2-devel/2018-April/023700.html

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 
Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf
 | 5 +
 1 file changed, 5 insertions(+)

diff --git 
a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf
 
b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf
index e475529eaf58..8b8bb5df57d3 100644
--- 
a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf
+++ 
b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf
@@ -54,3 +54,8 @@ [FixedPcd]
 [Pcd]
   gSynQuacerTokenSpaceGuid.PcdPcieEnableMask
   gSynQuacerTokenSpaceGuid.PcdPlatformSettings
+
+[Depex]
+  # gSynQuacerTokenSpaceGuid.PcdPlatformSettings may be of the dynamic HII
+  # variety, which are backed by EFI variables
+  gEfiVariableArchProtocolGuid
-- 
2.17.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms 3/4] Platform/DeveloperBox: switch to protocol based DevicePathLib

2018-05-23 Thread Ard Biesheuvel
We already include DevicePathDxe, which exposes a protocol that implements
DevicePathLib in a way that can be shared across modules, avoiding the
need for multiple copies of UefiDevicePathLib, which is rather heavy
weight. However, we are not actually using it, and all DevicePathLib
users carry a private copy of UefiDevicePathLib.

So wire up all modules except DxeCore and DevicePathDxe itself, which
cannot use the protocol for obvious reasons. Also, avoid creating a
cyclic dependency between PcdDxe and DevicePathDxe by using PcdLibNull
in the latter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc 
b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
index 1bfe7fcaca01..3decc22e25b1 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
@@ -93,7 +93,7 @@ [LibraryClasses.common]
   UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
-  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+  
DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf
   
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
   
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
   
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
@@ -475,6 +475,7 @@ [Components.common]
   MdeModulePkg/Core/Dxe/DxeMain.inf {
 
   
NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf
+  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
 
   gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x800F
   }
@@ -497,7 +498,12 @@ [Components.common]
   ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
 
-  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
+  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf {
+
+  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  }
+
   MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
   MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
   MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
-- 
2.17.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms 2/4] Platform/DeveloperBox: add PCI serial driver

2018-05-23 Thread Ard Biesheuvel
Add the generic PCI serial driver so UART plugin cards can be used
as the serial console in UEFI.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 1 +
 Platform/Socionext/DeveloperBox/DeveloperBox.fdf | 1 +
 2 files changed, 2 insertions(+)

diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc 
b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
index e7068a5b629c..1bfe7fcaca01 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
@@ -581,6 +581,7 @@ [Components.common]
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
   
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
   Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.inf
+  MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxe.inf
 
   #
   # eMMC support
diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf 
b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
index 9e06abb38682..c36104da3b46 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
@@ -149,6 +149,7 @@ [FV.FvMain]
   INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
   INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
   INF 
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
+  INF MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxe.inf
 
   #
   # eMMC support
-- 
2.17.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms 1/4] Platform/DeveloperBox: add 96boards/Socionext logo

2018-05-23 Thread Ard Biesheuvel
Add a nice splash screen with the Socionext and 96boards logos.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
Binary omitted. File can be found here:
http://people.linaro.org/~ard.biesheuvel/devbox/Logo.bmp

 Platform/Socionext/DeveloperBox/DeveloperBox.dsc |   2 +-
 Platform/Socionext/DeveloperBox/DeveloperBox.fdf |   2 +-
 Platform/Socionext/DeveloperBox/Logo/Logo.bmp| Bin 0 -> 1050122 bytes
 Platform/Socionext/DeveloperBox/Logo/Logo.c  | 149 
 Platform/Socionext/DeveloperBox/Logo/Logo.idf|  15 ++
 Platform/Socionext/DeveloperBox/Logo/LogoDxe.inf |  52 +++
 6 files changed, 218 insertions(+), 2 deletions(-)

diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc 
b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
index 24b2925bf954..e7068a5b629c 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
@@ -504,7 +504,7 @@ [Components.common]
   MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
   MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
   MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
-  MdeModulePkg/Logo/LogoDxe.inf
+  Platform/Socionext/DeveloperBox/Logo/LogoDxe.inf
 
   MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
 
diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf 
b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
index 1b8de4c3823a..9e06abb38682 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
@@ -116,7 +116,7 @@ [FV.FvMain]
   INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
   INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
   INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
-  INF MdeModulePkg/Logo/LogoDxe.inf
+  INF Platform/Socionext/DeveloperBox/Logo/LogoDxe.inf
   INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
 
   #
diff --git a/Platform/Socionext/DeveloperBox/Logo/Logo.bmp 
b/Platform/Socionext/DeveloperBox/Logo/Logo.bmp
new file mode 100644
index ..bf87981ee71e
Binary files /dev/null and b/Platform/Socionext/DeveloperBox/Logo/Logo.bmp 
differ
diff --git a/Platform/Socionext/DeveloperBox/Logo/Logo.c 
b/Platform/Socionext/DeveloperBox/Logo/Logo.c
new file mode 100644
index ..03bf748efd73
--- /dev/null
+++ b/Platform/Socionext/DeveloperBox/Logo/Logo.c
@@ -0,0 +1,149 @@
+/** @file
+  Logo DXE Driver, install Edkii Platform Logo protocol.
+
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2018, Linaro, 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+typedef struct {
+  EFI_IMAGE_ID  ImageId;
+  EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute;
+  INTN  OffsetX;
+  INTN  OffsetY;
+} LOGO_ENTRY;
+
+STATIC EFI_HII_IMAGE_EX_PROTOCOL *mHiiImageEx;
+STATIC EFI_HII_HANDLEmHiiHandle;
+STATIC LOGO_ENTRYmLogos[] = {
+  {
+IMAGE_TOKEN (IMG_LOGO),
+EdkiiPlatformLogoDisplayAttributeCenter,
+0,
+0
+  }
+};
+
+/**
+  Load a platform logo image and return its data and attributes.
+
+  @param This  The pointer to this protocol instance.
+  @param Instance  The visible image instance is found.
+  @param Image Points to the image.
+  @param Attribute The display attributes of the image returned.
+  @param OffsetX   The X offset of the image regarding the Attribute.
+  @param OffsetY   The Y offset of the image regarding the Attribute.
+
+  @retval EFI_SUCCESS  The image was fetched successfully.
+  @retval EFI_NOT_FOUNDThe specified image could not be found.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+GetImage (
+  IN EDKII_PLATFORM_LOGO_PROTOCOL  *This,
+  IN OUT UINT32*Instance,
+ OUT EFI_IMAGE_INPUT   *Image,
+ OUT EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE *Attribute,
+ OUT INTN  *OffsetX,
+ OUT INTN  *OffsetY
+  )
+{
+  UINT32 Current;
+
+  if (Instance == NULL || Image == NULL ||
+  Attribute == NULL || OffsetX == NULL || OffsetY == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  Current = *Instance;
+  if (Current >= ARRAY_SIZE (mLogos)) {
+return 

[edk2] [PATCH edk2-platforms 0/4] SynQuacer updates

2018-05-23 Thread Ard Biesheuvel
Patch #4 fixes a bug that breaks the DEBUG build. Remaining patches
are general improvements.

Ard Biesheuvel (4):
  Platform/DeveloperBox: add 96boards/Socionext logo
  Platform/DeveloperBox: add PCI serial driver
  Platform/DeveloperBox: switch to protocol based DevicePathLib
  Silicon/Socionext/SynQuacerPciHostBridgeLib: DEPEX on variable
protocol

 .../Socionext/DeveloperBox/DeveloperBox.dsc   |  13 +-
 .../Socionext/DeveloperBox/DeveloperBox.fdf   |   3 +-
 Platform/Socionext/DeveloperBox/Logo/Logo.bmp | Bin 0 -> 1050122 bytes
 Platform/Socionext/DeveloperBox/Logo/Logo.c   | 149 ++
 Platform/Socionext/DeveloperBox/Logo/Logo.idf |  15 ++
 .../Socionext/DeveloperBox/Logo/LogoDxe.inf   |  52 ++
 .../SynQuacerPciHostBridgeLib.inf |   5 +
 7 files changed, 233 insertions(+), 4 deletions(-)
 create mode 100644 Platform/Socionext/DeveloperBox/Logo/Logo.bmp
 create mode 100644 Platform/Socionext/DeveloperBox/Logo/Logo.c
 create mode 100644 Platform/Socionext/DeveloperBox/Logo/Logo.idf
 create mode 100644 Platform/Socionext/DeveloperBox/Logo/LogoDxe.inf

-- 
2.17.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v1] Platform/ARM: Declare FVP Generic Timer Frame #1 as Non-secure

2018-05-23 Thread AlexeiFedorov
From: Alexei Fedorov 

Programming Reference for Base FVPs describes 2 Generic Memory-mapped
Timer frames with Non-secure access permitted to frame #1.
However ACPI GTDT lists both timer frames #0 and #1 with
Secure Timer flag being set in GTx Common Flags field:
 #define FVP_GTX_COMMON_FLAGS
   (GTX_TIMER_SAVE_CONTEXT | GTX_TIMER_SECURE)
Declaring both timer frames as Secure prevents OS running
in Non-secure state from accessing Generic Timer frame #1.

This patch fixes the above issue by removal of FVP_GTX_COMMON_FLAGS
and adding two FVP_GTX_COMMON_FLAGS_S and FVP_GTX_COMMON_FLAGS_NS
definitions used for Secure frame #0 and Non-secure frame #1
accordingly.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Alexei Fedorov 
---
All the changes can be reviewed at:
https://github.com/AlexeiFedorov/edk2-platforms/tree/262_gtdt_timer_frame_ns_v1

Notes:
v1:
- remove FVP_GTX_COMMON_FLAGS [Alexei]
- define FVP_GTX_COMMON_FLAGS_S and FVP_GTX_COMMON_FLAGS_NS   [Alexei]
- use FVP_GTX_COMMON_FLAGS_S for timer frame #0 and   [Alexei]
  FVP_GTX_COMMON_FLAGS_NS for frame #1

 Platform/ARM/VExpressPkg/AcpiTables/Gtdt.aslc | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/AcpiTables/Gtdt.aslc 
b/Platform/ARM/VExpressPkg/AcpiTables/Gtdt.aslc
index 
1cb4b498300cf1a08514835677154eace1dd1803..7a0b2b686ec849a8385ac5793e5d5855b9ba83ca
 100644
--- a/Platform/ARM/VExpressPkg/AcpiTables/Gtdt.aslc
+++ b/Platform/ARM/VExpressPkg/AcpiTables/Gtdt.aslc
@@ -1,7 +1,7 @@
 /** @file
 *  Generic Timer Description Table (GTDT)
 *
-*  Copyright (c) 2012 - 2017, ARM Limited. All rights reserved.
+*  Copyright (c) 2012 - 2018, ARM Limited. All rights reserved.
 *  Copyright (c) 2016, Linaro Ltd. All rights reserved
 *
 *  This program and the accompanying materials
@@ -61,7 +61,8 @@
 #define GTX_TIMER_SAVE_CONTEXT  
EFI_ACPI_6_1_GTDT_GT_BLOCK_COMMON_FLAG_ALWAYS_ON_CAPABILITY
 #define GTX_TIMER_LOSE_CONTEXT  0
 
-#define FVP_GTX_COMMON_FLAGS(GTX_TIMER_SAVE_CONTEXT | GTX_TIMER_SECURE)
+#define FVP_GTX_COMMON_FLAGS_S  (GTX_TIMER_SAVE_CONTEXT | GTX_TIMER_SECURE)
+#define FVP_GTX_COMMON_FLAGS_NS (GTX_TIMER_SAVE_CONTEXT | 
GTX_TIMER_NON_SECURE)
 
 #define FVP_SBSA_WATCHDOG_REFRESH_BASE 0x2a45
 #define FVP_SBSA_WATCHDOG_CONTROL_BASE 0x2a44
@@ -136,7 +137,7 @@ FVP_GENERIC_TIMER_DESCRIPTION_TABLES Gtdt = {
   FVP_GTX_TIMER_FLAGS,  // UINT32 
GTxPhysicalTimerFlags
   0,// UINT32 
GTxVirtualTimerGSIV
   0,// UINT32 
GTxVirtualTimerFlags
-  FVP_GTX_COMMON_FLAGS  // UINT32 
GTxCommonFlags
+  FVP_GTX_COMMON_FLAGS_S// UINT32 
GTxCommonFlags
 },
 {
   1,// UINT8 
GTFrameNumber
@@ -149,7 +150,7 @@ FVP_GENERIC_TIMER_DESCRIPTION_TABLES Gtdt = {
   FVP_GTX_TIMER_FLAGS,  // UINT32 
GTxPhysicalTimerFlags
   0,// UINT32 
GTxVirtualTimerGSIV
   0,// UINT32 
GTxVirtualTimerFlags
-  FVP_GTX_COMMON_FLAGS  // UINT32 
GTxCommonFlags
+  FVP_GTX_COMMON_FLAGS_NS   // UINT32 
GTxCommonFlags
 }
   },
 #if (FVP_WATCHDOG_COUNT != 0)
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v6 5/9] Platform/ARM/Sgi: add the initial set of acpi tables

2018-05-23 Thread Alexei Fedorov
Thomas, Daniil,


Have you seen my comment regarding bug in GTDT.aslc?


Alexei


From: edk2-devel  on behalf of Thomas Abraham 

Sent: 23 May 2018 06:45:39
To: edk2-devel@lists.01.org
Cc: leif.lindh...@linaro.org; ard.biesheu...@linaro.org
Subject: [edk2] [PATCH edk2-platforms v6 5/9] Platform/ARM/Sgi: add the initial 
set of acpi tables

From: Daniil Egranov 

Add the initial set of Acpi tables for the SGI-575 platform. These tables
conform to the ACPI specification version 6.1. Some of the mandatory tables
required for SBBR v1.0 compilance are not included in this initial set
of Acpi tables.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Daniil Egranov 
Signed-off-by: Thomas Abraham 
---
 .../ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf|  51 ++
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc|  90 +++
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl |  99 
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Fadt.aslc|  87 +++
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Gtdt.aslc| 151 ++
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Madt.aslc| 173 +
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Spcr.aslc|  77 +
 .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c   |   7 +
 .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf |   6 +
 Platform/ARM/SgiPkg/Include/SgiAcpiHeader.h|  41 +
 .../ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf |   4 +
 11 files changed, 786 insertions(+)
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Fadt.aslc
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Gtdt.aslc
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Madt.aslc
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Spcr.aslc
 create mode 100644 Platform/ARM/SgiPkg/Include/SgiAcpiHeader.h

diff --git a/Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf 
b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
new file mode 100644
index 000..ec47f94
--- /dev/null
+++ b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
@@ -0,0 +1,51 @@
+## @file
+#  ACPI table data and ASL sources required to boot the platform.
+#
+#  Copyright (c) 2018, 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.
+#
+##
+
+[Defines]
+  INF_VERSION= 0x0001001A
+  BASE_NAME  = Sgi575AcpiTables
+  FILE_GUID  = c712719a-0aaf-438c-9cdd-35ab4d60207d  # 
gSgi575AcpiTablesiFileGuid
+  MODULE_TYPE= USER_DEFINED
+  VERSION_STRING = 1.0
+
+[Sources]
+  Dbg2.aslc
+  Dsdt.asl
+  Fadt.aslc
+  Gtdt.aslc
+  Madt.aslc
+  Spcr.aslc
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+  Platform/ARM/SgiPkg/SgiPlatform.dec
+
+[FixedPcd]
+  gArmPlatformTokenSpaceGuid.PcdCoreCount
+  gArmPlatformTokenSpaceGuid.PcdClusterCount
+  gArmPlatformTokenSpaceGuid.PcdSerialDbgRegisterBase
+  gArmPlatformTokenSpaceGuid.PL011UartInterrupt
+
+  gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
+  gArmTokenSpaceGuid.PcdArmArchTimerIntrNum
+  gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum
+  gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum
+  gArmTokenSpaceGuid.PcdGicDistributorBase
+  gArmTokenSpaceGuid.PcdGicRedistributorsBase
+  gArmTokenSpaceGuid.PcdGenericWatchdogControlBase
+  gArmTokenSpaceGuid.PcdGenericWatchdogRefreshBase
diff --git a/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc 
b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc
new file mode 100644
index 000..ed671f3
--- /dev/null
+++ b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc
@@ -0,0 +1,90 @@
+/** @file
+*  Debug Port Table 2 (DBG2)
+*
+*  Copyright (c) 2018, 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.
+*
+**/
+
+#include 

Re: [edk2] [PATCH edk2-platforms v6 5/9] Platform/ARM/Sgi: add the initial set of acpi tables

2018-05-23 Thread Alexei Fedorov
Please see my comment in-lined.

> -Original Message-
> From: edk2-devel  On Behalf Of Thomas
> Abraham
> Sent: 23 May 2018 06:46
> To: edk2-devel@lists.01.org
> Cc: leif.lindh...@linaro.org; ard.biesheu...@linaro.org
> Subject: [edk2] [PATCH edk2-platforms v6 5/9] Platform/ARM/Sgi: add the 
> initial
> set of acpi tables
>
> From: Daniil Egranov 
>
> Add the initial set of Acpi tables for the SGI-575 platform. These tables 
> conform
> to the ACPI specification version 6.1. Some of the mandatory tables required 
> for
> SBBR v1.0 compilance are not included in this initial set of Acpi tables.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Daniil Egranov 
> Signed-off-by: Thomas Abraham 
> ---
>  .../ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf|  51 ++
>  Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc|  90 +++
>  Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl |  99 
>  Platform/ARM/SgiPkg/AcpiTables/Sgi575/Fadt.aslc|  87 +++
>  Platform/ARM/SgiPkg/AcpiTables/Sgi575/Gtdt.aslc| 151
> ++
>  Platform/ARM/SgiPkg/AcpiTables/Sgi575/Madt.aslc| 173
> +
>  Platform/ARM/SgiPkg/AcpiTables/Sgi575/Spcr.aslc|  77 +
>  .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c   |   7 +
>  .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf |   6 +
>  Platform/ARM/SgiPkg/Include/SgiAcpiHeader.h|  41 +
>  .../ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf |   4 +
>  11 files changed, 786 insertions(+)
>  create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
>  create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc
>  create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl
>  create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Fadt.aslc
>  create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Gtdt.aslc
>  create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Madt.aslc
>  create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Spcr.aslc
>  create mode 100644 Platform/ARM/SgiPkg/Include/SgiAcpiHeader.h
>
> diff --git a/Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
> b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
> new file mode 100644
> index 000..ec47f94
> --- /dev/null
> +++ b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
> @@ -0,0 +1,51 @@
> +## @file
> +#  ACPI table data and ASL sources required to boot the platform.
> +#
> +#  Copyright (c) 2018, 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.
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION= 0x0001001A
> +  BASE_NAME  = Sgi575AcpiTables
> +  FILE_GUID  = c712719a-0aaf-438c-9cdd-35ab4d60207d  #
> gSgi575AcpiTablesiFileGuid
> +  MODULE_TYPE= USER_DEFINED
> +  VERSION_STRING = 1.0
> +
> +[Sources]
> +  Dbg2.aslc
> +  Dsdt.asl
> +  Fadt.aslc
> +  Gtdt.aslc
> +  Madt.aslc
> +  Spcr.aslc
> +
> +[Packages]
> +  ArmPkg/ArmPkg.dec
> +  ArmPlatformPkg/ArmPlatformPkg.dec
> +  EmbeddedPkg/EmbeddedPkg.dec
> +  MdePkg/MdePkg.dec
> +  Platform/ARM/SgiPkg/SgiPlatform.dec
> +
> +[FixedPcd]
> +  gArmPlatformTokenSpaceGuid.PcdCoreCount
> +  gArmPlatformTokenSpaceGuid.PcdClusterCount
> +  gArmPlatformTokenSpaceGuid.PcdSerialDbgRegisterBase
> +  gArmPlatformTokenSpaceGuid.PL011UartInterrupt
> +
> +  gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
> +  gArmTokenSpaceGuid.PcdArmArchTimerIntrNum
> +  gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum
> +  gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum
> +  gArmTokenSpaceGuid.PcdGicDistributorBase
> +  gArmTokenSpaceGuid.PcdGicRedistributorsBase
> +  gArmTokenSpaceGuid.PcdGenericWatchdogControlBase
> +  gArmTokenSpaceGuid.PcdGenericWatchdogRefreshBase
> diff --git a/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc
> b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc
> new file mode 100644
> index 000..ed671f3
> --- /dev/null
> +++ b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc
> @@ -0,0 +1,90 @@
> +/** @file
> +*  Debug Port Table 2 (DBG2)
> +*
> +*  Copyright (c) 2018, 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 

[edk2] PciSegmentInfoLib instances

2018-05-23 Thread Laszlo Ersek
Hi Ray,

do you know of any open source, non-Null, PciSegmentInfoLib instance?
(Possibly outside of edk2?)

More precisely, it's not the PciSegmentInfoLib instance itself that's of
particular interest, but the hardware and the platform support code that
offer multiple PCIe segments.

Thanks
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] MdeModulePkg/PciBus: Use actual max bus # for subordinary bus #

2018-05-23 Thread Zeng, Star
The code comment "// Get next available PCI bus number" comes from 
PciAllocateBusNumber?
It should be updated accordingly for PciGetMaxBusNumber, right?

With the comment updated, Reviewed-by: Star Zeng .


Thanks,
Star
-Original Message-
From: Ni, Ruiyu 
Sent: Wednesday, May 23, 2018 11:30 AM
To: edk2-devel@lists.01.org
Cc: Zeng, Star 
Subject: [PATCH] MdeModulePkg/PciBus: Use actual max bus # for subordinary bus #

Current code assumes the max bus(0xFF) is under this P2P bridge and temporarily 
set it as subordinate bus.
It may cause silicon hangs during PCI enumeration in some specific case.

Instead, it should get the max bus number from the bus number resources 
returned from
PCI_HOST_BRIDGE_RESOURCE_ALLOCATION.StartBusEnumeration() and set it as 
subordinate bus.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Star Zeng 
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 39 -
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
index 976496379a..729e86b55e 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
@@ -29,6 +29,43 @@ CHAR16 *mBarTypeStr[] = {
   L"Unknow"
   };
 
+/**
+  Retrieve the max bus number that is assigned to the Root Bridge hierarchy.
+  It can support the case that there are multiple bus ranges.
+
+  @param  Bridge   Bridge device instance.
+
+  @retval  The max bus number that is assigned to this Root 
Bridge hierarchy.
+
+**/
+UINT16
+PciGetMaxBusNumber (
+  IN PCI_IO_DEVICE  *Bridge
+  )
+{
+  PCI_IO_DEVICE  *RootBridge;
+  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  *BusNumberRanges;
+  UINT64 MaxNumberInRange;
+
+  //
+  // Get PCI Root Bridge device
+  //
+  RootBridge = Bridge;
+  while (RootBridge->Parent != NULL) {
+RootBridge = RootBridge->Parent;
+  }
+  MaxNumberInRange = 0;
+  //
+  // Get next available PCI bus number
+  //
+  BusNumberRanges = RootBridge->BusNumberRanges;
+  while (BusNumberRanges->Desc != ACPI_END_TAG_DESCRIPTOR) {
+MaxNumberInRange = BusNumberRanges->AddrRangeMin + 
BusNumberRanges->AddrLen - 1;
+BusNumberRanges++;
+  }
+  return (UINT16) MaxNumberInRange;
+}
+
 /**
   Retrieve the PCI Card device BAR information via PciIo interface.
 
@@ -1193,7 +1230,7 @@ PciScanBus (
   // Temporarily initialize SubBusNumber to maximum bus number to 
ensure the
   // PCI configuration transaction to go through any PPB
   //
-  Register  = 0xFF;
+  Register  = PciGetMaxBusNumber (Bridge);
   Address   = EFI_PCI_ADDRESS (StartBusNumber, Device, Func, 
PCI_BRIDGE_SUBORDINATE_BUS_REGISTER_OFFSET);
   Status = PciRootBridgeIo->Pci.Write (
   PciRootBridgeIo,
--
2.16.1.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v4 2/6] Platform/HiKey960: do basic initialization

2018-05-23 Thread Haojian Zhuang
>> +STATIC
>> +VOID
>> +OnEndOfDxe (
>> +  IN EFI_EVENT  Event,
>> +  IN VOID   *Context
>> +  )
>> +{
>> +  UINT32BootMode;
>> +
>> +  BootMode = MmioRead32 (SCTRL_BAK_DATA0) & BOOT_MODE_MASK;
>> +  if (BootMode == BOOT_MODE_RECOVERY) {
>> +SerialPortWrite ((UINT8 *)"WARNING: CAN NOT BOOT KERNEL IN RECOVERY 
>> MODE!\r\n", 48);
>> +SerialPortWrite ((UINT8 *)"Switch to normal boot mode, then reboot to 
>> boot kernel.\r\n", 57);
> 
> I commented on v1:
> ---
> 1) Why this use of SerialPortWrite instead of Print?
> 2) This cast to (UINT8 *) works by accident. Please don't do this.
> 3) Please _never_ use hand-coded values for compile-time determined
> (and known) information. In this case the output string length.
> ---
> Please change to Print().
> 

I can't use Print() at here since console isn't ready. The OnEndOfDxe() is 
executed
before console ready. SerialPortWrite () is the only choice to me.

I'll fix other issues with comments.

Best Regards
Haojian
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] MdePkg/BaseLib: Add GenerateGuid() to BaseLib

2018-05-23 Thread Ni, Ruiyu
Good points!
I will hold the patch.

Thanks/Ray

> -Original Message-
> From: Zeng, Star
> Sent: Wednesday, May 23, 2018 2:11 PM
> To: Ni, Ruiyu ; Ni, Ruiyu ; edk2-
> de...@lists.01.org
> Cc: Kinney, Michael D ; Gao, Liming
> ; Long, Qin ; Zeng, Star
> 
> Subject: RE: [edk2] [PATCH] MdePkg/BaseLib: Add GenerateGuid() to
> BaseLib
> 
> Ray,
> 
> Two points need be noticed.
> 1. BaseLib.inf forgets to include RngLib.
> 2. This patch will include RngLib dependency to BaseLib, that may break many
> platforms that do not declare RngLib in their platform dsc.
> 
> 
> Thanks,
> Star
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ni,
> Ruiyu
> Sent: Wednesday, May 23, 2018 1:58 PM
> To: Ni, Ruiyu ; edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Gao, Liming
> ; Long, Qin 
> Subject: Re: [edk2] [PATCH] MdePkg/BaseLib: Add GenerateGuid() to
> BaseLib
> 
> Sorry, I forgot to include Long Qin.
> 
> Thanks/Ray
> 
> > -Original Message-
> > From: edk2-devel  On Behalf Of Ruiyu
> > Ni
> > Sent: Wednesday, May 23, 2018 1:34 PM
> > To: edk2-devel@lists.01.org
> > Cc: Kinney, Michael D ; Gao, Liming
> > 
> > Subject: [edk2] [PATCH] MdePkg/BaseLib: Add GenerateGuid() to BaseLib
> >
> > Per RFC4122, there are five versions of UUID (GUID).
> > The version 4 only depends on truly random or pseudo-random number
> > generation.
> > So GenerateGuid () can be added to BaseLib. It uses the
> > GetRandomNumber128() services exposed from MdePkg/RngLib.
> > This API can be used by some EFI utilities which needs the guidgen
> > services,
> > e.g.: utility that partitions the disk in GPT format needs to fill the
> > generated GUID in partition table.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ruiyu Ni 
> > Cc: Liming Gao 
> > Cc: Michael D Kinney 
> > Cc: Qin Long 
> > ---
> >  MdePkg/Include/Library/BaseLib.h  | 18 -
> >  MdePkg/Library/BaseLib/BaseLibInternals.h |  3 +-
> >  MdePkg/Library/BaseLib/GenerateGuid.c | 64
> > +++
> >  3 files changed, 83 insertions(+), 2 deletions(-)  create mode 100644
> > MdePkg/Library/BaseLib/GenerateGuid.c
> >
> > diff --git a/MdePkg/Include/Library/BaseLib.h
> > b/MdePkg/Include/Library/BaseLib.h
> > index eb2899f852..272596d64c 100644
> > --- a/MdePkg/Include/Library/BaseLib.h
> > +++ b/MdePkg/Include/Library/BaseLib.h
> > @@ -2,7 +2,7 @@
> >Provides string functions, linked list functions, math functions,
> > synchronization
> >functions, file path functions, and CPU architecture-specific functions.
> >
> > -Copyright (c) 2006 - 2017, Intel Corporation. All rights
> > reserved.
> > +Copyright (c) 2006 - 2018, Intel Corporation. All rights
> > +reserved.
> >  Portions copyright (c) 2008 - 2009, Apple Inc. All rights
> > reserved.  This program and the accompanying materials  are
> > licensed and made available under the terms and conditions of the BSD
> > License @@ -5104,6 +5104,22 @@ EFIAPI  CpuDeadLoop (
> >VOID
> >);
> > +
> > +/**
> > +  Generate a raw 128-bit (16-byte) GUID.
> > +
> > +  If Guid is NULL, then ASSERT().
> > +
> > +  @param Guid   Receive the 128-bit (16-byte) GUID.
> > +
> > +  @retval TRUE  The GUID is generated successfully.
> > +  @retval FALSE The GUID is not generated.
> > +**/
> > +BOOLEAN
> > +EFIAPI
> > +GenerateGuid (
> > +  OUT GUID  *Guid
> > +  );
> >
> >  #if defined (MDE_CPU_IPF)
> >
> > diff --git a/MdePkg/Library/BaseLib/BaseLibInternals.h
> > b/MdePkg/Library/BaseLib/BaseLibInternals.h
> > index 9dca97a0dc..427eb44eba 100644
> > --- a/MdePkg/Library/BaseLib/BaseLibInternals.h
> > +++ b/MdePkg/Library/BaseLib/BaseLibInternals.h
> > @@ -1,7 +1,7 @@
> >  /** @file
> >Declaration of internal functions in BaseLib.
> >
> > -  Copyright (c) 2006 - 2017, Intel Corporation. All rights
> > reserved.
> > +  Copyright (c) 2006 - 2018, Intel Corporation. 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 @@ -20,6 +20,7 @@  #include 
> > #include   #include 
> > +#include 
> >
> >  //
> >  // Math functions
> > diff --git a/MdePkg/Library/BaseLib/GenerateGuid.c
> > b/MdePkg/Library/BaseLib/GenerateGuid.c
> > new file mode 100644
> > index 00..b90f7c5a83
> > --- /dev/null
> > +++ b/MdePkg/Library/BaseLib/GenerateGuid.c
> > @@ -0,0 +1,64 @@
> > +/** @file
> > +  Generate 

Re: [edk2] reg: EDK2 - HTTP Boot Image Validation

2018-05-23 Thread Fu, Siyuan
Using standardized HTTP header is high priority, you also mentioned that RFC 
says " If and only if the media type is not given by a Content-Type field..."

BestRegards
Fu Siyuan


> -Original Message-
> From: Sivaraman Nainar [mailto:sivaram...@amiindia.co.in]
> Sent: Wednesday, May 23, 2018 2:00 PM
> To: Fu, Siyuan ; edk2-devel@lists.01.org
> Subject: RE: reg: EDK2 - HTTP Boot Image Validation
> 
> Hello Fu Siyuan,
> 
> We can skip the header check if we know the image type. That should be
> enough.
> 
> -Siva
> -Original Message-
> From: Fu, Siyuan [mailto:siyuan...@intel.com]
> Sent: Wednesday, May 23, 2018 11:14 AM
> To: Sivaraman Nainar; edk2-devel@lists.01.org
> Subject: RE: reg: EDK2 - HTTP Boot Image Validation
> 
> Hi, Siva
> 
> What do you mean by "skip the validation of image types"? Do you want to
> skip the "Content-type" HTTP header check, or name extension check, or
> both of them?
> 
> 
> BestRegards
> Fu Siyuan
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > Sivaraman Nainar
> > Sent: Friday, May 18, 2018 5:17 PM
> > To: edk2-devel@lists.01.org
> > Subject: [edk2] reg: EDK2 - HTTP Boot Image Validation
> >
> > Hello all,
> > When HTTP Boot performed the code checking if the Image type as EFI
> > ISO and IMG. If not the boot not when the content type is as
> > "Content-type: text/plain".
> > https://github.com/tianocore/edk2/blob/master/NetworkPkg/HttpBootDxe/H
> > ttpB ootSupport.c (HttpBootCheckImageType())
> >
> > But as per RFC it described below.
> > https://tools.ietf.org/html/rfc2616#section-7.2.1:
> > "If and only if the media type is not given by a Content-Type field,
> > the recipient MAY attempt to guess the media type via inspection of
> > its content and/or the name extension(s) of the URI used to identify
> > the resource."
> > Can you please comment if this need to be addressed such a way we can
> > skip the validation of image types.
> > -Siva
> > ___
> > 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


Re: [edk2] [PATCH] MdePkg/BaseLib: Add GenerateGuid() to BaseLib

2018-05-23 Thread Zeng, Star
Ray,

Two points need be noticed.
1. BaseLib.inf forgets to include RngLib.
2. This patch will include RngLib dependency to BaseLib, that may break many 
platforms that do not declare RngLib in their platform dsc.


Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ni, Ruiyu
Sent: Wednesday, May 23, 2018 1:58 PM
To: Ni, Ruiyu ; edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Gao, Liming 
; Long, Qin 
Subject: Re: [edk2] [PATCH] MdePkg/BaseLib: Add GenerateGuid() to BaseLib

Sorry, I forgot to include Long Qin.

Thanks/Ray

> -Original Message-
> From: edk2-devel  On Behalf Of Ruiyu 
> Ni
> Sent: Wednesday, May 23, 2018 1:34 PM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Gao, Liming 
> 
> Subject: [edk2] [PATCH] MdePkg/BaseLib: Add GenerateGuid() to BaseLib
> 
> Per RFC4122, there are five versions of UUID (GUID).
> The version 4 only depends on truly random or pseudo-random number 
> generation.
> So GenerateGuid () can be added to BaseLib. It uses the
> GetRandomNumber128() services exposed from MdePkg/RngLib.
> This API can be used by some EFI utilities which needs the guidgen 
> services,
> e.g.: utility that partitions the disk in GPT format needs to fill the 
> generated GUID in partition table.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni 
> Cc: Liming Gao 
> Cc: Michael D Kinney 
> Cc: Qin Long 
> ---
>  MdePkg/Include/Library/BaseLib.h  | 18 -
>  MdePkg/Library/BaseLib/BaseLibInternals.h |  3 +-
>  MdePkg/Library/BaseLib/GenerateGuid.c | 64
> +++
>  3 files changed, 83 insertions(+), 2 deletions(-)  create mode 100644 
> MdePkg/Library/BaseLib/GenerateGuid.c
> 
> diff --git a/MdePkg/Include/Library/BaseLib.h
> b/MdePkg/Include/Library/BaseLib.h
> index eb2899f852..272596d64c 100644
> --- a/MdePkg/Include/Library/BaseLib.h
> +++ b/MdePkg/Include/Library/BaseLib.h
> @@ -2,7 +2,7 @@
>Provides string functions, linked list functions, math functions, 
> synchronization
>functions, file path functions, and CPU architecture-specific functions.
> 
> -Copyright (c) 2006 - 2017, Intel Corporation. All rights 
> reserved.
> +Copyright (c) 2006 - 2018, Intel Corporation. All rights 
> +reserved.
>  Portions copyright (c) 2008 - 2009, Apple Inc. All rights 
> reserved.  This program and the accompanying materials  are 
> licensed and made available under the terms and conditions of the BSD 
> License @@ -5104,6 +5104,22 @@ EFIAPI  CpuDeadLoop (
>VOID
>);
> +
> +/**
> +  Generate a raw 128-bit (16-byte) GUID.
> +
> +  If Guid is NULL, then ASSERT().
> +
> +  @param Guid   Receive the 128-bit (16-byte) GUID.
> +
> +  @retval TRUE  The GUID is generated successfully.
> +  @retval FALSE The GUID is not generated.
> +**/
> +BOOLEAN
> +EFIAPI
> +GenerateGuid (
> +  OUT GUID  *Guid
> +  );
> 
>  #if defined (MDE_CPU_IPF)
> 
> diff --git a/MdePkg/Library/BaseLib/BaseLibInternals.h
> b/MdePkg/Library/BaseLib/BaseLibInternals.h
> index 9dca97a0dc..427eb44eba 100644
> --- a/MdePkg/Library/BaseLib/BaseLibInternals.h
> +++ b/MdePkg/Library/BaseLib/BaseLibInternals.h
> @@ -1,7 +1,7 @@
>  /** @file
>Declaration of internal functions in BaseLib.
> 
> -  Copyright (c) 2006 - 2017, Intel Corporation. All rights 
> reserved.
> +  Copyright (c) 2006 - 2018, Intel Corporation. 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 @@ -20,6 +20,7 @@  #include  
> #include   #include 
> +#include 
> 
>  //
>  // Math functions
> diff --git a/MdePkg/Library/BaseLib/GenerateGuid.c
> b/MdePkg/Library/BaseLib/GenerateGuid.c
> new file mode 100644
> index 00..b90f7c5a83
> --- /dev/null
> +++ b/MdePkg/Library/BaseLib/GenerateGuid.c
> @@ -0,0 +1,64 @@
> +/** @file
> +  Generate GUID implementation.
> +
> +  Copyright (c) 2018, Intel Corporation. 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 "BaseLibInternals.h"
> +
> +/**
> +  Generate a raw 128-bit (16-byte) GUID.
> +
> +  If Guid is NULL, then ASSERT().
> +
> +  @param Guid  

Re: [edk2] [PATCH edk2-platforms v5 9/9] Platform/ARM/Sgi: Add Ssdt, Iort and Mcfg tables

2018-05-23 Thread Ard Biesheuvel
On 23 May 2018 at 07:09, Thomas Abraham  wrote:
> Hi Ard,
>
> On Wed, May 23, 2018 at 10:13 AM, Ard Biesheuvel
>  wrote:
>> On 23 May 2018 at 06:29, Thomas Abraham  wrote:
>>> SGI platforms support a AHCI controller which is attached to a PCIe
>>> root complex and it can generate PCIe ITS-MSI transactions. So the
>>> Ssdt, Iort and Mcfg ACPI tables to desribe this topology to the
>>> linux kernel.
>>>
>>> Change-Id: I45d4cb03a5f25364f75587899faed634c612bb69
>>
>> Please remove the change-ids
>
> Sorry, missed that. Will remove this from all the other patches in
> this series in the next version.
>
>>
>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>> Signed-off-by: Thomas Abraham 
>>> ---
>>>  .../ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf|   3 +
>>>  Platform/ARM/SgiPkg/AcpiTables/Sgi575/Iort.aslc| 106 
>>> +
>>>  Platform/ARM/SgiPkg/AcpiTables/Sgi575/Mcfg.aslc|  59 
>>>  Platform/ARM/SgiPkg/AcpiTables/Sgi575/Ssdt.asl |  95 ++
>>>  4 files changed, 263 insertions(+)
>>>  create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Iort.aslc
>>>  create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Mcfg.aslc
>>>  create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Ssdt.asl
>>>
>>> diff --git a/Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf 
>>> b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
>>> index 3694de9..e9bdd8a 100644
>>> --- a/Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
>>> +++ b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
>>> @@ -25,8 +25,11 @@
>>>Dsdt.asl
>>>Fadt.aslc
>>>Gtdt.aslc
>>> +  Iort.aslc
>>>Madt.aslc
>>> +  Mcfg.aslc
>>>Spcr.aslc
>>> +  Ssdt.asl
>>>
>>>  [Packages]
>>>ArmPkg/ArmPkg.dec
>>> diff --git a/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Iort.aslc 
>>> b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Iort.aslc
>>> new file mode 100644
>>> index 000..a8b6363
>>> --- /dev/null
>>> +++ b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Iort.aslc
>>> @@ -0,0 +1,106 @@
>>> +/** @file
>>> +*  I/O Remapping Table (Iort)
>>> +*
>>> +*  Copyright (c) 2018, 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 
>>> +#include 
>>> +#include 
>>> +#include "SgiAcpiHeader.h"
>>> +
>>> +#pragma pack(1)
>>> +
>>> +typedef struct
>>> +{
>>> +  EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE   ItsNode;
>>> +  UINT32   ItsIdentifiers;
>>> +} ARM_EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE;
>>> +
>>> +typedef struct
>>> +{
>>> +  EFI_ACPI_6_0_IO_REMAPPING_RC_NODERcNode;
>>> +  EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE   RcIdMap;
>>> +} ARM_EFI_ACPI_6_0_IO_REMAPPING_RC_NODE;
>>> +
>>> +typedef struct
>>> +{
>>> +  EFI_ACPI_6_0_IO_REMAPPING_TABLE  Header;
>>> +  ARM_EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE   ItsNode;
>>> +  ARM_EFI_ACPI_6_0_IO_REMAPPING_RC_NODERcNode;
>>> +} ARM_EFI_ACPI_6_0_IO_REMAPPING_TABLE;
>>> +
>>> +#pragma pack ()
>>> +
>>> +ARM_EFI_ACPI_6_0_IO_REMAPPING_TABLE Iort =
>>> +{
>>> +  // EFI_ACPI_6_0_IO_REMAPPING_TABLE
>>> +  {
>>> + ARM_ACPI_HEADER  // EFI_ACPI_DESCRIPTION_HEADER
>>> + (
>>> +   EFI_ACPI_6_0_IO_REMAPPING_TABLE_SIGNATURE,
>>> +   ARM_EFI_ACPI_6_0_IO_REMAPPING_TABLE,
>>> +   EFI_ACPI_IO_REMAPPING_TABLE_REVISION
>>> + ),
>>> + 2,  // NumNodes
>>> + sizeof (EFI_ACPI_6_0_IO_REMAPPING_TABLE),  // NodeOffset
>>> + 0,  // Reserved
>>> +  },
>>> +  // ARM_EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE
>>> +  {
>>> +// EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE
>>> +{
>>> +  // EFI_ACPI_6_0_IO_REMAPPING_NODE
>>> +  {
>>> +EFI_ACPI_IORT_TYPE_ITS_GROUP,  // Type
>>> +sizeof (ARM_EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE), // Length
>>> +0,  // Revision
>>> +0,  // Reserved
>>> +0,  // NumIdMappings
>>> +0,  // IdReference
>>> +  },
>>> +  1,// GIC ITS Identifiers
>>> +},
>>> +0,
>>> +  },
>>> +  // ARM_EFI_ACPI_6_0_IO_REMAPPING_RC_NODE
>>> +  {
>>> +// EFI_ACPI_6_0_IO_REMAPPING_RC_NODE
>>> +{
>>> +  // EFI_ACPI_6_0_IO_REMAPPING_NODE
>>> +  {
>>> +EFI_ACPI_IORT_TYPE_ROOT_COMPLEX,  // Type
>>> +sizeof (ARM_EFI_ACPI_6_0_IO_REMAPPING_RC_NODE),  // Length
>>> +0,  // Revision
>>> +0,  // Reserved
>>> +1,  // NumIdMappings
>>> +__builtin_offsetof (ARM_EFI_ACPI_6_0_IO_REMAPPING_RC_NODE, 
>>> RcIdMap),  // 

Re: [edk2] reg: EDK2 - HTTP Boot Image Validation

2018-05-23 Thread Sivaraman Nainar
Hello Fu Siyuan,

We can skip the header check if we know the image type. That should be enough.

-Siva
-Original Message-
From: Fu, Siyuan [mailto:siyuan...@intel.com] 
Sent: Wednesday, May 23, 2018 11:14 AM
To: Sivaraman Nainar; edk2-devel@lists.01.org
Subject: RE: reg: EDK2 - HTTP Boot Image Validation

Hi, Siva

What do you mean by "skip the validation of image types"? Do you want to skip 
the "Content-type" HTTP header check, or name extension check, or both of them?


BestRegards
Fu Siyuan

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Sivaraman Nainar
> Sent: Friday, May 18, 2018 5:17 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] reg: EDK2 - HTTP Boot Image Validation
> 
> Hello all,
> When HTTP Boot performed the code checking if the Image type as EFI 
> ISO and IMG. If not the boot not when the content type is as
> "Content-type: text/plain".
> https://github.com/tianocore/edk2/blob/master/NetworkPkg/HttpBootDxe/H
> ttpB ootSupport.c (HttpBootCheckImageType())
> 
> But as per RFC it described below.
> https://tools.ietf.org/html/rfc2616#section-7.2.1:
> "If and only if the media type is not given by a Content-Type field, 
> the recipient MAY attempt to guess the media type via inspection of 
> its content and/or the name extension(s) of the URI used to identify 
> the resource."
> Can you please comment if this need to be addressed such a way we can 
> skip the validation of image types.
> -Siva
> ___
> 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