OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [testbench/] [eth.c] - Diff between revs 733 and 836

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 733 Rev 836
Line 44... Line 44...
{
{
    unsigned i,len;
    unsigned i,len;
 
 
    printf ("Int\n");
    printf ("Int\n");
    switch (*eth_int_source & 0x7f) {
    switch (*eth_int_source & 0x7f) {
    case 0x2 : printf ("Transmit Error.\n"); break;
    case 0x2 :
    case 0x8 : printf ("Receive Error\n");break;
        printf ("Transmit Error.\n");
 
        *eth_int_source = 0x2;
 
         break;
 
    case 0x8 :
 
        printf ("Receive Error\n");
 
        *eth_int_source = 0x8;
 
        break;
    case 0x4 :
    case 0x4 :
        printf ("Receive Frame\n");
        printf ("Receive Frame\n");
 
        *eth_int_source = 0x4;
 
 
        CLEAR_FLAG(*eth_moder, ETH_MODER, RXEN);
        CLEAR_FLAG(*eth_moder, ETH_MODER, RXEN);
 
 
        len = GET_FIELD(eth_bd_base[*eth_tx_bd_num + 2], ETH_RX_BD, LENGTH);
        len = GET_FIELD(eth_bd_base[*eth_tx_bd_num + 2], ETH_RX_BD, LENGTH);
        for (i=0; i<len; i++)
        for (i=0; i<len; i++)
          if (r_packet[i] != (unsigned char)i)
          if (r_packet[i] != (unsigned char)i)
          {
          {
              printf("Failed at byte %d. expect %d, received %d\n", i, i, r_packet[i]);
              printf("Failed at byte %d. expect %d, received %d\n", i, i, r_packet[i]);
              exit(1);
              exit(1);
          }
          }
        break;
        break;
    case 0x10: printf ("Busy\n"); break;
    case 0x10:
 
        printf ("Busy\n");
 
        *eth_int_source = 0x10;
 
        break;
    case 0x1 :
    case 0x1 :
        printf ("Transmit Frame.\n");
        printf ("Transmit Frame.\n");
        CLEAR_FLAG(*eth_moder, ETH_MODER, RXEN);
        *eth_int_source = 0x1;
 
        CLEAR_FLAG(*eth_moder, ETH_MODER, TXEN);
 
 
        break;
        break;
    default:
    default:
      printf ("Invalid int @ %0x\n", *eth_int_source & 0x1f);
        printf ("Invalid int @ %0x\n", (unsigned int)*eth_int_source & 0x7f);
 
        *eth_int_source = 0x7f;
      exit (1);
      exit (1);
    }
    }
    *eth_int_source = 0;
 
 
 
    mtspr(SPR_PICSR, 0);
    mtspr(SPR_PICSR, 0);
    int_happend = 1;
    int_happend = 1;
}
}
 
 
Line 99... Line 111...
        SET_FLAG(*eth_moder, ETH_MODER, TXEN);
        SET_FLAG(*eth_moder, ETH_MODER, TXEN);
 
 
        /* Now wait till sent */
        /* Now wait till sent */
        while ( TEST_FLAG( eth_bd_base[tx_bindex], ETH_TX_BD, READY ) );
        while ( TEST_FLAG( eth_bd_base[tx_bindex], ETH_TX_BD, READY ) );
        CLEAR_FLAG(*eth_moder, ETH_MODER, TXEN);
        CLEAR_FLAG(*eth_moder, ETH_MODER, TXEN);
        *eth_int_source = 0;
        *eth_int_source = 0x7f;
}
}
 
 
static void transmit_one_packet_int( void )
static void transmit_one_packet_int( void )
{
{
        unsigned i;
        unsigned i;
Line 136... Line 148...
  SET_FLAG(eth_bd_base[rx_bindex], ETH_RX_BD, READY);
  SET_FLAG(eth_bd_base[rx_bindex], ETH_RX_BD, READY);
  SET_FLAG(*eth_moder, ETH_MODER, RXEN);
  SET_FLAG(*eth_moder, ETH_MODER, RXEN);
 
 
  while ( TEST_FLAG( eth_bd_base[rx_bindex], ETH_RX_BD, READY ) );
  while ( TEST_FLAG( eth_bd_base[rx_bindex], ETH_RX_BD, READY ) );
  CLEAR_FLAG(*eth_moder, ETH_MODER, RXEN);
  CLEAR_FLAG(*eth_moder, ETH_MODER, RXEN);
  *eth_int_source = 0;
  *eth_int_source = 0x7f;
 
 
  len = GET_FIELD(eth_bd_base[rx_bindex], ETH_RX_BD, LENGTH);
  len = GET_FIELD(eth_bd_base[rx_bindex], ETH_RX_BD, LENGTH);
  for (i=0; i<len; i++)
  for (i=0; i<len; i++)
      if (r_packet[i] != (unsigned char)i)
      if (r_packet[i] != (unsigned char)i)
      {
      {
Line 187... Line 199...
        /* Enable interrup      ts */
        /* Enable interrup      ts */
        printf("enable ints\n");
        printf("enable ints\n");
        mtspr (SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
        mtspr (SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
        mtspr (SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << ETH_INT_LINE));
        mtspr (SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << ETH_INT_LINE));
 
 
        printf("set mask flags\n");
        printf("set mask flags TX\n");
        SET_FLAG(*eth_int_mask, ETH_INT_MASK, TXB_M);
        SET_FLAG(*eth_int_mask, ETH_INT_MASK, TXB_M);
        transmit_one_packet_int();
        transmit_one_packet_int();
 
        tx_bindex += 2;
        printf("waiting for int\n");
        printf("waiting for int\n");
        while (!int_happend);
        while (!int_happend);
        CLEAR_FLAG(*eth_int_mask, ETH_INT_MASK, TXB_M);
        CLEAR_FLAG(*eth_int_mask, ETH_INT_MASK, TXB_M);
 
 
        printf("seting mask flagx RX\n");
        printf("seting mask flag RX\n");
        SET_FLAG(*eth_int_mask, ETH_INT_MASK, RXB_M);
        SET_FLAG(*eth_int_mask, ETH_INT_MASK, RXB_M);
        receive_one_packet_int();
        receive_one_packet_int();
        printf("waiting for int RX\n");
        rx_bindex += 2;
 
        printf("waiting for int\n");
        while (!int_happend);
        while (!int_happend);
        CLEAR_FLAG(*eth_int_mask, ETH_INT_MASK, RXB_M);
        CLEAR_FLAG(*eth_int_mask, ETH_INT_MASK, RXB_M);
 
 
 
 
        printf( "Ending Ethernet test\n" );
        printf( "Ending Ethernet test\n" );
 
 
        report (0xdeaddead);
        report (0xdeaddead);
        return 0;
        exit(1);
}
}
 
 
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.