arch: save user context in assert common code

This is the work continue with #7875

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
zhangyuan21
2022-12-21 22:26:38 +08:00
committed by Xiang Xiao
parent cb958e5d69
commit 45394eb6dc
110 changed files with 654 additions and 1271 deletions
+2 -2
View File
@@ -198,9 +198,9 @@ APIs Exported by Architecture-Specific Logic to NuttX
function should disable interrupts before performing scheduling
operations.
.. c:function:: void up_assert(FAR const char *filename, int linenum)
.. c:function:: void up_dump_register(FAR void *dumpregs)
Assertions may be handled in an
Register dump may be handled in an
architecture-specific way.
.. c:function:: void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
+1 -1
View File
@@ -82,7 +82,7 @@ int arm_start_handler(int irq, void *context, void *arg)
/* Dump registers so that we can see what is going to happen on return */
#if 0
arm_registerdump(tcb->xcp.regs);
up_dump_register(tcb->xcp.regs);
#endif
/* Then switch contexts. This instantiates the exception context of the
+6 -8
View File
@@ -20,14 +20,12 @@
# Common ARM files
CMN_CSRCS += arm_allocateheap.c arm_assert.c
CMN_CSRCS += arm_createstack.c arm_exit.c
CMN_CSRCS += arm_initialize.c arm_lowputs.c
CMN_CSRCS += arm_modifyreg16.c arm_modifyreg32.c
CMN_CSRCS += arm_modifyreg8.c arm_nputs.c
CMN_CSRCS += arm_releasestack.c arm_saveusercontext.c
CMN_CSRCS += arm_stackframe.c arm_registerdump.c arm_getintstack.c
CMN_CSRCS += arm_vfork.c arm_switchcontext.c arm_usestack.c
CMN_CSRCS += arm_allocateheap.c arm_createstack.c arm_exit.c
CMN_CSRCS += arm_getintstack.c arm_initialize.c arm_lowputs.c
CMN_CSRCS += arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c
CMN_CSRCS += arm_nputs.c arm_releasestack.c arm_registerdump.c
CMN_CSRCS += arm_stackframe.c arm_saveusercontext.c
CMN_CSRCS += arm_switchcontext.c arm_usestack.c arm_vfork.c
ifneq ($(CONFIG_ALARM_ARCH),y)
ifneq ($(CONFIG_TIMER_ARCH),y)
-74
View File
@@ -1,74 +0,0 @@
/****************************************************************************
* arch/arm/src/common/arm_assert.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 <stdio.h>
#include <stdint.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "sched/sched.h"
#include "arm_internal.h"
/****************************************************************************
* Private Data
****************************************************************************/
static uint8_t s_last_regs[XCPTCONTEXT_SIZE];
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_assert
****************************************************************************/
void up_assert(void)
{
struct tcb_s *rtcb = running_task();
board_autoled_on(LED_ASSERTION);
/* Update the xcp context */
if (CURRENT_REGS)
{
rtcb->xcp.regs = (uint32_t *)CURRENT_REGS;
}
else
{
up_saveusercontext(s_last_regs);
rtcb->xcp.regs = (uint32_t *)s_last_regs;
}
/* Dump the interrupt registers */
arm_registerdump(rtcb->xcp.regs);
}
-2
View File
@@ -480,8 +480,6 @@ size_t arm_stack_check(void *stackbase, size_t nbytes);
void arm_stack_color(void *stackbase, size_t nbytes);
#endif
void arm_registerdump(volatile uint32_t *regs);
#undef EXTERN
#ifdef __cplusplus
}
+4 -2
View File
@@ -51,11 +51,13 @@ uintptr_t up_getusrsp(void)
}
/****************************************************************************
* Name: arm_registerdump
* Name: up_dump_register
****************************************************************************/
void arm_registerdump(volatile uint32_t *regs)
void up_dump_register(void *dumpregs)
{
volatile uint32_t *regs = dumpregs ? dumpregs : CURRENT_REGS;
/* Dump the interrupt registers */
_alert("R0: %08" PRIx32 " R1: %08" PRIx32
+4 -5
View File
@@ -43,12 +43,11 @@ endif
# Common C source files ( OS call up_xxx)
CMN_CSRCS = arm64_initialize.c arm64_initialstate.c arm64_boot.c
CMN_CSRCS += arm64_nputs.c arm64_idle.c arm64_copystate.c
CMN_CSRCS += arm64_createstack.c arm64_releasestack.c arm64_stackframe.c arm64_usestack.c
CMN_CSRCS += arm64_nputs.c arm64_idle.c arm64_copystate.c arm64_createstack.c
CMN_CSRCS += arm64_releasestack.c arm64_stackframe.c arm64_usestack.c
CMN_CSRCS += arm64_task_sched.c arm64_exit.c arm64_vfork.c arm64_switchcontext.c
CMN_CSRCS += arm64_assert.c arm64_schedulesigaction.c arm64_backtrace.c
CMN_CSRCS += arm64_sigdeliver.c arm64_systemreset.c
CMN_CSRCS += arm64_getintstack.c arm64_registerdump.c
CMN_CSRCS += arm64_schedulesigaction.c arm64_sigdeliver.c arm64_systemreset.c
CMN_CSRCS += arm64_backtrace.c arm64_getintstack.c arm64_registerdump.c
# Common C source files ( hardware BSP )
CMN_CSRCS += arm64_mmu.c arm64_arch_timer.c arm64_cache.c
-101
View File
@@ -1,101 +0,0 @@
/****************************************************************************
* arch/arm64/src/common/arm64_assert.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 <stdio.h>
#include <stdint.h>
#include <nuttx/arch.h>
#include <debug.h>
#include "arm64_arch.h"
#include "arm64_internal.h"
#include "chip.h"
#ifdef CONFIG_ARCH_FPU
#include "arm64_fpu.h"
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: arm64_dump_fatal
****************************************************************************/
void arm64_dump_fatal(struct regs_context *regs)
{
#ifdef CONFIG_SCHED_BACKTRACE
struct tcb_s *rtcb = (struct tcb_s *)regs->tpidr_el1;
/* Show back trace */
sched_dumpstack(rtcb->pid);
#endif
/* Dump the registers */
arm64_registerdump(regs);
}
void up_mdelay(unsigned int milliseconds)
{
volatile unsigned int i;
volatile unsigned int j;
for (i = 0; i < milliseconds; i++)
{
for (j = 0; j < CONFIG_BOARD_LOOPSPERMSEC; j++)
{
}
}
}
/****************************************************************************
* Name: up_assert
****************************************************************************/
void up_assert(void)
{
struct tcb_s *rtcb = (struct tcb_s *)arch_get_current_tcb();
/* Update the xcp context */
if (CURRENT_REGS)
{
/* in interrupt */
rtcb->xcp.regs = (uint64_t *)CURRENT_REGS;
}
else
{
up_saveusercontext(rtcb->xcp.regs);
}
/* Dump the registers */
arm64_registerdump((struct regs_context *)rtcb->xcp.regs);
}
+36
View File
@@ -284,6 +284,42 @@ static void print_ec_cause(uint64_t esr)
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_mdelay
****************************************************************************/
void up_mdelay(unsigned int milliseconds)
{
volatile unsigned int i;
volatile unsigned int j;
for (i = 0; i < milliseconds; i++)
{
for (j = 0; j < CONFIG_BOARD_LOOPSPERMSEC; j++)
{
}
}
}
/****************************************************************************
* Name: arm64_dump_fatal
****************************************************************************/
void arm64_dump_fatal(struct regs_context *regs)
{
#ifdef CONFIG_SCHED_BACKTRACE
struct tcb_s *rtcb = (struct tcb_s *)regs->tpidr_el1;
/* Show back trace */
sched_dumpstack(rtcb->pid);
#endif
/* Dump the registers */
up_dump_register(regs);
}
/****************************************************************************
* Name: arm64_fatal_error
*
-2
View File
@@ -347,8 +347,6 @@ size_t arm64_stack_check(void *stackbase, size_t nbytes);
void arm64_stack_color(void *stackbase, size_t nbytes);
#endif
void arm64_registerdump(struct regs_context * regs);
#undef EXTERN
#ifdef __cplusplus
}
+5 -2
View File
@@ -53,11 +53,14 @@ uintptr_t up_getusrsp(void)
}
/****************************************************************************
* Name: arm64_registerdump
* Name: up_dump_register
****************************************************************************/
void arm64_registerdump(struct regs_context * regs)
void up_dump_register(void *dumpregs)
{
volatile struct regs_context *regs = dumpregs ? dumpregs :
(struct regs_context *)CURRENT_REGS;
_alert("stack = %p\n", regs);
_alert("x0: 0x%-16"PRIx64" x1: 0x%"PRIx64"\n",
regs->regs[REG_X0], regs->regs[REG_X1]);
+2
View File
@@ -82,6 +82,8 @@
# define REG_PC2 37
#endif
#define XCPTCONTEXT_SIZE XCPTCONTEXT_REGS
/****************************************************************************
* Public Types
****************************************************************************/
+1
View File
@@ -82,6 +82,7 @@
#define INTCONTEXT_REGS 8 /* r8-r12, lr, pc, sr */
#define XCPTCONTEXT_REGS 17 /* Plus r0-r7, sp */
#define XCPTCONTEXT_SIZE (4 * XCPTCONTEXT_REGS)
/****************************************************************************
* Public Types
+5 -7
View File
@@ -24,14 +24,12 @@ HEAD_ASRC = avr_nommuhead.S
# Common AVR/AVR32 files
CMN_ASRCS = avr_exceptions.S avr_fullcontextrestore.S avr_doswitch.S
CMN_CSRCS = avr_assert.c avr_allocateheap.c avr_copystate.c
CMN_CSRCS += avr_createstack.c avr_mdelay.c avr_udelay.c avr_exit.c avr_idle.c
CMN_CSRCS += avr_initialize.c avr_initialstate.c
CMN_ASRCS = avr_exceptions.S avr_fullcontextrestore.S avr_doswitch.S avr_saveusercontext.S
CMN_CSRCS = avr_allocateheap.c avr_copystate.c avr_createstack.c avr_exit.c
CMN_CSRCS += avr_mdelay.c avr_udelay.c avr_initialize.c avr_initialstate.c avr_idle.c
CMN_CSRCS += avr_modifyreg8.c avr_modifyreg16.c avr_modifyreg32.c avr_releasestack.c
CMN_CSRCS += avr_schedulesigaction.c avr_sigdeliver.c avr_stackframe.c
CMN_CSRCS += avr_switchcontext.c avr_usestack.c avr_doirq.c avr_nputs.c
CMN_CSRCS += avr_registerdump.c avr_getintstack.c
CMN_CSRCS += avr_schedulesigaction.c avr_sigdeliver.c avr_stackframe.c avr_switchcontext.c
CMN_CSRCS += avr_usestack.c avr_doirq.c avr_nputs.c avr_registerdump.c avr_getintstack.c
# Required AT32UC3 files
+8 -9
View File
@@ -24,15 +24,14 @@ HEAD_ASRC = at90usb_head.S
# Common AVR files
CMN_ASRCS = avr_doswitch.S
CMN_CSRCS = avr_allocateheap.c avr_assert.c avr_copystate.c
CMN_CSRCS += avr_createstack.c avr_doirq.c avr_exit.c avr_idle.c avr_initialize.c
CMN_CSRCS += avr_initialstate.c avr_irq.c avr_lowputs.c
CMN_CSRCS += avr_mdelay.c avr_modifyreg8.c avr_modifyreg16.c avr_modifyreg32.c
CMN_CSRCS += avr_nputs.c avr_releasestack.c
CMN_CSRCS += avr_schedulesigaction.c avr_sigdeliver.c
CMN_CSRCS += avr_stackframe.c avr_udelay.c avr_switchcontext.c avr_usestack.c
CMN_CSRCS += avr_registerdump.c avr_getintstack.c
CMN_ASRCS = avr_doswitch.S avr_saveusercontext.S
CMN_CSRCS = avr_allocateheap.c avr_copystate.c avr_createstack.c
CMN_CSRCS += avr_doirq.c avr_exit.c avr_idle.c avr_irq.c avr_udelay.c
CMN_CSRCS += avr_initialize.c avr_initialstate.c avr_lowputs.c avr_mdelay.c
CMN_CSRCS += avr_modifyreg8.c avr_modifyreg16.c avr_modifyreg32.c
CMN_CSRCS += avr_nputs.c avr_releasestack.c avr_registerdump.c
CMN_CSRCS += avr_schedulesigaction.c avr_sigdeliver.c avr_getintstack.c
CMN_CSRCS += avr_stackframe.c avr_switchcontext.c avr_usestack.c
# Configuration-dependent common files
+7 -8
View File
@@ -24,15 +24,14 @@ HEAD_ASRC = atmega_head.S
# Common AVR files
CMN_ASRCS = avr_doswitch.S
CMN_CSRCS = avr_allocateheap.c avr_assert.c avr_copystate.c
CMN_CSRCS += avr_createstack.c avr_doirq.c avr_exit.c avr_idle.c avr_initialize.c
CMN_CSRCS += avr_initialstate.c avr_irq.c avr_lowputs.c
CMN_CSRCS += avr_mdelay.c avr_modifyreg8.c avr_modifyreg16.c avr_modifyreg32.c
CMN_CSRCS += avr_nputs.c avr_releasestack.c
CMN_CSRCS += avr_schedulesigaction.c avr_sigdeliver.c
CMN_ASRCS = avr_doswitch.S avr_saveusercontext.S
CMN_CSRCS = avr_allocateheap.c avr_copystate.c avr_createstack.c
CMN_CSRCS += avr_doirq.c avr_exit.c avr_idle.c avr_initialize.c
CMN_CSRCS += avr_initialstate.c avr_irq.c avr_lowputs.c avr_mdelay.c
CMN_CSRCS += avr_modifyreg8.c avr_modifyreg16.c avr_modifyreg32.c
CMN_CSRCS += avr_nputs.c avr_releasestack.c avr_registerdump.c
CMN_CSRCS += avr_schedulesigaction.c avr_sigdeliver.c avr_getintstack.c
CMN_CSRCS += avr_stackframe.c avr_udelay.c avr_switchcontext.c avr_usestack.c
CMN_CSRCS += avr_registerdump.c avr_getintstack.c
# Configuration-dependent common files
+4 -3
View File
@@ -48,11 +48,13 @@ uintptr_t up_getusrsp(void)
}
/****************************************************************************
* Name: avr_registerdump
* Name: up_dump_register
****************************************************************************/
void avr_registerdump(volatile uint8_t *regs)
void up_dump_register(void *dumpregs)
{
volatile uint8_t *regs = dumpregs ? dumpregs : g_current_regs;
/* Are user registers available from interrupt processing? */
if (regs)
@@ -98,4 +100,3 @@ void avr_registerdump(volatile uint8_t *regs)
#endif
}
}
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/risc-v/src/common/riscv_assert.c
/************************************************************************************
* arch/avr/src/avr/avr_saveusercontext.S
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -16,61 +16,55 @@
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
************************************************************************************/
/****************************************************************************
/************************************************************************************
* Included Files
****************************************************************************/
************************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <stdint.h>
#include <debug.h>
#include <arch/irq.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include "excptmacros.h"
#include <arch/board/board.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
#include "sched/sched.h"
#include "riscv_internal.h"
/************************************************************************************
* Public Symbols
************************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
.file "avr_saveusercontext.S"
/****************************************************************************
* Private Data
****************************************************************************/
/************************************************************************************
* Macros
************************************************************************************/
static uint8_t s_last_regs[XCPTCONTEXT_SIZE];
/****************************************************************************
/************************************************************************************
* Public Functions
****************************************************************************/
************************************************************************************/
/****************************************************************************
* Name: up_assert
* Name: up_saveusercontext
*
* Description:
* Save the current thread context
*
****************************************************************************/
void up_assert(void)
{
struct tcb_s *rtcb = running_task();
.text
.globl up_saveusercontext
.func up_saveusercontext
up_saveusercontext:
/* Use X [r26:r27] to reference the save structure. (X is Call-used) */
board_autoled_on(LED_ASSERTION);
movw r26, r24
/* Update the xcp context */
/* Save the context to saveregs */
if (CURRENT_REGS)
{
rtcb->xcp.regs = (uintptr_t *)CURRENT_REGS;
}
else
{
up_saveusercontext(s_last_regs);
rtcb->xcp.regs = (uintptr_t *)s_last_regs;
}
USER_SAVE
riscv_registerdump(rtcb->xcp.regs);
}
.endfunc
.end
+4 -3
View File
@@ -48,11 +48,13 @@ uintptr_t up_getusrsp(void)
}
/****************************************************************************
* Name: avr_registerdump
* Name: up_dump_register
****************************************************************************/
void avr_registerdump(volatile uint32_t *regs)
void up_dump_register(void *dumpregs)
{
volatile uint32_t *regs = dumpregs ? dumpregs : g_current_regs;
/* Are user registers available from interrupt processing? */
if (regs)
@@ -74,4 +76,3 @@ void avr_registerdump(volatile uint32_t *regs)
_alert("SR: %08x\n", regs[REG_SR]);
}
}
+86
View File
@@ -0,0 +1,86 @@
/************************************************************************************
* arch/avr/src/avr32/avr_saveusercontext.S
*
* 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 <arch/irq.h>
#include <arch/avr32/avr32.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Public Symbols
************************************************************************************/
.file "avr_saveusercontext.S"
/************************************************************************************
* Macros
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/****************************************************************************
* Name: up_saveusercontext
*
* Description:
* Save the current thread context
*
****************************************************************************/
.text
.globl up_saveusercontext
.type up_saveusercontext, @function
up_saveusercontext:
/* "Pickle" the current thread context in the saveregs "can." r12=saveregs. */
/* xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx */
/* ^r12 */
/* Sample SR and set r12 to just after the LR storage location. */
/* xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx */
/* ^r12 */
mfsr r10, AVR32_SR
sub r12, -4*(REG_LR+1)
/* Then "push" PC=LR, LR, SR, and SP as they are on entry. */
/* xx xx xx xx xx xx xx xx SP SR PC LR xx xx xx xx xx */
/* ^r12 */
st.w --r12, lr
st.w --r12, lr
st.w --r12, r10
st.w --r12, sp
/* Save the preserved/static registers, r0-r7. There is no reason to save the */
/* scratch/volatile registers, r8-r12, in this context. */
/* 07 06 05 04 03 02 01 00 SP SR PC LR xx xx xx xx xx */
/* ^r12 */
stm --r12, r0-r7
.size up_saveusercontext, .-up_saveusercontext
.end
-5
View File
@@ -119,11 +119,6 @@ void weak_function avr_dma_initialize(void);
void avr_sigdeliver(void);
void avr_lowputc(char ch);
void avr_lowputs(const char *str);
#ifdef CONFIG_ARCH_FAMILY_AVR32
void avr_registerdump(volatile uint32_t *regs);
#else
void avr_registerdump(volatile uint8_t *regs);
#endif
/* Defined in common/avr_allocateheap.c or chip/xxx_allocateheap.c */
-63
View File
@@ -1,63 +0,0 @@
/****************************************************************************
* arch/ceva/src/common/ceva_assert.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 <debug.h>
#include <nuttx/arch.h>
#include "sched/sched.h"
#include "ceva_internal.h"
/****************************************************************************
* Private Data
****************************************************************************/
static uint32_t s_last_regs[XCPTCONTEXT_REGS];
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_assert
****************************************************************************/
void up_assert(void)
{
volatile uint32_t *regs = CURRENT_REGS;
/* Are user registers available from interrupt processing? */
if (regs == NULL)
{
/* No.. capture user registers by hand */
up_saveusercontext(s_last_regs);
regs = s_last_regs;
}
ceva_registerdump(regs);
}
-2
View File
@@ -305,8 +305,6 @@ size_t ceva_stack_check(uintptr_t alloc, size_t size);
void ceva_stack_color(void *stackbase, size_t nbytes);
#endif
void ceva_registerdump(volatile uint32_t *regs);
#undef EXTERN
#ifdef __cplusplus
}
+3 -2
View File
@@ -45,11 +45,12 @@ uintptr_t up_getusrsp(void)
}
/****************************************************************************
* Name: ceva_registerdump
* Name: up_dump_register
****************************************************************************/
void ceva_registerdump(volatile uint32_t *regs)
void up_dump_register(void *dumpregs)
{
volatile uint32_t *regs = dumpregs ? dumpregs : CURRENT_REGS;
int rx;
/* Dump the interrupt registers */
-2
View File
@@ -195,8 +195,6 @@ void hc_usbuninitialize(void);
# define hc_usbuninitialize()
#endif
void hc_registerdump(volatile uint8_t *regs);
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_HC_SRC_COMMON_UP_INTERNAL_H */
+5 -5
View File
@@ -20,14 +20,14 @@
HEAD_ASRC = m9s12_vectors.S
CMN_CSRCS = hc_allocateheap.c hc_copystate.c hc_createstack.c
CMN_CSRCS += hc_doirq.c hc_exit.c hc_idle.c hc_initialize.c
CMN_CSRCS = hc_allocateheap.c hc_copystate.c hc_createstack.c hc_doirq.c
CMN_CSRCS += hc_exit.c hc_getintstack.c hc_idle.c hc_initialize.c
CMN_CSRCS += hc_mdelay.c hc_modifyreg16.c hc_modifyreg32.c hc_modifyreg8.c
CMN_CSRCS += hc_nputs.c hc_releasestack.c hc_getintstack.c
CMN_CSRCS += hc_stackframe.c hc_udelay.c hc_switchcontext.c hc_usestack.c
CMN_CSRCS += hc_nputs.c hc_releasestack.c hc_stackframe.c hc_switchcontext.c
CMN_CSRCS += hc_udelay.c hc_usestack.c
CHIP_ASRCS = m9s12_start.S m9s12_lowputc.S m9s12_saveusercontext.S
CHIP_CSRCS = m9s12_assert.c m9s12_gpio.c m9s12_gpioirq.c m9s12_initialstate.c
CHIP_CSRCS = m9s12_gpio.c m9s12_gpioirq.c m9s12_initialstate.c
CHIP_CSRCS += m9s12_irq.c m9s12_serial.c m9s12_registerdump.c
ifneq ($(CONFIG_SCHED_TICKLESS),y)
-70
View File
@@ -1,70 +0,0 @@
/****************************************************************************
* arch/hc/src/m9s12/m9s12_assert.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 <stdint.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "sched/sched.h"
#include "hc_internal.h"
/****************************************************************************
* Private Data
****************************************************************************/
static uint8_t s_last_regs[XCPTCONTEXT_REGS];
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_assert
****************************************************************************/
void up_assert(void)
{
volatile uint8_t *regs = g_current_regs;
board_autoled_on(LED_ASSERTION);
/* Are user registers available from interrupt processing? */
if (regs == NULL)
{
/* No.. capture user registers by hand */
up_saveusercontext(s_last_regs);
regs = s_last_regs;
}
hc_registerdump(regs);
}
+4 -2
View File
@@ -47,11 +47,13 @@ uintptr_t up_getusrsp(void)
}
/****************************************************************************
* Name: hc_registerdump
* Name: up_dump_register
****************************************************************************/
void hc_registerdump(volatile uint8_t *regs)
void up_dump_register(void *dumpregs)
{
volatile uint8_t *regs = dumpregs ? dumpregs : (uint8_t *)g_current_regs;
_alert("A:%02x B:%02x X:%02x%02x Y:%02x%02x PC:%02x%02x CCR:%02x\n",
regs[REG_A], regs[REG_B], regs[REG_XH], regs[REG_XL],
regs[REG_YH], regs[REG_YL], regs[REG_PCH], regs[REG_PCL],
+6 -1
View File
@@ -136,7 +136,12 @@
/* Context switching system calls *******************************************/
/* SYS call 0: (not used) */
/* SYS call 0:
*
* int up_saveusercontext(void *saveregs);
*/
#define SYS_save_context (0)
/* SYS call 1:
*
-4
View File
@@ -176,10 +176,6 @@ void mips_copystate(uint32_t *dest, uint32_t *src);
void mips_lowputs(const char *str);
/* Debug */
void mips_registerdump(volatile uint32_t *regs);
/* Common MIPS32 functions defined in arch/mips/src/MIPS32 */
/* IRQs */
+4 -2
View File
@@ -48,11 +48,13 @@ uintptr_t up_getusrsp(void)
}
/****************************************************************************
* Name: mips_registerdump
* Name: up_dump_register
****************************************************************************/
void mips_registerdump(volatile uint32_t *regs)
void up_dump_register(void *dumpregs)
{
volatile uint32_t *regs = dumpregs ? dumpregs : CURRENT_REGS;
/* Are user registers available from interrupt processing? */
if (regs)
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/avr/src/common/avr_assert.c
* arch/mips/src/mips32/mips_saveusercontext.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -23,22 +23,28 @@
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "avr_internal.h"
#include <arch/syscall.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_assert
* Name: up_saveusercontext
*
* Description:
* Save the current thread context. Full prototype is:
*
* int up_saveusercontext(void *saveregs);
*
* Returned Value:
* 0: Normal return
* 1: Context switch return
*
****************************************************************************/
void up_assert(void)
int up_saveusercontext(void *saveregs)
{
board_autoled_on(LED_ASSERTION);
avr_registerdump(g_current_regs);
return sys_call1(SYS_save_context, (uintptr_t)saveregs);
}
+22 -2
View File
@@ -109,13 +109,33 @@ int mips_swint0(int irq, void *context, void *arg)
#ifdef CONFIG_DEBUG_SYSCALL_INFO
svcinfo("Entry: regs: %p cmd: %d\n", regs, regs[REG_R4]);
mips_registerdump(regs);
up_dump_register(regs);
#endif
/* Handle the SWInt according to the command in $4 */
switch (regs[REG_R4])
{
/* R4=SYS_save_context: This is a save context command:
*
* int up_saveusercontext(void *saveregs);
*
* At this point, the following values are saved in context:
*
* R4 = SYS_save_context
* R5 = saveregs
*
* In this case, we simply need to copy the current registers to the
* save register space references in the saved R1 and return.
*/
case SYS_save_context:
{
DEBUGASSERT(regs[REG_A1] != 0);
mips_copystate((uint32_t *)regs[REG_A1], regs);
}
break;
/* R4=SYS_restore_context: This a restore context command:
*
* void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function;
@@ -256,7 +276,7 @@ int mips_swint0(int irq, void *context, void *arg)
if (regs != CURRENT_REGS)
{
svcinfo("SWInt Return: Context switch!\n");
mips_registerdump(CURRENT_REGS);
up_dump_register(CURRENT_REGS);
}
else
{
+8 -9
View File
@@ -25,15 +25,14 @@ HEAD_ASRC = pic32mx_head.S
# Common MIPS files
CMN_ASRCS = mips_syscall0.S vfork.S
CMN_CSRCS = mips_allocateheap.c mips_assert.c mips_copystate.c
CMN_CSRCS += mips_createstack.c mips_doirq.c mips_exit.c mips_initialize.c
CMN_CSRCS += mips_initialstate.c mips_irq.c mips_lowputs.c
CMN_CSRCS += mips_mdelay.c mips_modifyreg8.c mips_modifyreg16.c mips_modifyreg32.c
CMN_CSRCS += mips_nputs.c mips_releasestack.c
CMN_CSRCS += mips_schedulesigaction.c mips_sigdeliver.c
CMN_CSRCS += mips_stackframe.c mips_swint0.c mips_udelay.c mips_switchcontext.c
CMN_CSRCS += mips_usestack.c mips_vfork.c
CMN_CSRCS += mips_registerdump.c mips_getintstack.c
CMN_CSRCS = mips_allocateheap.c mips_copystate.c mips_createstack.c
CMN_CSRCS += mips_doirq.c mips_exit.c mips_getintstack.c mips_initialize.c
CMN_CSRCS += mips_initialstate.c mips_irq.c mips_lowputs.c mips_mdelay.c
CMN_CSRCS += mips_modifyreg8.c mips_modifyreg16.c mips_modifyreg32.c
CMN_CSRCS += mips_nputs.c mips_releasestack.c mips_registerdump.c
CMN_CSRCS += mips_schedulesigaction.c mips_sigdeliver.c mips_swint0.c
CMN_CSRCS += mips_stackframe.c mips_switchcontext.c mips_saveusercontext.c
CMN_CSRCS += mips_udelay.c mips_usestack.c mips_vfork.c
# Configuration dependent common files
+8 -9
View File
@@ -25,15 +25,14 @@ HEAD_ASRC = pic32mz_head.S
# Common MIPS files
CMN_ASRCS = mips_syscall0.S vfork.S mips_cache.S
CMN_CSRCS = mips_allocateheap.c mips_assert.c mips_copystate.c
CMN_CSRCS += mips_createstack.c mips_doirq.c mips_exit.c mips_initialize.c
CMN_CSRCS += mips_initialstate.c mips_irq.c mips_lowputs.c
CMN_CSRCS += mips_mdelay.c mips_modifyreg8.c mips_modifyreg16.c mips_modifyreg32.c
CMN_CSRCS += mips_nputs.c mips_releasestack.c
CMN_CSRCS += mips_schedulesigaction.c mips_sigdeliver.c
CMN_CSRCS += mips_stackframe.c mips_swint0.c mips_udelay.c mips_switchcontext.c
CMN_CSRCS += mips_usestack.c mips_vfork.c
CMN_CSRCS += mips_registerdump.c mips_getintstack.c
CMN_CSRCS = mips_allocateheap.c mips_copystate.c mips_createstack.c
CMN_CSRCS += mips_doirq.c mips_exit.c mips_getintstack.c mips_initialize.c
CMN_CSRCS += mips_initialstate.c mips_irq.c mips_lowputs.c mips_mdelay.c
CMN_CSRCS += mips_modifyreg8.c mips_modifyreg16.c mips_modifyreg32.c
CMN_CSRCS += mips_nputs.c mips_releasestack.c mips_registerdump.c
CMN_CSRCS += mips_schedulesigaction.c mips_sigdeliver.c mips_swint0.c
CMN_CSRCS += mips_stackframe.c mips_switchcontext.c mips_saveusercontext.c
CMN_CSRCS += mips_udelay.c mips_usestack.c mips_vfork.c
# Configuration dependent common files
+6 -1
View File
@@ -61,7 +61,12 @@
/* Context switching system calls *******************************************/
/* SYS call 0: (not used) */
/* SYS call 0:
*
* int up_saveusercontext(void *saveregs);
*/
#define SYS_save_context (0)
/* SYS call 1:
*
+6 -8
View File
@@ -27,11 +27,9 @@ CMN_CSRCS += misoc_timerisr.c misoc_net.c misoc_flushcache.c
CHIP_ASRCS = lm32_syscall.S
CHIP_CSRCS = lm32_allocateheap.c lm32_assert.c
CHIP_CSRCS += lm32_copystate.c lm32_createstack.c lm32_decodeirq.c
CHIP_CSRCS += lm32_doirq.c lm32_registerdump.c lm32_exit.c lm32_idle.c
CHIP_CSRCS += lm32_initialstate.c lm32_irq.c
CHIP_CSRCS += lm32_releasestack.c lm32_stackframe.c lm32_swint.c
CHIP_CSRCS += lm32_switchcontext.c
CHIP_CSRCS += lm32_schedulesigaction.c lm32_sigdeliver.c
CHIP_CSRCS += lm32_flushcache.c lm32_usetack.c
CHIP_CSRCS = lm32_allocateheap.c lm32_copystate.c lm32_createstack.c
CHIP_CSRCS += lm32_decodeirq.c lm32_doirq.c lm32_exit.c lm32_flushcache.c
CHIP_CSRCS += lm32_idle.c lm32_initialstate.c lm32_irq.c lm32_usetack.c
CHIP_CSRCS += lm32_registerdump.c lm32_releasestack.c lm32_swint.c
CHIP_CSRCS += lm32_stackframe.c lm32_switchcontext.c lm32_sigdeliver.c
CHIP_CSRCS += lm32_schedulesigaction.c lm32_saveusercontext.c
-4
View File
@@ -126,9 +126,5 @@ void lm32_sigdeliver(void);
void lm32_flush_dcache(void);
void lm32_flush_icache(void);
/* Debug ********************************************************************/
void lm32_registerdump(volatile uint32_t *regs);
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_MISOC_SRC_LM32_LM32_H */
+4 -3
View File
@@ -47,11 +47,13 @@ uintptr_t up_getusrsp(void)
}
/****************************************************************************
* Name: lm32_registerdump
* Name: up_dump_register
****************************************************************************/
void lm32_registerdump(volatile uint32_t *regs)
void up_dump_register(void *dumpregs)
{
volatile uint32_t *regs = dumpregs ? dumpregs : g_current_regs;
/* Are user registers available from interrupt processing? */
if (regs)
@@ -85,4 +87,3 @@ void lm32_registerdump(volatile uint32_t *regs)
_alert(" IE:%08x\n", regs[REG_X32_NDX]);
}
}
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/misoc/src/lm32/lm32_assert.c
* arch/misoc/src/lm32/lm32_saveusercontext.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -24,22 +24,27 @@
#include <nuttx/config.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "lm32.h"
#include <arch/syscall.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_assert
* Name: up_saveusercontext
*
* Description:
* Save the current thread context. Full prototype is:
*
* int up_saveusercontext(void *saveregs);
*
* Returned Value:
* 0: Normal return
* 1: Context switch return
*
****************************************************************************/
void up_assert(void)
int up_saveusercontext(void *saveregs)
{
board_autoled_on(LED_ASSERTION);
lm32_registerdump(g_current_regs);
return sys_call1(SYS_save_context, (uintptr_t)saveregs);
}
+22 -2
View File
@@ -106,13 +106,33 @@ int lm32_swint(int irq, void *context, void *arg)
#ifdef CONFIG_DEBUG_SYSCALL_INFO
svcinfo("Entry: regs: %p cmd: %d\n", regs, regs[REG_A0]);
lm32_registerdump(regs);
up_dump_register(regs);
#endif
/* Handle the SWInt according to the command in $a0 */
switch (regs[REG_A0])
{
/* A0=SYS_save_context: This is a save context command:
*
* int up_saveusercontext(void *saveregs);
*
* At this point, the following values are saved in context:
*
* A0 = SYS_save_context
* A1 = saveregs
*
* In this case, we simply need to copy the current registers to the
* save register space references in the saved R1 and return.
*/
case SYS_save_context:
{
DEBUGASSERT(regs[REG_A1] != 0);
lm32_copystate((uint32_t *)regs[REG_A1], regs);
}
break;
/* A0=SYS_restore_context: This a restore context command:
*
* void up_fullcontextrestore(uint32_t *restoreregs)
@@ -254,7 +274,7 @@ int lm32_swint(int irq, void *context, void *arg)
if (regs != g_current_regs)
{
svcinfo("SWInt Return: Context switch!\n");
lm32_registerdump(g_current_regs);
up_dump_register(g_current_regs);
}
else
{
+7 -8
View File
@@ -27,11 +27,10 @@ CMN_CSRCS += misoc_timerisr.c misoc_net.c misoc_flushcache.c
CHIP_ASRCS = minerva_syscall.S
CHIP_CSRCS = minerva_allocateheap.c minerva_assert.c
CHIP_CSRCS += minerva_copystate.c minerva_createstack.c minerva_decodeirq.c
CHIP_CSRCS += minerva_doirq.c minerva_registerdump.c minerva_exit.c minerva_idle.c
CHIP_CSRCS += minerva_initialstate.c minerva_irq.c
CHIP_CSRCS += minerva_releasestack.c minerva_stackframe.c minerva_swint.c
CHIP_CSRCS += minerva_switchcontext.c
CHIP_CSRCS += minerva_schedulesigaction.c minerva_sigdeliver.c
CHIP_CSRCS += minerva_flushcache.c minerva_doexceptions.c minerva_usetack.c
CHIP_CSRCS = minerva_allocateheap.c minerva_copystate.c minerva_createstack.c
CHIP_CSRCS += minerva_decodeirq.c minerva_doirq.c minerva_doexceptions.c
CHIP_CSRCS += minerva_exit.c minerva_flushcache.c minerva_idle.c minerva_irq.c
CHIP_CSRCS += minerva_initialstate.c minerva_registerdump.c minerva_releasestack.c
CHIP_CSRCS += minerva_stackframe.c minerva_swint.c minerva_saveusercontext.c
CHIP_CSRCS += minerva_switchcontext.c minerva_schedulesigaction.c minerva_sigdeliver.c
CHIP_CSRCS += minerva_usetack.c
-4
View File
@@ -125,9 +125,5 @@ void minerva_sigdeliver(void);
void minerva_flush_dcache(void);
void minerva_flush_icache(void);
/* Debug ********************************************************************/
void mineva_registerdump(volatile uint32_t *regs);
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_MISOC_SRC_MINERVA_MINERVA_H */
@@ -47,11 +47,13 @@ uintptr_t up_getusrsp(void)
}
/****************************************************************************
* Name: mineva_registerdump
* Name: up_dump_register
****************************************************************************/
void mineva_registerdump(volatile uint32_t *regs)
void up_dump_register(void *dumpregs)
{
volatile uint32_t *regs = dumpregs ? dumpregs : g_current_regs;
/* Are user registers available from interrupt processing? */
if (regs)
@@ -84,4 +86,3 @@ void mineva_registerdump(volatile uint32_t *regs)
_alert(" IE:%08x\n", regs[REG_CSR_MSTATUS]);
}
}
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/misoc/src/minerva/minerva_assert.c
* arch/misoc/src/minerva/minerva_saveusercontext.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -24,22 +24,27 @@
#include <nuttx/config.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "minerva.h"
#include <arch/syscall.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_assert
* Name: up_saveusercontext
*
* Description:
* Save the current thread context. Full prototype is:
*
* int up_saveusercontext(void *saveregs);
*
* Returned Value:
* 0: Normal return
* 1: Context switch return
*
****************************************************************************/
void up_assert(void)
int up_saveusercontext(void *saveregs)
{
board_autoled_on(LED_ASSERTION);
mineva_registerdump(g_current_regs);
return sys_call1(SYS_save_context, (uintptr_t)saveregs);
}
+15
View File
@@ -109,6 +109,21 @@ int minerva_swint(int irq, void *context, void *arg)
switch (regs[REG_A0])
{
/* A0=SYS_save_context: This a save context command: void
* int up_saveusercontext(void *saveregs);
* At this point, the following values are saved in context: A0 =
* SYS_save_context A1 = saveregs A2 = saveregs. In this case, we
* save the context registers to the save register area referenced by
* the saved contents of R5.
*/
case SYS_save_context:
{
DEBUGASSERT(regs[REG_A1] != 0);
minerva_copystate((uint32_t *) regs[REG_A1], regs);
}
break;
/* A0=SYS_restore_context: This a restore context command: void
* up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; At
* this point, the following values are saved in context: A0 =
-70
View File
@@ -1,70 +0,0 @@
/****************************************************************************
* arch/or1k/src/common/or1k_assert.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 <stdint.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "sched/sched.h"
#include "or1k_internal.h"
/****************************************************************************
* Private Data
****************************************************************************/
static uint32_t s_last_regs[XCPTCONTEXT_REGS];
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_assert
****************************************************************************/
void up_assert(void)
{
volatile uint32_t *regs = CURRENT_REGS;
board_autoled_on(LED_ASSERTION);
/* Are user registers available from interrupt processing? */
if (regs == NULL)
{
/* No.. capture user registers by hand */
up_saveusercontext(s_last_regs);
regs = s_last_regs;
}
or1k_registerdump(regs);
}
-2
View File
@@ -323,8 +323,6 @@ size_t or1k_stack_check(uintptr_t alloc, size_t size);
void or1k_stack_color(void *stackbase, size_t nbytes);
#endif
void or1k_registerdump(volatile uint32_t *regs);
#undef EXTERN
#ifdef __cplusplus
}
+4 -2
View File
@@ -46,11 +46,13 @@ uintptr_t up_getusrsp(void)
}
/****************************************************************************
* Name: or1k_registerdump
* Name: up_dump_register
****************************************************************************/
void or1k_registerdump(volatile uint32_t *regs)
void up_dump_register(void *dumpregs)
{
volatile uint32_t *regs = dumpregs ? dumpregs : CURRENT_REGS;
/* Dump the interrupt registers */
_alert("R0: %08x %08x %08x %08x %08x %08x %08x %08x\n",
-1
View File
@@ -34,7 +34,6 @@ CMN_CSRCS = or1k_initialize.c \
or1k_copyfullstate.c \
or1k_registerdump.c \
or1k_getintstack.c \
or1k_assert.c \
or1k_exit.c \
or1k_udelay.c \
or1k_mdelay.c \

Some files were not shown because too many files have changed in this diff Show More