[edk2-devel] [PATCH v5 06/23] ArmPkg: Fix the return type of the ReadCCSIDR function

Rebecca Cran posted 23 patches 5 months, 2 weeks ago

[edk2-devel] [PATCH v5 06/23] ArmPkg: Fix the return type of the ReadCCSIDR function

Posted by Rebecca Cran 5 months, 2 weeks ago
When CCIDX is supported, the Current Cache Size ID Register contains
data above 32 bits: namely the number of sets. Avoid truncating this
by returning a UINTN instead of UINT32. On AARCH32, the expanded
number of sets data can be read via the CCSIDR2 register.

Also, add Doxygen comments for the function.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
---
 ArmPkg/Library/ArmLib/ArmLibPrivate.h           | 9 ++++++++-
 ArmPkg/Library/ArmLib/AArch64/ArmLibSupportV8.S | 2 +-
 ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S     | 2 +-
 ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm   | 2 +-
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/ArmPkg/Library/ArmLib/ArmLibPrivate.h b/ArmPkg/Library/ArmLib/ArmLibPrivate.h
index 2e90739eb858..8959bdd9d73c 100644
--- a/ArmPkg/Library/ArmLib/ArmLibPrivate.h
+++ b/ArmPkg/Library/ArmLib/ArmLibPrivate.h
@@ -61,7 +61,14 @@ CPSRRead (
   VOID
   );
 
-UINT32
+/** Reads the CCSIDR register for the specified cache.
+
+  @param CSSELR The CSSELR cache selection register value.
+
+  @return The contents of the CCSIDR_EL1 register for the specified cache, when in AARCH64 mode.
+          Returns the contents of the CCSIDR register in AARCH32 mode.
+**/
+UINTN
 ReadCCSIDR (
   IN UINT32 CSSELR
   );
diff --git a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupportV8.S b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupportV8.S
index 0e8d21e2264f..0ae75e4cb9f9 100644
--- a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupportV8.S
+++ b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupportV8.S
@@ -84,7 +84,7 @@ ASM_FUNC(ArmDisableAllExceptions)
   ret
 
 
-// UINT32
+// UINTN
 // ReadCCSIDR (
 //   IN UINT32 CSSELR
 //   )
diff --git a/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S b/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S
index a60a2f634132..af61dbee5261 100644
--- a/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S
+++ b/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S
@@ -64,7 +64,7 @@ ASM_FUNC(ArmReadIdMmfr4)
   mrc    p15,0,r0,c0,c2,6     @ Read ID_MMFR4 Register
   bx     lr
 
-// UINT32
+// UINTN
 // ReadCCSIDR (
 //   IN UINT32 CSSELR
 //   )
diff --git a/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm b/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm
index 1679b09b797a..81f3cb79994c 100644
--- a/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm
+++ b/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm
@@ -68,7 +68,7 @@
   mrc    p15,0,r0,c0,c2,6     ; Read ID_MMFR4 Register
   bx     LR
 
-// UINT32
+// UINTN
 // ReadCCSIDR (
 //   IN UINT32 CSSELR
 //   )
-- 
2.26.2



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