xiaohu.huang | 797c4c1 | 2024-01-24 18:52:43 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | */ |
| 6 | |
| 7 | #include <stdio.h> |
| 8 | #include "exception_handler.h" |
| 9 | #include "riscv_encoding.h" |
| 10 | #include "interrupt_control_eclic.h" |
| 11 | |
| 12 | uint32_t handle_exception(uint32_t mcause, uint32_t sp) |
| 13 | { |
| 14 | uint32_t mstatus_mps_bits = ((read_csr(mstatus) & MSTATUS_MPS) >> MSTATUS_MPS_LSB); |
| 15 | uint8_t exception_type = (mcause & 0x1f); |
| 16 | |
| 17 | printf("mstatus mps:0x%x,exception type:0x%x\n", mstatus_mps_bits, exception_type); |
| 18 | |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | uint32_t handle_nmi(uint32_t mcause, uint32_t sp) |
| 23 | { |
| 24 | return 0; |
| 25 | } |
| 26 | |
| 27 | uint32_t interrupt_register_exception(uint32_t mcause, uint32_t sp) |
| 28 | { |
| 29 | return handle_exception(mcause, sp); |
| 30 | } |
| 31 | |
| 32 | uint32_t interrupt_register_nmi(uint32_t mcause, uint32_t sp) |
| 33 | { |
| 34 | return handle_nmi(mcause, sp); |
| 35 | } |
| 36 | |