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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [drivers/] [eth.c] - Diff between revs 175 and 246

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

Rev 175 Rev 246
Line 4... Line 4...
#include "common.h"
#include "common.h"
#include "support.h"
#include "support.h"
#include "uart.h"
#include "uart.h"
#include "eth.h"
#include "eth.h"
#include "int.h"
#include "int.h"
#include "spr_defs.h"
#include "spr-defs.h"
 
 
//#define PRINT_PACKETS
//#define PRINT_PACKETS
//#define ETHPHY_10MBPS
//#define ETHPHY_10MBPS
 
 
extern int printf (const char *fmt, ...);
extern int printf (const char *fmt, ...);
Line 330... Line 330...
 
 
/* Send a packet at address */
/* Send a packet at address */
void eth_send (void *buf, unsigned long len)
void eth_send (void *buf, unsigned long len)
{
{
    eth_bd  *bd;
    eth_bd  *bd;
 
    int i;
 
 
#ifdef PRINT_PACKETS  
#ifdef PRINT_PACKETS  
  printf("transmitted packet:\t");
  printf("transmitted packet:\t");
  print_packet(buf, len);
  print_packet(buf, len);
#endif
#endif
 
 
  bd = (eth_bd *)ETH_BD_BASE;
  bd = (eth_bd *)ETH_BD_BASE;
 
 
  bd[tx_last].addr = (unsigned long)buf;
  bd[tx_last].addr = (unsigned long)buf;
 
 
 retry_eth_send:
 retry_eth_send:
  bd[tx_last].len_status &= 0x0000ffff & ~ETH_TX_BD_STATS;
  bd[tx_last].len_status &= 0x0000ffff & ~ETH_TX_BD_STATS;
  if (eth_monitor_enabled) // enable IRQ when sending
  if (eth_monitor_enabled) // enable IRQ when sending
    bd[tx_last].len_status |= ETH_TX_BD_IRQ;
    bd[tx_last].len_status |= ETH_TX_BD_IRQ;
  bd[tx_last].len_status |= len << 16 | ETH_TX_BD_READY;
  bd[tx_last].len_status |= len << 16 | ETH_TX_BD_READY;
Line 367... Line 369...
/* Waits for packet and pass it to the upper layers */
/* Waits for packet and pass it to the upper layers */
unsigned long eth_rx (void)
unsigned long eth_rx (void)
{
{
  eth_bd  *bd;
  eth_bd  *bd;
  unsigned long len = 0;
  unsigned long len = 0;
 
  int i;
 
 
  bd = (eth_bd *)ETH_BD_BASE + ETH_TXBD_NUM;
  bd = (eth_bd *)ETH_BD_BASE + ETH_TXBD_NUM;
 
 
  while(1) {
  while(1) {
 
 
Line 411... Line 414...
    if(!bad) {
    if(!bad) {
#ifdef PRINT_PACKETS
#ifdef PRINT_PACKETS
      printf("received packet:\t");
      printf("received packet:\t");
      print_packet(bd[rx_next].addr, bd[rx_next].len_status >> 16);
      print_packet(bd[rx_next].addr, bd[rx_next].len_status >> 16);
#endif
#endif
 
 
      receive((void *)bd[rx_next].addr, bd[rx_next].len_status >> 16);
      receive((void *)bd[rx_next].addr, bd[rx_next].len_status >> 16);
      len += bd[rx_next].len_status >> 16;
      len += bd[rx_next].len_status >> 16;
    }
    }
 
 
    bd[rx_next].len_status &= ~ETH_RX_BD_STATS;
    bd[rx_next].len_status &= ~ETH_RX_BD_STATS;

powered by: WebSVN 2.1.0

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