Commit 194dbb15 authored by hongming's avatar hongming

add ext config.

    Change the network parameters in dev/ext_config.c.
parent fb0c83e3
...@@ -9,7 +9,8 @@ obj-$(CONFIG_WR_NODE) += \ ...@@ -9,7 +9,8 @@ obj-$(CONFIG_WR_NODE) += \
dev/sfp.o \ dev/sfp.o \
dev/devicelist.o \ dev/devicelist.o \
dev/rxts_calibrator.o \ dev/rxts_calibrator.o \
dev/flash.o dev/flash.o\
dev/ext_config.o
obj-$(CONFIG_WR_SWITCH) += dev/timer-wrs.o dev/ad9516.o obj-$(CONFIG_WR_SWITCH) += dev/timer-wrs.o dev/ad9516.o
...@@ -32,4 +33,3 @@ $(pfilter-y): tools/pfilter-builder ...@@ -32,4 +33,3 @@ $(pfilter-y): tools/pfilter-builder
tools/pfilter-builder: tools/pfilter-builder:
$(MAKE) -C tools pfilter-builder $(MAKE) -C tools pfilter-builder
#include <string.h>
#include "endpoint.h"
#include "hw/ext-config.h"
#include "ext_config.h"
void ext_config(unsigned char *IP,unsigned char *MAC)
{
unsigned int *ext_tmp;
unsigned int tmp;
ext_tmp = (unsigned int *)(BASE_EXT_CFG + EXT_MAC_HIGH16);
tmp = (*MAC << 8) | (*(MAC+1));
*ext_tmp = tmp;
ext_tmp = (unsigned int *)(BASE_EXT_CFG + EXT_MAC_LOW32);
tmp = (*(MAC+2) << 24) | (*(MAC+3) << 16) | (*(MAC+4) << 8) | (*(MAC+5));
*ext_tmp = tmp;
ext_tmp = (unsigned int *)(BASE_EXT_CFG + EXT_IP_ADDR);
tmp = (*IP << 24) | (*(IP+1) << 16) | (*(IP+2) << 8) | (*(IP+3));
*ext_tmp = tmp;
ext_tmp = (unsigned int *)(BASE_EXT_CFG + EXT_UDP_RX_PORT);
tmp = 60000;
*ext_tmp = tmp;
ext_tmp = (unsigned int *)(BASE_EXT_CFG + EXT_UDP_TX_SRC_PORT);
tmp = 60001;
*ext_tmp = tmp;
ext_tmp = (unsigned int *)(BASE_EXT_CFG + EXT_UDP_TX_DST_PORT);
tmp = 60002;
*ext_tmp = tmp;
ext_tmp = (unsigned int *)(BASE_EXT_CFG + EXT_UDP_TX_DST_IP);
tmp = 0xC0A80001;
*ext_tmp = tmp;
ext_tmp = (unsigned int *)(BASE_EXT_CFG + EXT_UDP_TX_DST_MAC_HIGH16);
tmp = 0x9890;
*ext_tmp = tmp;
ext_tmp = (unsigned int *)(BASE_EXT_CFG + EXT_UDP_TX_DST_MAC_LOW32);
tmp = 0x96aa9e04;
*ext_tmp = tmp;
ext_tmp = (unsigned int *)(BASE_EXT_CFG + EXT_TCP_LOCAL_PORT);
tmp = 8000;
*ext_tmp = tmp;
}
#ifndef __EXT_CONFIG_H
#define __EXT_CONFIG_H
#include <stdint.h>
void ext_config(unsigned char *IP,unsigned char *MAC);
#endif
...@@ -14,7 +14,13 @@ ...@@ -14,7 +14,13 @@
/* These are implementation specific */ /* These are implementation specific */
#define EXT_MAC_HIGH16 16 #define EXT_MAC_HIGH16 16
#define EXT_MAC_LOW32 20 #define EXT_MAC_LOW32 20
#define EXT_IPV4 24 #define EXT_IP_ADDR 24
#define EXT_PORT 28 #define EXT_UDP_RX_PORT 28
#define EXT_UDP_TX_SRC_PORT 32
#define EXT_UDP_TX_DST_PORT 36
#define EXT_UDP_TX_DST_IP 40
#define EXT_UDP_TX_DST_MAC_HIGH16 44
#define EXT_UDP_TX_DST_MAC_LOW32 48
#define EXT_TCP_LOCAL_PORT 52
#endif #endif
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
#include "ptpd_netif.h" #include "ptpd_netif.h"
#include "hw/memlayout.h" #include "hw/memlayout.h"
#include "hw/etherbone-config.h" #include "hw/etherbone-config.h"
#include "hw/ext-config.h" #include "ext_config.h"
#ifndef htons #ifndef htons
#define htons(x) x #define htons(x) x
#endif #endif
int needIP = 1; int needIP = 0;
static uint8_t myIP[4]; static uint8_t myIP[4];
static wr_socket_t *ipv4_socket; static wr_socket_t *ipv4_socket;
...@@ -43,7 +43,7 @@ void ipv4_init(void) ...@@ -43,7 +43,7 @@ void ipv4_init(void)
wr_sockaddr_t saddr; wr_sockaddr_t saddr;
/* Reset => need a fresh IP */ /* Reset => need a fresh IP */
needIP = 1; needIP = 0;
/* Configure socket filter */ /* Configure socket filter */
memset(&saddr, 0, sizeof(saddr)); memset(&saddr, 0, sizeof(saddr));
...@@ -92,22 +92,17 @@ void setIP(unsigned char *IP) ...@@ -92,22 +92,17 @@ void setIP(unsigned char *IP)
{ {
volatile unsigned int *eb_ip = volatile unsigned int *eb_ip =
(unsigned int *)(BASE_ETHERBONE_CFG + EB_IPV4); (unsigned int *)(BASE_ETHERBONE_CFG + EB_IPV4);
volatile unsigned int *ext_ip =
(unsigned int *)(BASE_EXT_CFG + EXT_IPV4);
unsigned int ip; unsigned int ip;
unsigned char mac[6];
memcpy(myIP, IP, 4); memcpy(myIP, IP, 4);
ip = (myIP[0] << 24) | (myIP[1] << 16) | (myIP[2] << 8) | (myIP[3]); ip = (myIP[0] << 24) | (myIP[1] << 16) | (myIP[2] << 8) | (myIP[3]);
while (*eb_ip != ip) get_mac_addr(mac);
*eb_ip = ip; *eb_ip = ip;
while (*ext_ip != ip) ext_config(IP,mac);
*ext_ip = ip;
needIP = 0;
needIP = (ip == 0);
if (!needIP) {
bootp_retry = 0;
bootp_timer = 0;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment