Sony PlayStation2 Study
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.9 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. # _____ ___ ____ ___ ____
  3. # ____| | ____| | | |____|
  4. # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
  5. #-----------------------------------------------------------------------
  6. # Copyright 2001-2004, ps2dev - http://www.ps2dev.org
  7. # Licenced under Academic Free License version 2.0
  8. # Review ps2sdk README & LICENSE files for further details.
  9. */
  10. /**
  11. * @file
  12. * IOP exception handling.
  13. */
  14. #ifndef __IOPTRAP_H__
  15. #define __IOPTRAP_H__
  16. #include <types.h>
  17. #include <irx.h>
  18. /* IDT_R3000_20.pdf 3-11 table 3.5 */
  19. typedef enum {
  20. EXCEPTION_Int, /* note you can't really work with this one. */
  21. EXCEPTION_Mod,
  22. EXCEPTION_TLBL,
  23. EXCEPTION_TLBS,
  24. EXCEPTION_AdEL,
  25. EXCEPTION_AdES,
  26. EXCEPTION_IBE,
  27. EXCEPTION_DBE,
  28. EXCEPTION_Syscall,
  29. EXCEPTION_Bp,
  30. EXCEPTION_RI,
  31. EXCEPTION_CpU,
  32. EXCEPTION_Ov,
  33. EXCEPTION_RESERVED13,
  34. EXCEPTION_RESERVED14 /* would be FPE, but that's not going to happen on the IOP */
  35. } exception_type_t;
  36. typedef struct exception_frame
  37. {
  38. u32 epc;
  39. u32 cause;
  40. u32 badvaddr;
  41. u32 sr;
  42. u32 regs[32];
  43. u32 hi;
  44. u32 lo;
  45. u32 dcic;
  46. } exception_frame_t;
  47. /* Beware: the handler will be run in a 'bad' state. Consider you are
  48. on interrupt mode, so, only i* functions. */
  49. typedef void (*trap_exception_handler_t)(exception_type_t, exception_frame_t *);
  50. #define DCIC_WR (1 << 27)
  51. #define DCIC_RD (1 << 26)
  52. #define DCIC_DA (1 << 25)
  53. #define DCIC_PC (1 << 24)
  54. const char *get_exception_name(exception_type_t type);
  55. /* Will act as a setjmp. Returns 0 to say it was the first call,
  56. otherwise, returns the exception number. (note that you'll never
  57. get any interrupt...) Note that using this will completely disable
  58. user defined exception handlers. */
  59. exception_type_t dbg_setjmp();
  60. /* Will return the old handler. */
  61. trap_exception_handler_t set_exception_handler(exception_type_t type, trap_exception_handler_t handler);
  62. trap_exception_handler_t get_exception_handler(exception_type_t type);
  63. /* Breakpoint stuff. */
  64. void set_dba(u32 v);
  65. void set_dbam(u32 v);
  66. void set_dcic(u32 v);
  67. u32 get_dba();
  68. u32 get_dbam();
  69. u32 get_dcic();
  70. #define ioptrap_IMPORTS_start DECLARE_IMPORT_TABLE(ioptrap, 1, 1)
  71. #define ioptrap_IMPORTS_end END_IMPORT_TABLE
  72. #define I_get_exception_name DECLARE_IMPORT(4, get_exception_name)
  73. #define I_dbg_setjmp DECLARE_IMPORT(5, dbg_setjmp)
  74. #define I_set_exception_handler DECLARE_IMPORT(6, set_exception_handler)
  75. #define I_get_exception_handler DECLARE_IMPORT(7, get_exception_handler)
  76. #define I_set_dba DECLARE_IMPORT(8, set_dba)
  77. #define I_set_dbam DECLARE_IMPORT(9, set_dbam)
  78. #define I_set_dcic DECLARE_IMPORT(10, set_dcic)
  79. #define I_get_dba DECLARE_IMPORT(11, get_dba)
  80. #define I_get_dbam DECLARE_IMPORT(12, get_dbam)
  81. #define I_get_dcic DECLARE_IMPORT(13, get_dcic)
  82. #endif /* __IOPTRAP_H__ */