yang.li | 5bef2f6 | 2022-01-11 14:08:06 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | */ |
| 6 | |
Xiaohu.Huang | be56506 | 2021-10-15 17:29:19 +0800 | [diff] [blame] | 7 | #include <stdint.h> |
| 8 | #include <stdio.h> |
| 9 | #include <unistd.h> |
| 10 | #include "riscv_encoding.h" |
| 11 | #include "n200_func.h" |
| 12 | |
| 13 | uintptr_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.Huang | 0424881 | 2022-01-17 10:44:18 +0800 | [diff] [blame] | 45 | #ifdef CONFIG_N200_REVA |
Xiaohu.Huang | be56506 | 2021-10-15 17:29:19 +0800 | [diff] [blame] | 46 | /*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 | |