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

📄 gdb_c_test.c

📁 lwip在ucos上的移植
💻 C
📖 第 1 页 / 共 5 页
字号:
  q1 = q2;						/* gdbtestline 2 */  q2 = q3;						/* gdbtestline 3 */  q3 = q4;						/* gdbtestline 4 */  q4 = q5;						/* gdbtestline 5 */  q5 = q6;						/* gdbtestline 6 */  q6 = q;						/* gdbtestline 7 */  if (depth--)						/* gdbtestline 8 */    gdb_recursion_test (depth, q1, q2, q3, q4, q5, q6);	/* gdbtestline 9 */}ULONG   gdb_c_test( ULONG *parm ){   char *p = "gdb_c_test";   char *rediculously_long_variable_name_with_equally_long_string_assignment;   register long local_reg = 7;   static unsigned long local_static, local_static_sizeof;   long local_long;   unsigned long *stack_ptr;   unsigned long end_of_stack;   rediculously_long_variable_name_with_equally_long_string_assignment =      "rediculously long variable name with equally long string assignment";   local_static = 9;   local_static_sizeof = sizeof (struct GDB_STRUCT_TEST);   local_long = local_reg + 1;   stack_ptr  = (unsigned long *) &local_long;   end_of_stack =      (unsigned long) &stack_ptr + sizeof(stack_ptr) + sizeof(end_of_stack) - 1;   printp ("\n$Id: gdb_c_test.c,v 1.1.1.1 2003/02/19 02:42:16 skyeye Exp $\n");   printp( "%s: arguments = %X, %X, %X, %X, %X, %X\n",           p, parm[ 1 ], parm[ 2 ], parm[ 3 ], parm[ 4 ], parm[ 5 ], parm[ 6 ] );   gdb_char_test   = gdb_struct1_test.c = (char)   ((long) parm[1] & 0xff);   gdb_short_test  = gdb_struct1_test.s = (short)  ((long) parm[2] & 0xffff);   gdb_long_test   = gdb_struct1_test.l = (long)   ((long) parm[3] & 0xffffffff);   gdb_union1_test.l = (long) parm[4];   gdb_arr_test[0] = gdb_struct1_test.arr[0] = (char) ((long) parm[1] & 0xff);   gdb_arr_test[1] = gdb_struct1_test.arr[1] = (char) ((long) parm[2] & 0xff);   gdb_arr_test[2] = gdb_struct1_test.arr[2] = (char) ((long) parm[3] & 0xff);   gdb_arr_test[3] = gdb_struct1_test.arr[3] = (char) ((long) parm[4] & 0xff);   gdb_arr_test[4] = gdb_struct1_test.arr[4] = (char) ((long) parm[5] & 0xff);   gdb_arr_test[5] = gdb_struct1_test.arr[5] = (char) ((long) parm[6] & 0xff);   gdb_struct1_test.bfield = 144;   gdb_struct1_test.next = &gdb_struct2_test;   gdb_structp_test      = &gdb_struct1_test;   gdb_structpp_test     = &gdb_structp_test;   gdb_recursion_test (3, (long) parm[1], (long) parm[2], (long) parm[3],		       (long) parm[4], (long) parm[5], (long) parm[6]);   gdb_char_test = gdb_short_test = gdb_long_test = 0;   gdb_structp_test  = (void *) 0;   gdb_structpp_test = (void *) 0;   memset ((char *) &gdb_struct1_test, 0, sizeof (gdb_struct1_test));   memset ((char *) &gdb_struct2_test, 0, sizeof (gdb_struct2_test));   local_static_sizeof = 0;   local_static = 0;   return ( (ULONG) 0 );}/*----------------------------------------------------------------------------- * * FUNCTION NAME:   lan_init * * * DESCRIPTION: * * * RETURN VALUE: * * * USED GLOBAL VARIABLES: * * * AFFECTED GLOBAL VARIABLES/SIDE EFFECTS: * * * NOTES: * * * *---------------------------------------------------------------------------*/void    lan_init( void ){  if ( IS_SIDE_A( ) )  {    lan_reset( );    lan_init_queue( &lan_input_queue );    lan_init_queue( &lan_output_queue );    lan_configure( );  }  return;}/* end of 'lan_init' *===========================================================================*//*----------------------------------------------------------------------------- * * FUNCTION NAME:   lan_isr * * * DESCRIPTION: * * * RETURN VALUE:    None. * * * USED GLOBAL VARIABLES: * * * AFFECTED GLOBAL VARIABLES/SIDE EFFECTS: * * * NOTES: * * *---------------------------------------------------------------------------*/void      lan_isr( void ){  UCHAR   c;  lan_shadow_imr = 0;           /*  Disable all UART interrupts.  */  *P_LAN_IMR = lan_shadow_imr;  if ( *P_LAN_ISR & M_UART_ISR_RxRDY )  {    gdb_host_comm = VIA_RS232;    c = *P_LAN_RCV;    if ( test_echo )    {      /* ????? */    }    if ( c == CONTROL_C )    {        /* can't stop the target, but we can tell gdb to stop waiting... */      discard_packet( );      putpacket( "S03" );       /* send back SIGINT to the debugger */    }    else    {      lan_add_to_queue( (long) c, &lan_input_queue );      get_gdb_input( (long) c, &lan_input_queue );    }  }  if ( XMT_VIA_BP_ENABLED( ) )  {    c = 0;    while ( (*P_LAN_ISR & M_UART_ISR_TxRDY)  &&  (c = lan_next_queue_char( &lan_output_queue )) )    {      *P_LAN_XMT = c;      ++tx_by_intr;    }    if ( c )    {      lan_shadow_imr |= UART_IMR_TxRDY;   /*  (Re-)Enable 'TxRDY' interrupt from UART.  */    }  }  lan_shadow_imr |= UART_IMR_RxRDY;       /*  Re-Enable 'RxRDY' interrupt from UART.  */  *P_LAN_IMR = lan_shadow_imr;  return;}/* end of 'lan_isr' *===========================================================================*//*----------------------------------------------------------------------------- * * FUNCTION NAME:   lan_get_char * * * DESCRIPTION:     Fetches a character from the UART. * * * RETURN VALUE:    0 on success, -1 on failure. * * * USED GLOBAL VARIABLES: * * * AFFECTED GLOBAL VARIABLES/SIDE EFFECTS: * * * NOTES: * * *---------------------------------------------------------------------------*/long    lan_get_char( void ){  long status = -2; /* AGD: nothing found in rcv buffer */  if ( *P_LAN_SR & M_UART_SR_RxRDY )  {    char c = (char) *P_LAN_RCV;    if ( test_echo )    {      LAN_PUT_CHAR ( c );    }    if ( c == CONTROL_C )    {        /* can't stop the target, but we can tell gdb to stop waiting... */      discard_packet( );      putpacket( "S03" );       /* send back SIGINT to the debugger */      status = 0;               /* success */    }    else    {      lan_add_to_queue( (long) c, &lan_input_queue );      status = get_gdb_input( (long) c, &lan_input_queue );    }  }  return( status );}/* end of 'lan_get_char' *===========================================================================*//*----------------------------------------------------------------------------- * * FUNCTION NAME:   lan_put_char * * DESCRIPTION:     Puts a character out via the UART. * * RETURN VALUE:    0 on success, -1 on failure. * * USED GLOBAL VARIABLES: none. * * AFFECTED GLOBAL VARIABLES/SIDE EFFECTS: * * NOTES: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! *        !!                                                                  !! *        !!  If 'XMT_VIA_BP_ENABLED()' is FALSE then output is THROWN AWAY.  !! *        !!  This prevents anyone infinite-looping on this function.         !! *        !!                                                                  !! *        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * *---------------------------------------------------------------------------*/long    lan_put_char( UCHAR c ){  long    status = -1;  if ( XMT_VIA_BP_ENABLED( ) )  {    if ( *P_LAN_SR & M_UART_SR_TxRDY )    {      lan_add_to_queue( (long) c, &lan_output_queue );      c = lan_next_queue_char( &lan_output_queue );      *P_LAN_XMT = c;      ++tx_by_poll;      status = 0;    }#if 0    else    {      status = 0;      lan_shadow_imr |= UART_IMR_TxRDY;   /*  Enable 'TxRDY' interrupt from UART. */      *P_LAN_IMR = lan_shadow_imr;    }#endif  }  else  {    status = 0;   /* You lose: input character goes to the bit bucket. */  }  return( status );}/* end of 'lan_put_char' *===========================================================================*//*----------------------------------------------------------------------------- * * FUNCTION NAME:   lan_util * * DESCRIPTION: * * RETURN VALUE: * * USED GLOBAL VARIABLES: * * AFFECTED GLOBAL VARIABLES/SIDE EFFECTS: * * NOTES: * *---------------------------------------------------------------------------*/ULONG   lan_util( ULONG *parm ){  static const struct {    ULONG rate_code;    UCHAR acr_setting;    UCHAR csr_setting;  } baud_rate_setting [] = {    { 0x38400, LAN_ACR_SELECT_BRG_0, UART_CSR_BR_38400 },    { 0x19200, LAN_ACR_SELECT_BRG_1, UART_CSR_BR_19200 },    { 0x9600,  LAN_ACR_SELECT_BRG_0, UART_CSR_BR_9600  },    { 0x4800,  LAN_ACR_SELECT_BRG_0, UART_CSR_BR_4800  }  };#define BOGUS_P1        0xE1#define BOGUS_P2        0xE2  ULONG   not_done_code;  ULONG   opcode;  ULONG   parm_1;  ULONG   parm_2;  int     i;  UCHAR   c;  not_done_code = 0;  opcode = parm[ 1 ];  parm_1 = parm[ 2 ];  parm_2 = parm[ 3 ];  switch ( opcode )  {    case LAN_INIT:      {        lan_init( );        printp( "\n\n  Interface (Re)Initialized ...\n\n" );        break;      }    case LAN_BAUD:      {        for ( i = 0; i < (int)(sizeof(baud_rate_setting) / sizeof(baud_rate_setting[0])); i ++ )        {          if ( baud_rate_setting[i].rate_code == parm_1 )          {            baud_rate_idx = i;            *P_LAN_ACR = baud_rate_setting[i].acr_setting;            *P_LAN_CSR = baud_rate_setting[i].csr_setting;            printp ( "Baud rate set to %X!\n", baud_rate_setting[i].rate_code );            return( not_done_code );          }        }        printp( "\n\n  *** SYNTAX Error  -  Invalid baudrate (P2)\n\n" );        not_done_code = BOGUS_P2;        break;      }    case LAN_INTR:      {        switch ( parm_1 )        {          case 0x0D: /* Disable 'RxRDY' Interrupts */            {              lan_shadow_imr &= ~UART_IMR_RxRDY;              *P_LAN_IMR = lan_shadow_imr;              printp( "\n\n  Receive Ready Interrupts DISABLED ...\n\n" );              break;            }          case 0x0E: /* Enable 'RxRDY' Interrupts */            {              lan_shadow_imr |= UART_IMR_RxRDY;              *P_LAN_IMR = lan_shadow_imr;              printp( "\n\n  Receive Ready Interrupts ENABLED ...\n\n" );              break;            }          default:            {              printp( "\n\n  *** SYNTAX Error  -  Invalid P2 (use D or E)\n\n" );              not_done_code = BOGUS_P2;            }        }        break;      }    case LAN_XMT:      {        switch ( parm_1 )        {          case 0x0E: /* Enable Transmission-via-Backplane */            {              if ( !(*P_LAN0TR_REG & M_LAN0TR) )              {                *P_LAN0TR_REG |= M_LAN0TR;  /* 0 -> 1 */              }              printp( "\n\n  Transmit-via-Backplane ENABLED ...\n\n" );              break;            }          case 0x0D: /* Disable Transmission-via-Backplane */            {              if ( *P_LAN0TR_REG & M_LAN0TR )              {                *P_LAN0TR_REG &= ~M_LAN0TR; /* 1 -> 0 */              }              printp( "\n\n  Transmit-via-Backplane DISABLED ...\n\n" );              break;            }          default:            {              printp( "\n\n  *** SYNTAX Error  -  Invalid P2 (use D or E)\n\n" );              not_done_code = BOGUS_P2;              lan_util_menu( );            }        }        break;      }

⌨️ 快捷键说明

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