summaryrefslogtreecommitdiff
path: root/zephyr/shim/core/cortex-m/irq_command.c
blob: 651f8048000dede706230a2d77e592c97ca2eef4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Copyright 2022 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "console.h"

#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>

/* IRQ counters */
int irq_count[CONFIG_NUM_IRQS];

void sys_trace_isr_enter_user(int nested_interrupts)
{
	ARG_UNUSED(nested_interrupts);

	/* read the exception number */
	uint32_t irq = __get_IPSR() - 16;

	__ASSERT(irq < CONFIG_NUM_IRQS, "Invalid IRQ number");

	irq_count[irq]++;
}

static int command_irq(int argc, const char **argv)
{
	ARG_UNUSED(argc);
	ARG_UNUSED(argv);

	for (int i = 0; i < CONFIG_NUM_IRQS; i++) {
		if (irq_count[i])
			ccprintf("  IRQ %d: %d\n", i, irq_count[i]);
	}

	return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(irq, command_irq, "", "List irq counters");