summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bsp/ls1cdev/applications/application.c3
-rw-r--r--bsp/ls1cdev/drivers/net/debug.h5
-rw-r--r--bsp/ls1cdev/drivers/net/mii.c9
-rw-r--r--bsp/ls1cdev/drivers/net/mii.h5
-rw-r--r--bsp/ls1cdev/drivers/net/ping.c182
-rw-r--r--bsp/ls1cdev/drivers/net/synopGMAC.c5
-rw-r--r--bsp/ls1cdev/drivers/net/synopGMAC.h4
-rw-r--r--bsp/ls1cdev/drivers/net/synopGMAC_Host.h88
-rw-r--r--bsp/ls1cdev/drivers/net/types.h5
9 files changed, 38 insertions, 268 deletions
diff --git a/bsp/ls1cdev/applications/application.c b/bsp/ls1cdev/applications/application.c
index 333a335e31..61672edfca 100644
--- a/bsp/ls1cdev/applications/application.c
+++ b/bsp/ls1cdev/applications/application.c
@@ -21,9 +21,10 @@
void rt_init_thread_entry(void *parameter)
{
-
/* initialization RT-Thread Components */
rt_components_init();
+
+ // ����EMAC��ʼ��
rt_hw_eth_init();
}
diff --git a/bsp/ls1cdev/drivers/net/debug.h b/bsp/ls1cdev/drivers/net/debug.h
index 27aa2525c8..d64982fc68 100644
--- a/bsp/ls1cdev/drivers/net/debug.h
+++ b/bsp/ls1cdev/drivers/net/debug.h
@@ -1,3 +1,8 @@
+/*
+ * Copyright (C) chinesebear
+ */
+
+
#ifndef __DEBUG_H__
#define __DEBUG_H__
diff --git a/bsp/ls1cdev/drivers/net/mii.c b/bsp/ls1cdev/drivers/net/mii.c
index 1098f9d42f..1afad9053c 100644
--- a/bsp/ls1cdev/drivers/net/mii.c
+++ b/bsp/ls1cdev/drivers/net/mii.c
@@ -1,6 +1,11 @@
+/*
+ * Copyright (C) chinesebear
+ */
+
+
#include "mii.h"
-#if 1
+
static inline unsigned int mii_nway_result (unsigned int negotiated)
{
unsigned int ret;
@@ -122,4 +127,4 @@ static int mii_link_ok (struct mii_if_info *mii)
return 1;
return 0;
}
-#endif
+
diff --git a/bsp/ls1cdev/drivers/net/mii.h b/bsp/ls1cdev/drivers/net/mii.h
index 3bcc55d0b8..d7a07cfe45 100644
--- a/bsp/ls1cdev/drivers/net/mii.h
+++ b/bsp/ls1cdev/drivers/net/mii.h
@@ -1,3 +1,8 @@
+/*
+ * Copyright (C) chinesebear
+ */
+
+
#ifndef __MII_H__
#define __MII_H__
/* Generic MII registers. */
diff --git a/bsp/ls1cdev/drivers/net/ping.c b/bsp/ls1cdev/drivers/net/ping.c
deleted file mode 100644
index cb83212033..0000000000
--- a/bsp/ls1cdev/drivers/net/ping.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * netutils: ping implementation
- */
-
-#include "lwip/opt.h"
-
-#include "lwip/mem.h"
-#include "lwip/icmp.h"
-#include "lwip/netif.h"
-#include "lwip/sys.h"
-#include "lwip/sockets.h"
-#include "lwip/inet.h"
-#include "lwip/inet_chksum.h"
-#include "lwip/ip.h"
-#include <rthw.h>
-#include <rtthread.h>
-
-/**
- * PING_DEBUG: Enable debugging for PING.
- */
-#ifndef PING_DEBUG
-#define PING_DEBUG LWIP_DBG_ON
-#endif
-
-/** ping receive timeout - in milliseconds */
-#define PING_RCV_TIMEO 1000
-/** ping delay - in milliseconds */
-#define PING_DELAY 100
-
-/** ping identifier - must fit on a u16_t */
-#ifndef PING_ID
-#define PING_ID 0xAFAF
-#endif
-
-/** ping additional data size to include in the packet */
-#ifndef PING_DATA_SIZE
-#define PING_DATA_SIZE 32
-#endif
-
-/* ping variables */
-static u16_t ping_seq_num;
-struct _ip_addr
-{
- rt_uint8_t addr0, addr1, addr2, addr3;
-};
-
-/** Prepare a echo ICMP request */
-static void ping_prepare_echo( struct icmp_echo_hdr *iecho, u16_t len)
-{
- size_t i;
- size_t data_len = len - sizeof(struct icmp_echo_hdr);
-
- ICMPH_TYPE_SET(iecho, ICMP_ECHO);
- ICMPH_CODE_SET(iecho, 0);
- iecho->chksum = 0;
- iecho->id = PING_ID;
- iecho->seqno = htons(++ping_seq_num);
-
- /* fill the additional data buffer with some data */
- for(i = 0; i < data_len; i++)
- {
- ((char*)iecho)[sizeof(struct icmp_echo_hdr) + i] = (char)i;
- }
-
- iecho->chksum = inet_chksum(iecho, len);
-}
-
-/* Ping using the socket ip */
-static err_t ping_send(int s, struct ip_addr *addr, int size)
-{
- int err;
- struct icmp_echo_hdr *iecho;
- struct sockaddr_in to;
- size_t ping_size = sizeof(struct icmp_echo_hdr) + size;
- LWIP_ASSERT("ping_size is too big", ping_size <= 0xffff);
-
- iecho = rt_malloc(ping_size);
- if (iecho == RT_NULL)
- {
- return ERR_MEM;
- }
-
- ping_prepare_echo(iecho, (u16_t)ping_size);
-
- to.sin_len = sizeof(to);
- to.sin_family = AF_INET;
- to.sin_addr.s_addr = addr->addr;
-
- err = lwip_sendto(s, iecho, ping_size, 0, (struct sockaddr*)&to, sizeof(to));
- rt_free(iecho);
-
- return (err ? ERR_OK : ERR_VAL);
-}
-
-static void ping_recv(int s)
-{
- char buf[64];
- int fromlen, len;
- struct sockaddr_in from;
- struct ip_hdr *iphdr;
- struct icmp_echo_hdr *iecho;
- struct _ip_addr *addr;
-
- while((len = lwip_recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr*)&from, (socklen_t*)&fromlen)) > 0)
- {
- if (len >= (sizeof(struct ip_hdr)+sizeof(struct icmp_echo_hdr)))
- {
- addr = (struct _ip_addr *)&(from.sin_addr);
- rt_kprintf("ping: recv %d.%d.%d.%d\n", addr->addr0, addr->addr1, addr->addr2, addr->addr3);
-
- iphdr = (struct ip_hdr *)buf;
- iecho = (struct icmp_echo_hdr *)(buf+(IPH_HL(iphdr) * 4));
- if ((iecho->id == PING_ID) && (iecho->seqno == htons(ping_seq_num)))
- {
- return;
- }
- else
- {
- rt_kprintf("ping: drop\n");
- }
- }
- }
-
- if (len <= 0)
- {
- rt_kprintf("ping: timeout\n");
- }
-}
-
-rt_err_t ping(char* target, rt_uint32_t time, rt_size_t size)
-{
- int s;
- int timeout = PING_RCV_TIMEO;
- struct ip_addr ping_target;
- rt_uint32_t send_time;
- struct _ip_addr
- {
- rt_uint8_t addr0, addr1, addr2, addr3;
- } *addr;
-
- send_time = 0;
-
- if(size == 0)
- size = PING_DATA_SIZE;
-
- if (inet_aton(target, (struct in_addr*)&ping_target) == 0) return -RT_ERROR;
- addr = (struct _ip_addr*)&ping_target;
-
- if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0)
- {
- rt_kprintf("create socket failled\n");
- return -RT_ERROR;
- }
-
- lwip_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
-
- while (1)
- {
- if (ping_send(s, &ping_target, size) == ERR_OK)
- {
- rt_kprintf("ping: send %d.%d.%d.%d\n", addr->addr0, addr->addr1, addr->addr2, addr->addr3);
- ping_recv(s);
- }
- else
- {
- rt_kprintf("ping: send %d.%d.%d.%d - error\n", addr->addr0, addr->addr1, addr->addr2, addr->addr3);
- }
-
- send_time ++;
- if (send_time >= time) break; /* send ping times reached, stop */
-
- rt_thread_delay(PING_DELAY); /* take a delay */
- }
-
- lwip_close(s);
-
- return RT_EOK;
-}
-#ifdef RT_USING_FINSH
-#include <finsh.h>
-FINSH_FUNCTION_EXPORT(ping, ping network host)
-#endif
diff --git a/bsp/ls1cdev/drivers/net/synopGMAC.c b/bsp/ls1cdev/drivers/net/synopGMAC.c
index ecf5f49c00..a18b7f263e 100644
--- a/bsp/ls1cdev/drivers/net/synopGMAC.c
+++ b/bsp/ls1cdev/drivers/net/synopGMAC.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright (C) chinesebear
+ */
+
+
#include <rtthread.h>
#include <components.h>
#include <rtdef.h>
diff --git a/bsp/ls1cdev/drivers/net/synopGMAC.h b/bsp/ls1cdev/drivers/net/synopGMAC.h
index 5a14076b3c..e687afee63 100644
--- a/bsp/ls1cdev/drivers/net/synopGMAC.h
+++ b/bsp/ls1cdev/drivers/net/synopGMAC.h
@@ -1,3 +1,7 @@
+/*
+ * Copyright (C) chinesebear
+ */
+
#ifndef __SYNOPGMAC__H
#define __SYNOPGMAC__H
diff --git a/bsp/ls1cdev/drivers/net/synopGMAC_Host.h b/bsp/ls1cdev/drivers/net/synopGMAC_Host.h
index eef533d839..1e620f47e4 100644
--- a/bsp/ls1cdev/drivers/net/synopGMAC_Host.h
+++ b/bsp/ls1cdev/drivers/net/synopGMAC_Host.h
@@ -1,19 +1,16 @@
+/*
+ * Copyright (C) chinesebear
+ */
+
+
#ifndef SYNOP_GMAC_HOST_H
#define SYNOP_GMAC_HOST_H 1
-/*
-#include <linux/pci.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-*/
#include "synopGMAC_plat.h"
-//#include "synopGMAC_pci_bus_interface.h"
#include "synopGMAC_Dev.h"
#include "mii.h"
-//#define ENH_DESC
-//#define ENH_DESC_8W
struct net_device_stats
@@ -49,96 +46,21 @@ struct net_device_stats
unsigned long tx_compressed;
};
-/*
-struct PmonInet{
- struct device sc_dev;
- void *sc_ih;
-
- struct arpcom arpcom;
-
-// struct mii_data sc_mii; // MII media information
- char dev_addr[6]; //the net interface's address
- unsigned long ioaddr;
-
-// int flags;
-// int mc_count;
-
-};
-*/
-
-
-//typedef struct synopGMACAdapterStruct{
-#if 0
-struct synopGMACAdapterStruct{
-
-/*Device Dependent Data structur*/
-struct synopGMACdevice * synopGMACdev;
-/*Os/Platform Dependent Data Structures*/
-//struct pci_dev * synopGMACpcidev;
-//struct net_device *synopGMACnetdev;
-
-struct net_device_stats synopGMACNetStats;
-//u32 synopGMACPciState[16];
-
-struct PmonInet * PInetdev;
-
-//} synopGMACPciNetworkAdapter;
-}synopGMACNetworkAdapter;
-#endif
typedef struct synopGMACNetworkAdapter{
/*Device Dependent Data structur*/
synopGMACdevice * synopGMACdev;
-/*Os/Platform Dependent Data Structures*/
-//struct pci_dev * synopGMACpcidev;
-
-//struct net_device *synopGMACnetdev;
struct net_device_stats synopGMACNetStats;
-//u32 synopGMACPciState[16];
-//struct PmonInet * PInetdev;
struct mii_if_info mii;
} synopGMACPciNetworkAdapter;
-/*
-static struct mbuf * getmbuf(struct synopGMACNetworkAdapter * tp)
-{
- struct mbuf *m;
-// struct PomnInet * tp = adapter->PInetDev;
-
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if(m == NULL){
- printf("getmbuf failed, Out of memory!!!\n");
- return NULL;
- } else {
- MCLGET(m, M_DONTWAIT);
- if ((m->m_flags & M_EXT) == 0) {
- m_freem(m);
- return NULL;
- }
- if(m->m_data != m->m_ext.ext_buf){
- printf("m_data not equal to ext_buf!!!\n");
- }
- }
-
-#if defined(__mips__)
-
-// pci_sync_cache(tp->sc_pc, (vm_offset_t)tp->tx_buffer[entry], len, SYNC_W);
- ;
-#define RFA_ALIGNMENT_FUDGE 2
- m->m_data += RFA_ALIGNMENT_FUDGE;
-#else
- m->m_data += RFA_ALIGNMENT_FUDGE;
-#endif
- return m;
-}
-*/
diff --git a/bsp/ls1cdev/drivers/net/types.h b/bsp/ls1cdev/drivers/net/types.h
index 57f89f3f45..ae53dac777 100644
--- a/bsp/ls1cdev/drivers/net/types.h
+++ b/bsp/ls1cdev/drivers/net/types.h
@@ -1,3 +1,8 @@
+/*
+ * Copyright (C) chinesebear
+ */
+
+
#ifndef __TYPES__H
#define __TYPES__H