1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2016-17 Microsemi Corporation.
4 * Padmarao Begari, Microsemi Corporation <padmarao.begari@microsemi.com>
6 * Copyright (C) 2017 Andes Technology Corporation
7 * Rick Chen, Andes Technology Corporation <rick@andestech.com>
11 #include <asm/ptrace.h>
12 #include <asm/system.h>
13 #include <asm/encoding.h>
15 static void _exit_trap(ulong code, ulong epc, struct pt_regs *regs);
17 int interrupt_init(void)
25 void enable_interrupts(void)
32 int disable_interrupts(void)
37 ulong handle_trap(ulong cause, ulong epc, struct pt_regs *regs)
41 is_irq = (cause & MCAUSE_INT);
42 irq = (cause & ~MCAUSE_INT);
48 external_interrupt(0); /* handle external interrupt */
52 timer_interrupt(0); /* handle timer interrupt */
55 _exit_trap(cause, epc, regs);
59 _exit_trap(cause, epc, regs);
66 *Entry Point for PLIC Interrupt Handler
68 __attribute__((weak)) void external_interrupt(struct pt_regs *regs)
72 __attribute__((weak)) void timer_interrupt(struct pt_regs *regs)
76 static void _exit_trap(ulong code, ulong epc, struct pt_regs *regs)
78 static const char * const exception_code[] = {
79 "Instruction address misaligned",
80 "Instruction access fault",
81 "Illegal instruction",
83 "Load address misaligned",
85 "Store/AMO address misaligned",
86 "Store/AMO access fault",
87 "Environment call from U-mode",
88 "Environment call from S-mode",
90 "Environment call from M-mode",
91 "Instruction page fault",
94 "Store/AMO page fault",
97 if (code < ARRAY_SIZE(exception_code)) {
98 printf("exception code: %ld , %s , epc %lx , ra %lx\n",
99 code, exception_code[code], epc, regs->ra);
101 printf("Reserved\n");