Core commit. Compile and run on the OpenPandora
[mupen64plus-pandora.git] / source / mupen64plus-core / src / api / m64p_debugger.h
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  *   Mupen64plus-core - m64p_debugger.h                                    *
3  *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
4  *   Copyright (C) 2009 Richard Goedeken                                   *
5  *                                                                         *
6  *   This program is free software; you can redistribute it and/or modify  *
7  *   it under the terms of the GNU General Public License as published by  *
8  *   the Free Software Foundation; either version 2 of the License, or     *
9  *   (at your option) any later version.                                   *
10  *                                                                         *
11  *   This program is distributed in the hope that it will be useful,       *
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14  *   GNU General Public License for more details.                          *
15  *                                                                         *
16  *   You should have received a copy of the GNU General Public License     *
17  *   along with this program; if not, write to the                         *
18  *   Free Software Foundation, Inc.,                                       *
19  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
20  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
21
22 /* This header file defines typedefs for function pointers to Core Debugger
23  * functions.
24  */
25
26 #if !defined(M64P_DEBUGGER_H)
27 #define M64P_DEBUGGER_H
28
29 #include "m64p_types.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /* DebugSetCallbacks()
36  *
37  * This function is called by the front-end to supply debugger callback
38  * function pointers. If debugger is enabled and then later disabled within the
39  * UI, this function may be called with NULL pointers in order to disable the
40  * callbacks. 
41  */
42 typedef m64p_error (*ptr_DebugSetCallbacks)(void (*)(void), void (*)(unsigned int), void (*)(void));
43 #if defined(M64P_CORE_PROTOTYPES)
44 EXPORT m64p_error CALL DebugSetCallbacks(void (*)(void), void (*)(unsigned int), void (*)(void));
45 #endif
46
47 /* DebugSetCoreCompare()
48  *
49  * This function is called by the front-end to supply callback function pointers
50  * for the Core Comparison feature.
51  */
52 typedef m64p_error (*ptr_DebugSetCoreCompare)(void (*)(unsigned int), void (*)(int, void *));
53 #if defined(M64P_CORE_PROTOTYPES)
54 EXPORT m64p_error CALL DebugSetCoreCompare(void (*)(unsigned int), void (*)(int, void *));
55 #endif
56
57 /* DebugSetRunState()
58  *
59  * This function sets the run state of the R4300 CPU emulator.
60  */
61 typedef m64p_error (*ptr_DebugSetRunState)(int);
62 #if defined(M64P_CORE_PROTOTYPES)
63 EXPORT m64p_error CALL DebugSetRunState(int);
64 #endif
65
66 /* DebugGetState()
67  *
68  * This function reads and returns a debugger state variable, which are
69  * enumerated in m64p_types.h. 
70  */
71 typedef int (*ptr_DebugGetState)(m64p_dbg_state);
72 #if defined(M64P_CORE_PROTOTYPES)
73 EXPORT int CALL DebugGetState(m64p_dbg_state);
74 #endif
75
76 /* DebugStep()
77  *
78  * This function signals the debugger to advance one instruction when in the
79  * stepping mode.
80  */
81 typedef m64p_error (*ptr_DebugStep)(void);
82 #if defined(M64P_CORE_PROTOTYPES)
83 EXPORT m64p_error CALL DebugStep(void);
84 #endif
85
86 /* DebugDecodeOp()
87  *
88  * This is a helper function for the debugger front-end. This instruction takes
89  * a PC value and an R4300 instruction opcode and writes the disassembled
90  * instruction mnemonic and arguments into character buffers. This is intended
91  * to be used to display disassembled code. 
92  */
93 typedef void (*ptr_DebugDecodeOp)(unsigned int, char *, char *, int);
94 #if defined(M64P_CORE_PROTOTYPES)
95 EXPORT void CALL DebugDecodeOp(unsigned int, char *, char *, int);
96 #endif
97
98 /* DebugMemGetRecompInfo()
99  *
100  * This function is used by the front-end to retrieve disassembly information
101  * about recompiled code. For example, the dynamic recompiler may take a single
102  * R4300 instruction and compile it into 10 x86 instructions. This function may
103  * then be used to retrieve the disassembled code of the 10 x86 instructions.
104  */
105 typedef void * (*ptr_DebugMemGetRecompInfo)(m64p_dbg_mem_info, unsigned int, int);
106 #if defined(M64P_CORE_PROTOTYPES)
107 EXPORT void * CALL DebugMemGetRecompInfo(m64p_dbg_mem_info, unsigned int, int);
108 #endif
109
110 /* DebugMemGetMemInfo()
111  *
112  * This function returns an integer value regarding the memory location address,
113  * corresponding to the information requested by mem_info_type, which is a type
114  * enumerated in m64p_types.h.
115  */
116 typedef int (*ptr_DebugMemGetMemInfo)(m64p_dbg_mem_info, unsigned int);
117 #if defined(M64P_CORE_PROTOTYPES)
118 EXPORT int CALL DebugMemGetMemInfo(m64p_dbg_mem_info, unsigned int);
119 #endif
120
121 /* DebugMemGetPointer()
122  *
123  * This function returns a memory pointer (in x86 memory space) to a block of
124  * emulated N64 memory. This may be used to retrieve a pointer to a special N64
125  * block (such as the serial, video, or audio registers) or the RDRAM.
126  */
127 typedef void * (*ptr_DebugMemGetPointer)(m64p_dbg_memptr_type);
128 #if defined(M64P_CORE_PROTOTYPES)
129 EXPORT void * CALL DebugMemGetPointer(m64p_dbg_memptr_type);
130 #endif
131
132 /* DebugMemRead**()
133  *
134  * These functions retrieve a value from the emulated N64 memory. The returned
135  * value will be correctly byte-swapped for the host architecture. 
136  */
137 typedef unsigned long long (*ptr_DebugMemRead64)(unsigned int);
138 typedef unsigned int       (*ptr_DebugMemRead32)(unsigned int);
139 typedef unsigned short     (*ptr_DebugMemRead16)(unsigned int);
140 typedef unsigned char      (*ptr_DebugMemRead8)(unsigned int);
141 #if defined(M64P_CORE_PROTOTYPES)
142 EXPORT unsigned long long  CALL DebugMemRead64(unsigned int);
143 EXPORT unsigned int        CALL DebugMemRead32(unsigned int);
144 EXPORT unsigned short      CALL DebugMemRead16(unsigned int);
145 EXPORT unsigned char       CALL DebugMemRead8(unsigned int);
146 #endif
147
148 /* DebugMemWrite**()
149  *
150  * These functions write a value into the emulated N64 memory. The given value
151  * will be correctly byte-swapped before storage. 
152  */
153 typedef void (*ptr_DebugMemWrite64)(unsigned int, unsigned long long);
154 typedef void (*ptr_DebugMemWrite32)(unsigned int, unsigned int);
155 typedef void (*ptr_DebugMemWrite16)(unsigned int, unsigned short);
156 typedef void (*ptr_DebugMemWrite8)(unsigned int, unsigned char);
157 #if defined(M64P_CORE_PROTOTYPES)
158 EXPORT void CALL DebugMemWrite64(unsigned int, unsigned long long);
159 EXPORT void CALL DebugMemWrite32(unsigned int, unsigned int);
160 EXPORT void CALL DebugMemWrite16(unsigned int, unsigned short);
161 EXPORT void CALL DebugMemWrite8(unsigned int, unsigned char);
162 #endif
163
164 /* DebugGetCPUDataPtr()
165  *
166  * This function returns a memory pointer (in x86 memory space) to a specific
167  * register in the emulated R4300 CPU.
168  */
169 typedef void * (*ptr_DebugGetCPUDataPtr)(m64p_dbg_cpu_data);
170 #if defined(M64P_CORE_PROTOTYPES)
171 EXPORT void * CALL DebugGetCPUDataPtr(m64p_dbg_cpu_data);
172 #endif
173
174 /* DebugBreakpointLookup()
175  *
176  * This function searches through all current breakpoints in the debugger to
177  * find one that matches the given input parameters. If a matching breakpoint
178  * is found, the index number is returned. If no breakpoints are found, -1 is
179  * returned. 
180  */
181 typedef int (*ptr_DebugBreakpointLookup)(unsigned int, unsigned int, unsigned int);
182 #if defined(M64P_CORE_PROTOTYPES)
183 EXPORT int CALL DebugBreakpointLookup(unsigned int, unsigned int, unsigned int);
184 #endif
185
186 /* DebugBreakpointCommand()
187  *
188  * This function is used to process common breakpoint commands, such as adding,
189  * removing, or searching the breakpoints. The meanings of the index and ptr
190  * input parameters vary by command.
191  */
192 typedef int (*ptr_DebugBreakpointCommand)(m64p_dbg_bkp_command, unsigned int, void *);
193 #if defined(M64P_CORE_PROTOTYPES)
194 EXPORT int CALL DebugBreakpointCommand(m64p_dbg_bkp_command, unsigned int, void *);
195 #endif
196
197 #ifdef __cplusplus
198 }
199 #endif
200
201 #endif /* #define M64P_DEBUGGER_H */
202