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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [test-code-or1k/] [eth/] [eth.c] - Diff between revs 90 and 457

Show entire file | Details | Blame | View Log

Rev 90 Rev 457
Line 1... Line 1...
/* eth.c. Test of Or1ksim Ethernet
/* eth.c. Test of Or1ksim Ethernet
 
 
   Copyright (C) 1999-2006 OpenCores
   Copyright (C) 1999-2006, 2010 OpenCores
   Copyright (C) 2010 Embecosm Limited
   Copyright (C) 2010 Embecosm Limited
 
 
   Contributors various OpenCores participants
   Contributors various OpenCores participants
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
 
   Contributor Julius Baxter <julius@opencores.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 it
   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 the Free
   under the terms of the GNU General Public License as published by the Free
Line 23... Line 24...
 
 
/* ----------------------------------------------------------------------------
/* ----------------------------------------------------------------------------
   This code is commented throughout for use with Doxygen.
   This code is commented throughout for use with Doxygen.
   --------------------------------------------------------------------------*/
   --------------------------------------------------------------------------*/
 
 
 
/* TODO: Add loopback test.
 
*/
 
 
#include "spr-defs.h"
#include "spr-defs.h"
#include "support.h"
#include "support.h"
#include "board.h"
#include "board.h"
 
 
typedef long off_t;
typedef long off_t;
Line 56... Line 60...
        eth_mac_addr0 = (unsigned long *)(ETH_BASE + ETH_MAC_ADDR0),
        eth_mac_addr0 = (unsigned long *)(ETH_BASE + ETH_MAC_ADDR0),
        eth_mac_addr1 = (unsigned long *)(ETH_BASE + ETH_MAC_ADDR1),
        eth_mac_addr1 = (unsigned long *)(ETH_BASE + ETH_MAC_ADDR1),
        eth_bd_base = (unsigned long *)(ETH_BASE + ETH_BD_BASE);
        eth_bd_base = (unsigned long *)(ETH_BASE + ETH_BD_BASE);
 
 
volatile unsigned int_happend;
volatile unsigned int_happend;
unsigned char r_packet[2000];
#define R_PACKET_SIZE 2000
unsigned char s_packet[1003];
unsigned char r_packet[R_PACKET_SIZE];
 
#define S_PACKET_SIZE 1003
 
unsigned char s_packet[S_PACKET_SIZE];
unsigned tx_bindex;
unsigned tx_bindex;
unsigned rx_bindex;
unsigned rx_bindex;
 
 
void interrupt_handler()
void interrupt_handler()
{
{
Line 120... Line 126...
static void transmit_one_packet( void )
static void transmit_one_packet( void )
{
{
        unsigned i;
        unsigned i;
 
 
        /* Initialize packet */
        /* Initialize packet */
        for ( i = 0; i < sizeof(s_packet); ++ i )
        for ( i = 0; i < S_PACKET_SIZE; ++ i )
                s_packet[i] = (unsigned char)i;
                s_packet[i] = (unsigned char)i;
 
 
        /* Set Ethernet BD */
        /* Set Ethernet BD */
        SET_FIELD(eth_bd_base[tx_bindex], ETH_TX_BD, LENGTH, sizeof(s_packet));
        SET_FIELD(eth_bd_base[tx_bindex], ETH_TX_BD, LENGTH, S_PACKET_SIZE);
        eth_bd_base[tx_bindex + 1] = (unsigned long)s_packet;
        eth_bd_base[tx_bindex + 1] = (unsigned long)s_packet;
 
 
        /* Start Ethernet */
        /* Start Ethernet */
        SET_FLAG(eth_bd_base[tx_bindex], ETH_TX_BD, READY);
        SET_FLAG(eth_bd_base[tx_bindex], ETH_TX_BD, READY);
        SET_FLAG(*eth_moder, ETH_MODER, TXEN);
        SET_FLAG(*eth_moder, ETH_MODER, TXEN);
Line 144... Line 150...
        unsigned i;
        unsigned i;
 
 
        int_happend = 0;
        int_happend = 0;
        /* Initialize packet */
        /* Initialize packet */
        printf("Init\n");
        printf("Init\n");
        for ( i = 0; i < sizeof(s_packet); ++ i )
        for ( i = 0; i < S_PACKET_SIZE; ++ i )
                s_packet[i] = (unsigned char)i;
                s_packet[i] = (unsigned char)i;
 
 
        /* Set Ethernet BD */
        /* Set Ethernet BD */
        printf("Set BD\n");
        printf("Set BD\n");
        SET_FIELD(eth_bd_base[tx_bindex], ETH_TX_BD, LENGTH, sizeof(s_packet));
        SET_FIELD(eth_bd_base[tx_bindex], ETH_TX_BD, LENGTH, S_PACKET_SIZE);
        eth_bd_base[tx_bindex + 1] = (unsigned long)s_packet;
        eth_bd_base[tx_bindex + 1] = (unsigned long)s_packet;
 
 
        /* Start Ethernet */
        /* Start Ethernet */
        printf("Set Flags\n");
        printf("Set Flags\n");
        SET_FLAG(eth_bd_base[tx_bindex], ETH_TX_BD, IRQ);
        SET_FLAG(eth_bd_base[tx_bindex], ETH_TX_BD, IRQ);
Line 199... Line 205...
 
 
int main()
int main()
{
{
        printf( "Starting Ethernet test\n" );
        printf( "Starting Ethernet test\n" );
 
 
 
        /* Buffer descriptor indexes. These are not changed in between the
 
        polling tests, as the RXEN and TXEN bits in the MODER are disabled
 
        between tests, resetting the respective buffer descriptor indexes,
 
        and so these should stay at their initial values. */
        tx_bindex = 0;
        tx_bindex = 0;
        rx_bindex = *eth_tx_bd_num << 1;
        rx_bindex = *eth_tx_bd_num << 1;
 
 
        set_mac();
        set_mac();
 
 
 
        /* Set promiscuous mode */
 
        *eth_moder |= (1 << ETH_MODER_PRO_OFFSET);
 
 
        /*-------------------*/
        /*-------------------*/
        /* non iterrupt test */
        /* non iterrupt test */
        transmit_one_packet();
        transmit_one_packet();
        tx_bindex += 2;
 
        receive_one_packet();
        receive_one_packet();
        rx_bindex += 2;
 
        transmit_one_packet();
        transmit_one_packet();
        tx_bindex += 2;
 
        receive_one_packet();
        receive_one_packet();
        rx_bindex += 2;
 
 
 
 
 
        /*-------------------*/
        /*-------------------*/
        /* interrupt test    */
        /* interrupt test    */
        excpt_int = (unsigned long)interrupt_handler;
        excpt_int = (unsigned long)interrupt_handler;

powered by: WebSVN 2.1.0

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