blob: 5ef9b56334ea8e5069d827c49d83972b91d33604 [file] [log] [blame]
yang.li5bef2f62022-01-11 14:08:06 +08001/*
2 * Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
Xiaohu.Huangbe565062021-10-15 17:29:19 +08007#include <stdint.h>
8#include <stdio.h>
9#include <unistd.h>
10#include "riscv_encoding.h"
11#include "n200_func.h"
12
13uintptr_t handle_trap(uintptr_t mcause, uintptr_t sp);
14__attribute__((weak)) uintptr_t handle_nmi(void);
15
16__attribute__((weak)) uintptr_t handle_nmi(void)
17{
18 //_exit(1);
19
20 printf("\nhandle_nmi");
21
22 do {}while(1);
23 return 0;
24}
25
26
27__attribute__((weak)) uintptr_t handle_trap(uintptr_t mcause, uintptr_t sp)
28{
29 sp = sp;
30 if ((mcause&0xFFF) == 0xFFF) {
31 handle_nmi();
32 }
33 //write(1, "trap\n", 5);
34 printf("In trap handler, the mcause is %d\n", mcause);
35 printf("In trap handler, the mepc is 0x%lx\n", read_csr(mepc));
36 printf("In trap handler, the mtval is 0x%lx\n", read_csr(mbadaddr));
37 //_exit(mcause);
38 printf("\nhandle_trap");
39
40 do {}while(1);
41 return 0;
42}
43
44
Xiaohu.Huang04248812022-01-17 10:44:18 +080045#ifdef CONFIG_N200_REVA
Xiaohu.Huangbe565062021-10-15 17:29:19 +080046/*Entry Point for PIC Interrupt Handler*/
47__attribute__((weak)) uint32_t handle_irq(uint32_t int_num);
48
49__attribute__((weak)) uint32_t handle_irq(uint32_t int_num){
50 // Enable interrupts to allow interrupt preempt based on priority
51 //set_csr(mstatus, MSTATUS_MIE);
52
53 pic_interrupt_handlers[int_num]();
54 pic_complete_interrupt(int_num);
55 // Disable interrupts
56 //clear_csr(mstatus, MSTATUS_MIE);
57 return int_num;
58}
59#endif
60
61