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 09:36:36 UTC

[incubator-nuttx] 02/03: tools/jlink-nuttx: update tcbinfo follow nuttx arch tcbinfo_s

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 8f1c6ee7bc1651c96789605305e6914e0047c7cf
Author: zhuyanlin <zh...@xiaomi.com>
AuthorDate: Tue Dec 28 15:34:34 2021 +0800

    tools/jlink-nuttx: update tcbinfo follow nuttx arch tcbinfo_s
    
    Signed-off-by: zhuyanlin <zh...@xiaomi.com>
---
 tools/jlink-nuttx.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/tools/jlink-nuttx.c b/tools/jlink-nuttx.c
index ee20c94..245f759 100644
--- a/tools/jlink-nuttx.c
+++ b/tools/jlink-nuttx.c
@@ -79,6 +79,11 @@ struct tcbinfo_s
   uint16_t pri_off;
   uint16_t name_off;
   uint16_t reg_num;
+  union
+  {
+    uint8_t  u[8];
+    uint16_t *p;
+  } reg_off;
   uint16_t reg_offs[0];
 };
 
@@ -249,6 +254,7 @@ static int update_tcbinfo(struct plugin_priv_s *priv)
     {
       uint16_t reg_num;
       int ret;
+      uint32_t reg_off;
 
       ret = READU16(g_symbols[TCBINFO].address +
                     offsetof(struct tcbinfo_s, reg_num), &reg_num);
@@ -258,6 +264,14 @@ static int update_tcbinfo(struct plugin_priv_s *priv)
           return ret;
         }
 
+      ret = READU32(g_symbols[TCBINFO].address +
+                    offsetof(struct tcbinfo_s, reg_off), &reg_off);
+      if (ret != 0 || !reg_off)
+        {
+          PERROR("error in read regoffs address ret %d\n", ret);
+          return ret;
+        }
+
       priv->tcbinfo = ALLOC(sizeof(struct tcbinfo_s) +
                             reg_num * sizeof(uint16_t));
 
@@ -268,13 +282,21 @@ static int update_tcbinfo(struct plugin_priv_s *priv)
         }
 
       ret = READMEM(g_symbols[TCBINFO].address, (char *)priv->tcbinfo,
-                    sizeof(struct tcbinfo_s) + reg_num * sizeof(uint16_t));
-      if (ret != sizeof(struct tcbinfo_s) + reg_num * sizeof(uint16_t))
+                    sizeof(struct tcbinfo_s));
+      if (ret != sizeof(struct tcbinfo_s))
         {
           PERROR("error in read tcbinfo_s ret %d\n", ret);
           return ret;
         }
 
+      ret = READMEM(reg_off, (char *)&priv->tcbinfo->reg_offs[0],
+                    reg_num * sizeof(uint16_t));
+      if (ret != reg_num * sizeof(uint16_t))
+        {
+          PERROR("error in read tcbinfo_s reg_offs ret %d\n", ret);
+          return ret;
+        }
+
       PLOG("setup success! regs %d\n", priv->tcbinfo->reg_num);
     }