From 0ef85af791e4c1ac28052be9609e5783774485b4 Mon Sep 17 00:00:00 2001 From: nyatla Date: Thu, 17 Oct 2013 07:48:25 +0000 Subject: [PATCH] =?utf8?q?bugfix=201.Ethernet=E3=83=89=E3=83=A9=E3=82=A4?= =?utf8?q?=E3=83=90=E3=81=AE=E4=BF=AE=E6=AD=A3=E3=80=82=E3=83=9A=E3=83=AA?= =?utf8?q?=E3=83=95=E3=82=A7=E3=83=A9=E3=83=AB=E3=81=AB=E8=A8=AD=E5=AE=9A?= =?utf8?q?=E3=81=99=E3=82=8B=E3=83=91=E3=82=B1=E3=83=83=E3=83=88=E3=82=B5?= =?utf8?q?=E3=82=A4=E3=82=BA=E3=81=8C=E9=96=93=E9=81=95=E3=81=A3=E3=81=A6?= =?utf8?q?=E3=81=84=E3=81=9F=E3=80=82=202.HttpStream=E3=81=AE=E9=80=81?= =?utf8?q?=E4=BF=A1=E3=81=AB=E5=A4=B1=E6=95=97=E3=81=97=E3=81=9F=E5=A0=B4?= =?utf8?q?=E5=90=88=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC=E4=BC=9D=E9=81=94?= =?utf8?q?=E4=B8=8D=E8=89=AF=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.osdn.jp/svnroot/mimic/trunk@336 47198e57-cb75-475f-84c4-a814cd6f29e0 --- lib/Debug/makefile | 1 + lib/Debug/sources.mk | 1 + lib/src/driver/uip/EthDev.h | 2 - lib/src/driver/uip/EthDev_LPC17xx.c | 86 +++++++++++++++++++--------------- lib/src/driver/uip/EtherDev_DP83848C.c | 22 ++++----- lib/src/driver/uip/EtherDev_LAN8720.c | 21 ++++----- lib/src/http/NyLPC_cHttpStream.c | 5 +- lib/src/uip/NyLPC_uip.h | 16 +------ 8 files changed, 75 insertions(+), 79 deletions(-) diff --git a/lib/Debug/makefile b/lib/Debug/makefile index 6989ec9..56c17c3 100644 --- a/lib/Debug/makefile +++ b/lib/Debug/makefile @@ -26,6 +26,7 @@ RM := rm -rf -include src/include/boot/subdir.mk -include src/http/subdir.mk -include src/flash/subdir.mk +-include src/econetlite/subdir.mk -include src/driver/uip/subdir.mk -include src/driver/irq/subdir.mk -include src/driver/flash/subdir.mk diff --git a/lib/Debug/sources.mk b/lib/Debug/sources.mk index 97ddbf6..36dbf18 100644 --- a/lib/Debug/sources.mk +++ b/lib/Debug/sources.mk @@ -31,6 +31,7 @@ src/mimicvm \ src/include/boot \ src/http \ src/flash \ +src/econetlite \ src/driver/uip \ src/driver/irq \ src/driver/flash \ diff --git a/lib/src/driver/uip/EthDev.h b/lib/src/driver/uip/EthDev.h index aeb1695..99189bd 100644 --- a/lib/src/driver/uip/EthDev.h +++ b/lib/src/driver/uip/EthDev.h @@ -42,8 +42,6 @@ extern "C" { Ethernet Device Defines *----------------------------------------------------------------------------*/ #define EthDev_ADDR_SIZE 6 /*!< Ethernet Address size in bytes */ -#define EthDev_MTU_SIZE 1514 /*!< Maximum Transmission Unit */ - /*---------------------------------------------------------------------------- Ethernet Device Configuration and Control Command Defines diff --git a/lib/src/driver/uip/EthDev_LPC17xx.c b/lib/src/driver/uip/EthDev_LPC17xx.c index d9fee8d..58e7a0b 100644 --- a/lib/src/driver/uip/EthDev_LPC17xx.c +++ b/lib/src/driver/uip/EthDev_LPC17xx.c @@ -20,36 +20,46 @@ * TXバッファ ***********************************************************************/ -//TXバッファの先頭アドレス +/** + * TXバッファの先頭アドレス + * Ethernetベースアドレス+RXメモリ領域 + */ #define ETH_TX_BUF_BASE (ETH_BUF_BASE+ETH_FRAG_SIZE*NUM_RX_FRAG) -#define NUM_OF_1536_BUF 3 +#define NUM_OF_MAX_BUF 3 #define NUM_OF_512_BUF 3 #define NUM_OF_256_BUF 4 #define NUM_OF_128_BUF 16 /** + * FULLサイズのEthernetFrame送信メモリのサイズ。 + * ここで最大送信サイズを制限する。 + * 通常は1460+20+20+14=1514バイト + */ +#define MAX_TX_ETHERNET_FRAME_SIZE 1514 + +/** * TXメモリブロックの配置 - * 12360バイト + * 9246バイト */ struct TTxMemoryBlock { struct{ struct NyLPC_TTxBufferHeader h; - NyLPC_TUInt8 b[1536]; - }buf1536[NUM_OF_1536_BUF];//(4+1536)*3=4620 + NyLPC_TUInt8 b[MAX_TX_ETHERNET_FRAME_SIZE]; + }buf_max[NUM_OF_MAX_BUF];//(4+MAX_TX_ETHERNET_FRAME_SIZE(1514))*3=? default=4554 struct{ struct NyLPC_TTxBufferHeader h; NyLPC_TUInt8 b[512]; - }buf512[NUM_OF_512_BUF];//(4+512)*3=1548 + }buf_512[NUM_OF_512_BUF];//(4+512)*3=1548 struct{ struct NyLPC_TTxBufferHeader h; NyLPC_TUInt8 b[256]; - }buf256[NUM_OF_256_BUF];//(4+256)*4=1560 + }buf_256[NUM_OF_256_BUF];//(4+256)*4=1560 struct{ struct NyLPC_TTxBufferHeader h; NyLPC_TUInt8 b[128]; - }buf128[NUM_OF_128_BUF];//(4+128)*16=1584 + }buf_128[NUM_OF_128_BUF];//(4+128)*16=1584 }; //メモリブロックの定義 @@ -63,26 +73,26 @@ int dbg_getNumofUsedTx(void) int x; NyLPC_TUInt8 r1,r2,r3,r4; r1=r2=r3=r4=0; - for(x=0;xbuf1536[x].h.is_lock || _txbuf->buf1536[x].h.ref>0){ + for(x=0;xbuf_max[x].h.is_lock || _txbuf->buf_max[x].h.ref>0){ r1++; continue; } } for(x=0;xbuf512[x].h.is_lock || _txbuf->buf512[x].h.ref>0){ + if(_txbuf->buf_512[x].h.is_lock || _txbuf->buf_512[x].h.ref>0){ r2++; continue; } } for(x=0;xbuf256[x].h.is_lock || _txbuf->buf256[x].h.ref>0){ + if(_txbuf->buf_256[x].h.is_lock || _txbuf->buf_256[x].h.ref>0){ r3++; continue; } } for(x=0;xbuf128[x].h.is_lock || _txbuf->buf128[x].h.ref>0){ + if(_txbuf->buf_128[x].h.is_lock || _txbuf->buf_128[x].h.ref>0){ r4++; continue; } @@ -104,21 +114,21 @@ void EthDev_LPC17xx_prevTxDescriptor(void) TX_STAT_INFO( x ) = 0; } //TXバッファを初期化 - for(x=0;xbuf1536[x].h.is_lock=NyLPC_TUInt8_FALSE; - _txbuf->buf1536[x].h.ref=0; + for(x=0;xbuf_max[x].h.is_lock=NyLPC_TUInt8_FALSE; + _txbuf->buf_max[x].h.ref=0; } for(x=0;xbuf512[x].h.is_lock=NyLPC_TUInt8_FALSE; - _txbuf->buf512[x].h.ref=0; + _txbuf->buf_512[x].h.is_lock=NyLPC_TUInt8_FALSE; + _txbuf->buf_512[x].h.ref=0; } for(x=0;xbuf256[x].h.is_lock=NyLPC_TUInt8_FALSE; - _txbuf->buf256[x].h.ref=0; + _txbuf->buf_256[x].h.is_lock=NyLPC_TUInt8_FALSE; + _txbuf->buf_256[x].h.ref=0; } for(x=0;xbuf128[x].h.is_lock=NyLPC_TUInt8_FALSE; - _txbuf->buf128[x].h.ref=0; + _txbuf->buf_128[x].h.is_lock=NyLPC_TUInt8_FALSE; + _txbuf->buf_128[x].h.ref=0; } /* Set LPC_EMAC Transmit Descriptor Registers. */ LPC_EMAC->TxDescriptor = TX_DESC_BASE; @@ -147,44 +157,44 @@ struct NyLPC_TTxBufferHeader* EthDev_LPC17xx_allocTxBuf(NyLPC_TUInt16 i_hint,NyL } switch(buf_type){ case 3: - for(i=0;ibuf1536[i].h.ref>0 || _txbuf->buf1536[i].h.is_lock){ + if(_txbuf->buf_max[i].h.ref>0 || _txbuf->buf_max[i].h.is_lock){ continue; } - _txbuf->buf1536[i].h.ref++; - *o_size=1536; - return &(_txbuf->buf1536[i].h); + _txbuf->buf_max[i].h.ref++; + *o_size=MAX_TX_ETHERNET_FRAME_SIZE; + return &(_txbuf->buf_max[i].h); } case 2: for(i=0;ibuf512[i].h.ref>0 || _txbuf->buf512[i].h.is_lock){ + if(_txbuf->buf_512[i].h.ref>0 || _txbuf->buf_512[i].h.is_lock){ continue; } *o_size=512; - _txbuf->buf512[i].h.ref++; - return &(_txbuf->buf512[i].h); + _txbuf->buf_512[i].h.ref++; + return &(_txbuf->buf_512[i].h); } case 1: for(i=0;ibuf256[i].h.ref>0 || (_txbuf->buf256[i].h.is_lock)){ + if(_txbuf->buf_256[i].h.ref>0 || (_txbuf->buf_256[i].h.is_lock)){ continue; } *o_size=256; - _txbuf->buf256[i].h.ref++; - return &(_txbuf->buf256[i].h); + _txbuf->buf_256[i].h.ref++; + return &(_txbuf->buf_256[i].h); } default: for(i=0;ibuf128[i].h.ref>0 || (_txbuf->buf128[i].h.is_lock)){ + if(_txbuf->buf_128[i].h.ref>0 || (_txbuf->buf_128[i].h.is_lock)){ continue; } *o_size=128; - _txbuf->buf128[i].h.ref++; - return &(_txbuf->buf128[i].h); + _txbuf->buf_128[i].h.ref++; + return &(_txbuf->buf_128[i].h); } } return NULL; @@ -279,9 +289,11 @@ void EthDev_LPC17xx_sendTxEthFrame(struct NyLPC_TTxBufferHeader* i_buf,unsigned if (i_size > ETH_FRAG_SIZE){ i_size = ETH_FRAG_SIZE; } + //送信処理 TX_DESC_PACKET( Index ) = ( unsigned long )(i_buf+1); - TX_DESC_CTRL( Index ) = ( i_size | TCTRL_LAST | TCTRL_INT ); + //See UM10360.pdf Table 181. Transmit descriptor control word + TX_DESC_CTRL( Index ) = ((i_size-1) | TCTRL_LAST | TCTRL_INT ); LPC_EMAC->TxProduceIndex = IndexNext; return; } diff --git a/lib/src/driver/uip/EtherDev_DP83848C.c b/lib/src/driver/uip/EtherDev_DP83848C.c index 99207d1..6321ff6 100644 --- a/lib/src/driver/uip/EtherDev_DP83848C.c +++ b/lib/src/driver/uip/EtherDev_DP83848C.c @@ -107,7 +107,7 @@ #define emacWAIT_FOR_LINK_TO_ESTABLISH_MS 500 /* Short delay used in several places during the initialisation process. */ -#define emacSHORT_DELAY_MS 2 +#define emacSHORT_DELAY_MS 10 /* Hardware specific bit definitions. */ #define emacPINSEL2_VALUE ( 0x50150105 ) @@ -200,8 +200,6 @@ static NyLPC_TBool start(const struct NyLPC_TEthAddr* i_eth_addr) EthDev_LPC17xx_prevRxDescriptor(); EthDev_LPC17xx_prevTxDescriptor(); - /* Receive broadcast and perfect match packets */ - LPC_EMAC->RxFilterCtrl = RFC_UCAST_EN | RFC_BCAST_EN | RFC_PERFECT_EN; /* Setup the PHY. */ prvConfigurePHY(); @@ -213,19 +211,19 @@ static NyLPC_TBool start(const struct NyLPC_TEthAddr* i_eth_addr) } /* Receive Broadcast and Perfect Match Packets */ - LPC_EMAC->RxFilterCtrl = RFC_BCAST_EN | RFC_PERFECT_EN; - - /* Reset all interrupts */ - LPC_EMAC->IntClear = 0xffff; - - /* Enable receive and transmit mode of MAC Ethernet core */ - LPC_EMAC->Command |= ( CR_RX_EN | CR_TX_EN ); - LPC_EMAC->MAC1 |= MAC1_REC_EN; + LPC_EMAC->RxFilterCtrl = RFC_BCAST_EN | RFC_PERFECT_EN | RFC_MCAST_EN; //Ethernetの割込み開始設定 NyLPC_cIsr_enterCritical(); { + /* Reset all interrupts */ + LPC_EMAC->IntClear = 0xffff; LPC_EMAC->IntEnable = ( INT_RX_DONE | INT_TX_DONE ); + + /* Enable receive and transmit mode of MAC Ethernet core */ + LPC_EMAC->Command |= ( CR_RX_EN | CR_TX_EN ); + LPC_EMAC->MAC1 |= MAC1_REC_EN; + /* Set the interrupt priority to the max permissible to cause some interrupt nesting. */ NVIC_SetPriority( ENET_IRQn, configEMAC_INTERRUPT_PRIORITY ); @@ -284,7 +282,7 @@ static void prvSetupEMACHardware( void ) /* Initialize MAC control registers. */ LPC_EMAC->MAC1 = MAC1_PASS_ALL; - LPC_EMAC->MAC2 = MAC2_CRC_EN | MAC2_PAD_EN; + LPC_EMAC->MAC2 = MAC2_CRC_EN | MAC2_PAD_EN | MAC2_VLAN_PAD_EN; LPC_EMAC->MAXF = ETH_MAX_FLEN; LPC_EMAC->CLRT = CLRT_DEF; LPC_EMAC->IPGR = IPGR_DEF; diff --git a/lib/src/driver/uip/EtherDev_LAN8720.c b/lib/src/driver/uip/EtherDev_LAN8720.c index c532b31..5a368db 100644 --- a/lib/src/driver/uip/EtherDev_LAN8720.c +++ b/lib/src/driver/uip/EtherDev_LAN8720.c @@ -97,7 +97,7 @@ #define emacWAIT_FOR_LINK_TO_ESTABLISH_MS 500 /* Short delay used in several places during the initialisation process. */ -#define emacSHORT_DELAY_MS 2 +#define emacSHORT_DELAY_MS 10 /* Hardware specific bit definitions. */ #define emacPINSEL2_VALUE ( 0x50150105 ) @@ -194,8 +194,6 @@ static NyLPC_TBool start(const struct NyLPC_TEthAddr* i_eth_addr) EthDev_LPC17xx_prevRxDescriptor(); EthDev_LPC17xx_prevTxDescriptor(); - /* Receive broadcast and perfect match packets */ - LPC_EMAC->RxFilterCtrl = RFC_UCAST_EN | RFC_BCAST_EN | RFC_PERFECT_EN; /* Setup the PHY. */ prvConfigurePHY(); @@ -207,19 +205,18 @@ static NyLPC_TBool start(const struct NyLPC_TEthAddr* i_eth_addr) } /* Receive Broadcast and Perfect Match Packets */ - LPC_EMAC->RxFilterCtrl = RFC_BCAST_EN | RFC_PERFECT_EN; - - /* Reset all interrupts */ - LPC_EMAC->IntClear = 0xffff; - - /* Enable receive and transmit mode of MAC Ethernet core */ - LPC_EMAC->Command |= ( CR_RX_EN | CR_TX_EN ); - LPC_EMAC->MAC1 |= MAC1_REC_EN; + LPC_EMAC->RxFilterCtrl = RFC_BCAST_EN | RFC_PERFECT_EN | RFC_MCAST_EN; //Ethernetの割込み開始設定 NyLPC_cIsr_enterCritical(); { + /* Reset all interrupts */ + LPC_EMAC->IntClear = 0xffff; LPC_EMAC->IntEnable = ( INT_RX_DONE | INT_TX_DONE ); + /* Enable receive and transmit mode of MAC Ethernet core */ + LPC_EMAC->Command |= ( CR_RX_EN | CR_TX_EN ); + LPC_EMAC->MAC1 |= MAC1_REC_EN; + /* Set the interrupt priority to the max permissible to cause some interrupt nesting. */ NVIC_SetPriority( ENET_IRQn, configEMAC_INTERRUPT_PRIORITY ); @@ -279,7 +276,7 @@ static void prvSetupEMACHardware( void ) /* Initialize MAC control registers. */ LPC_EMAC->MAC1 = MAC1_PASS_ALL; - LPC_EMAC->MAC2 = MAC2_CRC_EN | MAC2_PAD_EN; + LPC_EMAC->MAC2 = MAC2_CRC_EN | MAC2_PAD_EN | MAC2_VLAN_PAD_EN; LPC_EMAC->MAXF = ETH_MAX_FLEN; LPC_EMAC->CLRT = CLRT_DEF; LPC_EMAC->IPGR = IPGR_DEF; diff --git a/lib/src/http/NyLPC_cHttpStream.c b/lib/src/http/NyLPC_cHttpStream.c index c49361d..e359921 100644 --- a/lib/src/http/NyLPC_cHttpStream.c +++ b/lib/src/http/NyLPC_cHttpStream.c @@ -168,7 +168,10 @@ static NyLPC_TBool write_func(void* i_inst,const void* i_data,NyLPC_TInt32 i_len memcpy(inst->txb+inst->tx_len,src,free_size); inst->tx_len+=free_size; //書き込み - flush_func(i_inst); + if(!flush_func(i_inst)){ + //書込みエラー・・・ + return NyLPC_TBool_FALSE; + } //読み出し位置の調整 l-=free_size; src+=free_size; diff --git a/lib/src/uip/NyLPC_uip.h b/lib/src/uip/NyLPC_uip.h index 67f9b3b..85ff27a 100644 --- a/lib/src/uip/NyLPC_uip.h +++ b/lib/src/uip/NyLPC_uip.h @@ -155,21 +155,7 @@ NyLPC_TUInt16 NyLPC_uip_chksum(NyLPC_TUInt16 sum, const NyLPC_TUInt8 *data, NyLP */ #define UIP_MAXRTX 8 -/** - * The maximum number of times a SYN segment should be retransmitted - * before a connection request should be deemed to have been - * unsuccessful. - * - * This should not need to be changed. - */ -#define UIP_MAXSYNRTX 5 -/** - * How long a connection should stay in the TIME_WAIT state. - * - * This configiration option has no real implication, and it should be - * left untouched. - */ -#define UIP_TIME_WAIT_TIMEOUT 120 + -- 2.11.0