diff mbox

[Linaro-uefi,linaro-uefi,v5,06/44] Hisilicon: Rename ArmPlatformLibPv660 to Hisilicon common ArmPlatformLib

Message ID 1480652017-31676-7-git-send-email-heyi.guo@linaro.org
State New
Headers show

Commit Message

gary guo Dec. 2, 2016, 4:12 a.m. UTC
1. Rename ArmPlatformLibPv660 folder to ArmPlatformLibHisilicon.
2. Modify D02/D03 dsc file accordingly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.com>
---
 .../ArmPlatformLibHisilicon/AArch64/Helper.S       |  61 ++++++++++++
 .../ArmPlatformLibHisilicon/ArmPlatformLib.c       | 108 +++++++++++++++++++++
 .../ArmPlatformLibHisilicon/ArmPlatformLib.inf     |  69 +++++++++++++
 .../ArmPlatformLibHisilicon/ArmPlatformLibMem.c    |  98 +++++++++++++++++++
 .../ArmPlatformLibHisilicon/ArmPlatformLibSec.inf  |  56 +++++++++++
 .../Library/ArmPlatformLibPv660/AArch64/Helper.S   |  61 ------------
 .../Library/ArmPlatformLibPv660/ArmPlatformLib.c   | 108 ---------------------
 .../Library/ArmPlatformLibPv660/ArmPlatformLib.inf |  69 -------------
 .../ArmPlatformLibPv660/ArmPlatformLibMem.c        |  98 -------------------
 .../ArmPlatformLibPv660/ArmPlatformLibSec.inf      |  56 -----------
 Platforms/Hisilicon/D02/Pv660D02.dsc               |   6 +-
 Platforms/Hisilicon/D03/D03.dsc                    |   6 +-
 12 files changed, 398 insertions(+), 398 deletions(-)
 create mode 100644 Chips/Hisilicon/Library/ArmPlatformLibHisilicon/AArch64/Helper.S
 create mode 100644 Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.c
 create mode 100644 Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.inf
 create mode 100644 Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLibMem.c
 create mode 100644 Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLibSec.inf
 delete mode 100644 Chips/Hisilicon/Library/ArmPlatformLibPv660/AArch64/Helper.S
 delete mode 100644 Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLib.c
 delete mode 100644 Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLib.inf
 delete mode 100644 Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLibMem.c
 delete mode 100644 Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLibSec.inf
diff mbox

Patch

diff --git a/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/AArch64/Helper.S b/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/AArch64/Helper.S
new file mode 100644
index 0000000..3422df2
--- /dev/null
+++ b/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/AArch64/Helper.S
@@ -0,0 +1,61 @@ 
+//
+//  Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+//  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+//  Copyright (c) 2015, 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.
+//
+//  Based on the files under ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/
+//
+//
+
+#include <AsmMacroIoLibV8.h>
+#include <Library/ArmLib.h>
+
+ASM_FUNC(ArmPlatformPeiBootAction)
+  ret
+
+//UINTN
+//ArmPlatformGetPrimaryCoreMpId (
+//  VOID
+//  );
+ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
+  MOV32 (w0, FixedPcdGet32(PcdArmPrimaryCore))
+  ret
+
+# IN None
+# OUT x0 = number of cores present in the system
+ASM_FUNC(ArmGetCpuCountPerCluster)
+  MOV32 (w0, FixedPcdGet32(PcdCoreCount))
+  ret
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+//  IN UINTN MpId
+//  );
+ASM_FUNC(ArmPlatformIsPrimaryCore)
+  MOV32 (w1, FixedPcdGet32(PcdArmPrimaryCoreMask))
+  and   x0, x0, x1
+  MOV32 (w1, FixedPcdGet32(PcdArmPrimaryCore))
+  cmp   w0, w1
+  cset  x0, eq
+  ret
+
+//UINTN
+//ArmPlatformGetCorePosition (
+//  IN UINTN MpId
+//  );
+// With this function: CorePos = (ClusterId * 4) + CoreId
+ASM_FUNC(ArmPlatformGetCorePosition)
+  and   x1, x0, #ARM_CORE_MASK
+  and   x0, x0, #ARM_CLUSTER_MASK
+  add   x0, x1, x0, LSR #6
+  ret
+
+ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.c b/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.c
new file mode 100644
index 0000000..6c85958
--- /dev/null
+++ b/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.c
@@ -0,0 +1,108 @@ 
+/** @file
+*
+*  Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+*  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+*  Copyright (c) 2015, 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.
+*
+*  Based on the files under ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/
+*
+**/
+
+#include <Library/IoLib.h>
+#include <Library/ArmPlatformLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+
+#include <Ppi/ArmMpCoreInfo.h>
+
+#include <ArmPlatform.h>
+UINTN
+ArmGetCpuCountPerCluster (
+  VOID
+  );
+
+extern  EFI_STATUS MemInitEntry (VOID);
+
+/**
+  Return the current Boot Mode
+
+  This function returns the boot reason on the platform
+
+  @return   Return the current Boot Mode of the platform
+
+**/
+EFI_BOOT_MODE
+ArmPlatformGetBootMode (
+  VOID
+  )
+{
+  return BOOT_WITH_FULL_CONFIGURATION;
+}
+
+/**
+  Initialize controllers that must setup in the normal world
+
+  This function is called by the ArmPlatformPkg/Pei or ArmPlatformPkg/Pei/PlatformPeim
+  in the PEI phase.
+
+**/
+RETURN_STATUS
+ArmPlatformInitialize (
+  IN  UINTN                     MpId
+  )
+{
+  return RETURN_SUCCESS;
+}
+
+/**
+  Initialize the system (or sometimes called permanent) memory
+
+  This memory is generally represented by the DRAM.
+
+**/
+VOID
+ArmPlatformInitializeSystemMemory (
+  VOID
+  )
+{
+  // Nothing to do here
+}
+
+EFI_STATUS
+PrePeiCoreGetMpCoreInfo (
+  OUT UINTN                   *CoreCount,
+  OUT ARM_CORE_INFO           **ArmCoreTable
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+// Needs to be declared in the file. Otherwise gArmMpCoreInfoPpiGuid is undefined in the contect of PrePeiCore
+EFI_GUID mArmMpCoreInfoPpiGuid = ARM_MP_CORE_INFO_PPI_GUID;
+ARM_MP_CORE_INFO_PPI mMpCoreInfoPpi = { PrePeiCoreGetMpCoreInfo };
+
+EFI_PEI_PPI_DESCRIPTOR      gPlatformPpiTable[] = {
+  {
+    EFI_PEI_PPI_DESCRIPTOR_PPI,
+    &mArmMpCoreInfoPpiGuid,
+    &mMpCoreInfoPpi
+  }
+};
+
+VOID
+ArmPlatformGetPlatformPpiList (
+  OUT UINTN                   *PpiListSize,
+  OUT EFI_PEI_PPI_DESCRIPTOR  **PpiList
+  )
+{
+  *PpiListSize = sizeof(gPlatformPpiTable);
+  *PpiList = gPlatformPpiTable;
+}
diff --git a/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.inf b/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.inf
new file mode 100644
index 0000000..e86e53e
--- /dev/null
+++ b/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.inf
@@ -0,0 +1,69 @@ 
+#/* @file
+#  Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+#  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+#  Copyright (c) 2015, 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.
+#
+#  Based on the files under ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/
+#
+#*/
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = ArmPlatformLibPv660
+  FILE_GUID                      = 6887500D-32AD-41cd-855E-F8A5D5B0D4D2
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = ArmPlatformLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  ArmPkg/ArmPkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+
+  OpenPlatformPkg/Chips/Hisilicon/HisiPkg.dec
+
+[LibraryClasses]
+  IoLib
+  ArmLib
+  MemoryAllocationLib
+  SerialPortLib
+
+[Sources.common]
+  ArmPlatformLib.c
+  ArmPlatformLibMem.c
+
+[Sources.AARCH64]
+  AArch64/Helper.S
+
+[FeaturePcd]
+  gEmbeddedTokenSpaceGuid.PcdCacheEnable
+  gArmPlatformTokenSpaceGuid.PcdNorFlashRemapping
+
+[FixedPcd]
+  gArmTokenSpaceGuid.PcdSystemMemoryBase
+  gArmTokenSpaceGuid.PcdSystemMemorySize
+  gArmTokenSpaceGuid.PcdFvBaseAddress
+
+  gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
+  gArmTokenSpaceGuid.PcdArmPrimaryCore
+
+  gArmPlatformTokenSpaceGuid.PcdCoreCount
+
+  gHisiTokenSpaceGuid.PcdNORFlashBase
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase
+  gArmTokenSpaceGuid.PcdGicDistributorBase
+  gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
+  gHisiTokenSpaceGuid.PcdSysControlBaseAddress
+  gHisiTokenSpaceGuid.PcdPeriSubctrlAddress
+  gArmPlatformTokenSpaceGuid.PcdSP805WatchdogBase
+
diff --git a/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLibMem.c b/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLibMem.c
new file mode 100644
index 0000000..5bbcab3
--- /dev/null
+++ b/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLibMem.c
@@ -0,0 +1,98 @@ 
+/** @file
+*
+*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+*  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+*  Copyright (c) 2015, 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.
+*
+*  Based on the files under ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/
+*
+**/
+
+#include <Library/ArmPlatformLib.h>
+#include <Library/DebugLib.h>
+#include <Library/HobLib.h>
+#include <Library/PcdLib.h>
+#include <Library/IoLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <ArmPlatform.h>
+
+#include <Library/OemSetVirtualMapDesc.h>
+
+#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS          32
+
+// DDR attributes
+#define DDR_ATTRIBUTES_CACHED           ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
+#define DDR_ATTRIBUTES_UNCACHED         ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED
+
+/**
+  Return the Virtual Memory Map of your platform
+
+  This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU on your platform.
+
+  @param[out]   VirtualMemoryMap    Array of ARM_MEMORY_REGION_DESCRIPTOR describing a Physical-to-
+                                    Virtual Memory mapping. This array must be ended by a zero-filled
+                                    entry
+
+**/
+VOID
+ArmPlatformGetVirtualMemoryMap (
+  IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap
+  )
+{
+  ARM_MEMORY_REGION_ATTRIBUTES  CacheAttributes;
+  UINTN                         Index;
+  ARM_MEMORY_REGION_DESCRIPTOR  *VirtualMemoryTable;
+  EFI_PEI_HOB_POINTERS          NextHob;
+
+  ASSERT (VirtualMemoryMap != NULL);
+
+  VirtualMemoryTable = (ARM_MEMORY_REGION_DESCRIPTOR*)AllocatePages(EFI_SIZE_TO_PAGES (sizeof(ARM_MEMORY_REGION_DESCRIPTOR) * MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS));
+  if (VirtualMemoryTable == NULL) {
+      return;
+  }
+
+  if (FeaturePcdGet(PcdCacheEnable) == TRUE) {
+      CacheAttributes = DDR_ATTRIBUTES_CACHED;
+  } else {
+      CacheAttributes = DDR_ATTRIBUTES_UNCACHED;
+  }
+
+  Index = OemSetVirtualMapDesc(VirtualMemoryTable, CacheAttributes);
+
+  // Search for System Memory Hob that contains the EFI resource system memory
+  NextHob.Raw = GetHobList ();
+  while ((NextHob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, NextHob.Raw)) != NULL)
+  {
+    if (NextHob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY)
+    {
+        if (NextHob.ResourceDescriptor->PhysicalStart > BASE_4GB)
+        {
+            VirtualMemoryTable[++Index].PhysicalBase = NextHob.ResourceDescriptor->PhysicalStart;
+            VirtualMemoryTable[Index].VirtualBase  = NextHob.ResourceDescriptor->PhysicalStart;
+            VirtualMemoryTable[Index].Length       =NextHob.ResourceDescriptor->ResourceLength;
+            VirtualMemoryTable[Index].Attributes   =  CacheAttributes;
+        }
+    }
+
+    NextHob.Raw = GET_NEXT_HOB (NextHob);
+  }
+
+  // End of Table
+  VirtualMemoryTable[++Index].PhysicalBase = 0;
+  VirtualMemoryTable[Index].VirtualBase  = 0;
+  VirtualMemoryTable[Index].Length       = 0;
+  VirtualMemoryTable[Index].Attributes   = (ARM_MEMORY_REGION_ATTRIBUTES)0;
+
+  ASSERT((Index + 1) <= MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS);
+  DEBUG((EFI_D_INFO, "[%a]:[%dL] discriptor count=%d\n", __FUNCTION__, __LINE__, Index+1));
+
+  *VirtualMemoryMap = VirtualMemoryTable;
+}
diff --git a/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLibSec.inf b/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLibSec.inf
new file mode 100644
index 0000000..fa308bd
--- /dev/null
+++ b/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLibSec.inf
@@ -0,0 +1,56 @@ 
+#/* @file
+#  Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+#  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+#  Copyright (c) 2015, 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.
+#
+#  Based on the files under ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/
+#
+#*/
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = ArmPlatformLibPv660Sec
+  FILE_GUID                      = a79eed97-4b98-4974-9690-37b32d6a5b56
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = ArmPlatformLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  ArmPkg/ArmPkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+
+[LibraryClasses]
+  IoLib
+  ArmLib
+  SerialPortLib
+
+[Sources.common]
+  ArmPlatformLib.c
+
+[Sources.AARCH64]
+  AArch64/Helper.S
+
+[FeaturePcd]
+  gEmbeddedTokenSpaceGuid.PcdCacheEnable
+  gArmPlatformTokenSpaceGuid.PcdNorFlashRemapping
+
+[FixedPcd]
+  gArmTokenSpaceGuid.PcdSystemMemoryBase
+  gArmTokenSpaceGuid.PcdSystemMemorySize
+  gArmTokenSpaceGuid.PcdFvBaseAddress
+
+  gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
+  gArmTokenSpaceGuid.PcdArmPrimaryCore
+
+  gArmPlatformTokenSpaceGuid.PcdCoreCount
diff --git a/Chips/Hisilicon/Library/ArmPlatformLibPv660/AArch64/Helper.S b/Chips/Hisilicon/Library/ArmPlatformLibPv660/AArch64/Helper.S
deleted file mode 100644
index 3422df2..0000000
--- a/Chips/Hisilicon/Library/ArmPlatformLibPv660/AArch64/Helper.S
+++ /dev/null
@@ -1,61 +0,0 @@ 
-//
-//  Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-//  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
-//  Copyright (c) 2015, 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.
-//
-//  Based on the files under ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/
-//
-//
-
-#include <AsmMacroIoLibV8.h>
-#include <Library/ArmLib.h>
-
-ASM_FUNC(ArmPlatformPeiBootAction)
-  ret
-
-//UINTN
-//ArmPlatformGetPrimaryCoreMpId (
-//  VOID
-//  );
-ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)
-  MOV32 (w0, FixedPcdGet32(PcdArmPrimaryCore))
-  ret
-
-# IN None
-# OUT x0 = number of cores present in the system
-ASM_FUNC(ArmGetCpuCountPerCluster)
-  MOV32 (w0, FixedPcdGet32(PcdCoreCount))
-  ret
-
-//UINTN
-//ArmPlatformIsPrimaryCore (
-//  IN UINTN MpId
-//  );
-ASM_FUNC(ArmPlatformIsPrimaryCore)
-  MOV32 (w1, FixedPcdGet32(PcdArmPrimaryCoreMask))
-  and   x0, x0, x1
-  MOV32 (w1, FixedPcdGet32(PcdArmPrimaryCore))
-  cmp   w0, w1
-  cset  x0, eq
-  ret
-
-//UINTN
-//ArmPlatformGetCorePosition (
-//  IN UINTN MpId
-//  );
-// With this function: CorePos = (ClusterId * 4) + CoreId
-ASM_FUNC(ArmPlatformGetCorePosition)
-  and   x1, x0, #ARM_CORE_MASK
-  and   x0, x0, #ARM_CLUSTER_MASK
-  add   x0, x1, x0, LSR #6
-  ret
-
-ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLib.c b/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLib.c
deleted file mode 100644
index 6c85958..0000000
--- a/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLib.c
+++ /dev/null
@@ -1,108 +0,0 @@ 
-/** @file
-*
-*  Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-*  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
-*  Copyright (c) 2015, 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.
-*
-*  Based on the files under ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/
-*
-**/
-
-#include <Library/IoLib.h>
-#include <Library/ArmPlatformLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-
-#include <Ppi/ArmMpCoreInfo.h>
-
-#include <ArmPlatform.h>
-UINTN
-ArmGetCpuCountPerCluster (
-  VOID
-  );
-
-extern  EFI_STATUS MemInitEntry (VOID);
-
-/**
-  Return the current Boot Mode
-
-  This function returns the boot reason on the platform
-
-  @return   Return the current Boot Mode of the platform
-
-**/
-EFI_BOOT_MODE
-ArmPlatformGetBootMode (
-  VOID
-  )
-{
-  return BOOT_WITH_FULL_CONFIGURATION;
-}
-
-/**
-  Initialize controllers that must setup in the normal world
-
-  This function is called by the ArmPlatformPkg/Pei or ArmPlatformPkg/Pei/PlatformPeim
-  in the PEI phase.
-
-**/
-RETURN_STATUS
-ArmPlatformInitialize (
-  IN  UINTN                     MpId
-  )
-{
-  return RETURN_SUCCESS;
-}
-
-/**
-  Initialize the system (or sometimes called permanent) memory
-
-  This memory is generally represented by the DRAM.
-
-**/
-VOID
-ArmPlatformInitializeSystemMemory (
-  VOID
-  )
-{
-  // Nothing to do here
-}
-
-EFI_STATUS
-PrePeiCoreGetMpCoreInfo (
-  OUT UINTN                   *CoreCount,
-  OUT ARM_CORE_INFO           **ArmCoreTable
-  )
-{
-  return EFI_UNSUPPORTED;
-}
-
-// Needs to be declared in the file. Otherwise gArmMpCoreInfoPpiGuid is undefined in the contect of PrePeiCore
-EFI_GUID mArmMpCoreInfoPpiGuid = ARM_MP_CORE_INFO_PPI_GUID;
-ARM_MP_CORE_INFO_PPI mMpCoreInfoPpi = { PrePeiCoreGetMpCoreInfo };
-
-EFI_PEI_PPI_DESCRIPTOR      gPlatformPpiTable[] = {
-  {
-    EFI_PEI_PPI_DESCRIPTOR_PPI,
-    &mArmMpCoreInfoPpiGuid,
-    &mMpCoreInfoPpi
-  }
-};
-
-VOID
-ArmPlatformGetPlatformPpiList (
-  OUT UINTN                   *PpiListSize,
-  OUT EFI_PEI_PPI_DESCRIPTOR  **PpiList
-  )
-{
-  *PpiListSize = sizeof(gPlatformPpiTable);
-  *PpiList = gPlatformPpiTable;
-}
diff --git a/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLib.inf b/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLib.inf
deleted file mode 100644
index e86e53e..0000000
--- a/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLib.inf
+++ /dev/null
@@ -1,69 +0,0 @@ 
-#/* @file
-#  Copyright (c) 2011-2014, ARM Limited. All rights reserved.
-#  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
-#  Copyright (c) 2015, 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.
-#
-#  Based on the files under ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/
-#
-#*/
-
-[Defines]
-  INF_VERSION                    = 0x00010005
-  BASE_NAME                      = ArmPlatformLibPv660
-  FILE_GUID                      = 6887500D-32AD-41cd-855E-F8A5D5B0D4D2
-  MODULE_TYPE                    = BASE
-  VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = ArmPlatformLib
-
-[Packages]
-  MdePkg/MdePkg.dec
-  MdeModulePkg/MdeModulePkg.dec
-  EmbeddedPkg/EmbeddedPkg.dec
-  ArmPkg/ArmPkg.dec
-  ArmPlatformPkg/ArmPlatformPkg.dec
-
-  OpenPlatformPkg/Chips/Hisilicon/HisiPkg.dec
-
-[LibraryClasses]
-  IoLib
-  ArmLib
-  MemoryAllocationLib
-  SerialPortLib
-
-[Sources.common]
-  ArmPlatformLib.c
-  ArmPlatformLibMem.c
-
-[Sources.AARCH64]
-  AArch64/Helper.S
-
-[FeaturePcd]
-  gEmbeddedTokenSpaceGuid.PcdCacheEnable
-  gArmPlatformTokenSpaceGuid.PcdNorFlashRemapping
-
-[FixedPcd]
-  gArmTokenSpaceGuid.PcdSystemMemoryBase
-  gArmTokenSpaceGuid.PcdSystemMemorySize
-  gArmTokenSpaceGuid.PcdFvBaseAddress
-
-  gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
-  gArmTokenSpaceGuid.PcdArmPrimaryCore
-
-  gArmPlatformTokenSpaceGuid.PcdCoreCount
-
-  gHisiTokenSpaceGuid.PcdNORFlashBase
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase
-  gArmTokenSpaceGuid.PcdGicDistributorBase
-  gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
-  gHisiTokenSpaceGuid.PcdSysControlBaseAddress
-  gHisiTokenSpaceGuid.PcdPeriSubctrlAddress
-  gArmPlatformTokenSpaceGuid.PcdSP805WatchdogBase
-
diff --git a/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLibMem.c b/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLibMem.c
deleted file mode 100644
index 5bbcab3..0000000
--- a/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLibMem.c
+++ /dev/null
@@ -1,98 +0,0 @@ 
-/** @file
-*
-*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.
-*  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
-*  Copyright (c) 2015, 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.
-*
-*  Based on the files under ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/
-*
-**/
-
-#include <Library/ArmPlatformLib.h>
-#include <Library/DebugLib.h>
-#include <Library/HobLib.h>
-#include <Library/PcdLib.h>
-#include <Library/IoLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <ArmPlatform.h>
-
-#include <Library/OemSetVirtualMapDesc.h>
-
-#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS          32
-
-// DDR attributes
-#define DDR_ATTRIBUTES_CACHED           ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
-#define DDR_ATTRIBUTES_UNCACHED         ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED
-
-/**
-  Return the Virtual Memory Map of your platform
-
-  This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU on your platform.
-
-  @param[out]   VirtualMemoryMap    Array of ARM_MEMORY_REGION_DESCRIPTOR describing a Physical-to-
-                                    Virtual Memory mapping. This array must be ended by a zero-filled
-                                    entry
-
-**/
-VOID
-ArmPlatformGetVirtualMemoryMap (
-  IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap
-  )
-{
-  ARM_MEMORY_REGION_ATTRIBUTES  CacheAttributes;
-  UINTN                         Index;
-  ARM_MEMORY_REGION_DESCRIPTOR  *VirtualMemoryTable;
-  EFI_PEI_HOB_POINTERS          NextHob;
-
-  ASSERT (VirtualMemoryMap != NULL);
-
-  VirtualMemoryTable = (ARM_MEMORY_REGION_DESCRIPTOR*)AllocatePages(EFI_SIZE_TO_PAGES (sizeof(ARM_MEMORY_REGION_DESCRIPTOR) * MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS));
-  if (VirtualMemoryTable == NULL) {
-      return;
-  }
-
-  if (FeaturePcdGet(PcdCacheEnable) == TRUE) {
-      CacheAttributes = DDR_ATTRIBUTES_CACHED;
-  } else {
-      CacheAttributes = DDR_ATTRIBUTES_UNCACHED;
-  }
-
-  Index = OemSetVirtualMapDesc(VirtualMemoryTable, CacheAttributes);
-
-  // Search for System Memory Hob that contains the EFI resource system memory
-  NextHob.Raw = GetHobList ();
-  while ((NextHob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, NextHob.Raw)) != NULL)
-  {
-    if (NextHob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY)
-    {
-        if (NextHob.ResourceDescriptor->PhysicalStart > BASE_4GB)
-        {
-            VirtualMemoryTable[++Index].PhysicalBase = NextHob.ResourceDescriptor->PhysicalStart;
-            VirtualMemoryTable[Index].VirtualBase  = NextHob.ResourceDescriptor->PhysicalStart;
-            VirtualMemoryTable[Index].Length       =NextHob.ResourceDescriptor->ResourceLength;
-            VirtualMemoryTable[Index].Attributes   =  CacheAttributes;
-        }
-    }
-
-    NextHob.Raw = GET_NEXT_HOB (NextHob);
-  }
-
-  // End of Table
-  VirtualMemoryTable[++Index].PhysicalBase = 0;
-  VirtualMemoryTable[Index].VirtualBase  = 0;
-  VirtualMemoryTable[Index].Length       = 0;
-  VirtualMemoryTable[Index].Attributes   = (ARM_MEMORY_REGION_ATTRIBUTES)0;
-
-  ASSERT((Index + 1) <= MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS);
-  DEBUG((EFI_D_INFO, "[%a]:[%dL] discriptor count=%d\n", __FUNCTION__, __LINE__, Index+1));
-
-  *VirtualMemoryMap = VirtualMemoryTable;
-}
diff --git a/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLibSec.inf b/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLibSec.inf
deleted file mode 100644
index fa308bd..0000000
--- a/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLibSec.inf
+++ /dev/null
@@ -1,56 +0,0 @@ 
-#/* @file
-#  Copyright (c) 2011-2012, ARM Limited. All rights reserved.
-#  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
-#  Copyright (c) 2015, 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.
-#
-#  Based on the files under ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/
-#
-#*/
-
-[Defines]
-  INF_VERSION                    = 0x00010005
-  BASE_NAME                      = ArmPlatformLibPv660Sec
-  FILE_GUID                      = a79eed97-4b98-4974-9690-37b32d6a5b56
-  MODULE_TYPE                    = BASE
-  VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = ArmPlatformLib
-
-[Packages]
-  MdePkg/MdePkg.dec
-  MdeModulePkg/MdeModulePkg.dec
-  EmbeddedPkg/EmbeddedPkg.dec
-  ArmPkg/ArmPkg.dec
-  ArmPlatformPkg/ArmPlatformPkg.dec
-
-[LibraryClasses]
-  IoLib
-  ArmLib
-  SerialPortLib
-
-[Sources.common]
-  ArmPlatformLib.c
-
-[Sources.AARCH64]
-  AArch64/Helper.S
-
-[FeaturePcd]
-  gEmbeddedTokenSpaceGuid.PcdCacheEnable
-  gArmPlatformTokenSpaceGuid.PcdNorFlashRemapping
-
-[FixedPcd]
-  gArmTokenSpaceGuid.PcdSystemMemoryBase
-  gArmTokenSpaceGuid.PcdSystemMemorySize
-  gArmTokenSpaceGuid.PcdFvBaseAddress
-
-  gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
-  gArmTokenSpaceGuid.PcdArmPrimaryCore
-
-  gArmPlatformTokenSpaceGuid.PcdCoreCount
diff --git a/Platforms/Hisilicon/D02/Pv660D02.dsc b/Platforms/Hisilicon/D02/Pv660D02.dsc
index c000b26..8f840a1 100644
--- a/Platforms/Hisilicon/D02/Pv660D02.dsc
+++ b/Platforms/Hisilicon/D02/Pv660D02.dsc
@@ -34,7 +34,7 @@ 
 
 [LibraryClasses.common]
   ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
-  ArmPlatformLib|OpenPlatformPkg/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLib.inf
+  ArmPlatformLib|OpenPlatformPkg/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.inf
 
   ArmPlatformSysConfigLib|ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfigLib.inf
   NorFlashPlatformLib|ArmPlatformPkg/ArmVExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpressLib.inf
@@ -75,12 +75,12 @@ 
 ## GIC on D02/D03 is not fully ARM GIC compatible: IRQ cannot be cancelled when
 ## input signal is de-asserted, except for virtual timer interrupt IRQ #27.
 ## So we choose to use virtual timer instead of physical one as a workaround.
-## This library instance is to override the original define in LibraryClasses.AARCH64 in Pv660.dsc.inc.
+## This library instance is to override the original define in LibraryClasses.AARCH64 in Hisilicon.dsc.inc.
 [LibraryClasses.AARCH64]
   ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.inf
 
 [LibraryClasses.common.SEC]
-  ArmPlatformLib|OpenPlatformPkg/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLibSec.inf
+  ArmPlatformLib|OpenPlatformPkg/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLibSec.inf
 
 [LibraryClasses.common.DXE_RUNTIME_DRIVER]
   I2CLib|OpenPlatformPkg/Chips/Hisilicon/Library/I2CLib/I2CLibRuntime.inf
diff --git a/Platforms/Hisilicon/D03/D03.dsc b/Platforms/Hisilicon/D03/D03.dsc
index 509890f..1c0d8e8 100644
--- a/Platforms/Hisilicon/D03/D03.dsc
+++ b/Platforms/Hisilicon/D03/D03.dsc
@@ -34,7 +34,7 @@ 
 
 [LibraryClasses.common]
   ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
-  ArmPlatformLib|OpenPlatformPkg/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLib.inf
+  ArmPlatformLib|OpenPlatformPkg/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.inf
 
   ArmPlatformSysConfigLib|ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfigLib.inf
   NorFlashPlatformLib|ArmPlatformPkg/ArmVExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpressLib.inf
@@ -85,12 +85,12 @@ 
 ## GIC on D02/D03 is not fully ARM GIC compatible: IRQ cannot be cancelled when
 ## input signal is de-asserted, except for virtual timer interrupt IRQ #27.
 ## So we choose to use virtual timer instead of physical one as a workaround.
-## This library instance is to override the original define in LibraryClasses.AARCH64 in Pv660.dsc.inc.
+## This library instance is to override the original define in LibraryClasses.AARCH64 in Hisilicon.dsc.inc.
 [LibraryClasses.AARCH64]
   ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.inf
 
 [LibraryClasses.common.SEC]
-  ArmPlatformLib|OpenPlatformPkg/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLibSec.inf
+  ArmPlatformLib|OpenPlatformPkg/Chips/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLibSec.inf
 
 
 [LibraryClasses.common.DXE_RUNTIME_DRIVER]