You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by je...@apache.org on 2023/07/26 07:33:50 UTC

[nuttx] 03/05: arch/x86_64: Add g_tcb_info

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

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

commit 94f273130e7684f3a87396a99f8393a147fc4fc6
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue Jul 25 02:31:39 2023 -0700

    arch/x86_64: Add g_tcb_info
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/x86_64/src/common/x86_64_tcbinfo.c | 83 +++++++++++++++++++++++++++++++++
 arch/x86_64/src/intel64/Make.defs       |  2 +-
 2 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/arch/x86_64/src/common/x86_64_tcbinfo.c b/arch/x86_64/src/common/x86_64_tcbinfo.c
new file mode 100644
index 0000000000..760a550c51
--- /dev/null
+++ b/arch/x86_64/src/common/x86_64_tcbinfo.c
@@ -0,0 +1,83 @@
+/****************************************************************************
+ * arch/x86_64/src/common/x86_64_tcbinfo.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/sched.h>
+#include <arch/irq.h>
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const uint16_t g_reg_offs[] =
+{
+  TCB_REG_OFF(REG_RAX),    /* RAX */
+  TCB_REG_OFF(REG_RBX),    /* RBX */
+  TCB_REG_OFF(REG_RCX),    /* RCX */
+  TCB_REG_OFF(REG_RDX),    /* RDX */
+  TCB_REG_OFF(REG_RSI),    /* RSI */
+  TCB_REG_OFF(REG_RDI),    /* RDI */
+  TCB_REG_OFF(REG_RBP),    /* RBP */
+  TCB_REG_OFF(REG_RSP),    /* RSP */
+  TCB_REG_OFF(REG_R8),     /* R8 */
+  TCB_REG_OFF(REG_R9),     /* R9 */
+  TCB_REG_OFF(REG_R10),    /* R10 */
+  TCB_REG_OFF(REG_R11),    /* R11 */
+  TCB_REG_OFF(REG_R12),    /* R12 */
+  TCB_REG_OFF(REG_R13),    /* R13 */
+  TCB_REG_OFF(REG_R14),    /* R14 */
+  TCB_REG_OFF(REG_R15),    /* R15 */
+  TCB_REG_OFF(REG_RIP),    /* RIP */
+  TCB_REG_OFF(REG_RFLAGS), /* EFLAGS */
+  TCB_REG_OFF(REG_CS),     /* CS */
+  TCB_REG_OFF(REG_SS),     /* SS */
+  TCB_REG_OFF(REG_DS),     /* DS */
+  TCB_REG_OFF(REG_ES),     /* ES */
+  TCB_REG_OFF(REG_FS),     /* FS */
+};
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+const struct tcbinfo_s g_tcbinfo =
+{
+  .pid_off        = TCB_PID_OFF,
+  .state_off      = TCB_STATE_OFF,
+  .pri_off        = TCB_PRI_OFF,
+  .name_off       = TCB_NAME_OFF,
+  .stack_off      = TCB_STACK_OFF,
+  .stack_size_off = TCB_STACK_SIZE_OFF,
+  .regs_off       = TCB_REGS_OFF,
+  .basic_num      = sizeof(g_reg_offs) / sizeof(g_reg_offs[0]),
+  .total_num      = sizeof(g_reg_offs) / sizeof(g_reg_offs[0]),
+  {
+    .p = g_reg_offs,
+  },
+};
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
diff --git a/arch/x86_64/src/intel64/Make.defs b/arch/x86_64/src/intel64/Make.defs
index 820d2dfbbc..010b56acd6 100644
--- a/arch/x86_64/src/intel64/Make.defs
+++ b/arch/x86_64/src/intel64/Make.defs
@@ -28,7 +28,7 @@ CMN_CSRCS += intel64_createstack.c intel64_initialstate.c intel64_irq.c
 CMN_CSRCS += intel64_map_region.c intel64_regdump.c intel64_releasestack.c
 CMN_CSRCS += intel64_rtc.c intel64_restore_auxstate.c intel64_savestate.c
 CMN_CSRCS += intel64_stackframe.c intel64_schedulesigaction.c
-CMN_CSRCS += intel64_sigdeliver.c intel64_usestack.c
+CMN_CSRCS += intel64_sigdeliver.c intel64_usestack.c x86_64_tcbinfo.c
 
 # Required Intel64 files