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

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc2/] [or1ksim/] [peripheral/] [ethernet_i.h] - Diff between revs 346 and 406

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 346 Rev 406
/* ethernet_i.h -- Definition of internal types and structures for Ethernet MAC
/* ethernet_i.h -- Definition of internal types and structures for Ethernet MAC
   Copyright (C) 2001 Erez Volk, erez@mailandnews.comopencores.org
   Copyright (C) 2001 Erez Volk, erez@mailandnews.comopencores.org
 
 
   This file is part of OpenRISC 1000 Architectural Simulator.
   This file is part of OpenRISC 1000 Architectural Simulator.
 
 
   This program is free software; you can redistribute it and/or modify
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   (at your option) any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
*/
 
 
#ifndef __OR1KSIM_PERIPHERAL_ETHERNET_I_H
#ifndef __OR1KSIM_PERIPHERAL_ETHERNET_I_H
#define __OR1KSIM_PERIPHERAL_ETHERNET_I_H
#define __OR1KSIM_PERIPHERAL_ETHERNET_I_H
 
 
#include "ethernet.h"
#include "ethernet.h"
#include "config.h"
#include "config.h"
 
 
/*
/*
 * Ethernet protocol definitions
 * Ethernet protocol definitions
 */
 */
#if HAVE_NET_ETHERNET_H
#if HAVE_NET_ETHERNET_H
# include <net/ethernet.h>
# include <net/ethernet.h>
#else /* !HAVE_NET_ETHERNET_H -*/
#else /* !HAVE_NET_ETHERNET_H -*/
 
 
#include <sys/types.h>
#include <sys/types.h>
 
 
#define ETH_ALEN 6
#define ETH_ALEN 6
 
 
struct ether_addr
struct ether_addr
{
{
  u_int8_t ether_addr_octet[ETH_ALEN];
  u_int8_t ether_addr_octet[ETH_ALEN];
};
};
 
 
struct ether_header
struct ether_header
{
{
  u_int8_t  ether_dhost[ETH_ALEN];      /* destination eth addr */
  u_int8_t  ether_dhost[ETH_ALEN];      /* destination eth addr */
  u_int8_t  ether_shost[ETH_ALEN];      /* source ether addr    */
  u_int8_t  ether_shost[ETH_ALEN];      /* source ether addr    */
  u_int16_t ether_type;                 /* packet type ID field */
  u_int16_t ether_type;                 /* packet type ID field */
};
};
 
 
/* Ethernet protocol ID's */
/* Ethernet protocol ID's */
#define ETHERTYPE_PUP           0x0200          /* Xerox PUP */
#define ETHERTYPE_PUP           0x0200          /* Xerox PUP */
#define ETHERTYPE_IP            0x0800          /* IP */
#define ETHERTYPE_IP            0x0800          /* IP */
#define ETHERTYPE_ARP           0x0806          /* Address resolution */
#define ETHERTYPE_ARP           0x0806          /* Address resolution */
#define ETHERTYPE_REVARP        0x8035          /* Reverse ARP */
#define ETHERTYPE_REVARP        0x8035          /* Reverse ARP */
 
 
#define ETHER_ADDR_LEN  ETH_ALEN                 /* size of ethernet addr */
#define ETHER_ADDR_LEN  ETH_ALEN                 /* size of ethernet addr */
#define ETHER_TYPE_LEN  2                        /* bytes in type field */
#define ETHER_TYPE_LEN  2                        /* bytes in type field */
#define ETHER_CRC_LEN   4                        /* bytes in CRC field */
#define ETHER_CRC_LEN   4                        /* bytes in CRC field */
#define ETHER_HDR_LEN   ETH_HLEN                 /* total octets in header */
#define ETHER_HDR_LEN   ETH_HLEN                 /* total octets in header */
#define ETHER_MIN_LEN   (ETH_ZLEN + ETHER_CRC_LEN) /* min packet length */
#define ETHER_MIN_LEN   (ETH_ZLEN + ETHER_CRC_LEN) /* min packet length */
#define ETHER_MAX_LEN   (ETH_FRAME_LEN + ETHER_CRC_LEN) /* max packet length */
#define ETHER_MAX_LEN   (ETH_FRAME_LEN + ETHER_CRC_LEN) /* max packet length */
 
 
/* make sure ethenet length is valid */
/* make sure ethenet length is valid */
#define ETHER_IS_VALID_LEN(foo) \
#define ETHER_IS_VALID_LEN(foo) \
        ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
        ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
 
 
/*
/*
 * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
 * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
 * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
 * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
 * by an ETHER type (as given above) and then the (variable-length) header.
 * by an ETHER type (as given above) and then the (variable-length) header.
 */
 */
#define ETHERTYPE_TRAIL         0x1000          /* Trailer packet */
#define ETHERTYPE_TRAIL         0x1000          /* Trailer packet */
#define ETHERTYPE_NTRAILER      16
#define ETHERTYPE_NTRAILER      16
 
 
#define ETHERMTU        ETH_DATA_LEN
#define ETHERMTU        ETH_DATA_LEN
#define ETHERMIN        (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
#define ETHERMIN        (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
 
 
#endif /* HAVE_NET_ETHERNET_H */
#endif /* HAVE_NET_ETHERNET_H */
 
 
 
 
/*
/*
 * Implementatino of Ethernet MAC Registers and State
 * Implementatino of Ethernet MAC Registers and State
 */
 */
struct eth_device
struct eth_device
{
{
  /* Base address in memory */
  /* Base address in memory */
  unsigned long baseaddr;
  unsigned long baseaddr;
 
 
  /* Which Ethernet MAC is this? */
  /* Which Ethernet MAC is this? */
  unsigned eth_number;
  unsigned eth_number;
 
 
  /* Which DMA controller is this MAC connected to */
  /* Which DMA controller is this MAC connected to */
  unsigned dma;
  unsigned dma;
        unsigned tx_channel;
        unsigned tx_channel;
        unsigned rx_channel;
        unsigned rx_channel;
 
 
        /* Our address */
        /* Our address */
        unsigned char mac_address[ETH_ALEN];
        unsigned char mac_address[ETH_ALEN];
 
 
  /* RX and TX file names and handles */
  /* RX and TX file names and handles */
  const char *rxfile, *txfile;
  const char *rxfile, *txfile;
        int txfd;
        int txfd;
        int rxfd;
        int rxfd;
        off_t loopback_offset;
        off_t loopback_offset;
 
 
        /* Current TX state */
        /* Current TX state */
        struct
        struct
        {
        {
                unsigned long bd_index;
                unsigned long bd_index;
                unsigned long bd;
                unsigned long bd;
                unsigned working, waiting_for_ack, error;
                unsigned working, waiting_for_ack, error;
                unsigned packet_length;
                unsigned packet_length;
                unsigned minimum_length, maximum_length;
                unsigned minimum_length, maximum_length;
                unsigned add_crc;
                unsigned add_crc;
                unsigned long crc_value;
                unsigned long crc_value;
                unsigned bytes_left, bytes_sent;
                unsigned bytes_left, bytes_sent;
        } tx;
        } tx;
 
 
        /* Current RX state */
        /* Current RX state */
        struct
        struct
        {
        {
                unsigned long bd_index;
                unsigned long bd_index;
                unsigned long bd;
                unsigned long bd;
                int fd;
                int fd;
                off_t *offset;
                off_t *offset;
                unsigned working, error, waiting_for_ack;
                unsigned working, error, waiting_for_ack;
                unsigned packet_length, bytes_read, bytes_left;
                unsigned packet_length, bytes_read, bytes_left;
        } rx;
        } rx;
 
 
  /* Visible registers */
  /* Visible registers */
  struct
  struct
  {
  {
    unsigned long moder;
    unsigned long moder;
    unsigned long int_source;
    unsigned long int_source;
    unsigned long int_mask;
    unsigned long int_mask;
    unsigned long ipgt;
    unsigned long ipgt;
    unsigned long ipgr1;
    unsigned long ipgr1;
    unsigned long ipgr2;
    unsigned long ipgr2;
    unsigned long packetlen;
    unsigned long packetlen;
    unsigned long collconf;
    unsigned long collconf;
    unsigned long rx_bd_adr;
    unsigned long rx_bd_num;
    unsigned long controlmoder;
    unsigned long controlmoder;
    unsigned long miimoder;
    unsigned long miimoder;
    unsigned long miicommand;
    unsigned long miicommand;
    unsigned long miiaddress;
    unsigned long miiaddress;
    unsigned long miitx_data;
    unsigned long miitx_data;
    unsigned long miirx_data;
    unsigned long miirx_data;
    unsigned long miistatus;
    unsigned long miistatus;
 
 
                /* Buffer descriptors */
                /* Buffer descriptors */
                unsigned long bd_ram[ETH_BD_SPACE / 4];
                unsigned long bd_ram[ETH_BD_SPACE / 4];
  } regs;
  } regs;
};
};
 
 
 
 
 
 
 
 
#endif /* __OR1KSIM_PERIPHERAL_ETHERNET_I_H */
#endif /* __OR1KSIM_PERIPHERAL_ETHERNET_I_H */
 
 

powered by: WebSVN 2.1.0

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