[edk2-devel] [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code

Yu Pu posted 7 patches 3 years, 11 months ago
There is a newer version of this series
[edk2-devel] [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
Posted by Yu Pu 3 years, 11 months ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3394

Invoke GetPhysicalAddressBits() defined in UefiCpuPkg for CPU physical address
mask calculation and remove the duplicated code in UefiPayloadPkg\UefiPayloadEntry

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>

Signed-off-by: Yu Pu <yu.pu@intel.com>
---
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c  | 10 ++--------
 UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c |  9 ++-------
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 0fed1e36918a..4378aa4f1d97 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -4,6 +4,7 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
+#include <Library/UefiCpuLib.h>
 
 #include "UefiPayloadEntry.h"
 
@@ -341,7 +342,6 @@ BuildGenericHob (
   VOID
   )
 {
-  UINT32                       RegEax;
   UINT8                        PhysicalAddressBits;
   EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute;
 
@@ -351,13 +351,7 @@ BuildGenericHob (
   //
   // Build CPU memory space and IO space hob
   //
-  AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
-  if (RegEax >= 0x80000008) {
-    AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
-    PhysicalAddressBits = (UINT8)RegEax;
-  } else {
-    PhysicalAddressBits = 36;
-  }
+  PhysicalAddressBits = GetPhysicalAddressBits(NULL, NULL);
 
   BuildCpuHob (PhysicalAddressBits, 16);
 
diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
index ac0d58e685c8..c61aeeda7f2e 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
@@ -25,6 +25,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <PiPei.h>
 #include <Library/BaseLib.h>
 #include <Library/DebugLib.h>
+#include <Library/UefiCpuLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/PcdLib.h>
@@ -738,13 +739,7 @@ CreateIdentityMappingPageTables (
   if (Hob != NULL) {
     PhysicalAddressBits = ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace;
   } else {
-    AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
-    if (RegEax >= 0x80000008) {
-      AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
-      PhysicalAddressBits = (UINT8)RegEax;
-    } else {
-      PhysicalAddressBits = 36;
-    }
+    PhysicalAddressBits = GetPhysicalAddressBits (NULL, NULL);
   }
 
   //
-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87240): https://edk2.groups.io/g/devel/message/87240
Mute This Topic: https://groups.io/mt/89503330/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
Posted by Guo Dong 3 years, 11 months ago
Reviewed-by: Guo Dong <guo.dong@intel.com>

-----Original Message-----
From: Pu, Yu <yu.pu@intel.com> 
Sent: Wednesday, March 2, 2022 2:19 AM
To: devel@edk2.groups.io
Cc: Pu, Yu <yu.pu@intel.com>; Dong, Guo <guo.dong@intel.com>; Ni, Ray <ray.ni@intel.com>
Subject: [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3394

Invoke GetPhysicalAddressBits() defined in UefiCpuPkg for CPU physical address mask calculation and remove the duplicated code in UefiPayloadPkg\UefiPayloadEntry

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>

Signed-off-by: Yu Pu <yu.pu@intel.com>
---
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c  | 10 ++--------  UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c |  9 ++-------
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 0fed1e36918a..4378aa4f1d97 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -4,6 +4,7 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent  **/+#include <Library/UefiCpuLib.h>  #include "UefiPayloadEntry.h" @@ -341,7 +342,6 @@ BuildGenericHob (
   VOID   ) {-  UINT32                       RegEax;   UINT8                        PhysicalAddressBits;   EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute; @@ -351,13 +351,7 @@ BuildGenericHob (
   //   // Build CPU memory space and IO space hob   //-  AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);-  if (RegEax >= 0x80000008) {-    AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);-    PhysicalAddressBits = (UINT8)RegEax;-  } else {-    PhysicalAddressBits = 36;-  }+  PhysicalAddressBits = GetPhysicalAddressBits(NULL, NULL);    BuildCpuHob (PhysicalAddressBits, 16); diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
index ac0d58e685c8..c61aeeda7f2e 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
@@ -25,6 +25,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent  #include <PiPei.h> #include <Library/BaseLib.h> #include <Library/DebugLib.h>+#include <Library/UefiCpuLib.h> #include <Library/BaseMemoryLib.h> #include <Library/MemoryAllocationLib.h> #include <Library/PcdLib.h>@@ -738,13 +739,7 @@ CreateIdentityMappingPageTables (
   if (Hob != NULL) {     PhysicalAddressBits = ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace;   } else {-    AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);-    if (RegEax >= 0x80000008) {-      AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);-      PhysicalAddressBits = (UINT8)RegEax;-    } else {-      PhysicalAddressBits = 36;-    }+    PhysicalAddressBits = GetPhysicalAddressBits (NULL, NULL);   }    //-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87282): https://edk2.groups.io/g/devel/message/87282
Mute This Topic: https://groups.io/mt/89503330/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-