intel_adsp: cavs: add gdb support
Uses SRAM debug region to pass GDB messages to host, which is exposed via PTY by cavstool with -d arg or using the SOF kernel driver via a debugfs file. Signed-off-by: Noah Klayman <noah.klayman@intel.com> [guennadi.liakhovetski@linux.intel.com: update to current "main"] Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
committed by
Dan Kalowsky
parent
c524eb619a
commit
a9c47a47a4
@@ -13,6 +13,10 @@ zephyr_library_sources(
|
||||
power_down_cavs.S
|
||||
)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_GDBSTUB
|
||||
gdbstub.c
|
||||
)
|
||||
|
||||
if(CONFIG_SMP OR CONFIG_MP_MAX_NUM_CPUS GREATER 1)
|
||||
zephyr_library_sources(multiprocessing.c)
|
||||
endif()
|
||||
|
||||
@@ -10,6 +10,7 @@ config SOC_SERIES_INTEL_ADSP_CAVS
|
||||
select ATOMIC_OPERATIONS_BUILTIN if "$(ZEPHYR_TOOLCHAIN_VARIANT)" != "xcc"
|
||||
select ATOMIC_OPERATIONS_ARCH if "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "xcc"
|
||||
select ARCH_HAS_COHERENCE
|
||||
select ARCH_HAS_GDBSTUB
|
||||
select HAS_PM
|
||||
|
||||
config SOC_INTEL_CAVS_V25
|
||||
|
||||
@@ -44,4 +44,12 @@ config LOG_BACKEND_ADSP
|
||||
|
||||
endif # LOG
|
||||
|
||||
if GDBSTUB
|
||||
|
||||
# GDB expects 420 byte G-packet, so double for hexadecimal digits.
|
||||
config GDBSTUB_BUF_SZ
|
||||
default 840 if GDBSTUB
|
||||
|
||||
endif
|
||||
|
||||
endif # SOC_SERIES_INTEL_ADSP_CAVS
|
||||
|
||||
710
soc/intel/intel_adsp/cavs/gdbstub.c
Normal file
710
soc/intel/intel_adsp/cavs/gdbstub.c
Normal file
@@ -0,0 +1,710 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <xtensa_asm2_context.h>
|
||||
|
||||
#include <offsets.h>
|
||||
|
||||
static struct xtensa_register gdb_reg_list[] = {
|
||||
{
|
||||
/* PC */
|
||||
.idx = 0x20,
|
||||
.regno = 0x20,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 0,
|
||||
.stack_offset = ___xtensa_irq_bsa_t_pc_OFFSET,
|
||||
},
|
||||
{
|
||||
/* AR0 */
|
||||
.idx = 0x100,
|
||||
.regno = 0x100,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 4,
|
||||
},
|
||||
{
|
||||
/* AR1 */
|
||||
.idx = 0x101,
|
||||
.regno = 0x101,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 8,
|
||||
},
|
||||
{
|
||||
/* AR2 */
|
||||
.idx = 0x102,
|
||||
.regno = 0x102,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 12,
|
||||
},
|
||||
{
|
||||
/* AR3 */
|
||||
.idx = 0x103,
|
||||
.regno = 0x103,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 16,
|
||||
},
|
||||
{
|
||||
/* AR4 */
|
||||
.idx = 0x104,
|
||||
.regno = 0x104,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 20,
|
||||
},
|
||||
{
|
||||
/* AR5 */
|
||||
.idx = 0x105,
|
||||
.regno = 0x105,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 24,
|
||||
},
|
||||
{
|
||||
/* AR6 */
|
||||
.idx = 0x106,
|
||||
.regno = 0x106,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 28,
|
||||
},
|
||||
{
|
||||
/* AR7 */
|
||||
.idx = 0x107,
|
||||
.regno = 0x107,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 32,
|
||||
},
|
||||
{
|
||||
/* AR8 */
|
||||
.idx = 0x108,
|
||||
.regno = 0x108,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 36,
|
||||
},
|
||||
{
|
||||
/* AR9 */
|
||||
.idx = 0x109,
|
||||
.regno = 0x109,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 40,
|
||||
},
|
||||
{
|
||||
/* AR10 */
|
||||
.idx = 0x10a,
|
||||
.regno = 0x10a,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 44,
|
||||
},
|
||||
{
|
||||
/* AR11 */
|
||||
.idx = 0x10b,
|
||||
.regno = 0x10b,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 48,
|
||||
},
|
||||
{
|
||||
/* AR12 */
|
||||
.idx = 0x10c,
|
||||
.regno = 0x10c,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 52,
|
||||
},
|
||||
{
|
||||
/* AR13 */
|
||||
.idx = 0x10d,
|
||||
.regno = 0x10d,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 56,
|
||||
},
|
||||
{
|
||||
/* AR14 */
|
||||
.idx = 0x10e,
|
||||
.regno = 0x10e,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 60,
|
||||
},
|
||||
{
|
||||
/* AR15 */
|
||||
.idx = 0x10f,
|
||||
.regno = 0x10f,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 64,
|
||||
},
|
||||
{
|
||||
/* AR16 */
|
||||
.idx = 0x110,
|
||||
.regno = 0x110,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 68,
|
||||
},
|
||||
{
|
||||
/* AR17 */
|
||||
.idx = 0x111,
|
||||
.regno = 0x111,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 72,
|
||||
},
|
||||
{
|
||||
/* AR18 */
|
||||
.idx = 0x112,
|
||||
.regno = 0x112,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 76,
|
||||
},
|
||||
{
|
||||
/* AR19 */
|
||||
.idx = 0x113,
|
||||
.regno = 0x113,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 80,
|
||||
},
|
||||
{
|
||||
/* AR20 */
|
||||
.idx = 0x114,
|
||||
.regno = 0x114,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 84,
|
||||
},
|
||||
{
|
||||
/* AR21 */
|
||||
.idx = 0x115,
|
||||
.regno = 0x115,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 88,
|
||||
},
|
||||
{
|
||||
/* AR22 */
|
||||
.idx = 0x116,
|
||||
.regno = 0x116,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 92,
|
||||
},
|
||||
{
|
||||
/* AR23 */
|
||||
.idx = 0x117,
|
||||
.regno = 0x117,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 96,
|
||||
},
|
||||
{
|
||||
/* AR24 */
|
||||
.idx = 0x118,
|
||||
.regno = 0x118,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 100,
|
||||
},
|
||||
{
|
||||
/* AR25 */
|
||||
.idx = 0x119,
|
||||
.regno = 0x119,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 104,
|
||||
},
|
||||
{
|
||||
/* AR26 */
|
||||
.idx = 0x11a,
|
||||
.regno = 0x11a,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 108,
|
||||
},
|
||||
{
|
||||
/* AR27 */
|
||||
.idx = 0x11b,
|
||||
.regno = 0x11b,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 112,
|
||||
},
|
||||
{
|
||||
/* AR28 */
|
||||
.idx = 0x11c,
|
||||
.regno = 0x11c,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 116,
|
||||
},
|
||||
{
|
||||
/* AR29 */
|
||||
.idx = 0x11d,
|
||||
.regno = 0x11d,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 120,
|
||||
},
|
||||
{
|
||||
/* AR30 */
|
||||
.idx = 0x11e,
|
||||
.regno = 0x11e,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 124,
|
||||
},
|
||||
{
|
||||
/* AR31 */
|
||||
.idx = 0x11f,
|
||||
.regno = 0x11f,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 128,
|
||||
},
|
||||
{
|
||||
/* AR32 */
|
||||
.idx = 0x120,
|
||||
.regno = 0x120,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 132,
|
||||
},
|
||||
{
|
||||
/* AR33 */
|
||||
.idx = 0x121,
|
||||
.regno = 0x121,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 136,
|
||||
},
|
||||
{
|
||||
/* AR34 */
|
||||
.idx = 0x122,
|
||||
.regno = 0x122,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 140,
|
||||
},
|
||||
{
|
||||
/* AR35 */
|
||||
.idx = 0x123,
|
||||
.regno = 0x123,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 144,
|
||||
},
|
||||
{
|
||||
/* AR36 */
|
||||
.idx = 0x124,
|
||||
.regno = 0x124,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 148,
|
||||
},
|
||||
{
|
||||
/* AR37 */
|
||||
.idx = 0x125,
|
||||
.regno = 0x125,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 152,
|
||||
},
|
||||
{
|
||||
/* AR38 */
|
||||
.idx = 0x126,
|
||||
.regno = 0x126,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 156,
|
||||
},
|
||||
{
|
||||
/* AR39 */
|
||||
.idx = 0x127,
|
||||
.regno = 0x127,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 160,
|
||||
},
|
||||
{
|
||||
/* AR40 */
|
||||
.idx = 0x128,
|
||||
.regno = 0x128,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 164,
|
||||
},
|
||||
{
|
||||
/* AR41 */
|
||||
.idx = 0x129,
|
||||
.regno = 0x129,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 168,
|
||||
},
|
||||
{
|
||||
/* AR42 */
|
||||
.idx = 0x12a,
|
||||
.regno = 0x12a,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 172,
|
||||
},
|
||||
{
|
||||
/* AR43 */
|
||||
.idx = 0x12b,
|
||||
.regno = 0x12b,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 176,
|
||||
},
|
||||
{
|
||||
/* AR44 */
|
||||
.idx = 0x12c,
|
||||
.regno = 0x12c,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 180,
|
||||
},
|
||||
{
|
||||
/* AR45 */
|
||||
.idx = 0x12d,
|
||||
.regno = 0x12d,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 184,
|
||||
},
|
||||
{
|
||||
/* AR46 */
|
||||
.idx = 0x12e,
|
||||
.regno = 0x12e,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 188,
|
||||
},
|
||||
{
|
||||
/* AR47 */
|
||||
.idx = 0x12f,
|
||||
.regno = 0x12f,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 192,
|
||||
},
|
||||
{
|
||||
/* AR48 */
|
||||
.idx = 0x130,
|
||||
.regno = 0x130,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 196,
|
||||
},
|
||||
{
|
||||
/* AR49 */
|
||||
.idx = 0x131,
|
||||
.regno = 0x131,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 200,
|
||||
},
|
||||
{
|
||||
/* AR50 */
|
||||
.idx = 0x132,
|
||||
.regno = 0x132,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 204,
|
||||
},
|
||||
{
|
||||
/* AR51 */
|
||||
.idx = 0x133,
|
||||
.regno = 0x133,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 208,
|
||||
},
|
||||
{
|
||||
/* AR52 */
|
||||
.idx = 0x134,
|
||||
.regno = 0x134,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 212,
|
||||
},
|
||||
{
|
||||
/* AR53 */
|
||||
.idx = 0x135,
|
||||
.regno = 0x135,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 216,
|
||||
},
|
||||
{
|
||||
/* AR54 */
|
||||
.idx = 0x136,
|
||||
.regno = 0x136,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 220,
|
||||
},
|
||||
{
|
||||
/* AR55 */
|
||||
.idx = 0x137,
|
||||
.regno = 0x137,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 224,
|
||||
},
|
||||
{
|
||||
/* AR56 */
|
||||
.idx = 0x138,
|
||||
.regno = 0x138,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 228,
|
||||
},
|
||||
{
|
||||
/* AR57 */
|
||||
.idx = 0x139,
|
||||
.regno = 0x139,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 232,
|
||||
},
|
||||
{
|
||||
/* AR58 */
|
||||
.idx = 0x13a,
|
||||
.regno = 0x13a,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 236,
|
||||
},
|
||||
{
|
||||
/* AR59 */
|
||||
.idx = 0x13b,
|
||||
.regno = 0x13b,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 240,
|
||||
},
|
||||
{
|
||||
/* AR60 */
|
||||
.idx = 0x13c,
|
||||
.regno = 0x13c,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 244,
|
||||
},
|
||||
{
|
||||
/* AR61 */
|
||||
.idx = 0x13d,
|
||||
.regno = 0x13d,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 248,
|
||||
},
|
||||
{
|
||||
/* AR62 */
|
||||
.idx = 0x13e,
|
||||
.regno = 0x13e,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 252,
|
||||
},
|
||||
{
|
||||
/* AR63 */
|
||||
.idx = 0x13f,
|
||||
.regno = 0x13f,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 256,
|
||||
},
|
||||
{
|
||||
/* LBEG */
|
||||
.idx = 0x200,
|
||||
.regno = 0x200,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 260,
|
||||
.stack_offset = ___xtensa_irq_bsa_t_lbeg_OFFSET,
|
||||
},
|
||||
{
|
||||
/* LEND */
|
||||
.idx = 0x201,
|
||||
.regno = 0x201,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 264,
|
||||
.stack_offset = ___xtensa_irq_bsa_t_lend_OFFSET,
|
||||
},
|
||||
{
|
||||
/* LCOUNT */
|
||||
.idx = 0x202,
|
||||
.regno = 0x202,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 268,
|
||||
.stack_offset = ___xtensa_irq_bsa_t_lcount_OFFSET,
|
||||
},
|
||||
{
|
||||
/* SAR */
|
||||
.idx = 0x203,
|
||||
.regno = 0x203,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 272,
|
||||
.stack_offset = ___xtensa_irq_bsa_t_sar_OFFSET,
|
||||
},
|
||||
{
|
||||
/* BR */
|
||||
.idx = 0x204,
|
||||
.regno = 0x204,
|
||||
.byte_size = 4,
|
||||
.is_read_only = 1,
|
||||
},
|
||||
{
|
||||
/* PREFCTL */
|
||||
.idx = 0x228,
|
||||
.regno = 0x228,
|
||||
.byte_size = 4,
|
||||
.is_read_only = 1,
|
||||
},
|
||||
{
|
||||
/* WINDOWBASE */
|
||||
.idx = 0x248,
|
||||
.regno = 0x248,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 280,
|
||||
.is_read_only = 1,
|
||||
},
|
||||
{
|
||||
/* WINDOWSTART */
|
||||
.idx = 0x249,
|
||||
.regno = 0x249,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 284,
|
||||
.is_read_only = 1,
|
||||
},
|
||||
{
|
||||
/* PS */
|
||||
.idx = 0x2E6,
|
||||
.regno = 0x2E6,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 296,
|
||||
.stack_offset = ___xtensa_irq_bsa_t_ps_OFFSET,
|
||||
},
|
||||
{
|
||||
/* THREADPTR */
|
||||
.idx = 0x3E7,
|
||||
.regno = 0x3E7,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 300,
|
||||
IF_ENABLED(CONFIG_THREAD_LOCAL_STORAGE,
|
||||
(.stack_offset = ___xtensa_irq_bsa_t_threadptr_OFFSET,))
|
||||
},
|
||||
{
|
||||
/* SCOMPARE1 */
|
||||
.idx = 0x20C,
|
||||
.regno = 0x20C,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 308,
|
||||
.stack_offset = ___xtensa_irq_bsa_t_scompare1_OFFSET,
|
||||
},
|
||||
{
|
||||
/* EXCCAUSE */
|
||||
.idx = 0x2E8,
|
||||
.regno = 0x2E8,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 592,
|
||||
.stack_offset = ___xtensa_irq_bsa_t_exccause_OFFSET,
|
||||
},
|
||||
{
|
||||
/* DEBUGCAUSE */
|
||||
.idx = 0x2E9,
|
||||
.regno = 0x2E9,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 596,
|
||||
},
|
||||
{
|
||||
/* EXCVADDR */
|
||||
.idx = 0x2EE,
|
||||
.regno = 0x2EE,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 616,
|
||||
},
|
||||
{
|
||||
/* A0 */
|
||||
.idx = 0x0,
|
||||
.regno = 0x0,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 632,
|
||||
.stack_offset = ___xtensa_irq_bsa_t_a0_OFFSET,
|
||||
},
|
||||
{
|
||||
/* A1 */
|
||||
.idx = 0x1,
|
||||
.regno = 0x1,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 636,
|
||||
},
|
||||
{
|
||||
/* A2 */
|
||||
.idx = 0x2,
|
||||
.regno = 0x2,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 640,
|
||||
.stack_offset = ___xtensa_irq_bsa_t_a2_OFFSET,
|
||||
},
|
||||
{
|
||||
/* A3 */
|
||||
.idx = 0x3,
|
||||
.regno = 0x3,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 644,
|
||||
.stack_offset = ___xtensa_irq_bsa_t_a3_OFFSET,
|
||||
},
|
||||
{
|
||||
/* A4 */
|
||||
.idx = 0x4,
|
||||
.regno = 0x4,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 648,
|
||||
.stack_offset = -16,
|
||||
},
|
||||
{
|
||||
/* A5 */
|
||||
.idx = 0x5,
|
||||
.regno = 0x5,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 652,
|
||||
.stack_offset = -12,
|
||||
},
|
||||
{
|
||||
/* A6 */
|
||||
.idx = 0x6,
|
||||
.regno = 0x6,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 656,
|
||||
.stack_offset = -8,
|
||||
},
|
||||
{
|
||||
/* A7 */
|
||||
.idx = 0x7,
|
||||
.regno = 0x7,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 660,
|
||||
.stack_offset = -4,
|
||||
},
|
||||
{
|
||||
/* A8 */
|
||||
.idx = 0x8,
|
||||
.regno = 0x8,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 664,
|
||||
.stack_offset = -32,
|
||||
},
|
||||
{
|
||||
/* A9 */
|
||||
.idx = 0x9,
|
||||
.regno = 0x9,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 668,
|
||||
.stack_offset = -28,
|
||||
},
|
||||
{
|
||||
/* A10 */
|
||||
.idx = 0xA,
|
||||
.regno = 0xA,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 672,
|
||||
.stack_offset = -24,
|
||||
},
|
||||
{
|
||||
/* A11 */
|
||||
.idx = 0xB,
|
||||
.regno = 0xB,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 676,
|
||||
.stack_offset = -20,
|
||||
},
|
||||
{
|
||||
/* A12 */
|
||||
.idx = 0xC,
|
||||
.regno = 0xC,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 680,
|
||||
.stack_offset = -48,
|
||||
},
|
||||
{
|
||||
/* A13 */
|
||||
.idx = 0xD,
|
||||
.regno = 0xD,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 684,
|
||||
.stack_offset = -44,
|
||||
},
|
||||
{
|
||||
/* A14 */
|
||||
.idx = 0xE,
|
||||
.regno = 0xE,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 688,
|
||||
.stack_offset = -40,
|
||||
},
|
||||
{
|
||||
/* A15 */
|
||||
.idx = 0xF,
|
||||
.regno = 0xF,
|
||||
.byte_size = 4,
|
||||
.gpkt_offset = 692,
|
||||
.stack_offset = -36,
|
||||
},
|
||||
};
|
||||
|
||||
struct gdb_ctx xtensa_gdb_ctx = {
|
||||
.regs = gdb_reg_list,
|
||||
.num_regs = ARRAY_SIZE(gdb_reg_list),
|
||||
};
|
||||
@@ -11,6 +11,10 @@ zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_INTEL_ADSP_IPC ipc.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_GDBSTUB
|
||||
gdbstub_backend_sram.c
|
||||
)
|
||||
|
||||
zephyr_library_sources(
|
||||
rimage_modules.c
|
||||
boot.c
|
||||
|
||||
95
soc/intel/intel_adsp/common/gdbstub_backend_sram.c
Normal file
95
soc/intel/intel_adsp/common/gdbstub_backend_sram.c
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* This implements a backend for Zephyr's GDB stub. Since a serial connection is
|
||||
* not available, we need to implement a GDB communication system that uses an
|
||||
* alternative medium. This uses two circular buffers in shared SRAM within the
|
||||
* DEBUG region, similar to the closed-source FW implementation. The SOF kernel
|
||||
* driver will expose a DebugFS file which allows the GDB client to communicate
|
||||
* with Zephyr's stub through these buffers. Additionally, Cavstool.py can expose
|
||||
* these buffers via a pty for debugging without the kernel driver.
|
||||
*/
|
||||
|
||||
#include <soc.h>
|
||||
#include <adsp_debug_window.h>
|
||||
#include <adsp_memory.h>
|
||||
#include <mem_window.h>
|
||||
#include <zephyr/cache.h>
|
||||
|
||||
#define RING_SIZE 512
|
||||
#define SOF_GDB_WINDOW_OFFSET 1024
|
||||
|
||||
struct gdb_sram_ring {
|
||||
unsigned int head;
|
||||
/* Fill spaces are to ensure head/tail are in their own cache line */
|
||||
unsigned char fill1[60];
|
||||
unsigned int tail;
|
||||
unsigned char fill2[60];
|
||||
unsigned char data[RING_SIZE];
|
||||
};
|
||||
static inline unsigned int ring_next_head(const volatile struct gdb_sram_ring *ring)
|
||||
{
|
||||
return (ring->head + 1) & (RING_SIZE - 1);
|
||||
}
|
||||
|
||||
static inline unsigned int ring_next_tail(const volatile struct gdb_sram_ring *ring)
|
||||
{
|
||||
return (ring->tail + 1) & (RING_SIZE - 1);
|
||||
}
|
||||
|
||||
static inline int ring_have_space(const volatile struct gdb_sram_ring *ring)
|
||||
{
|
||||
return ring_next_head(ring) != ring->tail;
|
||||
}
|
||||
|
||||
static inline int ring_have_data(const volatile struct gdb_sram_ring *ring)
|
||||
{
|
||||
return ring->head != ring->tail;
|
||||
}
|
||||
|
||||
#define RX_UNCACHED (uint8_t *) (HP_SRAM_WIN2_BASE + SOF_GDB_WINDOW_OFFSET)
|
||||
#define TX_UNCACHED (uint8_t *) (RX_UNCACHED + sizeof(struct gdb_sram_ring))
|
||||
|
||||
static volatile struct gdb_sram_ring *rx;
|
||||
static volatile struct gdb_sram_ring *tx;
|
||||
|
||||
void z_gdb_backend_init(void)
|
||||
{
|
||||
__ASSERT_NO_MSG(sizeof(ADSP_DW->descs) <= SOF_GDB_WINDOW_OFFSET);
|
||||
|
||||
rx = sys_cache_uncached_ptr_get(RX_UNCACHED);
|
||||
tx = sys_cache_uncached_ptr_get(TX_UNCACHED);
|
||||
rx->head = rx->tail = 0;
|
||||
tx->head = tx->tail = 0;
|
||||
}
|
||||
|
||||
void z_gdb_putchar(unsigned char c)
|
||||
{
|
||||
while (!ring_have_space(tx)) {
|
||||
}
|
||||
|
||||
tx->data[tx->head] = c;
|
||||
tx->head = ring_next_head(tx);
|
||||
}
|
||||
|
||||
unsigned char z_gdb_getchar(void)
|
||||
{
|
||||
unsigned char v;
|
||||
|
||||
while (!ring_have_data(rx)) {
|
||||
}
|
||||
|
||||
v = rx->data[rx->tail];
|
||||
rx->tail = ring_next_tail(rx);
|
||||
return v;
|
||||
}
|
||||
|
||||
static int gdbstub_backend_sram_init(void)
|
||||
{
|
||||
ADSP_DW->descs[ADSP_DW_SLOT_NUM_GDB].type = ADSP_DW_SLOT_GDB_STUB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(gdbstub_backend_sram_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
|
||||
21
soc/intel/intel_adsp/common/include/gdbstub/soc.h
Normal file
21
soc/intel/intel_adsp/common/include/gdbstub/soc.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifndef SOC_XTENSA_ADSP_GDBSTUB_H_
|
||||
#define SOC_XTENSA_ADSP_GDBSTUB_H_
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_ARCH_XTENSA_GDBSTUB_SYS_H_
|
||||
#error "Must be included after arch/xtensa/gdbstub.h"
|
||||
#endif /* ZEPHYR_INCLUDE_ARCH_XTENSA_GDBSTUB_SYS_H_ */
|
||||
|
||||
#define SOC_GDB_GPKT_BIN_SIZE 420
|
||||
#define SOC_GDB_GPKT_HEX_SIZE (SOC_GDB_GPKT_BIN_SIZE * 2)
|
||||
|
||||
#define SOC_GDB_REGNO_A1 0x0001
|
||||
|
||||
#endif /* SOC_XTENSA_ADSP_GDBSTUB_H_ */
|
||||
Reference in New Issue
Block a user