PS2SDK
PS2 Homebrew Libraries
ioptrap.h
Go to the documentation of this file.
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 
16 #ifndef __IOPTRAP_H__
17 #define __IOPTRAP_H__
18 
19 #include <types.h>
20 #include <irx.h>
21 
22 /* IDT_R3000_20.pdf 3-11 table 3.5 */
23 typedef enum {
24  EXCEPTION_Int, /* note you can't really work with this one. */
25  EXCEPTION_Mod,
26  EXCEPTION_TLBL,
27  EXCEPTION_TLBS,
28  EXCEPTION_AdEL,
29  EXCEPTION_AdES,
30  EXCEPTION_IBE,
31  EXCEPTION_DBE,
32  EXCEPTION_Syscall,
33  EXCEPTION_Bp,
34  EXCEPTION_RI,
35  EXCEPTION_CpU,
36  EXCEPTION_Ov,
37  EXCEPTION_RESERVED13,
38  EXCEPTION_RESERVED14 /* would be FPE, but that's not going to happen on the IOP */
39 } exception_type_t;
40 
41 typedef struct exception_frame
42 {
43  u32 epc;
44  u32 cause;
45  u32 badvaddr;
46  u32 sr;
47  u32 regs[32];
48  u32 hi;
49  u32 lo;
50  u32 dcic;
52 
53 /* Beware: the handler will be run in a 'bad' state. Consider you are
54  on interrupt mode, so, only i* functions. */
55 typedef void (*trap_exception_handler_t)(exception_type_t type, exception_frame_t *ex);
56 
57 #define DCIC_WR (1 << 27)
58 #define DCIC_RD (1 << 26)
59 #define DCIC_DA (1 << 25)
60 #define DCIC_PC (1 << 24)
61 
62 extern const char *get_exception_name(exception_type_t type);
63 
64 /* Will act as a setjmp. Returns 0 to say it was the first call,
65  otherwise, returns the exception number. (note that you'll never
66  get any interrupt...) Note that using this will completely disable
67  user defined exception handlers. */
68 extern exception_type_t dbg_setjmp();
69 
70 /* Will return the old handler. */
71 extern trap_exception_handler_t set_exception_handler(exception_type_t type, trap_exception_handler_t handler);
72 extern trap_exception_handler_t get_exception_handler(exception_type_t type);
73 
74 /* Breakpoint stuff. */
75 extern void set_dba(u32 v);
76 extern void set_dbam(u32 v);
77 extern void set_dcic(u32 v);
78 extern u32 get_dba();
79 extern u32 get_dbam();
80 extern u32 get_dcic();
81 
82 #define ioptrap_IMPORTS_start DECLARE_IMPORT_TABLE(ioptrap, 1, 1)
83 #define ioptrap_IMPORTS_end END_IMPORT_TABLE
84 
85 #define I_get_exception_name DECLARE_IMPORT(4, get_exception_name)
86 #define I_dbg_setjmp DECLARE_IMPORT(5, dbg_setjmp)
87 #define I_set_exception_handler DECLARE_IMPORT(6, set_exception_handler)
88 #define I_get_exception_handler DECLARE_IMPORT(7, get_exception_handler)
89 #define I_set_dba DECLARE_IMPORT(8, set_dba)
90 #define I_set_dbam DECLARE_IMPORT(9, set_dbam)
91 #define I_set_dcic DECLARE_IMPORT(10, set_dcic)
92 #define I_get_dba DECLARE_IMPORT(11, get_dba)
93 #define I_get_dbam DECLARE_IMPORT(12, get_dbam)
94 #define I_get_dcic DECLARE_IMPORT(13, get_dcic)
95 
96 #endif /* __IOPTRAP_H__ */
exception_frame
Definition: ioptrap.h:41
irx.h