1/*
2 * Copyright (c) 2021 Henrik Brix Andersen <henrik@brixandersen.dk>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <zephyr/toolchain.h>
8
9GTEXT(__soc_handle_irq)
10
11/*
12 * SOC-specific function to handle pending IRQ number generating the interrupt.
13 * Exception number is given as parameter via register a0.
14 */
15SECTION_FUNC(exception.other, __soc_handle_irq)
16	/*
17	 * The MIP CSR on the NEORV32 is read-only and can thus not be used for
18	 * clearing a pending IRQ. Instead we disable the IRQ in the MIE CSR and
19	 * re-enable it (if it was enabled when clearing).
20	 */
21	li t1, 1
22	sll t0, t1, a0
23	csrrc t2, mie, t0
24	and t1, t2, t0
25	csrrs t2, mie, t1
26
27	/* Return */
28	ret
29