CpuExceptionHandlerLib.h 2.8 KB

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