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

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/or1ksim
    from Rev 433 to Rev 434
    Reverse comparison

Rev 433 → Rev 434

/configure
1,7 → 1,7
#! /bin/sh
# From configure.ac Id: configure.ac 420 2010-11-11 14:43:33Z jeremybennett using automake version AC_ACVERSION.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.65 for or1ksim 2010-11-25.
# Generated by GNU Autoconf 2.65 for or1ksim 2010-11-26.
#
# Report bugs to <openrisc@opencores.org>.
#
722,8 → 722,8
# Identity of this package.
PACKAGE_NAME='or1ksim'
PACKAGE_TARNAME='or1ksim'
PACKAGE_VERSION='2010-11-25'
PACKAGE_STRING='or1ksim 2010-11-25'
PACKAGE_VERSION='2010-11-26'
PACKAGE_STRING='or1ksim 2010-11-26'
PACKAGE_BUGREPORT='openrisc@opencores.org'
PACKAGE_URL=''
 
1476,7 → 1476,7
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures or1ksim 2010-11-25 to adapt to many kinds of systems.
\`configure' configures or1ksim 2010-11-26 to adapt to many kinds of systems.
 
Usage: $0 [OPTION]... [VAR=VALUE]...
 
1547,7 → 1547,7
 
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of or1ksim 2010-11-25:";;
short | recursive ) echo "Configuration of or1ksim 2010-11-26:";;
esac
cat <<\_ACEOF
 
1654,7 → 1654,7
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
or1ksim configure 2010-11-25
or1ksim configure 2010-11-26
generated by GNU Autoconf 2.65
 
Copyright (C) 2009 Free Software Foundation, Inc.
2316,7 → 2316,7
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
 
It was created by or1ksim $as_me 2010-11-25, which was
It was created by or1ksim $as_me 2010-11-26, which was
generated by GNU Autoconf 2.65. Invocation command line was
 
$ $0 $@
10717,7 → 10717,7
 
# Define the identity of the package.
PACKAGE='or1ksim'
VERSION='2010-11-25'
VERSION='2010-11-26'
 
 
cat >>confdefs.h <<_ACEOF
13736,7 → 13736,7
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by or1ksim $as_me 2010-11-25, which was
This file was extended by or1ksim $as_me 2010-11-26, which was
generated by GNU Autoconf 2.65. Invocation command line was
 
CONFIG_FILES = $CONFIG_FILES
13802,7 → 13802,7
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
or1ksim config.status 2010-11-25
or1ksim config.status 2010-11-26
configured by $0, generated by GNU Autoconf 2.65,
with options \\"\$ac_cs_config\\"
 
/configure.ac
28,7 → 28,7
 
# Use a full version number (x.y.z, possibly with "rcn" as a suffix) when
# preparing a release, otherwise use a the date version (yyyy-mm-dd).
AC_INIT([or1ksim], [2010-11-25], [openrisc@opencores.org])
AC_INIT([or1ksim], [2010-11-26], [openrisc@opencores.org])
AC_CONFIG_MACRO_DIR([m4])
 
# Generically use extensions such as _GNU_SOURCE if available.
/doc/or1ksim.info
64,7 → 64,7
Unpack the software and create a _separate_ directory in which to build
it:
 
tar jxf or1ksim-2010-11-25.tar.bz2
tar jxf or1ksim-2010-11-26.tar.bz2
mkdir builddir_or1ksim
cd builddir_or1ksim
 
81,7 → 81,7
OpenRISC 1000 32-bit architecture. If this argument is omitted, it will
default to OpenRISC 1000 32-bit with a warning
 
../or1ksim-2010-11-25/configure --target=or32-uclinux ...
../or1ksim-2010-11-26/configure --target=or32-uclinux ...
 
There are several other options available, many of which are standard
to GNU `configure' scripts. Use `configure --help' to see all the
/doc/version.texi
1,4 → 1,4
@set UPDATED 25 November 2010
@set UPDATED-MONTH November 2010
@set EDITION 2010-11-25
@set VERSION 2010-11-25
@set EDITION 2010-11-26
@set VERSION 2010-11-26
/ChangeLog
1,3 → 1,24
2010-11-26 Jeremy Bennett <jeremy.bennett@embecosm.com>
 
* configure: Regenerated.
* configure.ac: Updated version.
* peripheral/eth.c: Now uses TUN/TAP tunnelling. ETH_PHY
conditional compilation removed throughout.
<struct eth_device>: Redundant fields removed. New fields added.
(eth_controller_tx_clock): Use write to TAP instead of sendto
socket.
(eth_controller_rx_clock): Use read from TAP instead of recv from
socket.
(eth_reset): Socket initialization replaced by opening TAP.
(eth_rtx_type): Now string parameter. Currently "FILE" or "TAP"
permitted.
(eth_tap_dev): Created.
(eth_sock_if): Deleted.
(eth_sec_start, eth_sec_end, reg_ethernet_sec): Updated to add
tap_dev.
* peripheral/etch.h: ETH_PHY conditional compilation removed
throughout.
 
2010-11-25 Jeremy Bennett <jeremy.bennett@embecosm.com>
 
* configure: Regenerated.
/testsuite/libsim.tests/default.cfg
163,7 → 163,7
enabled = 0
baseaddr = 0x92000000
irq = 4
rtx_type = 0
rtx_type = "file"
end
 
section VAPI
/testsuite/libsim.tests/int-edge.cfg
129,7 → 129,7
enabled = 0
baseaddr = 0x92000000
irq = 4
rtx_type = 0
rtx_type = "file"
end
 
section VAPI
/testsuite/libsim.tests/int-level.cfg
129,7 → 129,7
enabled = 0
baseaddr = 0x92000000
irq = 4
rtx_type = 0
rtx_type = "file"
end
 
section VAPI
/testsuite/libsim.tests/upcalls.cfg
129,7 → 129,7
enabled = 0
baseaddr = 0x92000000
irq = 4
rtx_type = 0
rtx_type = "file"
end
 
section VAPI
/testsuite/test-code-or1k/configure
1,6 → 1,6
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.65 for or1ksim-testsuite 2010-11-25.
# Generated by GNU Autoconf 2.65 for or1ksim-testsuite 2010-11-26.
#
# Report bugs to <openrisc@opencores.org>.
#
701,8 → 701,8
# Identity of this package.
PACKAGE_NAME='or1ksim-testsuite'
PACKAGE_TARNAME='or1ksim-testsuite'
PACKAGE_VERSION='2010-11-25'
PACKAGE_STRING='or1ksim-testsuite 2010-11-25'
PACKAGE_VERSION='2010-11-26'
PACKAGE_STRING='or1ksim-testsuite 2010-11-26'
PACKAGE_BUGREPORT='openrisc@opencores.org'
PACKAGE_URL=''
 
1424,7 → 1424,7
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures or1ksim-testsuite 2010-11-25 to adapt to many kinds of systems.
\`configure' configures or1ksim-testsuite 2010-11-26 to adapt to many kinds of systems.
 
Usage: $0 [OPTION]... [VAR=VALUE]...
 
1495,7 → 1495,7
 
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of or1ksim-testsuite 2010-11-25:";;
short | recursive ) echo "Configuration of or1ksim-testsuite 2010-11-26:";;
esac
cat <<\_ACEOF
 
1600,7 → 1600,7
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
or1ksim-testsuite configure 2010-11-25
or1ksim-testsuite configure 2010-11-26
generated by GNU Autoconf 2.65
 
Copyright (C) 2009 Free Software Foundation, Inc.
2025,7 → 2025,7
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
 
It was created by or1ksim-testsuite $as_me 2010-11-25, which was
It was created by or1ksim-testsuite $as_me 2010-11-26, which was
generated by GNU Autoconf 2.65. Invocation command line was
 
$ $0 $@
10315,7 → 10315,7
 
# Define the identity of the package.
PACKAGE='or1ksim-testsuite'
VERSION='2010-11-25'
VERSION='2010-11-26'
 
 
cat >>confdefs.h <<_ACEOF
11742,7 → 11742,7
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by or1ksim-testsuite $as_me 2010-11-25, which was
This file was extended by or1ksim-testsuite $as_me 2010-11-26, which was
generated by GNU Autoconf 2.65. Invocation command line was
 
CONFIG_FILES = $CONFIG_FILES
11808,7 → 11808,7
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
or1ksim-testsuite config.status 2010-11-25
or1ksim-testsuite config.status 2010-11-26
configured by $0, generated by GNU Autoconf 2.65,
with options \\"\$ac_cs_config\\"
 
/testsuite/test-code-or1k/configure.ac
24,7 → 24,7
# directory. This uses a different tool chain, so has its own configuration
# script. Process this file with autoconf to produce a configure script.
 
AC_INIT([or1ksim-testsuite], [2010-11-25], [openrisc@opencores.org])
AC_INIT([or1ksim-testsuite], [2010-11-26], [openrisc@opencores.org])
AC_CONFIG_MACRO_DIR([m4])
 
AC_PROG_LIBTOOL
/testsuite/test-code-or1k/ChangeLog
1,3 → 1,8
2010-11-26 Jeremy Bennett <jeremy.bennett@embecosm.com>
 
* configure: Regenerated.
* configure.ac: Updated version.
 
2010-11-25 Jeremy Bennett <jeremy.bennett@embecosm.com>
 
* configure: Regenerated.
/testsuite/or1ksim.tests/default.cfg
129,7 → 129,7
enabled = 0
baseaddr = 0x92000000
irq = 4
rtx_type = 0
rtx_type = "file"
end
 
section VAPI
/testsuite/or1ksim.tests/eth.cfg
128,7 → 128,7
section ethernet
baseaddr = 0x92000000
irq = 4
rtx_type = 0
rtx_type = "file"
rxfile = "eth0.rx"
txfile = "eth0.tx"
sockif = "eth0"
/testsuite/or1ksim.tests/kbdtest.cfg
1,4 → 1,4
/* default.cfg -- Or1ksim default configuration script file
/* kbdtest.cfg -- Or1ksim keyboard configuration script file
 
Copyright (C) 2001, Marko Mlinar <markom@opencores.org>
Copyright (C) 2010 Embecosm Limited
129,7 → 129,7
enabled = 0
baseaddr = 0x92000000
irq = 4
rtx_type = 0
rtx_type = "file"
end
 
section VAPI
/testsuite/or1ksim.tests/fp.cfg
130,7 → 130,7
enabled = 0
baseaddr = 0x92000000
irq = 4
rtx_type = 0
rtx_type = "file"
end
 
section VAPI
/testsuite/ChangeLog
1,3 → 1,14
2010-11-26 Jeremy Bennett <jeremy.bennett@embecosm.com>
 
* libsim.tests/default.cfg: Updated Ethernet rtx_type parameter.
* libsim.tests/int-edge.cfg: Updated Ethernet rtx_type parameter.
* libsim.tests/int-level.cfg: Updated Ethernet rtx_type parameter.
* libsim.tests/upcalls.cfg: Updated Ethernet rtx_type parameter.
* or1ksim.tests/default.cfg: Updated Ethernet rtx_type parameter.
* or1ksim.tests/eth.cfg: Updated Ethernet rtx_type parameter.
* or1ksim.tests/fp.cfg: Updated Ethernet rtx_type parameter.
* or1ksim.tests/kbdtest.cfg: Updated Ethernet rtx_type parameter.
 
2010-11-25 Jeremy Bennett <jeremy.bennett@embecosm.com>
 
* libsim.tests/int-edge.exp: Updated for new interrupt interface.
/peripheral/eth.c
32,18 → 32,20
/* System includes */
#include <stdlib.h>
#include <stdio.h>
 
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
 
#include <sys/poll.h>
#include <sys/time.h>
#include <unistd.h>
#include <errno.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
 
#include <linux/if.h>
#include <linux/if_tun.h>
 
/* Package includes */
#include "arch.h"
#include "config.h"
84,20 → 86,19
/* Ethernet PHY address */
unsigned long phy_addr;
 
/* RX and TX file names and handles */
/* What sort of external I/F: FILE or TAP */
int rtx_type;
 
/* RX and TX file names and handles for FILE type connection. */
char *rxfile, *txfile;
int txfd;
int rxfd;
off_t loopback_offset;
 
/* Socket interface name */
char *sockif;
/* Info for TAP type connections */
int rtx_fd;
char *tap_dev;
 
int rtx_sock;
int rtx_type;
struct ifreq ifr;
fd_set rfds, wfds;
 
/* Current TX state */
struct
{
173,6 → 174,14
static void eth_rx_next_packet (struct eth_device *);
static void eth_write_tx_bd_num (struct eth_device *, unsigned long value);
static void eth_miim_trans (void *dat);
 
 
/* ========================================================================== */
/* Dummy socket routines. These are the points where we spoof an Ethernet */
/* network. */
/* -------------------------------------------------------------------------- */
 
 
/* ========================================================================= */
/* TX LOGIC */
/*---------------------------------------------------------------------------*/
186,9 → 195,6
{
struct eth_device *eth = dat;
int bAdvance = 1;
#if HAVE_ETH_PHY
struct sockaddr_ll sll;
#endif /* HAVE_ETH_PHY */
long nwritten = 0;
unsigned long read_word;
 
263,7 → 269,6
/* stay in this state if (TXEN && !READY) */
break;
case ETH_TXSTATE_READFIFO:
#if 1
if (eth->tx.bytes_sent < eth->tx.packet_length)
{
read_word =
277,14 → 282,6
eth->tx_buff[eth->tx.bytes_sent + 3] = (unsigned char) (read_word);
eth->tx.bytes_sent += 4;
}
#else
if (eth->tx.bytes_sent < eth->tx.packet_length)
{
eth->tx_buff[eth->tx.bytes_sent] =
eval_direct8 (eth->tx.bytes_sent + eth->tx.bd_addr, 0, 0);
eth->tx.bytes_sent += 1;
}
#endif
else
{
eth->tx.state = ETH_TXSTATE_TRANSMIT;
297,14 → 294,10
case ETH_RTX_FILE:
nwritten = write (eth->txfd, eth->tx_buff, eth->tx.packet_length);
break;
#if HAVE_ETH_PHY
case ETH_RTX_SOCK:
memset (&sll, 0, sizeof (sll));
sll.sll_ifindex = eth->ifr.ifr_ifindex;
nwritten =
sendto (eth->rtx_sock, eth->tx_buff, eth->tx.packet_length, 0,
(struct sockaddr *) &sll, sizeof (sll));
#endif /* HAVE_ETH_PHY */
case ETH_RTX_TAP:
printf ("Writing TAP\n");
nwritten = write (eth->rtx_fd, eth->tx_buff, eth->tx.packet_length);
break;
}
 
/* set BD status */
332,7 → 325,10
TEST_FLAG (eth->regs.int_mask, ETH_INT_MASK, TXB_M))
{
if (TEST_FLAG (eth->tx.bd, ETH_TX_BD, IRQ))
report_interrupt (eth->mac_int);
{
printf ("ETH_TXSTATE_TRANSMIT interrupt\n");
report_interrupt (eth->mac_int);
}
}
 
/* advance to next BD */
367,8 → 363,10
eth_controller_rx_clock (void *dat)
{
struct eth_device *eth = dat;
long nread;
unsigned long send_word;
long nread = 0;
unsigned long send_word;
struct pollfd fds[1];
int n;
 
 
switch (eth->rx.state)
378,7 → 376,8
break;
 
case ETH_RXSTATE_WAIT4BD:
eth->rx.bd = eth->regs.bd_ram[eth->rx.bd_index];
 
eth->rx.bd = eth->regs.bd_ram[eth->rx.bd_index];
eth->rx.bd_addr = eth->regs.bd_ram[eth->rx.bd_index + 1];
 
if (TEST_FLAG (eth->rx.bd, ETH_RX_BD, READY))
412,19 → 411,47
}
else
{
nread =
recv (eth->rtx_sock, eth->rx_buff, ETH_MAXPL, /*MSG_PEEK | */
MSG_DONTWAIT);
if (nread > 0)
/* Poll to see if there is data to read */
struct pollfd fds[1];
int n;
 
fds[0].fd = eth->rtx_fd;
fds[0].events = POLLIN;
n = poll (fds, 1, 0);
if (n < 0)
{
SET_FLAG (eth->regs.int_source, ETH_INT_SOURCE, BUSY);
if (TEST_FLAG (eth->regs.int_mask, ETH_INT_MASK, BUSY_M))
report_interrupt (eth->mac_int);
fprintf (stderr, "Warning: Poll of WAIT4BD failed %s: ignored.\n",
strerror (errno));
}
else if ((n > 0) && ((fds[0].revents & POLLIN) == POLLIN))
{
printf ("Reading TAP\n");
nread = read (eth->rtx_fd, eth->rx_buff, ETH_MAXPL);
 
if (nread < 0)
{
fprintf (stderr,
"Warning: Read of WAIT4BD failed %s: ignored\n",
strerror (errno));
}
else if (nread > 0)
{
SET_FLAG (eth->regs.int_source, ETH_INT_SOURCE, BUSY);
 
if (TEST_FLAG (eth->regs.int_mask, ETH_INT_MASK, BUSY_M))
{
printf ("ETH_RXSTATE_WAIT4BD interrupt\n");
report_interrupt (eth->mac_int);
}
}
}
}
 
break;
 
case ETH_RXSTATE_RECV:
 
switch (eth->rtx_type)
{
case ETH_RTX_FILE:
434,7 → 461,8
sizeof (eth->rx.packet_length)) <
sizeof (eth->rx.packet_length))
{
/* TODO: just do what real ethernet would do (some kind of error state) */
/* TODO: just do what real ethernet would do (some kind of error
state) */
sim_done ();
break;
}
467,22 → 495,41
 
break;
 
case ETH_RTX_SOCK:
nread = recv (eth->rtx_sock, eth->rx_buff, ETH_MAXPL, MSG_DONTWAIT);
 
if (nread == 0)
case ETH_RTX_TAP:
/* Poll to see if there is data to read */
fds[0].fd = eth->rtx_fd;
fds[0].events = POLLIN;
n = poll (fds, 1, 0);
if (n < 0)
{
break;
fprintf (stderr,
"Warning: Poll of RXTATE_RECV failed %s: ignored.\n",
strerror (errno));
}
else if (nread < 0)
else if ((n > 0) && ((fds[0].revents & POLLIN) == POLLIN))
{
if (errno != EAGAIN)
printf ("Reading TAP\n");
nread = read (eth->rtx_fd, eth->rx_buff, ETH_MAXPL);
 
if (nread < 0)
{
break;
fprintf (stderr,
"Warning: Read of RXTATE_RECV failed %s: ignored\n",
strerror (errno));
}
else
break;
else if (nread > 0)
{
SET_FLAG (eth->regs.int_source, ETH_INT_SOURCE, BUSY);
 
if (TEST_FLAG (eth->regs.int_mask, ETH_INT_MASK, BUSY_M))
{
printf ("ETH_RXTATE_RECV interrupt\n");
report_interrupt (eth->mac_int);
}
}
}
 
/* If not promiscouos mode, check the destination address */
if (!TEST_FLAG (eth->regs.moder, ETH_MODER, PRO))
{
514,7 → 561,6
break;
 
case ETH_RXSTATE_WRITEFIFO:
#if 1
send_word = ((unsigned long) eth->rx_buff[eth->rx.bytes_read] << 24) |
((unsigned long) eth->rx_buff[eth->rx.bytes_read + 1] << 16) |
((unsigned long) eth->rx_buff[eth->rx.bytes_read + 2] << 8) |
523,12 → 569,6
/* update counters */
eth->rx.bytes_left -= 4;
eth->rx.bytes_read += 4;
#else
set_direct8 (eth->rx.bd_addr + eth->rx.bytes_read,
eth->rx_buff[eth->rx.bytes_read], 0, 0);
eth->rx.bytes_left -= 1;
eth->rx.bytes_read += 1;
#endif
 
if (eth->rx.bytes_left <= 0)
{
556,6 → 596,7
if ((TEST_FLAG (eth->regs.int_mask, ETH_INT_MASK, RXB_M)) &&
(TEST_FLAG (eth->rx.bd, ETH_RX_BD, IRQ)))
{
printf ("ETH_RXSTATE_WRITEFIFO interrupt\n");
report_interrupt (eth->mac_int);
}
 
615,135 → 656,140
 
/* ========================================================================= */
 
/*
Reset. Initializes all registers to default and places devices in
memory address space.
*/
 
/* -------------------------------------------------------------------------- */
/*!Reset the Ethernet.
 
Open the correct type of simulation interface to the outside world.
 
Initialize all registers to default and places devices in memory address
space.
 
@param[in] dat The Ethernet interface data structure. */
/* -------------------------------------------------------------------------- */
static void
eth_reset (void *dat)
{
struct eth_device *eth = dat;
#if HAVE_ETH_PHY
int j;
struct sockaddr_ll sll;
#endif /* HAVE_ETH_PHY */
struct ifreq ifr;
 
if (eth->baseaddr != 0)
printf ("Resetting Ethernet\n");
 
/* Nothing to do if we do not have a base address set.
 
TODO: Surely this should test for being enabled? */
if (0 == eth->baseaddr)
{
switch (eth->rtx_type)
return;
}
 
switch (eth->rtx_type)
{
case ETH_RTX_FILE:
 
/* (Re-)open TX/RX files */
if (eth->rxfd >= 0)
{
case ETH_RTX_FILE:
/* (Re-)open TX/RX files */
if (eth->rxfd > 0)
close (eth->rxfd);
if (eth->txfd > 0)
close (eth->txfd);
eth->rxfd = eth->txfd = -1;
close (eth->rxfd);
}
 
if ((eth->rxfd = open (eth->rxfile, O_RDONLY)) < 0)
fprintf (stderr, "Cannot open Ethernet RX file \"%s\"\n",
eth->rxfile);
if ((eth->txfd = open (eth->txfile, O_RDWR | O_CREAT | O_APPEND
#if defined(O_SYNC) /* BSD / Mac OS X manual doesn't know about O_SYNC */
| O_SYNC
#endif
,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0)
fprintf (stderr, "Cannot open Ethernet TX file \"%s\"\n",
eth->txfile);
eth->loopback_offset = lseek (eth->txfd, 0, SEEK_END);
if (eth->txfd >= 0)
{
close (eth->txfd);
}
 
break;
#if HAVE_ETH_PHY
case ETH_RTX_SOCK:
/* (Re-)open TX/RX sockets */
if (eth->rtx_sock != 0)
break;
eth->rxfd = -1;
eth->txfd = -1;
 
eth->rtx_sock = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL));
if (eth->rtx_sock == -1)
{
fprintf (stderr, "Cannot open rtx_sock.\n");
return;
}
eth->rxfd = open (eth->rxfile, O_RDONLY);
if (eth->rxfd < 0)
{
fprintf (stderr, "Warning: Cannot open Ethernet RX file \"%s\": %s\n",
eth->rxfile, strerror (errno));
}
 
/* get interface index number */
memset (&(eth->ifr), 0, sizeof (eth->ifr));
strncpy (eth->ifr.ifr_name, eth->sockif, IFNAMSIZ);
if (ioctl (eth->rtx_sock, SIOCGIFINDEX, &(eth->ifr)) == -1)
{
fprintf (stderr, "SIOCGIFINDEX failed!\n");
return;
}
eth->txfd = open (eth->txfile,
#if defined(O_SYNC) /* BSD/MacOS X doesn't know about O_SYNC */
O_SYNC |
#endif
O_RDWR | O_CREAT | O_APPEND,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (eth->txfd < 0)
{
fprintf (stderr, "Warning: Cannot open Ethernet TX file \"%s\": %s\n",
eth->txfile, strerror (errno));
}
 
/* Bind to interface... */
memset (&sll, 0xff, sizeof (sll));
sll.sll_family = AF_PACKET; /* allways AF_PACKET */
sll.sll_protocol = htons (ETH_P_ALL);
sll.sll_ifindex = eth->ifr.ifr_ifindex;
if (bind (eth->rtx_sock, (struct sockaddr *) &sll, sizeof (sll)) ==
-1)
{
fprintf (stderr, "Error bind().\n");
return;
}
eth->loopback_offset = lseek (eth->txfd, 0, SEEK_END);
break;
 
/* first, flush all received packets. */
do
{
fd_set fds;
struct timeval t;
case ETH_RTX_TAP:
 
FD_ZERO (&fds);
FD_SET (eth->rtx_sock, &fds);
memset (&t, 0, sizeof (t));
j = select (FD_SETSIZE, &fds, NULL, NULL, &t);
if (j > 0)
recv (eth->rtx_sock, eth->rx_buff, j, 0);
}
while (j);
 
/* (Re-)open TAP interface if necessary */
if (eth->rtx_fd != 0)
{
break;
#else /* HAVE_ETH_PHY */
case ETH_RTX_SOCK:
fprintf (stderr,
"Ethernet phy not enabled in this configuration. Configure with --enable-ethphy.\n");
exit (1);
break;
#endif /* HAVE_ETH_PHY */
}
 
/* Set registers to default values */
/* Zero all registers */
memset (&(eth->regs), 0, sizeof (eth->regs));
/* Set those with non-zero reset defaults */
eth->regs.moder = 0x0000A000;
eth->regs.ipgt = 0x00000012;
eth->regs.ipgr1 = 0x0000000C;
eth->regs.ipgr2 = 0x00000012;
eth->regs.packetlen = 0x003C0600;
eth->regs.collconf = 0x000F003F;
eth->regs.miimoder = 0x00000064;
eth->regs.tx_bd_num = 0x00000040;
/* Open the TUN/TAP device */
eth->rtx_fd = open ("/dev/net/tun", O_RDWR);
if( eth->rtx_fd < 0 )
{
fprintf (stderr, "Warning: Failed to open TUN/TAP device: %s\n",
strerror (errno));
eth->rtx_fd = 0;
return;
}
 
/* Initialize TX/RX status */
memset (&(eth->tx), 0, sizeof (eth->tx));
memset (&(eth->rx), 0, sizeof (eth->rx));
eth->rx.bd_index = eth->regs.tx_bd_num << 1;
/* Turn it into a specific TAP device. If we haven't specified a
specific (persistent) device, one will be created, but that requires
superuser, or at least CAP_NET_ADMIN capabilities. */
memset (&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP;
strncpy (ifr.ifr_name, eth->tap_dev, IFNAMSIZ);
 
/* Initialize VAPI */
if (eth->base_vapi_id)
if (ioctl (eth->rtx_fd, TUNSETIFF, (void *) &ifr) < 0)
{
vapi_install_multi_handler (eth->base_vapi_id, ETH_NUM_VAPI_IDS,
eth_vapi_read, dat);
fprintf (stderr, "Warning: Failed to set TAP device: %s\n",
strerror (errno));
close (eth->rtx_fd);
eth->rtx_fd = 0;
return;
}
 
PRINTF ("Opened TAP %s\n", ifr.ifr_name);
 
/* Do we need to flush any packets? */
break;
}
}
 
/* ========================================================================= */
/* Set registers to default values */
memset (&(eth->regs), 0, sizeof (eth->regs));
 
eth->regs.moder = 0x0000A000;
eth->regs.ipgt = 0x00000012;
eth->regs.ipgr1 = 0x0000000C;
eth->regs.ipgr2 = 0x00000012;
eth->regs.packetlen = 0x003C0600;
eth->regs.collconf = 0x000F003F;
eth->regs.miimoder = 0x00000064;
eth->regs.tx_bd_num = 0x00000040;
 
/* Clear TX/RX status and initialize buffer descriptor index. */
memset (&(eth->tx), 0, sizeof (eth->tx));
memset (&(eth->rx), 0, sizeof (eth->rx));
 
eth->rx.bd_index = eth->regs.tx_bd_num << 1;
 
/* Initialize VAPI */
if (eth->base_vapi_id)
{
vapi_install_multi_handler (eth->base_vapi_id, ETH_NUM_VAPI_IDS,
eth_vapi_read, dat);
}
} /* eth_reset () */
 
 
/*
Print register values on stdout
*/
1080,10 → 1126,9
/*---------------------------------------------------------------------------*/
/*!Set the Ethernet interface type
 
Currently two types are supported, file and socket. Use of the socket
requires a compile time option.
Currently two types are supported, file and tap.
 
@param[in] val The value to use. 0 for file, 1 for socket.
@param[in] val The value to use. Currently "file" and "tap" are supported.
@param[in] dat The config data structure */
/*---------------------------------------------------------------------------*/
static void
1092,17 → 1137,21
{
struct eth_device *eth = dat;
 
if (val.int_val)
if (0 == strcasecmp ("file", val.str_val))
{
#ifndef HAVE_ETH_PHY
fprintf (stderr, "Warning: Ethernet PHY socket not enabled in this "
"configuration (configure with --enable-ethphy): ignored\n");
return;
#endif
printf ("Ethernet FILE type\n");
eth->rtx_type = ETH_RTX_FILE;
}
 
eth->rtx_type = val.int_val;
 
else if (0 == strcasecmp ("tap", val.str_val))
{
printf ("Ethernet TAP type\n");
eth->rtx_type = ETH_RTX_TAP;
}
else
{
fprintf (stderr, "Warning: Unknown Ethernet type: file assumed.\n");
eth->rtx_type = ETH_RTX_FILE;
}
} /* eth_rtx_type() */
 
 
1205,39 → 1254,35
 
 
/*---------------------------------------------------------------------------*/
/*!Set the Ethernet socket interface
/*!Set the Ethernet TAP device.
 
Free any previously allocated value. This is only meaningful if the socket
interface is configured.
If we are not superuser (or do not have CAP_NET_ADMIN priviledges), then we
must work with a persistent TAP device that is already set up. This option
specifies the device to user.
 
@param[in] val The value to use
@param[in] val The value to use.
@param[in] dat The config data structure */
/*---------------------------------------------------------------------------*/
static void
eth_sockif (union param_val val,
void *dat)
eth_tap_dev (union param_val val,
void *dat)
{
struct eth_device *eth = dat;
 
#ifndef HAVE_ETH_PHY
fprintf (stderr, "Warning: Ethernet PHY socket not enabled in this "
"configuration (configure with --enable-ethphy): "
"sockif ignored\n");
return;
#endif
 
if (NULL != eth->sockif)
if (NULL != eth->tap_dev)
{
free (eth->sockif);
eth->sockif = NULL;
free (eth->tap_dev);
eth->tap_dev = NULL;
}
 
if (!(eth->sockif = strdup (val.str_val)))
eth->tap_dev = strdup (val.str_val);
 
if (NULL == eth->tap_dev)
{
fprintf (stderr, "Peripheral Ethernet: Run out of memory\n");
fprintf (stderr, "ERROR: Peripheral Ethernet: Run out of memory\n");
exit (-1);
}
} /* eth_sockif() */
} /* eth_tap_dev() */
 
 
static void
1410,12 → 1455,12
new->baseaddr = 0;
new->dma = 0;
new->mac_int = 0;
new->rtx_type = 0;
new->rtx_type = ETH_RTX_FILE;
new->rx_channel = 0;
new->tx_channel = 0;
new->rxfile = strdup ("eth_rx");
new->txfile = strdup ("eth_tx");
new->sockif = strdup ("or1ksim_eth");
new->tap_dev = strdup ("");
new->base_vapi_id = 0;
new->phy_addr = 0;
 
1432,7 → 1477,7
{
free (eth->rxfile);
free (eth->txfile);
free (eth->sockif);
free (eth->tap_dev);
free (eth);
return;
}
1466,12 → 1511,12
reg_config_param (sec, "baseaddr", PARAMT_ADDR, eth_baseaddr);
reg_config_param (sec, "dma", PARAMT_INT, eth_dma);
reg_config_param (sec, "irq", PARAMT_INT, eth_irq);
reg_config_param (sec, "rtx_type", PARAMT_INT, eth_rtx_type);
reg_config_param (sec, "rtx_type", PARAMT_STR, eth_rtx_type);
reg_config_param (sec, "rx_channel", PARAMT_INT, eth_rx_channel);
reg_config_param (sec, "tx_channel", PARAMT_INT, eth_tx_channel);
reg_config_param (sec, "rxfile", PARAMT_STR, eth_rxfile);
reg_config_param (sec, "txfile", PARAMT_STR, eth_txfile);
reg_config_param (sec, "sockif", PARAMT_STR, eth_sockif);
reg_config_param (sec, "tap_dev", PARAMT_STR, eth_tap_dev);
reg_config_param (sec, "vapi_id", PARAMT_INT, eth_vapi_id);
reg_config_param (sec, "phy_addr", PARAMT_INT, eth_phy_addr);
 
/peripheral/eth.h
27,10 → 27,6
#ifndef ETH__H
#define ETH__H
 
#if HAVE_ETH_PHY
#include <netpacket/packet.h>
#endif /* HAVE_ETH_PHY */
 
#if HAVE_NET_ETHERNET_H
# include <net/ethernet.h>
#elif defined(HAVE_SYS_ETHERNET_H)
258,7 → 254,7
#define ETH_RXSTATE_WRITEFIFO 30
 
#define ETH_RTX_FILE 0
#define ETH_RTX_SOCK 1
#define ETH_RTX_TAP 1
#define ETH_RTX_VAPI 2
 
#define ETH_MAXPL 0x10000

powered by: WebSVN 2.1.0

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