⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdb_c_test.c

📁 lwip在ucos上的移植
💻 C
📖 第 1 页 / 共 5 页
字号:
/* ****************************************************************************** ****************************************************************************** * * COPYRIGHT (C) by EMC Corporation, 1997 All rights reserved. * $Id: gdb_c_test.c,v 1.1.1.1 2003/02/19 02:42:16 skyeye Exp $ * DESCRIPTION: This module has been provided for the purpose of testing GDB. * * NOTES: * ****************************************************************************** *****************************************************************************//*============================================================================= *                                  INCLUDE  FILES *===========================================================================*/#ifdef DO_IT_BY_THE_BOOK#include "symtypes_defs.h"#include "printp.h"#include "adbg_expression.h"#include "common_hw_ds.h"#include "common_hw_defs.h"#include "evnttrac.h"#include "sym_scratch_ds.h"#include "symglob_ds.h"#include "sym_protglob_ds.h"#include "ether.h"#include <ctype.h>#else#include "adbg_dtc.h"#define YES             1#define NO              0#define TRUE            1#define FALSE           0#define ENABLED         1#define DISABLED        0#define CONTROL_C       3   /* ASCII 'ETX' *//* * Faked after ctype.h */#define isxdigit(X) (((X) >= '0' && (X) <= '9') || \                     ((X) >= 'A' && (X) <= 'F') || \                     ((X) >= 'a' && (X) <= 'f'))/* * Borrowed from string.h */extern unsigned int strlen ( const char * );/* * Extracted from symtypes.h: */typedef char                    BOOL;     /*  8 Bits */typedef unsigned char           UCHAR;    /*  8 Bits */typedef unsigned short          USHORT;   /* 16 Bits */typedef unsigned long           ULONG;    /* 32 Bits *//* * for struct t_expr_tag and * decl of build_and_add_expression */#include "adbg_expression.h"#define NULL	0/* * Extracted from printp.h: */extern void printp ( const char * fptr, ... );extern void sprintp ( const char * fptr, ... );/* * Extracted from ether.h: */extern long eth_to_gdb ( UCHAR *buf, long length );/* * Derived from hwequs.s: */#define CS_CODE_START           0x100000#define CS_CODE_SIZE            0x200000#define LAST_CS_WORD            (CS_CODE_START + CS_CODE_SIZE - 2)#define sh_genstat1             (*((volatile ULONG *) 0xFFFFFE54))#define rs232_mode1             0               /* rs-232 mode 1 reg. */#define rs232_mode2             rs232_mode1     /* rs-232 mode 2 reg. */#define rs232_stat              4               /* rs-232 status reg. */#define rs232_clk               rs232_stat      /* rs-232 clock select reg. */#define rs232_cmd               8               /* rs-232 command reg */#define rs232_transmit          12              /* rs-232 transmit reg. */#define rs232_receive           rs232_transmit  /* rs-232 transmit reg. */#define rs232_aux               16              /* rs-232 aux control reg. */#define rs232_isr               20              /* rs-232 interrupt status reg. */#define rs232_imr               rs232_isr       /* rs-232 interrupt mask reg. */#define rs232_tc_high           24              /* rs-232 timer/counter high reg. */#define rs232_tc_low            28              /* rs-232 timer/counter low reg.  */#endif/*============================================================================ *                                 MODULE  DEFINES *===========================================================================*/#define P_RST_LAN_UART_REG      ((volatile UCHAR  *) 0xFFFFFE45)#define M_RST_LAN_UART          0x80          /* Bit  7 */#define P_LAN0TR_REG            P_RST_LAN_UART_REG#define M_LAN0TR                0x20          /* Bit  5 */#define M_SH_GENCON_LAN0TR      0x00200000    /* Bit 21 */#define MAX_RS232_CHARS         512#define LAN_Q_MOD(X)            ((X) % MAX_RS232_CHARS)/*---------------------------------------* *           LAN  UART  Registers        * *---------------------------------------*/#define LAN_UART_BASE               ((ULONG) 0xfffffc22)/*  Write-Read  */#define P_LAN_MR1                   ((volatile UCHAR *) (LAN_UART_BASE + ((ULONG) rs232_mode1   )))#define P_LAN_MR2                   ((volatile UCHAR *) (LAN_UART_BASE + ((ULONG) rs232_mode2   )))/*  Write-Only  */#define P_LAN_ACR                   ((volatile UCHAR *) (LAN_UART_BASE + ((ULONG) rs232_aux     )))#define P_LAN_CR                    ((volatile UCHAR *) (LAN_UART_BASE + ((ULONG) rs232_cmd     )))#define P_LAN_CSR                   ((volatile UCHAR *) (LAN_UART_BASE + ((ULONG) rs232_clk     )))#define P_LAN_CTLR                  ((volatile UCHAR *) (LAN_UART_BASE + ((ULONG) rs232_tc_low  )))#define P_LAN_CTUR                  ((volatile UCHAR *) (LAN_UART_BASE + ((ULONG) rs232_tc_high )))#define P_LAN_IMR                   ((volatile UCHAR *) (LAN_UART_BASE + ((ULONG) rs232_imr     )))/*  Read-Only */#define P_LAN_SR                    ((volatile UCHAR *) (LAN_UART_BASE + ((ULONG) rs232_stat    )))#define P_LAN_ISR                   ((volatile UCHAR *) (LAN_UART_BASE + ((ULONG) rs232_isr     )))#define P_LAN_XMT                   ((volatile UCHAR *) (LAN_UART_BASE + ((ULONG) rs232_transmit)))#define P_LAN_RCV                   ((volatile UCHAR *) (LAN_UART_BASE + ((ULONG) rs232_receive )))/* *   Bit Values for Write-Read and Write-Only Registers */#define DEFAULT_LAN_MR1             ((UCHAR) 0x13)#define DEFAULT_LAN_MR2             ((UCHAR) 0x07)#define DEFAULT_LAN_CSR             ((UCHAR) 0xcc)#define DEFAULT_LAN_ACR             ((UCHAR) 0x38)#define DEFAULT_LAN_CTUR            ((UCHAR) 0xff)#define DEFAULT_LAN_CTLR            ((UCHAR) 0xff)#define LAN_ACR_SELECT_BRG_0        DEFAULT_LAN_ACR#define LAN_ACR_SELECT_BRG_1        (DEFAULT_LAN_ACR | 0x80)#define UART_CR_RESET_MR_PTR        ((UCHAR) 0x10) /* Reset MR pointer (points to MR1). */#define UART_CR_RESET_RVCR          ((UCHAR) 0x20) /* Reset receiver (disabled).        */#define UART_CR_RESET_XMTR          ((UCHAR) 0x30) /* Reset transmitter (disabled).     */#define UART_CR_RESET_ERROR_STATUS  ((UCHAR) 0x40) /* Reset error status.               */#define UART_CR_RESET_BRK_CHG_INT   ((UCHAR) 0x50) /* Reset break change interrupt.     */#define UART_CR_START_CNTR_TIMER    ((UCHAR) 0x80) /* Start counter/timer.              */#define UART_CR_STOP_CNTR           ((UCHAR) 0x90) /* Stop counter.                     */#define UART_CR_DISABLE_XMTR        ((UCHAR) 0x08) /* Disable transmitter.              */#define UART_CR_ENABLE_XMTR         ((UCHAR) 0x04) /* Enable transmitter.               */#define UART_CR_DISABLE_RCVR        ((UCHAR) 0x02) /* Disable receiver.                 */#define UART_CR_ENABLE_RCVR         ((UCHAR) 0x01) /* Enable receiver.                  */#define UART_CSR_BR_4800            ((UCHAR) 0x99) /* With either BRG Set selected (via ACR). */#define UART_CSR_BR_9600            ((UCHAR) 0xbb) /* With either BRG Set selected (via ACR). */#define UART_CSR_BR_19200           ((UCHAR) 0xcc) /* With BRG Set '1' selected (via ACR). */#define UART_CSR_BR_38400           ((UCHAR) 0xcc) /* With BRG Set '0' selected (via ACR). */#define UART_IMR_RxRDY              ((UCHAR) 0x04) /* Enable 'RxRDY' interrupt. */#define UART_IMR_TxEMT              ((UCHAR) 0x02) /* Enable 'TxEMT' interrupt. */#define UART_IMR_TxRDY              ((UCHAR) 0x01) /* Enable 'TxRDY' interrupt. *//* *   Bit Masks for Read-Only Registers */#define M_UART_SR_RCVD_BRK      0x80    /* Bit 7 */#define M_UART_SR_FE            0x40    /* Bit 6 */#define M_UART_SR_PE            0x20    /* Bit 5 */#define M_UART_SR_OE            0x10    /* Bit 4 */#define M_UART_SR_TxEMT         0x08    /* Bit 3 */#define M_UART_SR_TxRDY         0x04    /* Bit 2 */#define M_UART_SR_FFULL         0x02    /* Bit 1 */#define M_UART_SR_RxRDY         0x01    /* Bit 0 */#define M_UART_ISR_RxRDY        0x04    /* Bit 2 */#define M_UART_ISR_TxEMT        0x02    /* Bit 1 */#define M_UART_ISR_TxRDY        0x01    /* Bit 0 *//*---------------------------------------* *       Support for 'Utility 83'.       * *---------------------------------------*/#define LAN_UTIL_CODE           0x83#define LAN_INIT                ((ULONG) (('I' << 24) | ('N' << 16) | ('I' << 8) | 'T'))#define LAN_BAUD                ((ULONG) (('B' << 24) | ('A' << 16) | ('U' << 8) | 'D'))#define LAN_INTR                ((ULONG) (('I' << 24) | ('N' << 16) | ('T' << 8) | 'R'))#define LAN_XMT                 ((ULONG)               (('X' << 16) | ('M' << 8) | 'T'))#define LAN_ECHO                ((ULONG) (('E' << 24) | ('C' << 16) | ('H' << 8) | 'O'))#define LAN_STAT                ((ULONG) (('S' << 24) | ('T' << 16) | ('A' << 8) | 'T'))#define LAN_IN                  ((ULONG)                             (('I' << 8) | 'N'))#define LAN_OUT                 ((ULONG)               (('O' << 16) | ('U' << 8) | 'T'))#define LAN_PUTC                ((ULONG) (('P' << 24) | ('U' << 16) | ('T' << 8) | 'C'))#define LAN_WPM                 ((ULONG)               (('W' << 16) | ('P' << 8) | 'M'))#define STATUS(X)               ( ( ( X ) == 0 ) ? "disabled" : "enabled" )#define XMT_VIA_BP_ENABLED()    ( *P_LAN0TR_REG & M_LAN0TR  ?  1 : 0 )#define TRAP_1_INST             0x4E41/* *   Bit #13 of shared genstat 1 indicates *   which processor we are as follows. * *           0 => X (side A) *           1 => Y (side B) */#define M_PROC_ID               0x00002000#define IS_SIDE_A()             ( ( (sh_genstat1) & M_PROC_ID ) == 0 )#define IS_SIDE_B()             ( (sh_genstat1) & M_PROC_ID )#ifdef STANDALONE       /* Compile this module stand-alone for debugging */#define LAN_PUT_CHAR(X) printf("%c", X)#else#define LAN_PUT_CHAR(X) while ( lan_put_char( X ) )#endif#define VIA_RS232             0#define VIA_ETHERNET          1#define MAX_IO_BUF_SIZE       400#define MAX_BYTE_CODES        200 /* maximum length for bytecode string */static  ULONG           gdb_host_comm;static  ULONG           gdb_cat_ack;static  char            eth_outbuffer[ MAX_IO_BUF_SIZE + 1 ];#ifdef STANDALONE#define ACK_PKT()       LAN_PUT_CHAR( '+' )#define NACK_PKT()      LAN_PUT_CHAR( '-' )#else#define ACK_PKT()       {                                             \                          if ( VIA_ETHERNET == gdb_host_comm )        \                          {                                           \                            gdb_cat_ack = YES;                        \                          }                                           \                          else                                        \                          {                                           \                            LAN_PUT_CHAR( '+' );                      \                          }                                           \                        }#define NACK_PKT()      {                                             \                          if ( VIA_ETHERNET == gdb_host_comm )        \                          {                                           \                            eth_outbuffer[ 0 ] = '-';                 \                            eth_to_gdb( (UCHAR *) eth_outbuffer, 1 ); \                          }                                           \                          else                                        \                          {                                           \                            LAN_PUT_CHAR( '-' );                      \                          }                                           \                        }#endif/*============================================================================ *                                 MODULE  TYPEDEFS *===========================================================================*/typedef struct rs232_queue {  long    head_index;  long    tail_index;  ULONG   overflows;  long    gdb_packet_start;  long    gdb_packet_end;  long    gdb_packet_csum1;  long    gdb_packet_csum2;  UCHAR   buf[ MAX_RS232_CHARS ];} T_RS232_QUEUE;/*============================================================================= *                        EXTERNAL GLOBAL VARIABLES *===========================================================================*/extern volatile UCHAR         sss_trace_flag;/*============================================================================= *                           STATIC  MODULE  DECLARATIONS *===========================================================================*/static  T_RS232_QUEUE lan_input_queue,                      lan_output_queue;static  BOOL          test_echo;#if 0/* The stub no longer seems to use this.  */static  BOOL          write_access_enabled;#endifstatic  int           baud_rate_idx;static  ULONG         tx_by_intr,                      tx_by_poll;static  UCHAR         lan_shadow_imr;/*============================================================================= *                        EXTERNAL FUNCTION PROTOTYPES *===========================================================================*/extern  long  write_to_protected_mem( void *address, unsigned short value );/*============================================================================= *                      MODULE GLOBAL FUNCTIONS PROTOTYPES *===========================================================================*/ULONG gdb_c_test( ULONG *parm );void  lan_init( void );void  lan_isr( void );long  lan_get_char( void );long  lan_put_char( UCHAR c );ULONG lan_util( ULONG *parm );/*============================================================================= *                      MODULE LOCAL FUNCTION PROTOTYPES *===========================================================================*/static  void  lan_reset( void );static  void  lan_configure( void );static  void  lan_init_queue( T_RS232_QUEUE *p_queue );static  void  lan_add_to_queue( long c, T_RS232_QUEUE *p_queue );static  UCHAR lan_next_queue_char( T_RS232_QUEUE *p_queue );static  void  lan_util_menu( void );static  long  get_gdb_input( long c, T_RS232_QUEUE *p_input_q );/*============================================================================= *                      GDB STUB FUNCTION PROTOTYPES *===========================================================================*/void  gdb_trap_1_handler( void );void  gdb_trace_handler ( void );void  gdb_get_eth_input( unsigned char *buf, long length );static void getpacket ( void );static void putpacket ( char * );static void discard_packet ( void );#ifdef    STANDALONE    /* Compile this module stand-alone for debugging */#include <stdio.h>#define printp printf   /* easier than declaring a local varargs stub func.  */#endif /* STANDALONE *//*============================================================================= *                              MODULE BODY *===========================================================================*//* ------------------- Things that belong in a header file --------------- */extern char *memset (char *, int, int);                  /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*                  *                                     *                  *       Global Module Functions       *                  *                                     *                  *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/static char   gdb_char_test;static short  gdb_short_test;static long   gdb_long_test;static char   gdb_arr_test[25];static struct GDB_STRUCT_TEST{  char   c;  short  s;  long   l;  int    bfield : 11;	/* collect bitfield */  char   arr[25];  struct GDB_STRUCT_TEST *next;} gdb_struct1_test, gdb_struct2_test, *gdb_structp_test, **gdb_structpp_test;static union GDB_UNION_TEST{  char   c;  short  s;  long   l;  int    bfield : 11;	/* collect bitfield */  char   arr[4];  union GDB_UNION_TEST *next;} gdb_union1_test;void gdb_recursion_test (int, int, int, int,  int,  int,  int);void gdb_recursion_test (int depth, 			 int q1, 			 int q2, 			 int q3, 			 int q4, 			 int q5, 			 int q6){	/* gdb_recursion_test line 0 */  int q = q1;						/* gdbtestline 1 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -