dbg_rdi.h 12 KB

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