You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/09/29 11:35:09 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 opened a new pull request, #7212: arch/armv[7|8]-m: Implement up_invalidate_icache

xiaoxiang781216 opened a new pull request, #7212:
URL: https://github.com/apache/incubator-nuttx/pull/7212

   ## Summary
   
   ## Impact
   New functions
   
   ## Testing
   Pass CI
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7212: arch/armv[7|8]-m: Implement up_invalidate_icache

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7212:
URL: https://github.com/apache/incubator-nuttx/pull/7212#discussion_r983664871


##########
arch/arm/src/armv7-m/arm_cache.c:
##########
@@ -176,6 +176,78 @@ void up_disable_icache(void)
 }
 #endif
 
+/****************************************************************************
+ * Name: up_invalidate_icache
+ *
+ * Description:
+ *   Invalidate the instruction cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARMV8M_ICACHE
+void up_invalidate_icache(uintptr_t start, uintptr_t end)
+{
+  uint32_t ccsidr;
+  uint32_t sshift;
+  uint32_t ssize;
+
+  /* Get the characteristics of the I-Cache */
+
+  ccsidr = getreg32(NVIC_CCSIDR);
+  sshift = CCSIDR_LSSHIFT(ccsidr) + 4;   /* log2(cache-line-size-in-bytes) */
+
+  /* Invalidate the I-Cache containing this range of addresses */
+
+  ssize  = (1 << sshift);
+
+  /* Round down the start address to the nearest cache line boundary.
+   *
+   *   sshift = 5      : Offset to the beginning of the set field
+   *   (ssize - 1)  = 0x007f : Mask of the set field
+   */
+
+  ARM_DSB();
+
+  if (start & (ssize - 1))

Review Comment:
   Done.



##########
arch/arm/src/armv8-m/arm_cache.c:
##########
@@ -176,6 +176,78 @@ void up_disable_icache(void)
 }
 #endif
 
+/****************************************************************************
+ * Name: up_invalidate_icache
+ *
+ * Description:
+ *   Invalidate the instruction cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARMV8M_ICACHE
+void up_invalidate_icache(uintptr_t start, uintptr_t end)
+{
+  uint32_t ccsidr;
+  uint32_t sshift;
+  uint32_t ssize;
+
+  /* Get the characteristics of the I-Cache */
+
+  ccsidr = getreg32(NVIC_CCSIDR);
+  sshift = CCSIDR_LSSHIFT(ccsidr) + 4;   /* log2(cache-line-size-in-bytes) */
+
+  /* Invalidate the I-Cache containing this range of addresses */
+
+  ssize  = (1 << sshift);
+
+  /* Round down the start address to the nearest cache line boundary.
+   *
+   *   sshift = 5      : Offset to the beginning of the set field
+   *   (ssize - 1)  = 0x007f : Mask of the set field
+   */
+
+  ARM_DSB();
+
+  if (start & (ssize - 1))

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko merged pull request #7212: arch/armv[7|8]-m: Implement up_invalidate_icache

Posted by GitBox <gi...@apache.org>.
pkarashchenko merged PR #7212:
URL: https://github.com/apache/incubator-nuttx/pull/7212


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7212: arch/armv[7|8]-m: Implement up_invalidate_icache

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7212:
URL: https://github.com/apache/incubator-nuttx/pull/7212#discussion_r983857813


##########
arch/arm/src/armv7-m/arm_cache.c:
##########
@@ -176,6 +176,78 @@ void up_disable_icache(void)
 }
 #endif
 
+/****************************************************************************
+ * Name: up_invalidate_icache
+ *
+ * Description:
+ *   Invalidate the instruction cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARMV8M_ICACHE
+void up_invalidate_icache(uintptr_t start, uintptr_t end)
+{
+  uint32_t ccsidr;
+  uint32_t sshift;
+  uint32_t ssize;
+
+  /* Get the characteristics of the I-Cache */
+
+  ccsidr = getreg32(NVIC_CCSIDR);
+  sshift = CCSIDR_LSSHIFT(ccsidr) + 4;   /* log2(cache-line-size-in-bytes) */
+
+  /* Invalidate the I-Cache containing this range of addresses */
+
+  ssize  = (1 << sshift);
+
+  /* Round down the start address to the nearest cache line boundary.
+   *
+   *   sshift = 5      : Offset to the beginning of the set field
+   *   (ssize - 1)  = 0x007f : Mask of the set field
+   */
+
+  ARM_DSB();
+
+  if (start & (ssize - 1) != 0)
+    {
+      start &= ~(ssize - 1);
+      putreg32(start, NVIC_ICIMVAU);
+      start += ssize;
+    }
+
+  while (start + ssize <= end)
+    {
+      /* The below store causes the cache to check its directory and
+       * determine if this address is contained in the cache. If so, it
+       * invalidate that cache line. Only the cache way containing the
+       * address is invalidated. If the address is not in the cache, then
+       * nothing is invalidated.
+       */
+
+      putreg32(start, NVIC_ICIMVAU);
+
+      /* Increment the address by the size of one cache line. */
+
+      start += ssize;
+    }
+
+  if (start < end)
+    {
+      putreg32(start, NVIC_ICIMVAU);
+    }
+
+  ARM_DSB();
+  ARM_ISB();
+}
+#endif /* CONFIG_ARMV8M_ICACHE */

Review Comment:
   Done.



##########
arch/arm/src/armv7-m/arm_cache.c:
##########
@@ -176,6 +176,78 @@ void up_disable_icache(void)
 }
 #endif
 
+/****************************************************************************
+ * Name: up_invalidate_icache
+ *
+ * Description:
+ *   Invalidate the instruction cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARMV8M_ICACHE

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] gustavonihei commented on a diff in pull request #7212: arch/armv[7|8]-m: Implement up_invalidate_icache

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on code in PR #7212:
URL: https://github.com/apache/incubator-nuttx/pull/7212#discussion_r983840298


##########
arch/arm/src/armv7-m/arm_cache.c:
##########
@@ -176,6 +176,78 @@ void up_disable_icache(void)
 }
 #endif
 
+/****************************************************************************
+ * Name: up_invalidate_icache
+ *
+ * Description:
+ *   Invalidate the instruction cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARMV8M_ICACHE

Review Comment:
   ```suggestion
   #ifdef CONFIG_ARMV7M_ICACHE
   ```
   Wrong definition



##########
arch/arm/src/armv7-m/arm_cache.c:
##########
@@ -176,6 +176,78 @@ void up_disable_icache(void)
 }
 #endif
 
+/****************************************************************************
+ * Name: up_invalidate_icache
+ *
+ * Description:
+ *   Invalidate the instruction cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARMV8M_ICACHE
+void up_invalidate_icache(uintptr_t start, uintptr_t end)
+{
+  uint32_t ccsidr;
+  uint32_t sshift;
+  uint32_t ssize;
+
+  /* Get the characteristics of the I-Cache */
+
+  ccsidr = getreg32(NVIC_CCSIDR);
+  sshift = CCSIDR_LSSHIFT(ccsidr) + 4;   /* log2(cache-line-size-in-bytes) */
+
+  /* Invalidate the I-Cache containing this range of addresses */
+
+  ssize  = (1 << sshift);
+
+  /* Round down the start address to the nearest cache line boundary.
+   *
+   *   sshift = 5      : Offset to the beginning of the set field
+   *   (ssize - 1)  = 0x007f : Mask of the set field
+   */
+
+  ARM_DSB();
+
+  if (start & (ssize - 1) != 0)
+    {
+      start &= ~(ssize - 1);
+      putreg32(start, NVIC_ICIMVAU);
+      start += ssize;
+    }
+
+  while (start + ssize <= end)
+    {
+      /* The below store causes the cache to check its directory and
+       * determine if this address is contained in the cache. If so, it
+       * invalidate that cache line. Only the cache way containing the
+       * address is invalidated. If the address is not in the cache, then
+       * nothing is invalidated.
+       */
+
+      putreg32(start, NVIC_ICIMVAU);
+
+      /* Increment the address by the size of one cache line. */
+
+      start += ssize;
+    }
+
+  if (start < end)
+    {
+      putreg32(start, NVIC_ICIMVAU);
+    }
+
+  ARM_DSB();
+  ARM_ISB();
+}
+#endif /* CONFIG_ARMV8M_ICACHE */

Review Comment:
   ```suggestion
   #endif /* CONFIG_ARMV7M_ICACHE */
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7212: arch/armv[7|8]-m: Implement up_invalidate_icache

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7212:
URL: https://github.com/apache/incubator-nuttx/pull/7212#discussion_r983528247


##########
arch/arm/src/armv8-m/arm_cache.c:
##########
@@ -176,6 +176,78 @@ void up_disable_icache(void)
 }
 #endif
 
+/****************************************************************************
+ * Name: up_invalidate_icache
+ *
+ * Description:
+ *   Invalidate the instruction cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARMV8M_ICACHE
+void up_invalidate_icache(uintptr_t start, uintptr_t end)

Review Comment:
   it's a little bit hard since common folder is for arm/armv6-m/armv7-a/armv7-r/armv7-m/armv8-m, but the cache operation is different from Cortex-A/R and Cortex-M. Now, the common folder only contain the code same across all arm 32bit arch.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7212: arch/armv[7|8]-m: Implement up_invalidate_icache

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7212:
URL: https://github.com/apache/incubator-nuttx/pull/7212#discussion_r983528247


##########
arch/arm/src/armv8-m/arm_cache.c:
##########
@@ -176,6 +176,78 @@ void up_disable_icache(void)
 }
 #endif
 
+/****************************************************************************
+ * Name: up_invalidate_icache
+ *
+ * Description:
+ *   Invalidate the instruction cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARMV8M_ICACHE
+void up_invalidate_icache(uintptr_t start, uintptr_t end)

Review Comment:
   it's a little bit hard since common folder is for arm/armv6-m/armv7-a/armv7-r/armv7-m/armv8-m, but the cache operation is different from Cortex-A/R and Cortex-M.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] acassis commented on a diff in pull request #7212: arch/armv[7|8]-m: Implement up_invalidate_icache

Posted by GitBox <gi...@apache.org>.
acassis commented on code in PR #7212:
URL: https://github.com/apache/incubator-nuttx/pull/7212#discussion_r983549650


##########
arch/arm/src/armv8-m/arm_cache.c:
##########
@@ -176,6 +176,78 @@ void up_disable_icache(void)
 }
 #endif
 
+/****************************************************************************
+ * Name: up_invalidate_icache
+ *
+ * Description:
+ *   Invalidate the instruction cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARMV8M_ICACHE
+void up_invalidate_icache(uintptr_t start, uintptr_t end)

Review Comment:
   Ok, understood! In this case duplication is better!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7212: arch/armv[7|8]-m: Implement up_invalidate_icache

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7212:
URL: https://github.com/apache/incubator-nuttx/pull/7212#discussion_r983565382


##########
arch/arm/src/armv7-m/arm_cache.c:
##########
@@ -176,6 +176,78 @@ void up_disable_icache(void)
 }
 #endif
 
+/****************************************************************************
+ * Name: up_invalidate_icache
+ *
+ * Description:
+ *   Invalidate the instruction cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARMV8M_ICACHE
+void up_invalidate_icache(uintptr_t start, uintptr_t end)
+{
+  uint32_t ccsidr;
+  uint32_t sshift;
+  uint32_t ssize;
+
+  /* Get the characteristics of the I-Cache */
+
+  ccsidr = getreg32(NVIC_CCSIDR);
+  sshift = CCSIDR_LSSHIFT(ccsidr) + 4;   /* log2(cache-line-size-in-bytes) */
+
+  /* Invalidate the I-Cache containing this range of addresses */
+
+  ssize  = (1 << sshift);
+
+  /* Round down the start address to the nearest cache line boundary.
+   *
+   *   sshift = 5      : Offset to the beginning of the set field
+   *   (ssize - 1)  = 0x007f : Mask of the set field
+   */
+
+  ARM_DSB();
+
+  if (start & (ssize - 1))

Review Comment:
   ```suggestion
     if (start & (ssize - 1) != 0)
   ```



##########
arch/arm/src/armv8-m/arm_cache.c:
##########
@@ -176,6 +176,78 @@ void up_disable_icache(void)
 }
 #endif
 
+/****************************************************************************
+ * Name: up_invalidate_icache
+ *
+ * Description:
+ *   Invalidate the instruction cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARMV8M_ICACHE
+void up_invalidate_icache(uintptr_t start, uintptr_t end)
+{
+  uint32_t ccsidr;
+  uint32_t sshift;
+  uint32_t ssize;
+
+  /* Get the characteristics of the I-Cache */
+
+  ccsidr = getreg32(NVIC_CCSIDR);
+  sshift = CCSIDR_LSSHIFT(ccsidr) + 4;   /* log2(cache-line-size-in-bytes) */
+
+  /* Invalidate the I-Cache containing this range of addresses */
+
+  ssize  = (1 << sshift);
+
+  /* Round down the start address to the nearest cache line boundary.
+   *
+   *   sshift = 5      : Offset to the beginning of the set field
+   *   (ssize - 1)  = 0x007f : Mask of the set field
+   */
+
+  ARM_DSB();
+
+  if (start & (ssize - 1))

Review Comment:
   ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] acassis commented on a diff in pull request #7212: arch/armv[7|8]-m: Implement up_invalidate_icache

Posted by GitBox <gi...@apache.org>.
acassis commented on code in PR #7212:
URL: https://github.com/apache/incubator-nuttx/pull/7212#discussion_r983523432


##########
arch/arm/src/armv8-m/arm_cache.c:
##########
@@ -176,6 +176,78 @@ void up_disable_icache(void)
 }
 #endif
 
+/****************************************************************************
+ * Name: up_invalidate_icache
+ *
+ * Description:
+ *   Invalidate the instruction cache within the specified region.
+ *
+ * Input Parameters:
+ *   start - virtual start address of region
+ *   end   - virtual end address of region + 1
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARMV8M_ICACHE
+void up_invalidate_icache(uintptr_t start, uintptr_t end)

Review Comment:
   @xiaoxiang781216 since the up_invalidate_icache() is basically the same for armv7-m and armv8-m, shouldn't it be possible to use a common definition for both?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org