dbg_rdi.h revision 1.1
1/*  dbg_rdi.h -- ARMulator RDI interface:  ARM6 Instruction Emulator.
2    Copyright (C) 1994 Advanced RISC Machines Ltd.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, see <http://www.gnu.org/licenses/>. */
16
17#ifndef dbg_rdi__h
18#define dbg_rdi__h
19
20/***************************************************************************\
21*                              Error Codes                                  *
22\***************************************************************************/
23
24#define RDIError_NoError                0
25
26#define RDIError_Reset                  1
27#define RDIError_UndefinedInstruction   2
28#define RDIError_SoftwareInterrupt      3
29#define RDIError_PrefetchAbort          4
30#define RDIError_DataAbort              5
31#define RDIError_AddressException       6
32#define RDIError_IRQ                    7
33#define RDIError_FIQ                    8
34#define RDIError_Error                  9
35#define RDIError_BranchThrough0         10
36
37#define RDIError_NotInitialised         128
38#define RDIError_UnableToInitialise     129
39#define RDIError_WrongByteSex           130
40#define RDIError_UnableToTerminate      131
41#define RDIError_BadInstruction         132
42#define RDIError_IllegalInstruction     133
43#define RDIError_BadCPUStateSetting     134
44#define RDIError_UnknownCoPro           135
45#define RDIError_UnknownCoProState      136
46#define RDIError_BadCoProState          137
47#define RDIError_BadPointType           138
48#define RDIError_UnimplementedType      139
49#define RDIError_BadPointSize           140
50#define RDIError_UnimplementedSize      141
51#define RDIError_NoMorePoints           142
52#define RDIError_BreakpointReached      143
53#define RDIError_WatchpointAccessed     144
54#define RDIError_NoSuchPoint            145
55#define RDIError_ProgramFinishedInStep  146
56#define RDIError_UserInterrupt          147
57#define RDIError_CantSetPoint           148
58#define RDIError_IncompatibleRDILevels  149
59
60#define RDIError_CantLoadConfig         150
61#define RDIError_BadConfigData          151
62#define RDIError_NoSuchConfig           152
63#define RDIError_BufferFull             153
64#define RDIError_OutOfStore             154
65#define RDIError_NotInDownload          155
66#define RDIError_PointInUse             156
67#define RDIError_BadImageFormat         157
68#define RDIError_TargetRunning          158
69
70#define RDIError_LittleEndian           240
71#define RDIError_BigEndian              241
72#define RDIError_SoftInitialiseError    242
73
74#define RDIError_InsufficientPrivilege  253
75#define RDIError_UnimplementedMessage   254
76#define RDIError_UndefinedMessage       255
77
78/***************************************************************************\
79*                          RDP Message Numbers                              *
80\***************************************************************************/
81
82#define RDP_Start               (unsigned char)0x0
83#define RDP_End                 (unsigned char)0x1
84#define RDP_Read                (unsigned char)0x2
85#define RDP_Write               (unsigned char)0x3
86#define RDP_CPUread             (unsigned char)0x4
87#define RDP_CPUwrite            (unsigned char)0x5
88#define RDP_CPread              (unsigned char)0x6
89#define RDP_CPwrite             (unsigned char)0x7
90#define RDP_SetBreak            (unsigned char)0xa
91#define RDP_ClearBreak          (unsigned char)0xb
92#define RDP_SetWatch            (unsigned char)0xc
93#define RDP_ClearWatch          (unsigned char)0xd
94#define RDP_Execute             (unsigned char)0x10
95#define RDP_Step                (unsigned char)0x11
96#define RDP_Info                (unsigned char)0x12
97#define RDP_OSOpReply           (unsigned char)0x13
98
99#define RDP_AddConfig           (unsigned char)0x14
100#define RDP_LoadConfigData      (unsigned char)0x15
101#define RDP_SelectConfig        (unsigned char)0x16
102#define RDP_LoadAgent           (unsigned char)0x17
103
104#define RDP_Stopped             (unsigned char)0x20
105#define RDP_OSOp                (unsigned char)0x21
106#define RDP_Fatal               (unsigned char)0x5e
107#define RDP_Return              (unsigned char)0x5f
108#define RDP_Reset               (unsigned char)0x7f
109
110/***************************************************************************\
111*                            Other RDI values                               *
112\***************************************************************************/
113
114#define RDISex_Little           0	/* the byte sex of the debuggee */
115#define RDISex_Big              1
116#define RDISex_DontCare         2
117
118#define RDIPoint_EQ             0	/* the different types of break/watchpoints */
119#define RDIPoint_GT             1
120#define RDIPoint_GE             2
121#define RDIPoint_LT             3
122#define RDIPoint_LE             4
123#define RDIPoint_IN             5
124#define RDIPoint_OUT            6
125#define RDIPoint_MASK           7
126
127#define RDIPoint_Inquiry        64	/* ORRed with point type in extended RDP */
128#define RDIPoint_Handle         128	/* messages                              */
129
130#define RDIWatch_ByteRead       1	/* types of data accesses to watch for */
131#define RDIWatch_HalfRead       2
132#define RDIWatch_WordRead       4
133#define RDIWatch_ByteWrite      8
134#define RDIWatch_HalfWrite      16
135#define RDIWatch_WordWrite      32
136
137#define RDIReg_R15              (1L << 15)	/* mask values for CPU */
138#define RDIReg_PC               (1L << 16)
139#define RDIReg_CPSR             (1L << 17)
140#define RDIReg_SPSR             (1L << 18)
141#define RDINumCPURegs           19
142
143#define RDINumCPRegs            10	/* current maximum */
144
145#define RDIMode_Curr            255
146
147/* Bits set in return value from RDIInfo_Target */
148#define RDITarget_LogSpeed              0x0f
149#define RDITarget_HW                    0x10	/* else emulator */
150#define RDITarget_AgentMaxLevel         0xe0
151#define RDITarget_AgentLevelShift       5
152#define RDITarget_DebuggerMinLevel      0x700
153#define RDITarget_DebuggerLevelShift    8
154#define RDITarget_CanReloadAgent        0x800
155#define RDITarget_CanInquireLoadSize    0x1000
156
157/* Bits set in return value from RDIInfo_Step */
158#define RDIStep_Multiple                1
159#define RDIStep_PCChange                2
160#define RDIStep_Single                  4
161
162/* Bits set in return value from RDIInfo_Points */
163#define RDIPointCapability_Comparison   1
164#define RDIPointCapability_Range        2
165/* 4 to 128 are RDIWatch_xx{Read,Write} left-shifted by two */
166#define RDIPointCapability_Mask         256
167#define RDIPointCapability_Status       512	/* Point status enquiries available */
168
169/* RDI_Info subcodes */
170#define RDIInfo_Target          0
171#define RDIInfo_Points          1
172#define RDIInfo_Step            2
173#define RDIInfo_MMU             3
174#define RDIInfo_DownLoad        4	/* Inquires whether configuration download
175					   and selection is available.
176					 */
177#define RDIInfo_SemiHosting     5	/* Inquires whether RDISemiHosting_* RDI_Info
178					   calls are available.
179					 */
180#define RDIInfo_CoPro           6	/* Inquires whether CoPro RDI_Info calls are
181					   available.
182					 */
183#define RDIInfo_Icebreaker      7
184
185/* The next two are only to be used if the value returned by RDIInfo_Points */
186/* has RDIPointCapability_Status set.                                       */
187#define RDIPointStatus_Watch    0x80
188#define RDIPointStatus_Break    0x81
189
190#define RDISignal_Stop          0x100
191
192#define RDIVector_Catch         0x180
193
194/* The next four are only to be used if RDIInfo_Semihosting returned no error */
195#define RDISemiHosting_SetState 0x181
196#define RDISemiHosting_GetState 0x182
197#define RDISemiHosting_SetVector 0x183
198#define RDISemiHosting_GetVector 0x184
199
200/* The next two are only to be used if RDIInfo_Icebreaker returned no error */
201#define RDIIcebreaker_GetLocks  0x185
202#define RDIIcebreaker_SetLocks  0x186
203
204/* Only if RDIInfo_Target returned RDITarget_CanInquireLoadSize */
205#define RDIInfo_GetLoadSize     0x187
206
207#define RDICycles               0x200
208#define RDICycles_Size          48
209#define RDIErrorP               0x201
210
211#define RDISet_Cmdline          0x300
212#define RDISet_RDILevel         0x301
213#define RDISet_Thread           0x302
214
215/* The next two are only to be used if RDIInfo_CoPro returned no error */
216#define RDIInfo_DescribeCoPro   0x400
217#define RDIInfo_RequestCoProDesc 0x401
218
219#define RDIInfo_Log             0x800
220#define RDIInfo_SetLog          0x801
221
222typedef unsigned long PointHandle;
223typedef unsigned long ThreadHandle;
224#define RDINoPointHandle        ((PointHandle)-1L)
225#define RDINoHandle             ((ThreadHandle)-1L)
226
227struct Dbg_ConfigBlock;
228struct Dbg_HostosInterface;
229struct Dbg_MCState;
230typedef int rdi_open_proc (unsigned type,
231			   struct Dbg_ConfigBlock const *config,
232			   struct Dbg_HostosInterface const *i,
233			   struct Dbg_MCState *dbg_state);
234typedef int rdi_close_proc (void);
235typedef int rdi_read_proc (ARMword source, void *dest, unsigned *nbytes);
236typedef int rdi_write_proc (const void *source, ARMword dest,
237			    unsigned *nbytes);
238typedef int rdi_CPUread_proc (unsigned mode, unsigned long mask,
239			      ARMword * state);
240typedef int rdi_CPUwrite_proc (unsigned mode, unsigned long mask,
241			       ARMword const *state);
242typedef int rdi_CPread_proc (unsigned CPnum, unsigned long mask,
243			     ARMword * state);
244typedef int rdi_CPwrite_proc (unsigned CPnum, unsigned long mask,
245			      ARMword const *state);
246typedef int rdi_setbreak_proc (ARMword address, unsigned type, ARMword bound,
247			       PointHandle * handle);
248typedef int rdi_clearbreak_proc (PointHandle handle);
249typedef int rdi_setwatch_proc (ARMword address, unsigned type,
250			       unsigned datatype, ARMword bound,
251			       PointHandle * handle);
252typedef int rdi_clearwatch_proc (PointHandle handle);
253typedef int rdi_execute_proc (PointHandle * handle);
254typedef int rdi_step_proc (unsigned ninstr, PointHandle * handle);
255typedef int rdi_info_proc (unsigned type, ARMword * arg1, ARMword * arg2);
256typedef int rdi_pointinq_proc (ARMword * address, unsigned type,
257			       unsigned datatype, ARMword * bound);
258
259typedef enum
260{
261  RDI_ConfigCPU,
262  RDI_ConfigSystem
263}
264RDI_ConfigAspect;
265
266typedef enum
267{
268  RDI_MatchAny,
269  RDI_MatchExactly,
270  RDI_MatchNoEarlier
271}
272RDI_ConfigMatchType;
273
274typedef int rdi_addconfig_proc (unsigned long nbytes);
275typedef int rdi_loadconfigdata_proc (unsigned long nbytes, char const *data);
276typedef int rdi_selectconfig_proc (RDI_ConfigAspect aspect, char const *name,
277				   RDI_ConfigMatchType matchtype,
278				   unsigned versionreq, unsigned *versionp);
279
280typedef char *getbufferproc (void *getbarg, unsigned long *sizep);
281typedef int rdi_loadagentproc (ARMword dest, unsigned long size,
282			       getbufferproc * getb, void *getbarg);
283
284typedef struct
285{
286  int itemmax;
287  char const *const *names;
288}
289RDI_NameList;
290
291typedef RDI_NameList const *rdi_namelistproc (void);
292
293typedef int rdi_errmessproc (char *buf, int buflen, int errno);
294
295struct RDIProcVec
296{
297  char rditypename[12];
298
299  rdi_open_proc *open;
300  rdi_close_proc *close;
301  rdi_read_proc *read;
302  rdi_write_proc *write;
303  rdi_CPUread_proc *CPUread;
304  rdi_CPUwrite_proc *CPUwrite;
305  rdi_CPread_proc *CPread;
306  rdi_CPwrite_proc *CPwrite;
307  rdi_setbreak_proc *setbreak;
308  rdi_clearbreak_proc *clearbreak;
309  rdi_setwatch_proc *setwatch;
310  rdi_clearwatch_proc *clearwatch;
311  rdi_execute_proc *execute;
312  rdi_step_proc *step;
313  rdi_info_proc *info;
314  /* V2 RDI */
315  rdi_pointinq_proc *pointinquiry;
316
317  /* These three useable only if RDIInfo_DownLoad returns no error */
318  rdi_addconfig_proc *addconfig;
319  rdi_loadconfigdata_proc *loadconfigdata;
320  rdi_selectconfig_proc *selectconfig;
321
322  rdi_namelistproc *drivernames;
323  rdi_namelistproc *cpunames;
324
325  rdi_errmessproc *errmess;
326
327  /* Only if RDIInfo_Target returns a value with RDITarget_LoadAgent set */
328  rdi_loadagentproc *loadagent;
329};
330
331#endif
332
333extern unsigned int swi_mask;
334
335#define SWI_MASK_DEMON		(1 << 0)
336#define SWI_MASK_ANGEL		(1 << 1)
337#define SWI_MASK_REDBOOT	(1 << 2)
338