You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/01/27 07:13:16 UTC

[incubator-nuttx] branch master updated: armv7-a/r:cp15_invalidate_dcache_all: fix Sets mask error.

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 4d5c258  armv7-a/r:cp15_invalidate_dcache_all: fix Sets mask error.
4d5c258 is described below

commit 4d5c2586a990ddd083c3972cef450d709056e694
Author: zhuyanlin <zh...@xiaomi.com>
AuthorDate: Thu Jan 27 12:18:36 2022 +0800

    armv7-a/r:cp15_invalidate_dcache_all: fix Sets mask error.
    
    As NumSets field is bits 13-27, use 0x7fff instead.
    And add way to get from CCSIDR.
---
 arch/arm/src/armv7-a/cp15_invalidate_dcache_all.S | 7 +++++--
 arch/arm/src/armv7-r/cp15_invalidate_dcache_all.S | 7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/arm/src/armv7-a/cp15_invalidate_dcache_all.S b/arch/arm/src/armv7-a/cp15_invalidate_dcache_all.S
index 281541b..1cc048e 100644
--- a/arch/arm/src/armv7-a/cp15_invalidate_dcache_all.S
+++ b/arch/arm/src/armv7-a/cp15_invalidate_dcache_all.S
@@ -92,9 +92,12 @@
 cp15_invalidate_dcache_all:
 
 	mrc		CP15_CCSIDR(r0)			/* Read the Cache Size Identification Register */
-	ldr		r3, =0xffff			/* Isolate the NumSets field (bits 13-27) */
+	ldr		r3, =0x7fff			/* Isolate the NumSets field (bits 13-27) */
 	and		r0, r3, r0, lsr #13		/* r0=NumSets (number of sets - 1) */
 
+	ldr		r3, =0x3ff			/* Isolate the way field (bits 3-12) */
+	add		r4, r3, r0, lsr #3		/* r4=(number of ways - 1) */
+
 	mov		r1, #0				/* r1 = way loop counter */
 way_loop:
 
@@ -108,7 +111,7 @@ set_loop:
 	bne		set_loop			/* Keep looping if not */
 
 	add		r1, r1, #1			/* Increment the way counter */
-	cmp		r1, #4				/* Last way? (four ways assumed) */
+	cmp		r4, r1				/* Last way? */
 	bne		way_loop			/* Keep looping if not */
 
 	dsb
diff --git a/arch/arm/src/armv7-r/cp15_invalidate_dcache_all.S b/arch/arm/src/armv7-r/cp15_invalidate_dcache_all.S
index 53e1f74..9662957 100644
--- a/arch/arm/src/armv7-r/cp15_invalidate_dcache_all.S
+++ b/arch/arm/src/armv7-r/cp15_invalidate_dcache_all.S
@@ -92,9 +92,12 @@
 cp15_invalidate_dcache_all:
 
 	mrc		CP15_CCSIDR(r0)			/* Read the Cache Size Identification Register */
-	ldr		r3, =0xffff			/* Isolate the NumSets field (bits 13-27) */
+	ldr		r3, =0x7fff			/* Isolate the NumSets field (bits 13-27) */
 	and		r0, r3, r0, lsr #13		/* r0=NumSets (number of sets - 1) */
 
+	ldr		r3, =0x3ff			/* Isolate the way field (bits 3-12) */
+	add		r4, r3, r0, lsr #3		/* r4=(number of ways - 1) */
+
 	mov		r1, #0				/* r1 = way loop counter */
 way_loop:
 
@@ -108,7 +111,7 @@ set_loop:
 	bne		set_loop			/* Keep looping if not */
 
 	add		r1, r1, #1			/* Increment the way counter */
-	cmp		r1, #4				/* Last way? (four ways assumed) */
+	cmp		r4, r1				/* Last way? (four ways assumed) */
 	bne		way_loop			/* Keep looping if not */
 
 	dsb