|
| 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