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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [ethmac/] [sim/] [ethmac-tx.c] - Diff between revs 411 and 439

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

Rev 411 Rev 439
Line 56... Line 56...
void oeth_interrupt(void);
void oeth_interrupt(void);
static void oeth_rx(void);
static void oeth_rx(void);
static void oeth_tx(void);
static void oeth_tx(void);
 
 
/* Let the ethernet packets use a space beginning here for buffering */
/* Let the ethernet packets use a space beginning here for buffering */
#define ETH_BUFF_BASE 0x01000000
#define ETH_BUFF_BASE 0x200000;
 
 
#define RXBUFF_PREALLOC 1
#define RXBUFF_PREALLOC 1
#define TXBUFF_PREALLOC 1
#define TXBUFF_PREALLOC 1
//#undef RXBUFF_PREALLOC
//#undef RXBUFF_PREALLOC
//#undef TXBUFF_PREALLOC
//#undef TXBUFF_PREALLOC
Line 328... Line 328...
  if (length <= ETH_ZLEN)
  if (length <= ETH_ZLEN)
    tx_bd->len_status |= OETH_TX_BD_PAD;
    tx_bd->len_status |= OETH_TX_BD_PAD;
  else
  else
    tx_bd->len_status &= ~OETH_TX_BD_PAD;
    tx_bd->len_status &= ~OETH_TX_BD_PAD;
 
 
#ifdef _ETH_RXTX_DATA_H_
 
  // Set the address pointer to the place
 
  // in memory where the data is and transmit from there
 
 
 
  tx_bd->addr = (char*) &tx_data_array[tx_data_pointer&~(0x3)];
 
 
 
  tx_data_pointer += length;
 
  if (tx_data_pointer > (255*1024))
 
    tx_data_pointer = 0;
 
 
 
 
 
#else
 
  if (data){
  if (data){
    //Copy the data into the transmit buffer, byte at a time 
    //Copy the data into the transmit buffer, byte at a time 
    char* data_p = (char*) data;
    char* data_p = (char*) data;
    char* data_b = (char*) tx_bd->addr;
    char* data_b = (char*) tx_bd->addr;
    for(i=0;i<length;i++)
    for(i=0;i<length;i++)
      {
      {
        data_b[i] = data_p[i];
        data_b[i] = data_p[i];
      }
      }
  }
  }
#endif    
 
 
 
  /* Set the length of the packet's data in the buffer descriptor */
  /* Set the length of the packet's data in the buffer descriptor */
  tx_bd->len_status = (tx_bd->len_status & 0x0000ffff) |
  tx_bd->len_status = (tx_bd->len_status & 0x0000ffff) |
    ((length&0xffff) << 16);
    ((length&0xffff) << 16);
 
 
Line 532... Line 519...
  tx_bd = (struct oeth_bd*) &tx_bd[next_tx_buf_num];
  tx_bd = (struct oeth_bd*) &tx_bd[next_tx_buf_num];
 
 
  // If it's in use - wait
  // If it's in use - wait
  while ((tx_bd->len_status & OETH_TX_BD_IRQ));
  while ((tx_bd->len_status & OETH_TX_BD_IRQ));
 
 
#ifndef _ETH_RXTX_DATA_H_  
 
 
 
  // Use rand() function to generate data for transmission
  // Use rand() function to generate data for transmission
  // Assumption: ethernet buffer descriptors are 4byte aligned
  // Assumption: ethernet buffer descriptors are 4byte aligned
  char* data_b = (char*) tx_bd->addr;
  char* data_b = (char*) tx_bd->addr;
  // We will fill with words until there' less than a word to go
  // We will fill with words until there' less than a word to go
  int words_to_fill = size/ sizeof(unsigned int);
  int words_to_fill = size/ sizeof(unsigned int);
Line 553... Line 538...
 
 
  for(i=0;i<leftover_size;i++)
  for(i=0;i<leftover_size;i++)
    {
    {
      data_b[i] = rand()&0xff;
      data_b[i] = rand()&0xff;
    }
    }
#endif
 
 
 
   tx_packet((void*)0, size);
   tx_packet((void*)0, size);
}
}
 
 
int
int
main ()
main ()
{
{
  int i;
  int i;
 
 
#ifdef _ETH_RXTX_DATA_H_
 
  tx_data_pointer = 0;
 
#endif
 
 
 
  /* Initialise handler vector */
  /* Initialise handler vector */
  int_init();
  int_init();
 
 
  /* Install ethernet interrupt handler, it is enabled here too */
  /* Install ethernet interrupt handler, it is enabled here too */
  int_add(ETH0_IRQ, oeth_interrupt, 0);
  int_add(ETH0_IRQ, oeth_interrupt, 0);

powered by: WebSVN 2.1.0

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