Add E1000 PIC NIC driver from Yu Qiang
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3638 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
cb057c36ea
commit
f2fcf596a0
@ -1764,3 +1764,9 @@
|
||||
|
||||
* lib/drivers/cc1101: Add initial, functional CC1101 wireless driver
|
||||
(contributed by Uros Platise)
|
||||
* arch/mips and configs/pcblogic-pic32mx: The MicroChip PIC32MX port is now
|
||||
code complete and ready to begin testing.
|
||||
* drivers/net/e1000.c/h: A PCI-based E1000 ethernet driver submitted
|
||||
by Yu Qiang.
|
||||
* lib/net/lib_inetaddr.c: An implementatino of the inet_addr() function
|
||||
submitted y Yu Qiang.
|
@ -8,7 +8,7 @@
|
||||
<tr align="center" bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
|
||||
<p>Last Updated: March 18, 2011</p>
|
||||
<p>Last Updated: May 21, 2011</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -603,7 +603,7 @@ mount -t vfat /dev/ram1 /tmp
|
||||
The behavior of this script depends upon three things:
|
||||
<ul>
|
||||
<li>The configuration settings then installed configuration.
|
||||
<li>The <code>genromfs<code> tool (available from <a href="http://romfs.sourceforge.net">http://romfs.sourceforge.net</a>).
|
||||
<li>The <code>genromfs</code> tool (available from <a href="http://romfs.sourceforge.net">http://romfs.sourceforge.net</a>).
|
||||
<li>The file <code>apps/nshlib/rcS.template</code>
|
||||
(OR, if <code>CONFIG_NSH_ARCHROMFS</code> is defined <code>include/arch/board/rcs.template</code>.
|
||||
</ul>
|
||||
@ -620,7 +620,7 @@ mount -t vfat /dev/ram1 /tmp
|
||||
<p>
|
||||
<b>NOTE</b>:
|
||||
<code>apps/nshlib/rcS.template</code> generates the standard, default <code>nsh_romfsimg.h</code> file.
|
||||
If <code>CONFIG_NSH_ARCHROMFS<code> is defined in the NuttX configuration file, then a custom, board-specific <code>nsh_romfsimg.h</code> file residing in <code>configs/<board>/include</code> will be used.
|
||||
If <code>CONFIG_NSH_ARCHROMFS</code> is defined in the NuttX configuration file, then a custom, board-specific <code>nsh_romfsimg.h</code> file residing in <code>configs/<board>/include</code> will be used.
|
||||
NOTE when the OS is configured, <code>include/arch/board</code> will be linked to <code>configs/<board>/include</code>.
|
||||
</p>
|
||||
<p>
|
||||
@ -985,21 +985,46 @@ help
|
||||
|
||||
<p><b>Command Syntax:</b></p>
|
||||
<ul><pre>
|
||||
ifconfig
|
||||
ifconfig [nic_name [ip_address]]
|
||||
</pre></ul>
|
||||
<p>
|
||||
<b>Synopsis</b>.
|
||||
Show the current configuration of the network, for example:
|
||||
Two forms of the <code>ifconfig</code>command are supported:
|
||||
</p>
|
||||
<ul><pre>
|
||||
<ol>
|
||||
<li>
|
||||
<p>
|
||||
With one or no arguments, <code>ifconfig</code> will shows the
|
||||
current configuration of the network and, perhaps, the status of ethernet
|
||||
device:
|
||||
</p>
|
||||
<ul><pre>
|
||||
ifconfig
|
||||
ifconfig [nic_name]
|
||||
</pre></ul>
|
||||
<p>
|
||||
As an example:
|
||||
</p>
|
||||
<ul><pre>
|
||||
nsh> ifconfig
|
||||
eth0 HWaddr 00:18:11:80:10:06
|
||||
IPaddr:10.0.0.2 DRaddr:10.0.0.1 Mask:255.255.255.0
|
||||
</pre></ul>
|
||||
<p>
|
||||
if uIP statistics are enabled (<code>CONFIG_NET_STATISTICS</code>), then
|
||||
this command will also show the detailed state of uIP.
|
||||
</p>
|
||||
<p>
|
||||
If uIP statistics are enabled (<code>CONFIG_NET_STATISTICS</code>), then
|
||||
this command will also show the detailed state of uIP.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
If both the network interface name and an IP address are supplied as arguments,
|
||||
then <code>ifconfig</code> will set the address of the ethernet device:
|
||||
</p>
|
||||
<ul><pre>
|
||||
ifconfig nic_name ip_address
|
||||
</pre><ul>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
@ -1631,7 +1656,7 @@ sh <script-path>
|
||||
<p>
|
||||
<b>Synopsis</b>.
|
||||
Execute the sequence of NSH commands in the file referred
|
||||
to by <code><script-path>.
|
||||
to by <code><script-path></code>.
|
||||
</p>
|
||||
|
||||
<table width ="100%">
|
||||
@ -1696,7 +1721,7 @@ unset <name>
|
||||
<p>
|
||||
<b>Synopsis</b>.
|
||||
Remove the value associated with the environment variable
|
||||
<code><name>. Example:
|
||||
<code><name></code>. Example:
|
||||
</p>
|
||||
<ul><pre>
|
||||
nsh> echo $foobar
|
||||
|
@ -85,6 +85,7 @@ void up_initialize(void)
|
||||
extern pidhash_t g_pidhash[];
|
||||
extern void up_register_bridges(void);
|
||||
extern void vnet_initialize(void);
|
||||
extern void e1000_mod_init(void);
|
||||
|
||||
// intialize the current_task to g_idletcb
|
||||
current_task = g_pidhash[PIDHASH(0)].tcb;
|
||||
@ -92,12 +93,19 @@ void up_initialize(void)
|
||||
// setup console
|
||||
up_register_bridges();
|
||||
|
||||
// setup net device
|
||||
#ifdef CONFIG_NET_VNET
|
||||
// setup vnet device
|
||||
vnet_initialize();
|
||||
#endif
|
||||
|
||||
// setup COM device
|
||||
up_serialinit();
|
||||
|
||||
#ifdef CONFIG_NET_E1000
|
||||
// setup e1000
|
||||
e1000_mod_init();
|
||||
#endif
|
||||
|
||||
// enable interrupt
|
||||
sti();
|
||||
}
|
||||
|
@ -154,4 +154,19 @@ int rtos_sem_down(void *sem)
|
||||
return sem_wait(sem);
|
||||
}
|
||||
|
||||
void rtos_stop_running(void)
|
||||
{
|
||||
extern void e1000_mod_exit(void);
|
||||
|
||||
cli();
|
||||
|
||||
#ifdef CONFIG_NET_E1000
|
||||
e1000_mod_exit();
|
||||
#endif
|
||||
|
||||
while(1) {
|
||||
asm volatile("hlt");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -385,13 +385,28 @@ CONFIG_HEAP_BASE=
|
||||
CONFIG_HEAP_SIZE=
|
||||
|
||||
|
||||
#
|
||||
##########################################
|
||||
# RGMP specific configuration
|
||||
##########################################
|
||||
|
||||
#
|
||||
# VNET
|
||||
#
|
||||
CONFIG_NET_VNET=y
|
||||
CONFIG_VNET_NINTERFACES=1
|
||||
|
||||
#
|
||||
# Serial port
|
||||
#
|
||||
CONFIG_COM1=y
|
||||
CONFIG_COM2=y
|
||||
CONFIG_COM3=n
|
||||
CONFIG_COM4=n
|
||||
CONFIG_E1000=n
|
||||
|
||||
#
|
||||
# E1000
|
||||
#
|
||||
CONFIG_NET_E1000=n
|
||||
CONFIG_E1000_N_TX_DESC=128
|
||||
CONFIG_E1000_N_RX_DESC=128
|
||||
CONFIG_E1000_BUFF_SIZE=0x800
|
||||
|
@ -415,13 +415,28 @@ CONFIG_HEAP_BASE=
|
||||
CONFIG_HEAP_SIZE=
|
||||
|
||||
|
||||
#
|
||||
##########################################
|
||||
# RGMP specific configuration
|
||||
##########################################
|
||||
|
||||
#
|
||||
# VNET
|
||||
#
|
||||
CONFIG_NET_VNET=y
|
||||
CONFIG_VNET_NINTERFACES=1
|
||||
|
||||
#
|
||||
# Serial port
|
||||
#
|
||||
CONFIG_COM1=y
|
||||
CONFIG_COM2=y
|
||||
CONFIG_COM3=n
|
||||
CONFIG_COM4=n
|
||||
CONFIG_E1000=n
|
||||
|
||||
#
|
||||
# E1000
|
||||
#
|
||||
CONFIG_NET_E1000=n
|
||||
CONFIG_E1000_N_TX_DESC=128
|
||||
CONFIG_E1000_N_RX_DESC=128
|
||||
CONFIG_E1000_BUFF_SIZE=0x800
|
||||
|
@ -55,6 +55,10 @@ ifeq ($(CONFIG_NET_VNET),y)
|
||||
CSRCS += vnet.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NET_E1000),y)
|
||||
CSRCS += e1000.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NET_SLIP),y)
|
||||
CSRCS += slip.c
|
||||
endif
|
||||
|
1044
drivers/net/e1000.c
Normal file
1044
drivers/net/e1000.c
Normal file
File diff suppressed because it is too large
Load Diff
123
drivers/net/e1000.h
Normal file
123
drivers/net/e1000.h
Normal file
@ -0,0 +1,123 @@
|
||||
/****************************************************************************
|
||||
* drivers/net/e1000.h
|
||||
*
|
||||
* Copyright (C) 2011 Yu Qiang. All rights reserved.
|
||||
* Author: Yu Qiang <yuq825@gmail.com>
|
||||
*
|
||||
* This file is a part of NuttX:
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __DRIVERS_NET_E1000_H
|
||||
#define __DRIVERS_NET_E1000_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <rgmp/types.h>
|
||||
#include <rgmp/trap.h>
|
||||
#include <rgmp/x86.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/************** PCI ID ***************/
|
||||
|
||||
#define INTEL_VENDERID 0x8086
|
||||
#define E1000_82573L 0x109a
|
||||
#define E1000_82540EM 0x100e
|
||||
#define E1000_82574L 0x10d3
|
||||
#define E1000_82567LM 0x10f5
|
||||
#define E1000_82541PI 0x107c
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
enum e1000_registers {
|
||||
E1000_CTRL = 0x0000, // Device Control
|
||||
E1000_STATUS = 0x0008, // Device Status
|
||||
E1000_CTRL_EXT = 0x0018, // Device Control Extension
|
||||
E1000_FCAL = 0x0028, // Flow Control Address Low
|
||||
E1000_FCAH = 0x002C, // Flow Control Address High
|
||||
E1000_FCT = 0x0030, // Flow Control Type
|
||||
E1000_ICR = 0x00C0, // Interrupt Cause Read
|
||||
E1000_ICS = 0x00C8, // Interrupt Cause Set
|
||||
E1000_IMS = 0x00D0, // Interrupt Mask Set
|
||||
E1000_IMC = 0x00D8, // Interrupt Mask Clear
|
||||
E1000_RCTL = 0x0100, // Receive Control
|
||||
E1000_FCTTV = 0x0170, // Flow Control Transmit Timer Value
|
||||
E1000_TCTL = 0x0400, // Transmit Control
|
||||
E1000_PBA = 0x1000, // Packet Buffer Allocation
|
||||
E1000_FCRTL = 0x2160, // Flow Control Receive Threshold Low
|
||||
E1000_FCRTH = 0x2168, // Flow Control Receive Threshold High
|
||||
E1000_RDBAL = 0x2800, // Rx Descriptor Base Address Low
|
||||
E1000_RDBAH = 0x2804, // Rx Descriptor Base Address High
|
||||
E1000_RDLEN = 0x2808, // Rx Descriptor Length
|
||||
E1000_RDH = 0x2810, // Rx Descriptor Head
|
||||
E1000_RDT = 0x2818, // Rx Descriptor Tail
|
||||
E1000_RXDCTL = 0x2828, // Rx Descriptor Control
|
||||
E1000_TDBAL = 0x3800, // Tx Descriptor Base Address Low
|
||||
E1000_TDBAH = 0x3804, // Tx Descriptor Base Address High
|
||||
E1000_TDLEN = 0x3808, // Tx Descriptor Length
|
||||
E1000_TDH = 0x3810, // Tx Descriptor Head
|
||||
E1000_TDT = 0x3818, // Tx Descriptor Tail
|
||||
E1000_TXDCTL = 0x3828, // Tx Descriptor Control
|
||||
E1000_TPR = 0x40D0, // Total Packets Received
|
||||
E1000_TPT = 0x40D4, // Total Packets Transmitted
|
||||
E1000_RA = 0x5400, // Receive-filter Array
|
||||
};
|
||||
|
||||
/***************** e1000 device structure *****************/
|
||||
|
||||
struct tx_desc {
|
||||
uint64_t base_address;
|
||||
uint16_t packet_length;
|
||||
uint8_t cksum_offset;
|
||||
uint8_t desc_command;
|
||||
uint8_t desc_status;
|
||||
uint8_t cksum_origin;
|
||||
uint16_t special_info;
|
||||
};
|
||||
|
||||
struct rx_desc {
|
||||
uint64_t base_address;
|
||||
uint16_t packet_length;
|
||||
uint16_t packet_cksum;
|
||||
uint8_t desc_status;
|
||||
uint8_t desc_errors;
|
||||
uint16_t vlan_tag;
|
||||
};
|
||||
|
||||
#endif
|
@ -123,7 +123,6 @@ static int vnet_uiptxpoll(struct uip_driver_s *dev);
|
||||
|
||||
/* Interrupt handling */
|
||||
|
||||
static void vnet_receive(FAR struct vnet_driver_s *vnet);
|
||||
static void vnet_txdone(FAR struct vnet_driver_s *vnet);
|
||||
|
||||
/* Watchdog timer expirations */
|
||||
@ -250,7 +249,7 @@ static int vnet_uiptxpoll(struct uip_driver_s *dev)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: vnet_receive
|
||||
* Function: rtos_vnet_recv
|
||||
*
|
||||
* Description:
|
||||
* An interrupt was received indicating the availability of a new RX packet
|
||||
|
@ -33,4 +33,4 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
NET_SRCS = lib_htons.c lib_htonl.c lib_inetntoa.c lib_etherntoa.c
|
||||
NET_SRCS = lib_htons.c lib_htonl.c lib_inetntoa.c lib_etherntoa.c lib_inetaddr.c
|
||||
|
74
lib/net/lib_inetaddr.c
Normal file
74
lib/net/lib_inetaddr.c
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
* lib/net/lib_inetaddr.c
|
||||
*
|
||||
* Copyright (C) 2011 Yu Qiang. All rights reserved.
|
||||
* Author: Yu Qiang <yuq825@gmail.com>
|
||||
*
|
||||
* This file is a part of NuttX:
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* name inet_addr
|
||||
*
|
||||
* Description:
|
||||
* The inet_addr() function converts the string pointed to by cp, in the
|
||||
* standard IPv4 dotted decimal notation, to an integer value suitable for
|
||||
* use as an Internet address.
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
in_addr_t inet_addr(FAR const char *cp)
|
||||
{
|
||||
unsigned int a, b, c, d;
|
||||
uint32_t result;
|
||||
|
||||
sscanf(cp, "%u.%u.%u.%u", &a, &b, &c, &d);
|
||||
result = a << 8;
|
||||
result |= b;
|
||||
result <<= 8;
|
||||
result |= c;
|
||||
result <<= 8;
|
||||
result |= d;
|
||||
return HTONL(result);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user