[edk2-devel] [PATCH v5 10/23] ArmPkg: Add helper to read the CCSIDR2 register

Rebecca Cran posted 23 patches 5 months, 2 weeks ago

[edk2-devel] [PATCH v5 10/23] ArmPkg: Add helper to read the CCSIDR2 register

Posted by Rebecca Cran 5 months, 2 weeks ago
Add helper function to read the CCSIDR2 register.
This is used when CCIDX is supported in AARCH32 mode.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
---
 ArmPkg/Library/ArmLib/ArmLibPrivate.h         | 11 +++++++++++
 ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S   | 10 ++++++++++
 ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm | 10 ++++++++++
 3 files changed, 31 insertions(+)

diff --git a/ArmPkg/Library/ArmLib/ArmLibPrivate.h b/ArmPkg/Library/ArmLib/ArmLibPrivate.h
index 5d0224080f3f..e0ec065f1f4a 100644
--- a/ArmPkg/Library/ArmLib/ArmLibPrivate.h
+++ b/ArmPkg/Library/ArmLib/ArmLibPrivate.h
@@ -170,6 +170,17 @@ ReadCCSIDR (
   IN UINT32 CSSELR
   );
 
+/** Reads the CCSIDR2 for the specified cache.
+
+  @param CSSELR The CSSELR cache selection register value
+
+  @return The contents of the CCSIDR2 register for the specified cache.
+**/
+UINT32
+ReadCCSIDR2 (
+  IN UINT32 CSSELR
+  );
+
 UINT32
 ReadCLIDR (
   VOID
diff --git a/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S b/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S
index af61dbee5261..8f75f5051083 100644
--- a/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S
+++ b/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S
@@ -74,6 +74,16 @@ ASM_FUNC(ReadCCSIDR)
   mrc p15,1,r0,c0,c0,0   @ Read current CP15 Cache Size ID Register (CCSIDR)
   bx  lr
 
+// UINT32
+// ReadCCSIDR2 (
+//   IN UINT32 CSSELR
+//   )
+ASM_FUNC(ReadCCSIDR2)
+  mcr p15,2,r0,c0,c0,0   @ Write Cache Size Selection Register (CSSELR)
+  isb
+  mrc p15,1,r0,c0,c2,0   @ Read current CP15 Cache Size ID Register (CCSIDR2)
+  bx  lr
+
 // UINT32
 // ReadCLIDR (
 //   IN UINT32 CSSELR
diff --git a/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm b/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm
index 81f3cb79994c..2fa7a046c0c6 100644
--- a/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm
+++ b/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm
@@ -78,6 +78,16 @@
   mrc p15,1,r0,c0,c0,0 ; Read current CP15 Cache Size ID Register (CCSIDR)
   bx  lr
 
+// UINT32
+// ReadCCSIDR2 (
+//   IN UINT32 CSSELR
+//   )
+ RVCT_ASM_EXPORT ReadCCSIDR2
+  mcr p15,2,r0,c0,c0,0 ; Write Cache Size Selection Register (CSSELR)
+  isb
+  mrc p15,1,r0,c0,c2,0 ; Read current CP15 Cache Size ID Register (CCSIDR2)
+  bx  lr
+
 // UINT32
 // ReadCLIDR (
 //   IN UINT32 CSSELR
-- 
2.26.2



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


Re: [edk2-devel] [PATCH v5 10/23] ArmPkg: Add helper to read the CCSIDR2 register

Posted by Leif Lindholm 5 months, 1 week ago
On Mon, Jan 04, 2021 at 15:58:17 -0700, Rebecca Cran wrote:
> Add helper function to read the CCSIDR2 register.
> This is used when CCIDX is supported in AARCH32 mode.
> 
> Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>

Reviewed-by: Leif Lindholm <leif@nuviainc.com>

> ---
>  ArmPkg/Library/ArmLib/ArmLibPrivate.h         | 11 +++++++++++
>  ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S   | 10 ++++++++++
>  ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm | 10 ++++++++++
>  3 files changed, 31 insertions(+)
> 
> diff --git a/ArmPkg/Library/ArmLib/ArmLibPrivate.h b/ArmPkg/Library/ArmLib/ArmLibPrivate.h
> index 5d0224080f3f..e0ec065f1f4a 100644
> --- a/ArmPkg/Library/ArmLib/ArmLibPrivate.h
> +++ b/ArmPkg/Library/ArmLib/ArmLibPrivate.h
> @@ -170,6 +170,17 @@ ReadCCSIDR (
>    IN UINT32 CSSELR
>    );
>  
> +/** Reads the CCSIDR2 for the specified cache.
> +
> +  @param CSSELR The CSSELR cache selection register value
> +
> +  @return The contents of the CCSIDR2 register for the specified cache.
> +**/
> +UINT32
> +ReadCCSIDR2 (
> +  IN UINT32 CSSELR
> +  );
> +
>  UINT32
>  ReadCLIDR (
>    VOID
> diff --git a/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S b/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S
> index af61dbee5261..8f75f5051083 100644
> --- a/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S
> +++ b/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.S
> @@ -74,6 +74,16 @@ ASM_FUNC(ReadCCSIDR)
>    mrc p15,1,r0,c0,c0,0   @ Read current CP15 Cache Size ID Register (CCSIDR)
>    bx  lr
>  
> +// UINT32
> +// ReadCCSIDR2 (
> +//   IN UINT32 CSSELR
> +//   )
> +ASM_FUNC(ReadCCSIDR2)
> +  mcr p15,2,r0,c0,c0,0   @ Write Cache Size Selection Register (CSSELR)
> +  isb
> +  mrc p15,1,r0,c0,c2,0   @ Read current CP15 Cache Size ID Register (CCSIDR2)
> +  bx  lr
> +
>  // UINT32
>  // ReadCLIDR (
>  //   IN UINT32 CSSELR
> diff --git a/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm b/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm
> index 81f3cb79994c..2fa7a046c0c6 100644
> --- a/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm
> +++ b/ArmPkg/Library/ArmLib/Arm/ArmLibSupportV7.asm
> @@ -78,6 +78,16 @@
>    mrc p15,1,r0,c0,c0,0 ; Read current CP15 Cache Size ID Register (CCSIDR)
>    bx  lr
>  
> +// UINT32
> +// ReadCCSIDR2 (
> +//   IN UINT32 CSSELR
> +//   )
> + RVCT_ASM_EXPORT ReadCCSIDR2
> +  mcr p15,2,r0,c0,c0,0 ; Write Cache Size Selection Register (CSSELR)
> +  isb
> +  mrc p15,1,r0,c0,c2,0 ; Read current CP15 Cache Size ID Register (CCSIDR2)
> +  bx  lr
> +
>  // UINT32
>  // ReadCLIDR (
>  //   IN UINT32 CSSELR
> -- 
> 2.26.2
> 


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


Re: [edk2-devel] [PATCH v5 10/23] ArmPkg: Add helper to read the CCSIDR2 register

Posted by Sami Mujawar 5 months, 2 weeks ago
Hi Rebecca,

On Mon, Jan 4, 2021 at 02:58 PM, Rebecca Cran wrote:

> 
> +// UINT32
> +// ReadCCSIDR2 (
> +// IN UINT32 CSSELR
> +// )
> +ASM_FUNC(ReadCCSIDR2)
> + mcr p15,2,r0,c0,c0,0 @ Write Cache Size Selection Register (CSSELR)
> + isb
> + mrc p15,1,r0,c0,c2,0 @ Read current CP15 Cache Size ID Register
> (CCSIDR2)

I believe the instruction encoding for CCSIDR2 should be mrc p15,1,r0,c0,c0,2
Similar change is needed in ArmLibSupportV7.asm

> 
> + bx lr
> +

Regards,

Sami Mujawar


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