Merge remote-tracking branch 'aosp/upstream-hikey-aosp' into HEAD
am: a1e5dccd6a

Change-Id: If56e54850f1dff9679e7ac0942dad88c7f43d70e
diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 79d19e9..7736cfb 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -4344,7 +4344,7 @@
 DEFINE GCC_IPF_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -minline-int-divide-min-latency

 DEFINE GCC_ARM_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft -fno-pic -fno-pie

 DEFINE GCC_ARM_CC_XIPFLAGS         = -mno-unaligned-access

-DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections -fdata-sections -fno-builtin -Wno-address -fno-asynchronous-unwind-tables  -fno-pic -fno-pie -ffixed-x18

+DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections -fdata-sections -fno-builtin -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18

 DEFINE GCC_AARCH64_CC_XIPFLAGS     = -mstrict-align

 DEFINE GCC_DLINK_FLAGS_COMMON      = -nostdlib --pie

 DEFINE GCC_DLINK2_FLAGS_COMMON     = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds

diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
index fb31783..9074c6c 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
+++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
@@ -21,7 +21,6 @@
 #include <Library/BaseMemoryLib.h>

 #include <Library/PcdLib.h>

 #include <Library/PrintLib.h>

-#include <Library/TimerLib.h>

 #include <Library/UefiApplicationEntryPoint.h>

 #include <Library/UefiBootServicesTableLib.h>

 #include <Library/UefiRuntimeServicesTableLib.h>

@@ -440,7 +439,6 @@
       }

     }

     SEND_LITERAL ("OKAY");

-    MicroSecondDelay (3000000);

     gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);

 

     // Shouldn't get here

diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
index dd17aa8..b62c41d 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
+++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
@@ -35,7 +35,6 @@
   MemoryAllocationLib

   PcdLib

   PrintLib

-  TimerLib

   UefiApplicationEntryPoint

   UefiBootServicesTableLib

   UefiLib

diff --git a/EmbeddedPkg/Library/AbootimgLib/AbootimgLib.c b/EmbeddedPkg/Library/AbootimgLib/AbootimgLib.c
index a8db3ac..b4cd1e4 100644
--- a/EmbeddedPkg/Library/AbootimgLib/AbootimgLib.c
+++ b/EmbeddedPkg/Library/AbootimgLib/AbootimgLib.c
@@ -268,23 +268,26 @@
 
   ASSERT (IS_POWER_OF_2 (Header->PageSize));
 
-  Address = (EFI_PHYSICAL_ADDRESS)(UINTN)Header->RamdiskAddress;
-  Status = gBS->AllocatePages (
-                  AllocateAddress, EfiBootServicesData,
-                  EFI_SIZE_TO_PAGES (Header->RamdiskSize), &Address);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-  Source = (VOID *) (BootImgBytePtr + Header->PageSize +
-                     ALIGN_VALUE (Header->KernelSize, Header->PageSize));
-  CopyMem ((VOID *)(UINTN)Address, Source, Header->RamdiskSize);
-  // Set the ramdisk in command line arguments
-  if (KernelArgs != NULL) {
-    UnicodeSPrint (
-      (CHAR16 *)KernelArgs + StrLen (KernelArgs), BOOTIMG_KERNEL_ARGS_SIZE,
-      L" initrd=0x%x,0x%x",
-      (UINTN)Address, Header->RamdiskSize
-      );
+  Status = EFI_SUCCESS;
+  if (Header->RamdiskAddress && Header->RamdiskSize) {
+    Address = (EFI_PHYSICAL_ADDRESS)(UINTN)Header->RamdiskAddress;
+    Status = gBS->AllocatePages (
+                    AllocateAddress, EfiBootServicesData,
+                    EFI_SIZE_TO_PAGES (Header->RamdiskSize), &Address);
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+    Source = (VOID *) (BootImgBytePtr + Header->PageSize +
+                       ALIGN_VALUE (Header->KernelSize, Header->PageSize));
+    CopyMem ((VOID *)(UINTN)Address, Source, Header->RamdiskSize);
+    // Set the ramdisk in command line arguments
+    if (KernelArgs != NULL) {
+      UnicodeSPrint (
+        (CHAR16 *)KernelArgs + StrLen (KernelArgs), BOOTIMG_KERNEL_ARGS_SIZE,
+        L" initrd=0x%x,0x%x",
+        (UINTN)Address, Header->RamdiskSize
+        );
+    }
   }
   return Status;
 }
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index e71be6a..fbb31ed 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -811,12 +811,14 @@
   UINT32        Data;

   EFI_STATUS    Status;

 

-  Status = UfsMmioRead32 (Private, UFS_HC_UTRLRSR_OFFSET, &Data);

-  if (EFI_ERROR (Status)) {

-    return Status;

-  }

-

-  if ((Data & UFS_HC_UTRLRSR) != UFS_HC_UTRLRSR) {

+  for (;;) {

+    Status = UfsMmioRead32 (Private, UFS_HC_UTRLRSR_OFFSET, &Data);

+    if (EFI_ERROR (Status)) {

+      return Status;

+    }

+    if ((Data & UFS_HC_UTRLRSR) == UFS_HC_UTRLRSR) {

+      break;

+    }

     Status = UfsMmioWrite32 (Private, UFS_HC_UTRLRSR_OFFSET, UFS_HC_UTRLRSR);

     if (EFI_ERROR (Status)) {

       return Status;