Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:44

0001 /**
0002  * @file
0003  * @ingroup lm32_gdb
0004  * @brief definition of the interface between the stub and gdb
0005  */
0006 
0007 /*
0008  * gdb_if.h - definition of the interface between the stub and gdb
0009  *
0010  *                   THIS SOFTWARE IS NOT COPYRIGHTED
0011  *
0012  *  The following software is offered for use in the public domain.
0013  *  There is no warranty with regard to this software or its performance
0014  *  and the user must accept the software "AS IS" with all faults.
0015  *
0016  *  THE CONTRIBUTORS DISCLAIM ANY WARRANTIES, EXPRESS OR IMPLIED, WITH
0017  *  REGARD TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES
0018  *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
0019  */
0020 
0021 /**
0022  * @defgroup lm32_gdb LM32 GDB Interface
0023  * @ingroup RTEMSBSPsLM32Shared
0024  * @brief Definition of the interface between the stub and gdb,
0025  * @{
0026  */
0027 
0028 #ifndef _GDB_IF_H
0029 #define _GDB_IF_H
0030 
0031 /** @brief Max number of threads in qM response */
0032 #define QM_MAX_THREADS (20)
0033 
0034 struct rtems_gdb_stub_thread_info {
0035   char display[256];
0036   char name[256];
0037   char more_display[256];
0038 };
0039 
0040 /*
0041  *  Prototypes
0042  */
0043 
0044 int parse_zbreak(const char *in, int *type, unsigned char **addr, int *len);
0045 
0046 char* mem2hstr(char *buf, const unsigned char *mem, int count);
0047 int   hstr2mem(unsigned char *mem, const char *buf, int count);
0048 void  set_mem_err(void);
0049 unsigned char get_byte(const unsigned char *ptr);
0050 void  set_byte(unsigned char *ptr, int val);
0051 char* thread2vhstr(char *buf, int thread);
0052 char* thread2fhstr(char *buf, int thread);
0053 const char* fhstr2thread(const char *buf, int *thread);
0054 const char* vhstr2thread(const char *buf, int *thread);
0055 char* int2fhstr(char *buf, int val);
0056 char* int2vhstr(char *buf, int vali);
0057 const char* fhstr2int(const char *buf, int *ival);
0058 const char* vhstr2int(const char *buf, int *ival);
0059 int   hstr2byte(const char *buf, int *bval);
0060 int   hstr2nibble(const char *buf, int *nibble);
0061 
0062 Thread_Control *rtems_gdb_index_to_stub_id(int);
0063 int rtems_gdb_stub_thread_support_ok(void);
0064 int rtems_gdb_stub_get_current_thread(void);
0065 int rtems_gdb_stub_get_next_thread(int);
0066 int rtems_gdb_stub_get_offsets(
0067   unsigned char **text_addr,
0068   unsigned char **data_addr,
0069   unsigned char **bss_addr
0070 );
0071 int rtems_gdb_stub_get_thread_regs(
0072   int thread,
0073   unsigned int *registers
0074 );
0075 int rtems_gdb_stub_set_thread_regs(
0076   int thread,
0077   unsigned int *registers
0078 );
0079 void rtems_gdb_process_query(
0080   char *inbuffer,
0081   char *outbuffer,
0082   int   do_threads,
0083   int   thread
0084 );
0085 
0086 /** @brief Exception IDs */
0087 #define LM32_EXCEPTION_RESET                  0x0
0088 #define LM32_EXCEPTION_INST_BREAKPOINT        0x1
0089 #define LM32_EXCEPTION_INST_BUS_ERROR         0x2
0090 #define LM32_EXCEPTION_DATA_BREAKPOINT        0x3
0091 #define LM32_EXCEPTION_DATA_BUS_ERROR         0x4
0092 #define LM32_EXCEPTION_DIVIDE_BY_ZERO         0x5
0093 #define LM32_EXCEPTION_INTERRUPT              0x6
0094 #define LM32_EXCEPTION_SYSTEM_CALL            0x7
0095 
0096 /** @brief Breakpoint instruction */
0097 #define LM32_BREAK                            0xac000002UL
0098 
0099 /** @brief This numbering must be consistant with GDBs numbering in gdb/lm32-tdep.c */
0100 enum lm32_regnames {
0101   LM32_REG_R0, LM32_REG_R1, LM32_REG_R2, LM32_REG_R3, LM32_REG_R4, LM32_REG_R5,
0102   LM32_REG_R6, LM32_REG_R7, LM32_REG_R8, LM32_REG_R9, LM32_REG_R10,
0103   LM32_REG_R11, LM32_REG_R12, LM32_REG_R13, LM32_REG_R14, LM32_REG_R15,
0104   LM32_REG_R16, LM32_REG_R17, LM32_REG_R18, LM32_REG_R19, LM32_REG_R20,
0105   LM32_REG_R21, LM32_REG_R22, LM32_REG_R23, LM32_REG_R24, LM32_REG_R25,
0106   LM32_REG_GP, LM32_REG_FP, LM32_REG_SP, LM32_REG_RA, LM32_REG_EA, LM32_REG_BA,
0107   LM32_REG_PC, LM32_REG_EID, LM32_REG_EBA, LM32_REG_DEBA, LM32_REG_IE, NUM_REGS
0108 };
0109 
0110 /* keep this in sync with the debug isr handler in lm32-debug.S */
0111 enum lm32_int_regnames {
0112   LM32_INT_REG_R1, LM32_INT_REG_R2, LM32_INT_REG_R3, LM32_INT_REG_R4,
0113   LM32_INT_REG_R5, LM32_INT_REG_R6, LM32_INT_REG_R7, LM32_INT_REG_R8,
0114   LM32_INT_REG_R9, LM32_INT_REG_R10, LM32_INT_REG_RA, LM32_INT_REG_EA,
0115   LM32_INT_REG_BA, LM32_INT_REG_R11, LM32_INT_REG_R12, LM32_INT_REG_R13,
0116   LM32_INT_REG_R14, LM32_INT_REG_R15, LM32_INT_REG_R16, LM32_INT_REG_R17,
0117   LM32_INT_REG_R18, LM32_INT_REG_R19, LM32_INT_REG_R20, LM32_INT_REG_R21,
0118   LM32_INT_REG_R22, LM32_INT_REG_R23, LM32_INT_REG_R24, LM32_INT_REG_R25,
0119   LM32_INT_REG_GP, LM32_INT_REG_FP, LM32_INT_REG_SP, LM32_INT_REG_PC,
0120   LM32_INT_REG_EID, LM32_INT_REG_EBA, LM32_INT_REG_DEBA, LM32_INT_REG_IE,
0121 };
0122 
0123 #endif /* _GDB_IF_H */
0124 
0125 /** @} */