panic: move panic related functions to new panic.h

Moves panic related functions from arch/sof.h to newly created
arch/debug/panic.h. Also change definition of arch_dump_regs
function to take dump buffer from caller. It decreases the
number of included headers in arch/debug/panic.h.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This commit is contained in:
Tomasz Lauda 2019-07-25 10:52:31 +02:00 committed by Tomasz Lauda
parent 0ec0ff73bd
commit 418ddec569
7 changed files with 90 additions and 56 deletions

View File

@ -0,0 +1,24 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2019 Intel Corporation. All rights reserved.
*
* Author: Tomasz Lauda <tomasz.lauda@linux.intel.com>
*/
#ifdef __SOF_DEBUG_PANIC_H__
#ifndef __ARCH_DEBUG_PANIC_H__
#define __ARCH_DEBUG_PANIC_H__
#include <stdint.h>
static inline void arch_dump_regs(void *dump_buf, uint32_t ps,
uintptr_t stack_ptr, uintptr_t *epc1) { }
#endif /* __ARCH_DEBUG_PANIC_H__ */
#else
#error "This file shouldn't be included from outside of sof/debug/panic.h"
#endif /* __SOF_DEBUG_PANIC_H__ */

View File

@ -38,11 +38,6 @@ static inline void *arch_get_stack_ptr(void)
return NULL;
}
static inline void *arch_dump_regs(void)
{
return NULL;
}
#endif /* __ARCH_SOF_H__ */
#else

View File

@ -0,0 +1,62 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2019 Intel Corporation. All rights reserved.
*
* Author: Tomasz Lauda <tomasz.lauda@linux.intel.com>
*/
#ifdef __SOF_DEBUG_PANIC_H__
#ifndef __ARCH_DEBUG_PANIC_H__
#define __ARCH_DEBUG_PANIC_H__
#include <sof/lib/cache.h>
#include <ipc/trace.h>
#include <ipc/xtensa.h>
#include <xtensa/config/core-isa.h>
#include <stdint.h>
/* xtensa core specific oops size */
#define ARCH_OOPS_SIZE (sizeof(struct sof_ipc_dsp_oops_xtensa) \
+ (XCHAL_NUM_AREGS * sizeof(uint32_t)))
void arch_dump_regs_a(void *dump_buf, uint32_t ps);
static inline void fill_core_dump(struct sof_ipc_dsp_oops_xtensa *oops,
uint32_t ps, uintptr_t stack_ptr,
uintptr_t *epc1)
{
oops->arch_hdr.arch = ARCHITECTURE_ID;
oops->arch_hdr.totalsize = ARCH_OOPS_SIZE;
#if XCHAL_HW_CONFIGID_RELIABLE
oops->plat_hdr.configidhi = XCHAL_HW_CONFIGID0;
oops->plat_hdr.configidlo = XCHAL_HW_CONFIGID1;
#else
oops->plat_hdr.configidhi = 0;
oops->plat_hdr.configidlo = 0;
#endif
oops->plat_hdr.numaregs = XCHAL_NUM_AREGS;
oops->plat_hdr.stackoffset = oops->arch_hdr.totalsize
+ sizeof(struct sof_ipc_panic_info);
oops->plat_hdr.stackptr = stack_ptr;
oops->epc1 = *epc1;
arch_dump_regs_a((void *)&oops->exccause, ps);
}
static inline void arch_dump_regs(void *dump_buf, uint32_t ps,
uintptr_t stack_ptr, uintptr_t *epc1)
{
fill_core_dump(dump_buf, ps, stack_ptr, epc1);
dcache_writeback_region(dump_buf, ARCH_OOPS_SIZE);
}
#endif /* __ARCH_DEBUG_PANIC_H__ */
#else
#error "This file shouldn't be included from outside of sof/debug/panic.h"
#endif /* __SOF_DEBUG_PANIC_H__ */

View File

@ -11,26 +11,11 @@
#ifndef __ARCH_SOF_H__
#define __ARCH_SOF_H__
#include <sof/lib/cache.h>
#include <sof/lib/mailbox.h>
#include <ipc/xtensa.h>
#include <xtensa/config/core-isa.h>
#include <stdint.h>
/* architecture specific stack frames to dump */
#define ARCH_STACK_DUMP_FRAMES 32
/* xtensa core specific oops size */
#define ARCH_OOPS_SIZE (sizeof(struct sof_ipc_dsp_oops_xtensa) \
+ (XCHAL_NUM_AREGS * sizeof(uint32_t)))
/* entry point to main firmware */
void _ResetVector(void);
void boot_master_core(void);
void arch_dump_regs_a(void *dump_buf, uint32_t ps);
static inline void *arch_get_stack_ptr(void)
{
void *ptr;
@ -43,39 +28,6 @@ static inline void *arch_get_stack_ptr(void)
return ptr;
}
static inline void fill_core_dump(struct sof_ipc_dsp_oops_xtensa *oops,
uint32_t ps, uintptr_t stack_ptr,
uintptr_t *epc1)
{
oops->arch_hdr.arch = ARCHITECTURE_ID;
oops->arch_hdr.totalsize = ARCH_OOPS_SIZE;
#if XCHAL_HW_CONFIGID_RELIABLE
oops->plat_hdr.configidhi = XCHAL_HW_CONFIGID0;
oops->plat_hdr.configidlo = XCHAL_HW_CONFIGID1;
#else
oops->plat_hdr.configidhi = 0;
oops->plat_hdr.configidlo = 0;
#endif
oops->plat_hdr.numaregs = XCHAL_NUM_AREGS;
oops->plat_hdr.stackoffset = oops->arch_hdr.totalsize
+ sizeof(struct sof_ipc_panic_info);
oops->plat_hdr.stackptr = stack_ptr;
oops->epc1 = *epc1;
arch_dump_regs_a((void *)&oops->exccause, ps);
}
static inline void arch_dump_regs(uint32_t ps, uintptr_t stack_ptr,
uintptr_t *epc1)
{
void *buf = (void *)mailbox_get_exception_base();
fill_core_dump(buf, ps, stack_ptr, epc1);
dcache_writeback_region(buf, ARCH_OOPS_SIZE);
}
#endif /* __ARCH_SOF_H__ */
#else

View File

@ -10,7 +10,6 @@
#include <sof/lib/cache.h>
#include <sof/lib/mailbox.h>
#include <sof/platform.h>
#include <sof/sof.h>
#include <sof/string.h>
#include <sof/trace/trace.h>
#include <ipc/trace.h>
@ -59,7 +58,8 @@ void panic_rewind(uint32_t p, uint32_t stack_rewind_frames,
/* dump DSP core registers
* after arch_dump_regs() use only inline funcs if needed
*/
arch_dump_regs(oldps, stack_ptr, data);
arch_dump_regs((void *)mailbox_get_exception_base(), oldps, stack_ptr,
data);
/* panic - send IPC oops message to host */
platform_panic(p);

View File

@ -8,6 +8,7 @@
#ifndef __SOF_DEBUG_PANIC_H__
#define __SOF_DEBUG_PANIC_H__
#include <arch/debug/panic.h>
#include <ipc/trace.h>
#include <stdint.h>

View File

@ -9,7 +9,7 @@
#include <sof/lib/alloc.h>
#include <sof/trace/trace.h>
#include <sof/sof.h>
#include <sof/debug/panic.h>
#include <mock_trace.h>