亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? socket.c

?? 最新版FreeRTOS, 包擴多種開發平臺的移植
?? C
?? 第 1 頁 / 共 4 頁
字號:
/*
********************************************************************************
* TERN, Inc.
* (c) Copyright 2005, http://www.tern.com
*
* MODIFIED BY RICHARD BARRY TO ADD SEMAPHORE FOR COMMUNICATION BETWEEN THE 
* WIZnet ISR AND THE HTTP TASK.
*
* - Derived based on development version provided by Wiznet.
*
* Filename : socket.h
* Programmer(s):
* Created : 2002/06/20
* Modified :
*  2002/09/27 : - Renaming
*			       INT_STATUS --> INT_REG
*			       STATUS(i) --> INT_STATUS(i)
*			       C_STATUS(i) --> SOCK_STATUS(i)
*  2003/11/06 : Ported for use with TERN controller.  Note all byte access is at even addresses
*  2005/10/8  : Modified constants for easier initialization.
*
* Description : Header file of W3100A for TERN embedded controller
********************************************************************************
*/
/*
###############################################################################
File Include Section
###############################################################################
*/
#include "i2chip_hw.h" 
#include "socket.h"
#include "types.h"
#include <string.h>
#include <stdio.h>

#include <FreeRTOS.h>
#include <semphr.h>
#include <portasm.h>


/*
###############################################################################
Local Variable Declaration Section
###############################################################################
*/
u_char I_STATUS[4];				// Store Interrupt Status according to channels
u_int Local_Port;				   // Designate Local Port
union un_l2cval	SEQ_NUM;		// Set initial sequence number

u_long SMASK[MAX_SOCK_NUM];   // Variable to store MASK of Tx in each channel,
                              // on setting dynamic memory size.
u_long RMASK[MAX_SOCK_NUM];   // Variable to store MASK of Rx in each channel,
                              // on setting dynamic memory size.
int SSIZE[MAX_SOCK_NUM];      // Maximun Tx memory size by each channel
int RSIZE[MAX_SOCK_NUM];      // Maximun Rx memory size by each channel

u_int SBUFBASEADDRESS[MAX_SOCK_NUM];   // Maximun Tx memory base address by each channel
u_int RBUFBASEADDRESS[MAX_SOCK_NUM];   // Maximun Rx memory base address by each channel

/*
###############################################################################
Function Implementation Section
###############################################################################
*/

/*
********************************************************************************
*               Interrupt handling function of the W3100A
*
* Description :
*   Stores the status information that each function waits for in the global variable I_STATUS
*   for transfer. I_STATUS stores the interrupt status value for each channel.
* Arguments   : None
* Returns     : None
* Note        : Internal Function
********************************************************************************
*/

portBASE_TYPE prvProcessISR( void )
{
unsigned char status;
extern xSemaphoreHandle xTCPSemaphore;
portBASE_TYPE xSwitchRequired = pdFALSE;

#ifdef I2CHIP_WINDOW
u_int current_window = i2chip_get_window();
#endif

status = READ_VALUE(INT_REG);


if (status)
  {
  xSwitchRequired = pdTRUE;
  // channel 0 interrupt(sysinit, sockinit, established, closed, timeout, send_ok, recv_ok)
  if (status & 0x01)
    {
	 I_STATUS[0] = READ_VALUE(INT_STATUS(0));

//	 if (I_STATUS[0] & SESTABLISHED)
//    ISR_ESTABLISHED(0);
//	 if (I_STATUS[0] & SCLOSED)
//    ISR_CLOSED(0);

	 WRITE_VALUE(INT_REG, 0x01);
	 }

  // channel 1 interrupt(sysinit, sockinit, established, closed, timeout, send_ok, recv_ok)
  if (status & 0x02)
    {
	 I_STATUS[1] = READ_VALUE(INT_STATUS(1));

//	 if (I_STATUS[1] & SESTABLISHED)
//    ISR_ESTABLISHED(1);
//	 if (I_STATUS[1] & SCLOSED)
//    ISR_CLOSED(1);

	 WRITE_VALUE(INT_REG, 0x02);
	 }

  // channel 2 interrupt(sysinit, sockinit, established, closed, timeout, send_ok, recv_ok)
  if (status & 0x04)
    {
	 I_STATUS[2] = READ_VALUE(INT_STATUS(2));

//	 if (I_STATUS[2] & SESTABLISHED)
//    ISR_ESTABLISHED(2);
//	 if (I_STATUS[2] & SCLOSED)
//    ISR_CLOSED(2);

	 WRITE_VALUE(INT_REG, 0x04);
	 }

  // channel 3 interrupt(sysinit, sockinit, established, closed, timeout, send_ok, recv_ok)
  if (status & 0x08)
    {
	 I_STATUS[3] = READ_VALUE(INT_STATUS(3));

//	 if (I_STATUS[3] & SESTABLISHED) ISR_ESTABLISHED(3);
//	 if (I_STATUS[3] & SCLOSED) ISR_CLOSED(3);

	 WRITE_VALUE(INT_REG, 0x08);
	 }

  // channel 0 receive interrupt
  if (status & 0x10)
    {
//	 ISR_RX(0);
	 WRITE_VALUE(INT_REG, 0x10);
	 }

  // channel 1 receive interrupt
  if (status & 0x20)
    {
//	 ISR_RX(1);
	 WRITE_VALUE(INT_REG, 0x20);
	 }

  // channel 2 receive interrupt
  if (status & 0x40)
    {
//	 ISR_RX(2);
	 WRITE_VALUE(INT_REG, 0x40);
	 }

  // channel 3 receive interrupt
  if (status & 0x80)
    {
//	 ISR_RX(3);
	 WRITE_VALUE(INT_REG, 0x80);
	 }
  status = READ_VALUE(INT_REG);
  }

WRITE_VALUE(INT_REG, 0xFF);

#ifdef I2CHIP_WINDOW
i2chip_set_window(current_window);
#endif

	if( xSwitchRequired == pdTRUE )
    {
		xSwitchRequired = xSemaphoreGiveFromISR( xTCPSemaphore, pdFALSE );
    }

	return xSwitchRequired;
}

void far interrupt in4_isr_i2chip(void)
{
	if( prvProcessISR() == pdTRUE )
    {
		portEND_SWITCHING_ISR();
    }

    INT_EOI;
}

/*
****************************************************************************************************
*               Established connection interrupt handling function.
*
* Description :
*   Called upon connection establishment, and may be inserted in user code if needed by
*   the programmer.
* Arguments   : None
* Returns     : None
* Note        : Internal Function
****************************************************************************************************
*/
/*
void ISR_ESTABLISHED(SOCKET s)
{
// TO ADD YOUR CODE
}
*/

/*
****************************************************************************************************
*               Closed connection interrupt handling function
*
* Description :
*   Called upon connection closure, and may be inserted in user code if needed by the programmer.
* Arguments   : None
* Returns     : None
* Note        : Internal Function
****************************************************************************************************
*/
/*
void ISR_CLOSED(SOCKET s)
{
// TO ADD YOUR CODE
}
*/

/*
****************************************************************************************************
*               Received data interrupt handling function
*
* Description :
*   Called upon receiving data, and may be inserted in user code if needed by the programmer.
* Arguments   : None
* Returns     : None
* Note        : Internal Function
****************************************************************************************************
*/
/*
void ISR_RX(SOCKET s)
{
// TO ADD YOUR CODE
}
*/

/*
****************************************************************************************************
*              W3100A Initialization Function
*
* Description:  Reset of W3100A S/W and Registeration of i386 interrupt
* Arguments  : None.
* Returns    : None.
* Note       :
****************************************************************************************************
*/
void initW3100A(void)
{

// Install interrupt handler for i2Chip
INT_INIT(in4_isr_i2chip);


Local_Port = 1000;         // This default value will be set if you didn't designate it when you
                           // create a socket. If you don't designate port number and create a
                           // socket continuously, the port number will be assigned with
                           // incremented by one to Local_Port
SEQ_NUM.lVal = 4294967293ul;	// Sets the initial SEQ# to be used for TCP communication.
                           // (It should be ramdom value)
WRITE_VALUE(COMMAND(0), CSW_RESET);   // Software RESET
}

/*
****************************************************************************************************
*               W3100A initialization function
*
* Description :
*   Sets the Tx, Rx memory size by each channel, source MAC, source IP, gateway, and subnet mask
*   to be used by the W3100A to the designated values.
*   May be called when reflecting modified network information or Tx, Rx memory size on the W3100A
*   Include Ping Request for ARP update (In case that a device embedding W3100A is directly
*     connected to Router)
* Arguments  : sbufsize - Tx memory size (00 - 1KByte, 01- 2KBtye, 10 - 4KByte, 11 - 8KByte)
*                          bit 1-0 : Tx memory size of channel #0
*                          bit 3-2 : Tx memory size of channel #1
*                          bit 5-4 : Tx memory size of channel #2
*                          bit 7-6 : Tx memory size of channel #3
*              rbufsize - Rx memory size (00 - 1KByte, 01- 2KBtye, 10 - 4KByte, 11 - 8KByte)
*                          bit 1-0 : Rx memory size of channel #0
*                          bit 3-2 : Rx memory size of channel #1
*                          bit 5-4 : Rx memory size of channel #2
*                          bit 7-6 : Rx memory size of channel #3
* Returns    : None
* Note       : API Function
*              Maximum memory size for Tx, Rx in W3100A is 8KBytes,
*              In the range of 8KBytes, the memory size could be allocated dynamically by
*              each channel
*              Be attentive to sum of memory size shouldn't exceed 8Kbytes
*              and to data transmission and receiption from non-allocated channel may cause
*              some problems.
*              If 8KBytes memory already is assigned to centain channel, other 3 channels
*                couldn't be used, for there's no available memory.
*              If two 4KBytes memory are assigned to two each channels, other 2 channels couldn't
*                be used, for there's no available memory.
*              (Example of memory assignment)
*               sbufsize => 00000011, rbufsize => 00000011 :
*                 Assign 8KBytes for Tx and Rx to channel #0, Cannot use channel #1,#2,#3
*               sbufsize => 00001010, rbufsize => 00001010 :
*                 Assign 4KBytes for Tx and Rx to each channel #0,#1 respectively. Cannot use
*                 channel #2,#3
*               sbufsize => 01010101, rbufsize => 01010101 :
*                 Assign 2KBytes for Tx and Rx to each all channels respectively.
*               sbufsize => 00010110, rbufsize => 01010101 :
*                 Assign 4KBytes for Tx, 2KBytes for Rx to channel #0
*       s          2KBytes for Tx, 2KBytes for Rx to channel #1
*                 2KBytes for Tx, 2KBytes for Rx to channel #2
*                 2KBytes is available exclusively for Rx in channel #3. There's no memory for Tx.
****************************************************************************************************
*/
void sysinit(u_char sbufsize, u_char rbufsize)
{
char i;
int ssum,rsum;

ssum = 0;
rsum = 0;

// Set Tx memory size for each channel
WRITE_VALUE(TX_DMEM_SIZE, sbufsize);

// Set Rx memory size for each channel
WRITE_VALUE(RX_DMEM_SIZE, rbufsize);

// Set Base Address of Tx memory for channel #0
SBUFBASEADDRESS[0] = 0;

// Set Base Address of Rx memory for channel #0
RBUFBASEADDRESS[0] = 0;

// Set maximum memory size for Tx and Rx, mask, base address of memory by each channel
for(i = 0 ; i < MAX_SOCK_NUM; i++)
  {
  SSIZE[i] = 0;
  RSIZE[i] = 0;
  if(ssum < 8192)
	 {
	 switch((sbufsize >> i*2) & 0x03) // Set maximum Tx memory size
		{
		case 0:
		  SSIZE[i] = 1024;
		  SMASK[i] = 0x000003FF;
		  break;

		case 1:
		  SSIZE[i] = 2048;
		  SMASK[i] = 0x000007FF;
		  break;

		case 2:
		  SSIZE[i] = 4096;
		  SMASK[i] = 0x00000FFF;
		  break;

		case 3:
		  SSIZE[i] = 8192;
		  SMASK[i] = 0x00001FFF;
		  break;
		}
	 }
  if(rsum < 8192)
	 {
	 switch((rbufsize >> i*2) & 0x03)  // Set maximum Rx memory size
		{
		case 0:
		  RSIZE[i] = 1024;
		  RMASK[i] = 0x000003FF;
		  break;

		case 1:
		  RSIZE[i] = 2048;
		  RMASK[i] = 0x000007FF;
		  break;

		case 2:
		  RSIZE[i] = 4096;
		  RMASK[i] = 0x00000FFF;
		  break;

		case 3:
		  RSIZE[i] = 8192;
		  RMASK[i] = 0x00001FFF;
		  break;
		}
	 }
  ssum += SSIZE[i];
  rsum += RSIZE[i];

  // Set base address of Tx and Rx memory for channel #1,#2,#3
  if(i != 0)
    {
    SBUFBASEADDRESS[i] = ssum - SSIZE[i];
    RBUFBASEADDRESS[i] = rsum - RSIZE[i];
    }
  }

  WRITE_VALUE(COMMAND(0), CSYS_INIT);

while(!(I_STATUS[0] & SSYS_INIT_OK))
  I2CHIP_POLL_ISR(in4_isr_i2chip);

#ifdef __PING__
  {
  u_char xdata pingbuf[8];
  setIPprotocol(0, IPPROTO_ICMP);
  socket(0, SOCK_IPL_RAW, 3000,0);     // Create a socket for ARP update

  pingbuf[0] = 8;                      // ICMP TYPE
  pingbuf[1] = 0;                      // ICMP CODE
  pingbuf[2] = 0xf7;                   // CHECKSUM (already calculated)
  pingbuf[3] = 0xfd;
  pingbuf[4] = 0;                      // ID
  pingbuf[5] = 1;
  pingbuf[6] = 0;                      // SEQ #
  pingbuf[7] = 1;
  pingbuf[8] = 0;                      // Data 1 Byte

  sendto(0, pingbuf, 9, GATEWAY_PTR,3000);  // Ping Request
  close(0);
  printf("Route MAC Update Success");
  }
#endif
}

/*
****************************************************************************************************
*              Function to set subnet mask
*
* Description:
* Arguments  : addr--> Pointer that has the value to be set
* Returns    : None.
* Note       :
****************************************************************************************************
*/
void setsubmask(u_char * addr)
{
u_char i;
u_char far* sm_ptr = SUBNET_MASK_PTR;   // We can only convert to 'regular'
                                   // pointer if we're confident arithmetic
                                   // won't take us out of current window.

for (i = 0; i < 4; i++)
  {
  WRITE_VALUE(sm_ptr + SA_OFFSET(i), addr[i]);
  }
}

/*
****************************************************************************************************
*               Function to set gateway IP
*
* Description:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩在线亚洲一区蜜芽| 久久综合国产精品| 国产很黄免费观看久久| 亚洲国产一区在线观看| 日本一区二区三级电影在线观看 | 精品第一国产综合精品aⅴ| 91丨porny丨户外露出| 国内精品国产成人| 青青草国产精品97视觉盛宴| 亚洲色图制服诱惑| 国产午夜精品福利| 精品国产91久久久久久久妲己| 91视频国产资源| 国产成人精品亚洲日本在线桃色| 午夜电影久久久| 亚洲码国产岛国毛片在线| 国产婷婷色一区二区三区在线| 91精品国模一区二区三区| 91视频xxxx| 波多野结衣在线aⅴ中文字幕不卡| 久久精品99国产精品| 婷婷综合五月天| 亚洲一区二区偷拍精品| 亚洲色图视频网站| 国产精品九色蝌蚪自拍| 国产性天天综合网| 久久亚洲综合色一区二区三区| 91精品婷婷国产综合久久竹菊| 99在线精品视频| 国产v日产∨综合v精品视频| 精品一区二区三区的国产在线播放| 亚洲va欧美va天堂v国产综合| 国产精品久久夜| 中文字幕在线播放不卡一区| 中文字幕免费一区| 国产欧美日韩在线视频| 久久综合资源网| 久久综合久久99| 久久久久久夜精品精品免费| 亚洲精品一区二区三区福利| 欧美成人伊人久久综合网| 日韩视频免费观看高清在线视频| 欧美三级在线视频| 欧美酷刑日本凌虐凌虐| 欧美日本免费一区二区三区| 欧美日韩一级片在线观看| 欧美理论片在线| 日韩欧美视频一区| 精品美女被调教视频大全网站| 欧美大片在线观看一区二区| 欧美哺乳videos| 久久综合色天天久久综合图片| 久久久久99精品一区| 亚洲国产精品高清| 亚洲视频在线一区| 亚洲国产精品一区二区www| 秋霞电影网一区二区| 久久99久久99| 成人黄色在线视频| 色婷婷av一区二区| 欧美丰满高潮xxxx喷水动漫| 日韩三级伦理片妻子的秘密按摩| 久久久久久久网| 国产精品国产三级国产aⅴ无密码| 国产精品女主播在线观看| 亚洲乱码日产精品bd| 性做久久久久久久久| 国产一区视频网站| 91在线视频在线| 欧美日韩另类一区| 久久综合九色综合97婷婷女人 | 日韩欧美在线不卡| 久久精品欧美日韩精品| 亚洲欧美视频一区| 日韩高清一区在线| 国产91高潮流白浆在线麻豆| 色视频一区二区| 欧美电影免费观看高清完整版 | 91九色最新地址| 欧美日韩1234| 中文字幕免费在线观看视频一区| 亚洲制服欧美中文字幕中文字幕| 奇米一区二区三区av| 成人天堂资源www在线| 在线观看亚洲一区| 久久久久久综合| 午夜精品福利久久久| 成人综合在线观看| 欧美一卡二卡在线| 最好看的中文字幕久久| 青草国产精品久久久久久| 99视频精品在线| 欧美精品一二三四| 国产精品每日更新在线播放网址| 午夜私人影院久久久久| 国产91精品欧美| 日韩一区二区三| 亚洲精品国久久99热| 国产资源精品在线观看| 欧美丝袜丝交足nylons| 中文乱码免费一区二区 | 99re这里都是精品| 日韩一二三四区| 亚洲国产精品一区二区www| 岛国av在线一区| 欧美videossexotv100| 亚洲成人免费影院| 色综合久久综合网97色综合| 2024国产精品| 欧美aa在线视频| 欧美日韩国产高清一区二区 | 一级精品视频在线观看宜春院 | 色综合天天做天天爱| 国产性天天综合网| 精品一区二区免费视频| 91麻豆精品国产91久久久资源速度| 亚洲人成在线观看一区二区| 成人少妇影院yyyy| 久久精品一区蜜桃臀影院| 精品一区精品二区高清| 欧美一区二区三区视频在线| 亚洲成a人v欧美综合天堂| 日本精品视频一区二区三区| 国产亚洲一区字幕| 国产一区二区三区香蕉| 精品免费视频.| 精品在线视频一区| 2019国产精品| 国产成人精品免费在线| 久久综合久久综合久久综合| 国产精品一区二区在线播放| 精品国产污污免费网站入口| 久色婷婷小香蕉久久| 欧美成人一区二区三区| 激情综合色丁香一区二区| 91精品国产色综合久久久蜜香臀| 亚洲五月六月丁香激情| 99在线热播精品免费| 亚洲人成精品久久久久久| www.日韩大片| 亚洲欧洲综合另类| 欧美三级电影网站| 亚洲成人免费观看| 欧美精品三级日韩久久| 婷婷综合久久一区二区三区| 91精品国产综合久久蜜臀| 免费欧美日韩国产三级电影| 日韩欧美一区在线观看| 国产伦精品一区二区三区视频青涩| 精品国产乱码久久久久久久久| 美女一区二区三区在线观看| 欧美tk丨vk视频| 国产精品一区二区x88av| 国产女人aaa级久久久级| 成人妖精视频yjsp地址| 亚洲日本在线天堂| 欧美丝袜自拍制服另类| 蜜臀久久99精品久久久久久9| 日韩欧美色综合| 成人午夜激情视频| 亚洲欧美日韩中文播放| 911精品国产一区二区在线| 久久精品国产亚洲5555| 国产欧美一二三区| 91久久国产最好的精华液| 男男视频亚洲欧美| 国产日韩精品一区二区浪潮av| 99精品欧美一区二区三区综合在线| 亚洲激情第一区| 欧美mv日韩mv亚洲| 99久久99久久精品免费观看 | 国产不卡视频一区| 一级精品视频在线观看宜春院| 欧美一区二区视频免费观看| 国产一区二区h| 亚洲精品一二三| 日韩精品一区二区三区在线观看| 国产不卡在线视频| 五月婷婷另类国产| 国产亚洲成av人在线观看导航| 在线看不卡av| 激情综合网天天干| 亚洲精品高清在线观看| 欧美xxxxx裸体时装秀| 色欲综合视频天天天| 老汉av免费一区二区三区 | 亚洲v中文字幕| 久久免费偷拍视频| 欧美日精品一区视频| 国产成人av电影在线观看| 亚洲成人精品在线观看| 中文久久乱码一区二区| 91麻豆精品国产综合久久久久久| 成人av先锋影音| 久久99精品久久久久久动态图 | 欧美日韩国产成人在线91| 成人av片在线观看| 精品一区二区免费视频| 日韩在线卡一卡二| 中文字幕在线不卡一区|