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 2021/03/07 10:36:03 UTC
[incubator-nuttx] branch master updated (70442d1 -> 67b9f5f)
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.
from 70442d1 net/socket_rpmsg: add net socket rpmsg support
new afd6ad4 arch/armv7-m: Adds dwt helper functions for controlling watchpoints in code.
new 67b9f5f Fix nxstyle issues.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
arch/arm/src/armv7-m/dwt.h | 181 ++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 161 insertions(+), 20 deletions(-)
[incubator-nuttx] 01/02: arch/armv7-m: Adds dwt helper functions
for controlling watchpoints in code.
Posted by xi...@apache.org.
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
commit afd6ad4ff571f1bb4a4dcc88f24769fc9d2f57a1
Author: Anthony Merlino <an...@vergeaero.com>
AuthorDate: Sat Mar 6 22:36:42 2021 -0500
arch/armv7-m: Adds dwt helper functions for controlling watchpoints in code.
In scenarios where there is suspicion that someone might be touching your data when you don't expect, you can setup a watchpoint, and then guard accesses that you know are valid. If the debugger halts due to the watchpoint, you'll see where the unexpected access is coming from.
---
arch/arm/src/armv7-m/dwt.h | 139 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 139 insertions(+)
diff --git a/arch/arm/src/armv7-m/dwt.h b/arch/arm/src/armv7-m/dwt.h
index 6320d26..68067c3 100644
--- a/arch/arm/src/armv7-m/dwt.h
+++ b/arch/arm/src/armv7-m/dwt.h
@@ -63,6 +63,12 @@
#ifndef __ARCH_ARM_SRC_ARMV7_M_DWT_H
#define __ARCH_ARM_SRC_ARMV7_M_DWT_H
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "arm_arch.h"
+
/***********************************************************************************************
* Pre-processor Definitions
***********************************************************************************************/
@@ -95,6 +101,12 @@
#define DWT_COMP3 (DWT_BASE + 0x0050) /* Comparator Register 3 */
#define DWT_MASK3 (DWT_BASE + 0x0054) /* Mask Register 3 */
#define DWT_FUNCTION3 (DWT_BASE + 0x0058) /* Function Register 3 */
+#define DWT_LAR (DWT_BASE + 0x0FB0) /* Lock Access Register */
+
+#define DWT_LAR_ACCESS (0xC5ACCE55) /* Lock Access Magic Value */
+
+#define DWT_GRANT_ACCESS() (putreg32(DWT_LAR_ACCESS, DWT_LAR))
+#define DWT_REVOKE_ACCESS() (putreg32(~DWT_LAR_ACCESS, DWT_LAR))
/* DWT Register Bit Field Definitions **********************************************************/
@@ -188,4 +200,131 @@
#define DWT_FUNCTION_FUNCTION_SHIFT 0
#define DWT_FUNCTION_FUNCTION_MASK (0xful << DWT_FUNCTION_FUNCTION_SHIFT)
+#define DWT_FUNCTION_WATCHPOINT_RO (0x05ul << DWT_FUNCTION_FUNCTION_SHIFT)
+#define DWT_FUNCTION_WATCHPOINT_WO (0x06ul << DWT_FUNCTION_FUNCTION_SHIFT)
+#define DWT_FUNCTION_WATCHPOINT_RW (0x07ul << DWT_FUNCTION_FUNCTION_SHIFT)
+
+#define DWT_DATAVSIZE_BYTE (0x00ul << DWT_FUNCTION_DATAVSIZE_SHIFT)
+#define DWT_DATAVSIZE_HALFWORD (0x01ul << DWT_FUNCTION_DATAVSIZE_SHIFT)
+#define DWT_DATAVSIZE_WORD (0x02ul << DWT_FUNCTION_DATAVSIZE_SHIFT)
+
+/****************************************************************************
+ * Inline Functions
+ ****************************************************************************/
+
+static inline void dwt_comparator_setup(int compnum, uint32_t comp,
+ uint32_t mask, uint32_t func)
+{
+ DWT_GRANT_ACCESS();
+ switch (compnum)
+ {
+ case 0:
+ putreg32(comp, DWT_COMP0);
+ putreg32(mask, DWT_MASK0);
+ putreg32(func, DWT_FUNCTION0);
+ break;
+ case 1:
+ putreg32(comp, DWT_COMP1);
+ putreg32(mask, DWT_MASK1);
+ putreg32(func, DWT_FUNCTION1);
+ break;
+ case 2:
+ putreg32(comp, DWT_COMP2);
+ putreg32(mask, DWT_MASK2);
+ putreg32(func, DWT_FUNCTION2);
+ break;
+ case 3:
+ putreg32(comp, DWT_COMP3);
+ putreg32(mask, DWT_MASK3);
+ putreg32(func, DWT_FUNCTION3);
+ break;
+ default:
+ break;
+ }
+ DWT_REVOKE_ACCESS();
+}
+
+static inline void dwt_comparator_reset(int compnum)
+{
+ DWT_GRANT_ACCESS();
+ switch (compnum)
+ {
+ case 0:
+ putreg32(0, DWT_COMP0);
+ putreg32(0, DWT_MASK0);
+ putreg32(0, DWT_FUNCTION0);
+ break;
+ case 1:
+ putreg32(0, DWT_COMP1);
+ putreg32(0, DWT_MASK1);
+ putreg32(0, DWT_FUNCTION1);
+ break;
+ case 2:
+ putreg32(0, DWT_COMP2);
+ putreg32(0, DWT_MASK2);
+ putreg32(0, DWT_FUNCTION2);
+ break;
+ case 3:
+ putreg32(0, DWT_COMP3);
+ putreg32(0, DWT_MASK3);
+ putreg32(0, DWT_FUNCTION3);
+ break;
+ default:
+ break;
+ }
+ DWT_REVOKE_ACCESS();
+}
+
+static inline uint32_t dwt_comparator_block(int compnum)
+{
+ uint32_t funcval = 0;
+ DWT_GRANT_ACCESS();
+ switch (compnum)
+ {
+ case 0:
+ funcval = getreg32(DWT_FUNCTION0);
+ putreg32(0, DWT_FUNCTION0);
+ break;
+ case 1:
+ funcval = getreg32(DWT_FUNCTION1);
+ putreg32(0, DWT_FUNCTION1);
+ break;
+ case 2:
+ funcval = getreg32(DWT_FUNCTION2);
+ putreg32(0, DWT_FUNCTION2);
+ break;
+ case 3:
+ funcval = getreg32(DWT_FUNCTION3);
+ putreg32(0, DWT_FUNCTION3);
+ break;
+ default:
+ break;
+ }
+ DWT_REVOKE_ACCESS();
+ return funcval;
+}
+
+static inline void dwt_comparator_restore(int compnum, uint32_t func)
+{
+ DWT_GRANT_ACCESS();
+ switch (compnum)
+ {
+ case 0:
+ putreg32(func, DWT_FUNCTION0);
+ break;
+ case 1:
+ putreg32(func, DWT_FUNCTION1);
+ break;
+ case 2:
+ putreg32(func, DWT_FUNCTION2);
+ break;
+ case 3:
+ putreg32(func, DWT_FUNCTION3);
+ break;
+ default:
+ break;
+ }
+ DWT_REVOKE_ACCESS();
+}
+
#endif /* __ARCH_ARM_SRC_ARMV7_M_DWT_H */
[incubator-nuttx] 02/02: Fix nxstyle issues.
Posted by xi...@apache.org.
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
commit 67b9f5f9e3a0472a50373bc8c28dce7193060464
Author: Anthony Merlino <an...@vergeaero.com>
AuthorDate: Sun Mar 7 00:16:45 2021 -0500
Fix nxstyle issues.
# Conflicts:
# arch/arm/src/armv7-m/dwt.h
---
arch/arm/src/armv7-m/dwt.h | 114 +++++++++++++++++++++++----------------------
1 file changed, 58 insertions(+), 56 deletions(-)
diff --git a/arch/arm/src/armv7-m/dwt.h b/arch/arm/src/armv7-m/dwt.h
index 68067c3..274c2ae 100644
--- a/arch/arm/src/armv7-m/dwt.h
+++ b/arch/arm/src/armv7-m/dwt.h
@@ -1,11 +1,13 @@
-/***************************************************************************************
+/****************************************************************************
* arch/arm/src/armv7-m/dwt.h
*
* Copyright (c) 2009 - 2013 ARM LIMITED
*
* All rights reserved.
+ *
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
+ * modification, are permitted provided that the following conditions
+ * are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
@@ -16,17 +18,17 @@
* to endorse or promote products derived from this software without
* specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS
+ * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright (C) 2014 Pierre-noel Bouteville . All rights reserved.
* Author: Pierre-noel Bouteville <pn...@gmail.com>
@@ -58,7 +60,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ***********************************************************************************************/
+ ****************************************************************************/
#ifndef __ARCH_ARM_SRC_ARMV7_M_DWT_H
#define __ARCH_ARM_SRC_ARMV7_M_DWT_H
@@ -69,17 +71,17 @@
#include "arm_arch.h"
-/***********************************************************************************************
+/****************************************************************************
* Pre-processor Definitions
- ***********************************************************************************************/
+ ****************************************************************************/
-/* Data Watchpoint and Trace Register (DWT) Definitions ****************************************/
+/* Data Watchpoint and Trace Register (DWT) Definitions *********************/
-/* DWT Register Base Address *******************************************************************/
+/* DWT Register Base Address ************************************************/
#define DWT_BASE (0xe0001000ul)
-/* DWT Register Addresses **********************************************************************/
+/* DWT Register Addresses ***************************************************/
#define DWT_CTRL (DWT_BASE + 0x0000) /* Control Register */
#define DWT_CYCCNT (DWT_BASE + 0x0004) /* Cycle Count Register */
@@ -108,7 +110,7 @@
#define DWT_GRANT_ACCESS() (putreg32(DWT_LAR_ACCESS, DWT_LAR))
#define DWT_REVOKE_ACCESS() (putreg32(~DWT_LAR_ACCESS, DWT_LAR))
-/* DWT Register Bit Field Definitions **********************************************************/
+/* DWT Register Bit Field Definitions ***************************************/
/* DWT CTRL */
@@ -219,24 +221,24 @@ static inline void dwt_comparator_setup(int compnum, uint32_t comp,
switch (compnum)
{
case 0:
- putreg32(comp, DWT_COMP0);
- putreg32(mask, DWT_MASK0);
- putreg32(func, DWT_FUNCTION0);
+ putreg32(comp, DWT_COMP0);
+ putreg32(mask, DWT_MASK0);
+ putreg32(func, DWT_FUNCTION0);
break;
case 1:
- putreg32(comp, DWT_COMP1);
- putreg32(mask, DWT_MASK1);
- putreg32(func, DWT_FUNCTION1);
+ putreg32(comp, DWT_COMP1);
+ putreg32(mask, DWT_MASK1);
+ putreg32(func, DWT_FUNCTION1);
break;
case 2:
- putreg32(comp, DWT_COMP2);
- putreg32(mask, DWT_MASK2);
- putreg32(func, DWT_FUNCTION2);
+ putreg32(comp, DWT_COMP2);
+ putreg32(mask, DWT_MASK2);
+ putreg32(func, DWT_FUNCTION2);
break;
case 3:
- putreg32(comp, DWT_COMP3);
- putreg32(mask, DWT_MASK3);
- putreg32(func, DWT_FUNCTION3);
+ putreg32(comp, DWT_COMP3);
+ putreg32(mask, DWT_MASK3);
+ putreg32(func, DWT_FUNCTION3);
break;
default:
break;
@@ -250,24 +252,24 @@ static inline void dwt_comparator_reset(int compnum)
switch (compnum)
{
case 0:
- putreg32(0, DWT_COMP0);
- putreg32(0, DWT_MASK0);
- putreg32(0, DWT_FUNCTION0);
+ putreg32(0, DWT_COMP0);
+ putreg32(0, DWT_MASK0);
+ putreg32(0, DWT_FUNCTION0);
break;
case 1:
- putreg32(0, DWT_COMP1);
- putreg32(0, DWT_MASK1);
- putreg32(0, DWT_FUNCTION1);
+ putreg32(0, DWT_COMP1);
+ putreg32(0, DWT_MASK1);
+ putreg32(0, DWT_FUNCTION1);
break;
case 2:
- putreg32(0, DWT_COMP2);
- putreg32(0, DWT_MASK2);
- putreg32(0, DWT_FUNCTION2);
+ putreg32(0, DWT_COMP2);
+ putreg32(0, DWT_MASK2);
+ putreg32(0, DWT_FUNCTION2);
break;
case 3:
- putreg32(0, DWT_COMP3);
- putreg32(0, DWT_MASK3);
- putreg32(0, DWT_FUNCTION3);
+ putreg32(0, DWT_COMP3);
+ putreg32(0, DWT_MASK3);
+ putreg32(0, DWT_FUNCTION3);
break;
default:
break;
@@ -282,20 +284,20 @@ static inline uint32_t dwt_comparator_block(int compnum)
switch (compnum)
{
case 0:
- funcval = getreg32(DWT_FUNCTION0);
- putreg32(0, DWT_FUNCTION0);
+ funcval = getreg32(DWT_FUNCTION0);
+ putreg32(0, DWT_FUNCTION0);
break;
case 1:
- funcval = getreg32(DWT_FUNCTION1);
- putreg32(0, DWT_FUNCTION1);
+ funcval = getreg32(DWT_FUNCTION1);
+ putreg32(0, DWT_FUNCTION1);
break;
case 2:
- funcval = getreg32(DWT_FUNCTION2);
- putreg32(0, DWT_FUNCTION2);
+ funcval = getreg32(DWT_FUNCTION2);
+ putreg32(0, DWT_FUNCTION2);
break;
case 3:
- funcval = getreg32(DWT_FUNCTION3);
- putreg32(0, DWT_FUNCTION3);
+ funcval = getreg32(DWT_FUNCTION3);
+ putreg32(0, DWT_FUNCTION3);
break;
default:
break;
@@ -310,16 +312,16 @@ static inline void dwt_comparator_restore(int compnum, uint32_t func)
switch (compnum)
{
case 0:
- putreg32(func, DWT_FUNCTION0);
+ putreg32(func, DWT_FUNCTION0);
break;
case 1:
- putreg32(func, DWT_FUNCTION1);
+ putreg32(func, DWT_FUNCTION1);
break;
case 2:
- putreg32(func, DWT_FUNCTION2);
+ putreg32(func, DWT_FUNCTION2);
break;
case 3:
- putreg32(func, DWT_FUNCTION3);
+ putreg32(func, DWT_FUNCTION3);
break;
default:
break;