1/* 2 * Copyright (C) 1995 Advanced RISC Machines Limited. All rights reserved. 3 * 4 * This software may be freely used, copied, modified, and distributed 5 * provided that the above copyright notice is preserved in all copies of the 6 * software. 7 */ 8 9/* 10 * ARM debugger toolbox : dbg_rdi.h 11 */ 12 13/* 14 * RCS $Revision: 1.3 $ 15 * Checkin $Date: 2004/12/27 14:00:54 $ 16 */ 17 18#ifndef dbg_rdi__h 19#define dbg_rdi__h 20 21/***************************************************************************\ 22* Other RDI values * 23\***************************************************************************/ 24 25#define RDISex_Little 0 /* the byte sex of the debuggee */ 26#define RDISex_Big 1 27#define RDISex_DontCare 2 28 29#define RDIPoint_EQ 0 /* the different types of break/watchpoints */ 30#define RDIPoint_GT 1 31#define RDIPoint_GE 2 32#define RDIPoint_LT 3 33#define RDIPoint_LE 4 34#define RDIPoint_IN 5 35#define RDIPoint_OUT 6 36#define RDIPoint_MASK 7 37 38#define RDIPoint_16Bit 16 /* 16-bit breakpoint */ 39#define RDIPoint_Conditional 32 40 41/* ORRed with point type in extended RDP break and watch messages */ 42#define RDIPoint_Inquiry 64 43#define RDIPoint_Handle 128 /* messages */ 44 45#define RDIWatch_ByteRead 1 /* types of data accesses to watch for*/ 46#define RDIWatch_HalfRead 2 47#define RDIWatch_WordRead 4 48#define RDIWatch_ByteWrite 8 49#define RDIWatch_HalfWrite 16 50#define RDIWatch_WordWrite 32 51 52#define RDIReg_R15 (1L << 15) /* mask values for CPU */ 53#define RDIReg_PC (1L << 16) 54#define RDIReg_CPSR (1L << 17) 55#define RDIReg_SPSR (1L << 18) 56#define RDINumCPURegs 19 57 58#define RDINumCPRegs 10 /* current maximum */ 59 60#define RDIMode_Curr 255 61 62/* RDI_Info subcodes */ 63/* rdp in parameters are all preceded by */ 64/* in byte = RDP_Info, word = info subcode */ 65/* out parameters are all preceded by */ 66/* out byte = RDP_Return */ 67 68#define RDIInfo_Target 0 69/* rdi: out ARMword *targetflags, out ARMword *processor id */ 70/* rdp: in none, out word targetflags, word processorid, byte status */ 71/* the following bits are defined in targetflags */ 72# define RDITarget_LogSpeed 0x0f 73# define RDITarget_HW 0x10 /* else emulator */ 74# define RDITarget_AgentMaxLevel 0xe0 75# define RDITarget_AgentLevelShift 5 76# define RDITarget_DebuggerMinLevel 0x700 77# define RDITarget_DebuggerLevelShift 8 78# define RDITarget_CanReloadAgent 0x800 79# define RDITarget_CanInquireLoadSize 0x1000 80# define RDITarget_UnderstandsRDPInterrupt 0x2000 81# define RDITarget_CanProfile 0x4000 82# define RDITarget_Code16 0x8000 83# define RDITarget_HasCommsChannel 0x10000 84 85#define RDIInfo_Points 1 86/* rdi: out ARMword *pointcapabilities */ 87/* rdp: in none, out word pointcapabilities, byte status */ 88/* the following bits are defined in pointcapabilities */ 89# define RDIPointCapability_Comparison 1 90# define RDIPointCapability_Range 2 91/* 4 to 128 are RDIWatch_xx{Read,Write} left-shifted by two */ 92# define RDIPointCapability_Mask 0x100 93# define RDIPointCapability_ThreadBreak 0x200 94# define RDIPointCapability_ThreadWatch 0x400 95# define RDIPointCapability_CondBreak 0x800 96# define RDIPointCapability_Status 0x1000 /* status enquiries available */ 97 98#define RDIInfo_Step 2 99/* rdi: out ARMword *stepcapabilities */ 100/* rdp: in none, out word stepcapabilities, byte status */ 101/* the following bits are defined in stepcapabilities */ 102# define RDIStep_Multiple 1 103# define RDIStep_PCChange 2 104# define RDIStep_Single 4 105 106#define RDIInfo_MMU 3 107/* rdi: out ARMword *mmuidentity */ 108/* rdp: in none, out word mmuidentity, byte status */ 109 110#define RDIInfo_DownLoad 4 111/* Inquires whether configuration download and selection is available. */ 112/* rdp: in none, out byte status */ 113/* No argument, no return value. status == ok if available */ 114 115#define RDIInfo_SemiHosting 5 116/* Inquires whether RDISemiHosting_* RDI_Info calls are available. */ 117/* rdp: in none, out byte status */ 118/* No argument, no return value. status == ok if available */ 119 120#define RDIInfo_CoPro 6 121/* Inquires whether CoPro RDI_Info calls are available. */ 122/* rdp: in none, out byte status */ 123/* No argument, no return value. status == ok if available */ 124 125#define RDIInfo_Icebreaker 7 126/* Inquires whether debuggee controlled by IceBreaker. */ 127/* rdp: in none, out byte status */ 128/* No argument, no return value. status == ok if available */ 129 130#define RDIMemory_Access 8 131/* rdi: out RDI_MemAccessStats *p, in ARMword *handle */ 132/* rdp: in word handle */ 133/* out word nreads, word nwrites, word sreads, word swrites, */ 134/* word ns, word s, byte status */ 135 136/* Get memory access information for memory block with specified handle */ 137 138#define RDIMemory_Map 9 139/* rdi: in RDI_MemDescr md[n], in ARMword *n */ 140/* rdp: in word n, n * { */ 141/* word handle, word start, word limit, */ 142/* byte width, byte access */ 143/* word Nread_ns, word Nwrite_ns, */ 144/* word Sread_ns, word Swrite_ns} */ 145/* out byte status */ 146/* Sets memory characteristics. */ 147 148#define RDISet_CPUSpeed 10 149/* rdi: in ARMword *speed */ 150/* rdp: in word speed, out byte status */ 151/* Sets CPU speed (in ns) */ 152 153#define RDIRead_Clock 12 154/* rdi: out ARMword *ns, out ARMword *s */ 155/* rdp: in none, out word ns, word s, byte status */ 156/* Reads simulated time */ 157 158#define RDIInfo_Memory_Stats 13 159/* Inquires whether RDI_Info codes 8-10 are available */ 160/* rdp: in none, out byte status */ 161/* No argument, no return value. status == ok if available */ 162 163/* The next two are only to be used if RDIInfo_DownLoad returned no */ 164/* error */ 165#define RDIConfig_Count 14 166/* rdi: out ARMword *count */ 167/* rdp: out byte status, word count (if status == OK) */ 168 169/* In addition, the next one is only to be used if RDIConfig_Count */ 170/* returned no error */ 171typedef struct { unsigned32 version; char name[32]; } RDI_ConfigDesc; 172#define RDIConfig_Nth 15 173/* rdi: in ARMword *n, out RDI_ConfigDesc * */ 174/* rdp: in word n */ 175/* out word version, byte namelen, bytes * bytelen name, */ 176/* byte status */ 177 178/* Set a front-end polling function to be used from within driver poll */ 179/* loops */ 180typedef void RDI_PollProc(void *); 181typedef struct { RDI_PollProc *p; void *arg; } RDI_PollDesc; 182#define RDISet_PollProc 16 183/* rdi: in RDI_PollDesc const *from, RDI_PollDesc *to */ 184/* if from non-NULL, sets the polling function from it */ 185/* if to non-NULL, returns the previous polling function to it */ 186/* No corresponding RDP operation */ 187 188/* Called on debugger startup to see if the target is ready to execute */ 189#define RDIInfo_CanTargetExecute 20 190/* rdi: in void 191 * out byte status (RDIError_NoError => Yes, Otherwise No) 192 */ 193 194/* Called to set the top of target memory in an ICEman2 system 195 * This is then used by ICEman to tell the C Library via the INFOHEAP 196 * SWI where the stack should start. 197 * Note that only ICEman2 supports this call. Other systems eg. 198 * Demon, Angel, will simply return an error, which means that setting 199 * the top of memory in this fashion is not supported. 200 */ 201#define RDIInfo_SetTopMem 21 202/* rdi: in word mem_top 203 * out byte status (RDIError_NoError => Done, Other => Not supported 204 */ 205 206/* Called before performing a loadagent to determine the endianess of 207 * the debug agent, so that images of the wrong bytesex can be 208 * complained about 209 */ 210#define RDIInfo_AgentEndianess 22 211/* rdi: in void 212 * out byte status 213 * status should be RDIError_LittleEndian or RDIError_BigEndian 214 * any other value indicates the target does not support this 215 * request, so the debugger will have to make a best guess, which 216 * probably means only allow little endian loadagenting. 217 */ 218 219/* The next two are only to be used if the value returned by */ 220/* RDIInfo_Points has RDIPointCapability_Status set. */ 221#define RDIPointStatus_Watch 0x80 222#define RDIPointStatus_Break 0x81 223/* rdi: inout ARMword * (in handle, out hwresource), out ARMword *type */ 224/* rdp: in word handle, out word hwresource, word type, byte status */ 225 226#define RDISignal_Stop 0x100 227/* Requests that the debuggee stop */ 228/* No arguments, no return value */ 229/* rdp: no reply (when the debuggee stops, there will be a reply to the */ 230/* step or execute request which started it) */ 231 232#define RDIVector_Catch 0x180 233/* rdi: in ARMword *bitmap */ 234/* rdp: int word bitmap, out byte status */ 235/* bit i in bitmap set to cause vector i to cause entry to debugger */ 236 237/* The next four are only to be used if RDIInfo_Semihosting returned */ 238/* no error */ 239#define RDISemiHosting_SetState 0x181 240/* rdi: in ARMword *semihostingstate */ 241/* rdp: in word semihostingstate, out byte status */ 242#define RDISemiHosting_GetState 0x182 243/* rdi: out ARMword *semihostingstate */ 244/* rdp: in none, out word semihostingstate, byte status */ 245#define RDISemiHosting_SetVector 0x183 246/* rdi: in ARMword *semihostingvector */ 247/* rdp: in word semihostingvector, out byte status */ 248#define RDISemiHosting_GetVector 0x184 249/* rdi: out ARMword *semihostingvector */ 250/* rdp: in none, out word semihostingvector, byte status */ 251 252/* The next two are only to be used if RDIInfo_Icebreaker returned */ 253/* no error */ 254#define RDIIcebreaker_GetLocks 0x185 255/* rdi: out ARMword *lockedstate */ 256/* rdp: in none, out word lockedstate, byte status */ 257 258#define RDIIcebreaker_SetLocks 0x186 259/* rdi: in ARMword *lockedstate */ 260/* rdp: in word lockedstate, out byte status */ 261 262/* lockedstate is a bitmap of the icebreaker registers locked against */ 263/* use by IceMan (because explicitly written by the user) */ 264 265#define RDIInfo_GetLoadSize 0x187 266/* rdi: out ARMword *maxloadsize */ 267/* rdp: in none, out word maxloadsize, byte status */ 268/* Inquires the maximum length of data transfer the agent is prepared */ 269/* to receive */ 270/* Only usable if RDIInfo_Target returned RDITarget_CanInquireLoadSize */ 271/* rdi: out ARMword *size */ 272 273/* Only to be used if the value returned by RDIInfo_Target had */ 274/* RDITarget_HasCommsChannel set */ 275typedef void RDICCProc_ToHost(void *arg, ARMword data); 276typedef void RDICCProc_FromHost(void *arg, ARMword *data, int *valid); 277 278#define RDICommsChannel_ToHost 0x188 279/* rdi: in RDICCProc_ToHost *, in void *arg */ 280/* rdp: in byte connect, out byte status */ 281#define RDICommsChannel_FromHost 0x189 282/* rdi: in RDICCProc_FromHost *, in void *arg */ 283/* rdp: in byte connect, out byte status */ 284 285/* These 4 are only to be used if RDIInfo_Semihosting returns no error */ 286#define RDISemiHosting_SetARMSWI 0x190 287/* rdi: in ARMword ARM_SWI_number */ 288/* rdp: in ARMword ARM_SWI_number, out byte status */ 289 290#define RDISemiHosting_GetARMSWI 0x191 291/* rdi: out ARMword ARM_SWI_number */ 292/* rdp: out ARMword ARM_SWI_number, byte status */ 293 294#define RDISemiHosting_SetThumbSWI 0x192 295/* rdi: in ARMword Thumb_SWI_number */ 296/* rdp: in ARMword Thumb_SWI_number, out byte status */ 297 298#define RDISemiHosting_GetThumbSWI 0x193 299/* rdi: out ARMword ARM_Thumb_number */ 300/* rdp: out ARMword ARM_Thumb_number, byte status */ 301 302 303#define RDICycles 0x200 304/* rdi: out ARMword cycles[12] */ 305/* rdp: in none, out 6 words cycles, byte status */ 306/* the rdi result represents 6 big-endian doublewords; the rdp results */ 307/* return values for the ls halves of these */ 308# define RDICycles_Size 48 309 310#define RDIErrorP 0x201 311/* rdi: out ARMaddress *errorp */ 312/* rdp: in none, out word errorp, byte status */ 313/* Returns the error pointer associated with the last return from step */ 314/* or execute with status RDIError_Error. */ 315 316#define RDISet_Cmdline 0x300 317/* rdi: in char *commandline (a null-terminated string) */ 318/* No corresponding RDP operation (cmdline is sent to the agent in */ 319/* response to SWI_GetEnv) */ 320 321#define RDISet_RDILevel 0x301 322/* rdi: in ARMword *level */ 323/* rdp: in word level, out byte status */ 324/* Sets the RDI/RDP protocol level to be used (must lie between the */ 325/* limits returned by RDIInfo_Target). */ 326 327#define RDISet_Thread 0x302 328/* rdi: in ARMword *threadhandle */ 329/* rdp: in word threadhandle, out byte status */ 330/* Sets the thread context for subsequent thread-sensitive operations */ 331/* (null value sets no thread) */ 332 333/* The next two are only to be used if RDI_read or RDI_write returned */ 334/* RDIError_LittleEndian or RDIError_BigEndian, to signify that the */ 335/* debugger has noticed. */ 336#define RDIInfo_AckByteSex 0x303 337/* rdi: in ARMword *sex (RDISex_Little or RDISex_Big) */ 338 339/* The next two are only to be used if RDIInfo_CoPro returned no error */ 340#define RDIInfo_DescribeCoPro 0x400 341/* rdi: in int *cpno, Dbg_CoProDesc *cpd */ 342/* rdp: in byte cpno, */ 343/* cpd->entries * { */ 344/* byte rmin, byte rmax, byte nbytes, byte access, */ 345/* byte cprt_r_b0, cprt_r_b1, cprt_w_b0, cprt_w_b1} */ 346/* byte = 255 */ 347/* out byte status */ 348 349#define RDIInfo_RequestCoProDesc 0x401 350/* rdi: in int *cpno, out Dbg_CoProDesc *cpd */ 351/* rpd: in byte cpno */ 352/* out nentries * { */ 353/* byte rmin, byte rmax, byte nbytes, byte access, */ 354/* } */ 355/* byte = 255, byte status */ 356 357#define RDIInfo_Log 0x800 358/* rdi: out ARMword *logsetting */ 359/* No corresponding RDP operation */ 360#define RDIInfo_SetLog 0x801 361/* rdi: in ARMword *logsetting */ 362/* No corresponding RDP operation */ 363 364#define RDIProfile_Stop 0x500 365/* No arguments, no return value */ 366/* rdp: in none, out byte status */ 367/* Requests that pc sampling stop */ 368 369#define RDIProfile_Start 0x501 370/* rdi: in ARMword *interval */ 371/* rdp: in word interval, out byte status */ 372/* Requests that pc sampling start, with period <interval> usec */ 373 374#define RDIProfile_WriteMap 0x502 375/* rdi: in ARMword map[] */ 376/* map[0] is the length of the array, subsequent elements are sorted */ 377/* and are the base of ranges for pc sampling (so if the sampled pc */ 378/* lies between map[i] and map[i+1], count[i] is incremented). */ 379/* rdp: a number of messages, each of form: */ 380/* in word len, word size, word offset, <size> words map data */ 381/* out status */ 382/* len, size and offset are all word counts. */ 383 384#define RDIProfile_ReadMap 0x503 385/* rdi: in ARMword *len, out ARMword counts[len] */ 386/* Requests that the counts array be set to the accumulated pc sample */ 387/* counts */ 388/* rdp: a number of messages, each of form: */ 389/* in word offset, word size */ 390/* out <size> words, status */ 391/* len, size and offset are all word counts. */ 392 393#define RDIProfile_ClearCounts 0x504 394/* No arguments, no return value */ 395/* rdp: in none, out byte status */ 396/* Requests that pc sample counts be set to zero */ 397 398#define RDIInfo_RequestReset 0x900 399/* Request reset of the target environment */ 400/* No arguments, no return value */ 401/* No RDP equivalent, sends an RDP reset */ 402 403#define RDIInfo_CapabilityRequest 0x8000 404/* Request whether the interface supports the named capability. The */ 405/* capability is specified by or'ing the RDIInfo number with this, and */ 406/* sending that request */ 407/* rdi: in none */ 408/* rdp: in none, out byte status */ 409 410typedef struct { 411 ARMword len; 412 ARMword map[1]; 413} RDI_ProfileMap; 414 415typedef unsigned32 PointHandle; 416typedef unsigned32 ThreadHandle; 417#define RDINoPointHandle ((PointHandle)-1L) 418#define RDINoHandle ((ThreadHandle)-1L) 419 420struct Dbg_ConfigBlock; 421struct Dbg_HostosInterface; 422struct Dbg_MCState; 423typedef int rdi_open_proc(unsigned type, struct Dbg_ConfigBlock const *config, 424 struct Dbg_HostosInterface const *i, 425 struct Dbg_MCState *dbg_state); 426typedef int rdi_close_proc(void); 427typedef int rdi_read_proc(ARMword source, void *dest, unsigned *nbytes); 428typedef int rdi_write_proc(const void *source, ARMword dest, unsigned *nbytes); 429typedef int rdi_CPUread_proc(unsigned mode, unsigned32 mask, ARMword *state); 430typedef int rdi_CPUwrite_proc(unsigned mode, unsigned32 mask, ARMword const *state); 431typedef int rdi_CPread_proc(unsigned CPnum, unsigned32 mask, ARMword *state); 432typedef int rdi_CPwrite_proc(unsigned CPnum, unsigned32 mask, ARMword const *state); 433typedef int rdi_setbreak_proc(ARMword address, unsigned type, ARMword bound, 434 PointHandle *handle); 435typedef int rdi_clearbreak_proc(PointHandle handle); 436typedef int rdi_setwatch_proc(ARMword address, unsigned type, unsigned datatype, 437 ARMword bound, PointHandle *handle); 438typedef int rdi_clearwatch_proc(PointHandle handle); 439typedef int rdi_execute_proc(PointHandle *handle); 440typedef int rdi_step_proc(unsigned ninstr, PointHandle *handle); 441typedef int rdi_info_proc(unsigned type, ARMword *arg1, ARMword *arg2); 442typedef int rdi_pointinq_proc(ARMword *address, unsigned type, 443 unsigned datatype, ARMword *bound); 444 445typedef enum { 446 RDI_ConfigCPU, 447 RDI_ConfigSystem 448} RDI_ConfigAspect; 449 450typedef enum { 451 RDI_MatchAny, 452 RDI_MatchExactly, 453 RDI_MatchNoEarlier 454} RDI_ConfigMatchType; 455 456typedef int rdi_addconfig_proc(unsigned32 nbytes); 457typedef int rdi_loadconfigdata_proc(unsigned32 nbytes, char const *data); 458typedef int rdi_selectconfig_proc(RDI_ConfigAspect aspect, char const *name, 459 RDI_ConfigMatchType matchtype, unsigned versionreq, 460 unsigned *versionp); 461 462typedef char *getbufferproc(void *getbarg, unsigned32 *sizep); 463typedef int rdi_loadagentproc(ARMword dest, unsigned32 size, getbufferproc *getb, void *getbarg); 464typedef int rdi_targetisdead(void); 465 466typedef struct { 467 int itemmax; 468 char const * const *names; 469} RDI_NameList; 470 471typedef RDI_NameList const *rdi_namelistproc(void); 472 473typedef int rdi_errmessproc(char *buf, int buflen, int errnum); 474 475struct RDIProcVec { 476 char rditypename[12]; 477 478 rdi_open_proc *open; 479 rdi_close_proc *close; 480 rdi_read_proc *read; 481 rdi_write_proc *write; 482 rdi_CPUread_proc *CPUread; 483 rdi_CPUwrite_proc *CPUwrite; 484 rdi_CPread_proc *CPread; 485 rdi_CPwrite_proc *CPwrite; 486 rdi_setbreak_proc *setbreak; 487 rdi_clearbreak_proc *clearbreak; 488 rdi_setwatch_proc *setwatch; 489 rdi_clearwatch_proc *clearwatch; 490 rdi_execute_proc *execute; 491 rdi_step_proc *step; 492 rdi_info_proc *info; 493 /* V2 RDI */ 494 rdi_pointinq_proc *pointinquiry; 495 496 /* These three useable only if RDIInfo_DownLoad returns no error */ 497 rdi_addconfig_proc *addconfig; 498 rdi_loadconfigdata_proc *loadconfigdata; 499 rdi_selectconfig_proc *selectconfig; 500 501 rdi_namelistproc *drivernames; 502 rdi_namelistproc *cpunames; 503 504 rdi_errmessproc *errmess; 505 506 /* Only if RDIInfo_Target returns a value with RDITarget_LoadAgent set */ 507 rdi_loadagentproc *loadagent; 508 rdi_targetisdead *targetisdead; 509}; 510 511#endif 512