From 6a761ff0870799fc9a0c4fce8a6e586930a54b45 Mon Sep 17 00:00:00 2001 From: zhuyanlin Date: Tue, 29 Mar 2022 17:35:31 +0800 Subject: [PATCH] arch:tcbinfo: update tcbinfo as xcpcontext update Signed-off-by: zhuyanlin --- arch/arm/src/arm/arm_tcbinfo.c | 12 +++++++----- arch/arm/src/armv6-m/arm_tcbinfo.c | 20 +++++++++++--------- arch/arm/src/armv7-a/arm_tcbinfo.c | 12 +++++++----- arch/arm/src/armv7-m/arm_tcbinfo.c | 22 ++++++++++++---------- arch/arm/src/armv7-r/arm_tcbinfo.c | 12 +++++++----- arch/arm/src/armv8-m/arm_tcbinfo.c | 22 ++++++++++++---------- arch/risc-v/src/common/riscv_tcbinfo.c | 18 ++++++++++-------- arch/xtensa/src/common/xtensa_tcbinfo.c | 4 +++- include/nuttx/sched.h | 9 ++++++--- 9 files changed, 75 insertions(+), 56 deletions(-) diff --git a/arch/arm/src/arm/arm_tcbinfo.c b/arch/arm/src/arm/arm_tcbinfo.c index ad350f5c97..5540d8fc84 100644 --- a/arch/arm/src/arm/arm_tcbinfo.c +++ b/arch/arm/src/arm/arm_tcbinfo.c @@ -60,11 +60,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 17, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/arm/src/armv6-m/arm_tcbinfo.c b/arch/arm/src/armv6-m/arm_tcbinfo.c index c9f1b2aed0..cd80cf0d9c 100644 --- a/arch/arm/src/armv6-m/arm_tcbinfo.c +++ b/arch/arm/src/armv6-m/arm_tcbinfo.c @@ -53,12 +53,12 @@ static const uint16_t g_reg_offs[] = TCB_REG_OFF(REG_R15), TCB_REG_OFF(REG_XPSR), - 0, /* msp */ + UINT16_MAX, /* msp */ TCB_REG_OFF(REG_R13), TCB_REG_OFF(REG_PRIMASK), - 0, /* basepri */ - 0, /* faultmask */ - 0, /* control */ + UINT16_MAX, /* basepri */ + UINT16_MAX, /* faultmask */ + UINT16_MAX, /* control */ }; /**************************************************************************** @@ -67,11 +67,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 17, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/arm/src/armv7-a/arm_tcbinfo.c b/arch/arm/src/armv7-a/arm_tcbinfo.c index a4fc0a595e..2fefe348fb 100644 --- a/arch/arm/src/armv7-a/arm_tcbinfo.c +++ b/arch/arm/src/armv7-a/arm_tcbinfo.c @@ -102,11 +102,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 17, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/arm/src/armv7-m/arm_tcbinfo.c b/arch/arm/src/armv7-m/arm_tcbinfo.c index d212591ace..97a967f6e3 100644 --- a/arch/arm/src/armv7-m/arm_tcbinfo.c +++ b/arch/arm/src/armv7-m/arm_tcbinfo.c @@ -53,17 +53,17 @@ static const uint16_t g_reg_offs[] = TCB_REG_OFF(REG_R15), TCB_REG_OFF(REG_XPSR), - 0, /* msp */ + UINT16_MAX, /* msp */ TCB_REG_OFF(REG_R13), #ifdef CONFIG_ARMV7M_USEBASEPRI - 0, /* primask */ + UINT16_MAX, /* primask */ TCB_REG_OFF(REG_BASEPRI), #else TCB_REG_OFF(REG_PRIMASK), - 0, /* basepri */ + UINT16_MAX, /* basepri */ #endif - 0, /* faultmask */ - 0, /* control */ + UINT16_MAX, /* faultmask */ + UINT16_MAX, /* control */ #ifdef CONFIG_ARCH_FPU TCB_REG_OFF(REG_S0), @@ -108,11 +108,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 17, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/arm/src/armv7-r/arm_tcbinfo.c b/arch/arm/src/armv7-r/arm_tcbinfo.c index b8d8a438a7..72b1f895e6 100644 --- a/arch/arm/src/armv7-r/arm_tcbinfo.c +++ b/arch/arm/src/armv7-r/arm_tcbinfo.c @@ -102,11 +102,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 17, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/arm/src/armv8-m/arm_tcbinfo.c b/arch/arm/src/armv8-m/arm_tcbinfo.c index 6ec9219342..40b4db8b0e 100644 --- a/arch/arm/src/armv8-m/arm_tcbinfo.c +++ b/arch/arm/src/armv8-m/arm_tcbinfo.c @@ -53,17 +53,17 @@ static const uint16_t g_reg_offs[] = TCB_REG_OFF(REG_R15), TCB_REG_OFF(REG_XPSR), - 0, /* msp */ + UINT16_MAX, /* msp */ TCB_REG_OFF(REG_R13), #ifdef CONFIG_ARMV8M_USEBASEPRI - 0, /* primask */ + UINT16_MAX, /* primask */ TCB_REG_OFF(REG_BASEPRI), #else TCB_REG_OFF(REG_PRIMASK), - 0, /* basepri */ + UINT16_MAX, /* basepri */ #endif - 0, /* faultmask */ - 0, /* control */ + UINT16_MAX, /* faultmask */ + UINT16_MAX, /* control */ #ifdef CONFIG_ARCH_FPU TCB_REG_OFF(REG_S0), @@ -108,11 +108,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 17, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/risc-v/src/common/riscv_tcbinfo.c b/arch/risc-v/src/common/riscv_tcbinfo.c index bca8cff149..72183bd27f 100644 --- a/arch/risc-v/src/common/riscv_tcbinfo.c +++ b/arch/risc-v/src/common/riscv_tcbinfo.c @@ -35,7 +35,7 @@ static const uint16_t g_reg_offs[] = { - 0, /* x0 */ + UINT16_MAX, /* x0 */ TCB_REG_OFF(REG_X1_NDX), TCB_REG_OFF(REG_X2_NDX), TCB_REG_OFF(REG_X3_NDX), @@ -102,8 +102,8 @@ static const uint16_t g_reg_offs[] = TCB_REG_OFF(REG_F29_NDX), TCB_REG_OFF(REG_F30_NDX), TCB_REG_OFF(REG_F31_NDX), - 0, /* fflags */ - 0, /* frm */ + UINT16_MAX, /* fflags */ + UINT16_MAX, /* frm */ TCB_REG_OFF(REG_FCSR_NDX), #endif }; @@ -114,11 +114,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 33, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/xtensa/src/common/xtensa_tcbinfo.c b/arch/xtensa/src/common/xtensa_tcbinfo.c index 7e9c9ab284..836930d5a3 100644 --- a/arch/xtensa/src/common/xtensa_tcbinfo.c +++ b/arch/xtensa/src/common/xtensa_tcbinfo.c @@ -63,7 +63,9 @@ const struct tcbinfo_s g_tcbinfo = .state_off = TCB_STATE_OFF, .pri_off = TCB_PRI_OFF, .name_off = TCB_NAME_OFF, - .reg_num = XCPTCONTEXT_REGS, + .regs_off = TCB_REGS_OFF, + .basic_num = XCPTCONTEXT_REGS, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index 6c383138bd..06235096eb 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -193,7 +193,8 @@ #else # define TCB_NAME_OFF 0 #endif -# define TCB_REG_OFF(reg) offsetof(struct tcb_s, xcp.regs[reg]) +# define TCB_REGS_OFF offsetof(struct tcb_s, xcp.regs) +# define TCB_REG_OFF(reg) (reg * sizeof(uint32_t)) #endif /**************************************************************************** @@ -771,14 +772,16 @@ begin_packed_struct struct tcbinfo_s uint16_t state_off; /* Offset of tcb.task_state */ uint16_t pri_off; /* Offset of tcb.sched_priority */ uint16_t name_off; /* Offset of tcb.name */ - uint16_t reg_num; /* Num of regs in tcbinfo.reg_offs */ + uint16_t regs_off; /* Offset of tcb.regs */ + uint16_t basic_num; /* Num of genernal regs */ + uint16_t total_num; /* Num of regs in tcbinfo.reg_offs */ /* Offset pointer of xcp.regs, order in GDB org.gnu.gdb.xxx feature. * Please refer: * https://sourceware.org/gdb/current/onlinedocs/gdb/ARM-Features.html * https://sourceware.org/gdb/current/onlinedocs/gdb/RISC_002dV-Features * -.html - * value 0: This regsiter was not priovided by NuttX + * value UINT16_MAX: This regsiter was not priovided by NuttX */ begin_packed_struct