]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/CpuExceptionHandlerLib.h
UefiCpuPkg: Add BaseRiscV64CpuExceptionHandlerLib
[mirror_edk2.git] / UefiCpuPkg / Library / BaseRiscV64CpuExceptionHandlerLib / CpuExceptionHandlerLib.h
1 /** @file
2
3 RISC-V Exception Handler library definition file.
4
5 Copyright (c) 2019-2022, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #ifndef RISCV_CPU_EXECPTION_HANDLER_LIB_H_
12 #define RISCV_CPU_EXECPTION_HANDLER_LIB_H_
13
14 #include <Register/RiscV64/RiscVImpl.h>
15
16 /**
17 Trap Handler for S-mode
18
19 **/
20 VOID
21 SupervisorModeTrap (
22 VOID
23 );
24
25 //
26 // Index of SMode trap register
27 //
28 #define SMODE_TRAP_REGS_zero 0
29 #define SMODE_TRAP_REGS_ra 1
30 #define SMODE_TRAP_REGS_sp 2
31 #define SMODE_TRAP_REGS_gp 3
32 #define SMODE_TRAP_REGS_tp 4
33 #define SMODE_TRAP_REGS_t0 5
34 #define SMODE_TRAP_REGS_t1 6
35 #define SMODE_TRAP_REGS_t2 7
36 #define SMODE_TRAP_REGS_s0 8
37 #define SMODE_TRAP_REGS_s1 9
38 #define SMODE_TRAP_REGS_a0 10
39 #define SMODE_TRAP_REGS_a1 11
40 #define SMODE_TRAP_REGS_a2 12
41 #define SMODE_TRAP_REGS_a3 13
42 #define SMODE_TRAP_REGS_a4 14
43 #define SMODE_TRAP_REGS_a5 15
44 #define SMODE_TRAP_REGS_a6 16
45 #define SMODE_TRAP_REGS_a7 17
46 #define SMODE_TRAP_REGS_s2 18
47 #define SMODE_TRAP_REGS_s3 19
48 #define SMODE_TRAP_REGS_s4 20
49 #define SMODE_TRAP_REGS_s5 21
50 #define SMODE_TRAP_REGS_s6 22
51 #define SMODE_TRAP_REGS_s7 23
52 #define SMODE_TRAP_REGS_s8 24
53 #define SMODE_TRAP_REGS_s9 25
54 #define SMODE_TRAP_REGS_s10 26
55 #define SMODE_TRAP_REGS_s11 27
56 #define SMODE_TRAP_REGS_t3 28
57 #define SMODE_TRAP_REGS_t4 29
58 #define SMODE_TRAP_REGS_t5 30
59 #define SMODE_TRAP_REGS_t6 31
60 #define SMODE_TRAP_REGS_sepc 32
61 #define SMODE_TRAP_REGS_sstatus 33
62 #define SMODE_TRAP_REGS_sie 34
63 #define SMODE_TRAP_REGS_last 35
64
65 #define SMODE_TRAP_REGS_OFFSET(x) ((SMODE_TRAP_REGS_##x) * __SIZEOF_POINTER__)
66 #define SMODE_TRAP_REGS_SIZE SMODE_TRAP_REGS_OFFSET(last)
67
68 #pragma pack(1)
69 typedef struct {
70 //
71 // Below are follow the format of EFI_SYSTEM_CONTEXT
72 //
73 UINT64 zero;
74 UINT64 ra;
75 UINT64 sp;
76 UINT64 gp;
77 UINT64 tp;
78 UINT64 t0;
79 UINT64 t1;
80 UINT64 t2;
81 UINT64 s0;
82 UINT64 s1;
83 UINT64 a0;
84 UINT64 a1;
85 UINT64 a2;
86 UINT64 a3;
87 UINT64 a4;
88 UINT64 a5;
89 UINT64 a6;
90 UINT64 a7;
91 UINT64 s2;
92 UINT64 s3;
93 UINT64 s4;
94 UINT64 s5;
95 UINT64 s6;
96 UINT64 s7;
97 UINT64 s8;
98 UINT64 s9;
99 UINT64 s10;
100 UINT64 s11;
101 UINT64 t3;
102 UINT64 t4;
103 UINT64 t5;
104 UINT64 t6;
105 //
106 // Below are the additional information to
107 // EFI_SYSTEM_CONTEXT, private to supervisor mode trap
108 // and not public to EFI environment.
109 //
110 UINT64 sepc;
111 UINT64 sstatus;
112 UINT64 sie;
113 } SMODE_TRAP_REGISTERS;
114 #pragma pack()
115
116 #endif