mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 05:55:46 +08:00
arch: move stack and task dump to common code
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
@@ -24,7 +24,7 @@ CMN_CSRCS += sparc_allocateheap.c sparc_assert.c
|
||||
CMN_CSRCS += sparc_createstack.c sparc_exit.c sparc_idle.c sparc_initialize.c
|
||||
CMN_CSRCS += sparc_lowputs.c sparc_mdelay.c
|
||||
CMN_CSRCS += sparc_modifyreg8.c sparc_modifyreg16.c sparc_modifyreg32.c
|
||||
CMN_CSRCS += sparc_nputs.c sparc_releasestack.c
|
||||
CMN_CSRCS += sparc_nputs.c sparc_releasestack.c sparc_getintstack.c
|
||||
CMN_CSRCS += sparc_stackframe.c sparc_udelay.c sparc_usestack.c
|
||||
|
||||
# Configuration-dependent common files
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
* Name: up_assert
|
||||
****************************************************************************/
|
||||
|
||||
void up_assert(const char *filename, int lineno)
|
||||
void up_assert(void)
|
||||
{
|
||||
sparc_dumpstate();
|
||||
sparc_registerdump(CURRENT_REGS);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
* arch/sparc/src/common/sparc_getintstack.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 "sparc_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_get_intstackbase
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
uintptr_t up_get_intstackbase(void)
|
||||
{
|
||||
return (uintptr_t)sparc_intstack_alloc();
|
||||
}
|
||||
#endif
|
||||
@@ -185,11 +185,7 @@ void sparc_lowputs(const char *str);
|
||||
|
||||
/* Debug */
|
||||
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
void sparc_dumpstate(void);
|
||||
#else
|
||||
# define sparc_dumpstate()
|
||||
#endif
|
||||
void sparc_registerdump(volatile uint32_t *regs);
|
||||
|
||||
/* Software interrupt 0 handler */
|
||||
|
||||
|
||||
@@ -27,10 +27,4 @@ CMN_CSRCS += sparc_v8_copystate.c sparc_v8_doirq.c
|
||||
CMN_CSRCS += sparc_v8_initialstate.c sparc_v8_irq.c
|
||||
CMN_CSRCS += sparc_v8_schedulesigaction.c
|
||||
CMN_CSRCS += sparc_v8_sigdeliver.c sparc_v8_swint1.c sparc_v8_systemreset.c
|
||||
CMN_CSRCS += sparc_v8_switchcontext.c
|
||||
|
||||
# Configuration-dependent common files
|
||||
|
||||
ifeq ($(CONFIG_ARCH_STACKDUMP),y)
|
||||
CMN_CSRCS += sparc_v8_dumpstate.c
|
||||
endif
|
||||
CMN_CSRCS += sparc_v8_switchcontext.c sparc_v8_registerdump.c
|
||||
|
||||
@@ -1,216 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/sparc/src/sparc_v8/sparc_v8_dumpstate.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 <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "sparc_internal.h"
|
||||
|
||||
#ifdef CONFIG_ARCH_STACKDUMP
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_stackdump
|
||||
****************************************************************************/
|
||||
|
||||
static void up_stackdump(uint32_t sp, uint32_t stack_base)
|
||||
{
|
||||
uint32_t stack ;
|
||||
|
||||
for (stack = sp & ~0x1f; stack < stack_base; stack += 32)
|
||||
{
|
||||
uint32_t *ptr = (uint32_t *)stack;
|
||||
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
stack, ptr[0], ptr[1], ptr[2], ptr[3],
|
||||
ptr[4], ptr[5], ptr[6], ptr[7]);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_registerdump
|
||||
****************************************************************************/
|
||||
|
||||
static inline void up_registerdump(void)
|
||||
{
|
||||
uint32_t *regs = (uint32_t *)CURRENT_REGS; /* Don't need volatile here */
|
||||
|
||||
/* Are user registers available from interrupt processing? */
|
||||
|
||||
if (regs)
|
||||
{
|
||||
_alert("R%d: %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
0,
|
||||
regs[REG_R16], regs[REG_R17],
|
||||
regs[REG_R18], regs[REG_R19],
|
||||
regs[REG_R20], regs[REG_R21],
|
||||
regs[REG_R22], regs[REG_R23]);
|
||||
|
||||
_alert("R%d: %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
8,
|
||||
regs[REG_R24], regs[REG_R25],
|
||||
regs[REG_R26], regs[REG_R27],
|
||||
regs[REG_R28], regs[REG_R29],
|
||||
regs[REG_R30], regs[REG_R31]);
|
||||
|
||||
_alert("SR: %08x\n", regs[REG_R14]);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sparc_dumpstate
|
||||
****************************************************************************/
|
||||
|
||||
void sparc_dumpstate(void)
|
||||
{
|
||||
struct tcb_s *rtcb = running_task();
|
||||
uint32_t sp = up_getsp();
|
||||
uint32_t ustackbase;
|
||||
uint32_t ustacksize;
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
uint32_t istackbase;
|
||||
uint32_t istacksize;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
/* Show the CPU number */
|
||||
|
||||
_alert("CPU%d:\n", up_cpu_index());
|
||||
#endif
|
||||
|
||||
/* Dump the registers (if available) */
|
||||
|
||||
up_registerdump();
|
||||
|
||||
/* Get the limits on the user stack memory */
|
||||
|
||||
if (rtcb->pid == IDLE_PROCESS_ID) /* Check for CPU0 IDLE thread */
|
||||
{
|
||||
ustackbase = g_idle_topstack - 4;
|
||||
ustacksize = CONFIG_IDLETHREAD_STACKSIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ustackbase = (uint32_t)rtcb->stack_base_ptr;
|
||||
ustacksize = (uint32_t)rtcb->adj_stack_size;
|
||||
}
|
||||
|
||||
/* Get the limits on the interrupt stack memory */
|
||||
|
||||
#if CONFIG_ARCH_INTERRUPTSTACK > 3
|
||||
istackbase = (uint32_t)sparc_intstack_alloc();
|
||||
istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4;
|
||||
|
||||
/* Show interrupt stack info */
|
||||
|
||||
_alert("sp: %08x\n", sp);
|
||||
_alert("IRQ stack:\n");
|
||||
_alert(" base: %08x\n", istackbase);
|
||||
_alert(" size: %08x\n", istacksize);
|
||||
#ifdef CONFIG_STACK_COLORATION
|
||||
_alert(" used: %08x\n", up_check_intstack());
|
||||
#endif
|
||||
|
||||
/* Does the current stack pointer lie within the interrupt
|
||||
* stack?
|
||||
*/
|
||||
|
||||
if (sp <= istackbase && sp > istackbase - istacksize)
|
||||
{
|
||||
/* Yes.. dump the interrupt stack */
|
||||
|
||||
up_stackdump(sp, istackbase);
|
||||
}
|
||||
else if (CURRENT_REGS)
|
||||
{
|
||||
_alert("ERROR: Stack pointer is not within the interrupt stack\n");
|
||||
up_stackdump(istackbase - istacksize, istackbase);
|
||||
}
|
||||
|
||||
/* Extract the user stack pointer if we are in an interrupt handler.
|
||||
* If we are not in an interrupt handler. Then sp is the user stack
|
||||
* pointer (and the above range check should have failed).
|
||||
*/
|
||||
|
||||
if (CURRENT_REGS)
|
||||
{
|
||||
sp = CURRENT_REGS[REG_I6];
|
||||
_alert("sp: %08x\n", sp);
|
||||
}
|
||||
|
||||
_alert("User stack:\n");
|
||||
_alert(" base: %08x\n", ustackbase);
|
||||
_alert(" size: %08x\n", ustacksize);
|
||||
#ifdef CONFIG_STACK_COLORATION
|
||||
_alert(" used: %08x\n", up_check_tcbstack(rtcb));
|
||||
#endif
|
||||
|
||||
/* Dump the user stack if the stack pointer lies within the allocated user
|
||||
* stack memory.
|
||||
*/
|
||||
|
||||
if (sp <= ustackbase && sp > ustackbase - ustacksize)
|
||||
{
|
||||
up_stackdump(sp, ustackbase);
|
||||
}
|
||||
else
|
||||
{
|
||||
_alert("ERROR: Stack pointer is not within allocated stack\n");
|
||||
up_stackdump(ustackbase - ustacksize, ustackbase);
|
||||
}
|
||||
#else
|
||||
_alert("sp: %08x\n", sp);
|
||||
_alert("stack base: %08x\n", ustackbase);
|
||||
_alert("stack size: %08x\n", ustacksize);
|
||||
#ifdef CONFIG_STACK_COLORATION
|
||||
_alert("stack used: %08x\n", up_check_tcbstack(rtcb));
|
||||
#endif
|
||||
|
||||
/* Dump the user stack if the stack pointer lies within the allocated user
|
||||
* stack memory.
|
||||
*/
|
||||
|
||||
if (sp > ustackbase || sp <= ustackbase - ustacksize)
|
||||
{
|
||||
_alert("ERROR: Stack pointer is not within allocated stack\n");
|
||||
up_stackdump(ustackbase - ustacksize, ustackbase);
|
||||
}
|
||||
else
|
||||
{
|
||||
up_stackdump(sp, ustackbase);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* arch/sparc/src/sparc_v8/sparc_v8_registerdump.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 <stdlib.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "sparc_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getusrsp
|
||||
****************************************************************************/
|
||||
|
||||
uintptr_t up_getusrsp(void)
|
||||
{
|
||||
return CURRENT_REGS[REG_I6];
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sparc_registerdump
|
||||
****************************************************************************/
|
||||
|
||||
void sparc_registerdump(volatile uint32_t *regs)
|
||||
{
|
||||
/* Are user registers available from interrupt processing? */
|
||||
|
||||
if (regs)
|
||||
{
|
||||
_alert("R%d: %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
0,
|
||||
regs[REG_R16], regs[REG_R17],
|
||||
regs[REG_R18], regs[REG_R19],
|
||||
regs[REG_R20], regs[REG_R21],
|
||||
regs[REG_R22], regs[REG_R23]);
|
||||
|
||||
_alert("R%d: %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
||||
8,
|
||||
regs[REG_R24], regs[REG_R25],
|
||||
regs[REG_R26], regs[REG_R27],
|
||||
regs[REG_R28], regs[REG_R29],
|
||||
regs[REG_R30], regs[REG_R31]);
|
||||
|
||||
_alert("SR: %08x\n", regs[REG_R14]);
|
||||
}
|
||||
}
|
||||
@@ -40,18 +40,6 @@
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_registerdump
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_SYSCALL_INFO
|
||||
static void up_registerdump(const uint32_t *regs)
|
||||
{
|
||||
}
|
||||
#else
|
||||
# define up_registerdump(regs)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dispatch_syscall
|
||||
*
|
||||
@@ -229,7 +217,7 @@ int sparc_swint1(int irq, void *context, void *arg)
|
||||
if (regs != CURRENT_REGS)
|
||||
{
|
||||
svcinfo("SWInt Return: Context switch!\n");
|
||||
up_registerdump((const uint32_t *)CURRENT_REGS);
|
||||
up_registerdump(CURRENT_REGS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user