Skip to content

Commit 5107320

Browse files
ycsincarlescufi
authored andcommitted
arch: common: isr_tables: add shell command
Add a shell command to dump the isr_tables. ```CONFIG_SYMTAB=n uart:~$ isr_table sw_isr_table _sw_isr_table[1035] 7: 0x800056e2(0) 11: 0x80005048(0x80008148) 22: 0x800054ee(0x80008170) ``` ```CONFIG_SYMTAB=y uart:~$ isr_table sw_isr_table _sw_isr_table[1035] 7: timer_isr(0) 11: plic_irq_handler(0x80008188) 22: uart_ns16550_isr(0x800081b0) ``` Signed-off-by: Yong Cong Sin <[email protected]> Signed-off-by: Yong Cong Sin <[email protected]>
1 parent d6e0b43 commit 5107320

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

arch/common/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ if(CONFIG_GEN_ISR_TABLES)
1717
)
1818
endif()
1919

20+
zephyr_library_sources_ifdef(
21+
CONFIG_ISR_TABLE_SHELL
22+
isr_tables_shell.c
23+
)
24+
2025
zephyr_library_sources_ifdef(
2126
CONFIG_MULTI_LEVEL_INTERRUPTS
2227
multilevel_irq.c

arch/common/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,10 @@ config LEGACY_MULTI_LEVEL_TABLE_GENERATION
3030
help
3131
A make-shift Kconfig to continue generating the multi-level interrupt LUT
3232
with the legacy way using DT macros.
33+
34+
config ISR_TABLE_SHELL
35+
bool "Shell command to dump the ISR tables"
36+
depends on GEN_SW_ISR_TABLE
37+
depends on SHELL
38+
help
39+
This option enables a shell command to dump the ISR tables.

arch/common/isr_tables_shell.c

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) 2024 Meta Platforms.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/debug/symtab.h>
8+
#include <zephyr/shell/shell.h>
9+
#include <zephyr/sw_isr_table.h>
10+
11+
static void dump_isr_table_entry(const struct shell *sh, int idx, struct _isr_table_entry *entry)
12+
{
13+
14+
if ((entry->isr == z_irq_spurious) || (entry->isr == NULL)) {
15+
return;
16+
}
17+
#ifdef CONFIG_SYMTAB
18+
const char *name = symtab_find_symbol_name((uintptr_t)entry->isr, NULL);
19+
20+
shell_print(sh, "%4d: %s(%p)", idx, name, entry->arg);
21+
#else
22+
shell_print(sh, "%4d: %p(%p)", idx, entry->isr, entry->arg);
23+
#endif /* CONFIG_SYMTAB */
24+
}
25+
26+
static int cmd_sw_isr_table(const struct shell *sh, size_t argc, char **argv)
27+
{
28+
shell_print(sh, "_sw_isr_table[%d]\n", IRQ_TABLE_SIZE);
29+
30+
for (int idx = 0; idx < IRQ_TABLE_SIZE; idx++) {
31+
dump_isr_table_entry(sh, idx, &_sw_isr_table[idx]);
32+
}
33+
34+
return 0;
35+
}
36+
37+
#ifdef CONFIG_SHARED_INTERRUPTS
38+
static int cmd_shared_sw_isr_table(const struct shell *sh, size_t argc, char **argv)
39+
{
40+
shell_print(sh, "z_shared_sw_isr_table[%d][%d]\n", IRQ_TABLE_SIZE,
41+
CONFIG_SHARED_IRQ_MAX_NUM_CLIENTS);
42+
43+
for (int idx = 0; idx < IRQ_TABLE_SIZE; idx++) {
44+
for (int c = 0; c < z_shared_sw_isr_table[idx].client_num; c++) {
45+
dump_isr_table_entry(sh, idx, &z_shared_sw_isr_table[idx].clients[c]);
46+
}
47+
}
48+
49+
return 0;
50+
}
51+
#endif /* CONFIG_SHARED_INTERRUPTS */
52+
53+
SHELL_STATIC_SUBCMD_SET_CREATE(isr_table_cmds,
54+
SHELL_CMD_ARG(sw_isr_table, NULL,
55+
"Dump _sw_isr_table.\n"
56+
"Usage: isr_table sw_isr_table",
57+
cmd_sw_isr_table, 1, 0),
58+
#ifdef CONFIG_SHARED_INTERRUPTS
59+
SHELL_CMD_ARG(shared_sw_isr_table, NULL,
60+
"Dump z_shared_sw_isr_table.\n"
61+
"Usage: isr_table shared_sw_isr_table",
62+
cmd_shared_sw_isr_table, 1, 0),
63+
#endif /* CONFIG_SHARED_INTERRUPTS */
64+
SHELL_SUBCMD_SET_END);
65+
66+
SHELL_CMD_ARG_REGISTER(isr_table, &isr_table_cmds, "ISR tables shell command",
67+
NULL, 0, 0);

0 commit comments

Comments
 (0)