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

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

?? netdrv.cpp

?? coldfire5206芯片平臺的自撿程序
?? CPP
?? 第 1 頁 / 共 4 頁
字號:
	// but i don't know why the two bits writable can not be set.
	// WriteMiiRegister(0x10,31,0x0);
	
	return( NET_NO_ERROR );
}

/*
Name:         ReceiveAPacket
Description:  This routine will received a packet now 
              dangling on the MAC buffer, and "ReadPage" is 
			  a global thing.
Parameters:   buf - the buffer used to hold the packet.
Returns:      0 - A packet is successfully received.
              1 - No packet is found.
			  2 - this is a viewbed packet, and we care about it, saved.
			  3 - this is a viewbed packet, but we don't care about it, discard.
			  -1 - NET_ERROR_PAKLEN.
Test and revision:
              Ason. 2001.7
*/
// for debug 
unsigned long thistimesernum;
unsigned long lasttimesernum;
unsigned long serialnumerror = 0;
unsigned long trigger = 0;
INT16 ReceiveAPacket( UCHAR *tcpip_buf, UCHAR *vb_buf, UINT16 *type )
{
	UCHAR tempc, cur_page;
	UINT16 packet_len;
	UINT16 return_value = NET_NO_ERROR;
	UINT16 packet_type;
//	UCHAR  temp_buf[18];   // temporary buffer to hold packet head.
	UCHAR  temp_buf[24];   // temporary buffer to hold packet head.

    *type = packet_type = NET_PTL_NOONE;

    SETTOPAGE0
	tempc = inportb(RSRADD);

	// when set to page1, there should be an interrupt entry protection.
	SETTOPAGE1
    cur_page = inportb(CPRADD);
	SETTOPAGE0
	
    if ( ReadPage == cur_page )
		return( NET_ERROR_NOPAKIN );
	else 
    {
        // read packet head.
        // return_value = RemoteRead( ((UINT16)ReadPage) << 8 , 9, (UINT16*)temp_buf );
		// for debug.
		return_value = RemoteRead( ((UINT16)ReadPage) << 8 , 12, (UINT16*)temp_buf );
		if ( NET_NO_ERROR != return_value )
			return( return_value );

		// here, something must be done to make sure VB protocol
		// packets goes else where.
		if (   0xff == temp_buf[10] 
			&& 0xff == temp_buf[11] 
			&& 0xff == temp_buf[12]
			&& 0xff == temp_buf[13] )
		{
             if ( temp_buf[14] & 0x80 ) 
                 // this is a packet holding general information.
				 packet_type =  NET_PTL_VIEWBEDCARE;
			 else
			 {
                 // this is a packet holding real-time data.
				 //if ( temp_buf[15] == VBCtrl.ViewBedFocus )
				     packet_type = NET_PTL_VIEWBEDCARE;
				 //else
				   //  packet_type = NET_PTL_VIEWBEDNOTCARE;
			 }

			 // for debug only.
			 thistimesernum = *((unsigned long *)&temp_buf[18]);
			 if ( trigger > 10 )
			 {
			  if ( thistimesernum != lasttimesernum + 1 )
				 serialnumerror++; 
			 }
			 else
				 trigger++;
			 lasttimesernum = thistimesernum;
		}
		else
		    packet_type = NET_PTL_TCPIP;
		*type = packet_type;
		       
		
        packet_len = ((UINT16)256) * temp_buf[3] + temp_buf[2]
                      - 14;
		if ( packet_len > RECEIVE_BUF_SIZE - 14 )
			return( NET_ERROR_PAKLEN );
		
		if ( NET_PTL_TCPIP == packet_type  )
		{
			memcpy(tcpip_buf,&temp_buf[4],14);
			// read the whole packet in.
			return_value = RemoteRead( (((UINT16)ReadPage) << 8) + 18, ( packet_len + 1 ) >> 1, (UINT16 *)(tcpip_buf + 14) );
		}
		else if ( packet_type == NET_PTL_VIEWBEDCARE )
		{
            memcpy(vb_buf,&temp_buf[4],14);
			return_value = RemoteRead( (((UINT16)ReadPage) << 8) + 18, ( packet_len + 1 ) >> 1, (UINT16 *)(vb_buf + 14) );
		}

		if ( NET_NO_ERROR == return_value )
		{
			MacState.Rcv.PacketReallyReceived++;
			if ( NET_PTL_TCPIP == packet_type )
				MacState.Rcv.PacketReallyReceivedTcpip++;
			else if ( NET_PTL_VIEWBEDCARE == packet_type )
				MacState.Rcv.PacketReallyReceivedVBCare++;
			else if ( NET_PTL_VIEWBEDNOTCARE == packet_type )
				MacState.Rcv.PacketReallyReceivedVBNotCare++;
		}
        // move the BNYR to next page.
		
        SETTOPAGE0
        outportb( BNRYADD,ReadPage );
        ReadPage = temp_buf[1];
        
		SETTOPAGE1
        cur_page = inportb(CPRADD);
		SETTOPAGE0
    		
		return( NET_NO_ERROR );
	}
}


/*
Name:         MacLoopTest
Description:  Do two kinds of loop test: 1. internal loop
                                         2. internal loop with HPY
		  
Parameters:   None.
Returns:      Error code or NET_NO_ERROR
Test and revision:
              Ason. 2001.7
*/
INT16 MacLoopTest(void)
{
	
	INT16 i,return_value,looptimes;
	UCHAR tempc,cur_page;
	UINT16 tempus;
	UINT16 packet_type;
	BOOL  return_value_bool;
	
	for ( i = 0; i < 256; i++ )
	    SndLoopBuf[i] = i;
	SndLoopBuf[0] = 0xff;  // make it a broadcast address.
	SndLoopBuf[1] = 0xff;
	SndLoopBuf[2] = 0xff;
	SndLoopBuf[3] = 0xff;
	SndLoopBuf[4] = 0xff;
	SndLoopBuf[5] = 0xff;  // must make sure that [6],[7],[8],[9] will never be
		                   // 0xff to make it a non-viewbed packet.


	// first of all, set loop mode 1.
	SETTOPAGE0
	outportb(TCRADD,0x22);
    
	// start the MAC controller.
	STARTCNTLR

    for ( looptimes = 0; looptimes < 1000; looptimes++ )
	{
	   // clear receive buffer. 
	   for ( i = 0; i < 260; i++ )
   		  RcvLoopBuf[i] = i + 1;
 
       // "RemoteWrite" will not change register page.
	   return_value = TransmitAPacket( (UINT16*)SndLoopBuf, 128 );
	   if ( NET_NO_ERROR != return_value )
	    	return( return_value );
	
	   // polling for received state.
	   i = 0;
	   while( TRUE )
	   {
          tempc = inportb(ISRADD);
		  if ( tempc & 0x01 )
		       break;
		  wait(3);
		  if ( i++ > NET_TMO_LOOPWT )
		    	break;
	   }
	   if ( i > NET_TMO_LOOPWT )
          return( NET_ERROR_LOOPRSP );
		
	   return_value = ReceiveAPacket(RcvLoopBuf,RcvLoopBuf,&packet_type);
	   if ( NET_NO_ERROR != return_value )
  	       return( return_value );
	
	   if ( memcmp( SndLoopBuf, &(RcvLoopBuf[0]), 256 ) )
	       return( NET_ERROR_LOOPERR );

       // clear receive bit.
       SETTOPAGE0
	   outportb(ISRADD,0x01);	

	}

    
	// first of all, set loop mode 2.
    outportb(TCRADD,0x24);   // 0xa4 for internal loop with PHY,

	if ( NET_NO_ERROR !=  ReadMiiRegister(0x10,0x00,&tempus) )
		return( NET_ERROR_MIIRD );
	tempus |= 0x4000;        // set PHY loop;
	WriteMiiRegister(0x10,0x00,tempus);


	for ( looptimes = 0; looptimes < 1000; looptimes++ )
	{
	   // clear all the received bytes.
       for ( i = 0; i < 260; i++ )
	      RcvLoopBuf[i] = i + 1;
	
       // transmit a packet.
	   return_value = TransmitAPacket( (UINT16*)SndLoopBuf, 128 );
	   if ( NET_NO_ERROR != return_value )
	    	return( return_value );
		
	   i = 0;
	   while( TRUE )
	   {
           tempc = inportb(ISRADD);
		   if ( tempc & 0x01 )
		        break;
		   wait(3);
		   if ( i++ > NET_TMO_LOOPWT )
		    	break;
	   }
	   if ( i > NET_TMO_LOOPWT )
           return( NET_ERROR_LOOPRSP );

	   return_value = ReceiveAPacket(RcvLoopBuf, RcvLoopBuf, &packet_type );
       if ( NET_NO_ERROR != return_value )
	       return(return_value);
    
	   if ( memcmp( SndLoopBuf, &(RcvLoopBuf[0]), 256 ) )
	       return( NET_ERROR_LOOPERR );

       // clear receive bit.
       SETTOPAGE0
	   outportb(ISRADD,0x01);	
	}

    return( NET_NO_ERROR );  

}

/*
Name:        NU_Get_Address
Description: This file is used to return MAC address, as we don't use EEPROM
             or such things to determine MAC address, we just return it from 
			 bed number.
Parameters:  ether_addr - hold MAC address to return.
             not_used - things not used, but required by interface.
			 io_base - io base of MAC, as we don't use it, let it be, required
			 by interface.
Return:      always return success.
Test and revision:
             Ason. 2001.7

*/
INT16 NU_Get_Address (UCHAR *ether_addr, UINT32 not_used, UINT32 io_base)
{
	
	*ether_addr = BED_ETHER_ADDR_AREA1;
	*(ether_addr + 1) = BED_ETHER_ADDR_AREA2;
	*(ether_addr + 2) = BED_ETHER_ADDR_AREA3;
	*(ether_addr + 3) = BED_ETHER_ADDR_AREA4;
	*(ether_addr + 4) = BED_ETHER_ADDR_AREA5;
	*(ether_addr + 5) = BED_ETHER_ADDR_AREA6 + 0;
	
	return 0;
}

/*
Name:     RemedyHardwareBug
Description: 
          According to datasheet version-16, a software reset of 
		  at least 2.5s must be employed to PHY to remedy hardware
		  bugs.
Parameters:
          None.
Test and revision:
          Ason. 2001.11.20 <E>          

*/
void RemedyHardwareBug(void)
{
	WriteMiiRegister(0x10,0x00,0x800);
	
	wait( 1000 * 5 );

	// force to autonegotiation and restart it.
	WriteMiiRegister(0x10,0x00,0x00);

    // wait for 5 more seconds to make sure 
	// that the autonegotiation will finish.
	wait( 1000 * 5 );

}


/*
Name:        NU_Etopen                                                             
Description: 1. Initialize hardware, 2. load interrupt service. This
             is also the interface required by TCP/IP layer.
Parameters:  ether_addr - MAC address of the card.
             irq_num - external interrupt number.
			 buff_addr - shared memory or such things, as we don't 
			             use shared memory anyway, this is lefted.
			 base_addr - base address of the I/O.
Return:      NU_SUCCESS if the the procedure is success,
             error code if fail. NU_SUCCESS = 0;
			 -1, Reg Error.
			 -2, Ram Error.
Test and revision:
             Ason.  2001.7
*/
INT16 NU_Etopen (UCHAR *ether_addr, UINT16 irq_num,
		 UINT32 buff_addr, UINT32 base_addr)
{
    INT16 return_value;
	UCHAR tempc;

	RemedyHardwareBug();

	// step1, initialize statistics of MAC layer.
	InitStatistics();
		
	// step2, test NE2000 registers.
	return_value = TestMacReg();
    if (  NET_NO_ERROR != return_value )
		return( return_value );

	// step3, test SRAM.
	return_value = TestMacRam();
	if (  NET_NO_ERROR != return_value )
		return( return_value );

/*
	// step4, initialize things in MII registers of 88796.
	return_value = ConfigMacMii(0);
	if ( NET_NO_ERROR != return_value )
		return( return_value );
*/
	// step5, config 88796 to work.
    InitMacCntlr( ether_addr, 0 );

	// step6, loop test, both with PHY and without PHY, pooling.
	return_value = MacLoopTest();
	if ( NET_NO_ERROR != return_value )
		return( return_value );

	// step7, reinitialize things in MII of 88796.
	// beause in step 6, some MII register settings are changed.
	// and set PHY to autonegotiation mode.
/*	// input: 0:10M, 1:100M, 2:Autonegotiation.
	return_value = ConfigMacMii(0);
    if ( NET_NO_ERROR != return_value )
		return( return_value );
*/
	// step8, config 88796 to work once again.
	// because in step 6, some register settings are changed,
	// so, you must reinitialize the registers.
	// and set to normal mode.
    InitMacCntlr( ether_addr, 1 );
	
	// step9, clear IMR of CPU and let interrupt work.
	// SetIntRt();
    		
	return ( NET_NO_ERROR );
}


/*
Name:           NU_Xmit_Packet                                                        
Description:    interface function, transmit a packet immediately.
Parameters:     pack_addr - the packet address
                num_msg_bytes - the packet length.
Return:         .
Test and revision:
                Ason. 2001.7.

*/
INT16 NU_Xmit_Packet(UCHAR *pack_addr, UINT16 num_msg_bytes)
{
    // according to IEEE802.3, packet length not including checksum
	// should be at least 60 bytes.
	// and the hardware will add CRC automatically.
	// we say that CRC will be appended by transmitter, what's the
	// meaning of it? length is actual size of the packet or
	// the size should be actual size plus 4(CRC length?).
	// refer to data sheet, size is only actual size.
	if ( num_msg_bytes % 2 )
	    num_msg_bytes++;
	if ( num_msg_bytes < TRANSMIT_BUF_MIN_SIZE )
		num_msg_bytes = TRANSMIT_BUF_MIN_SIZE;          // add PAD.
	else if ( num_msg_bytes > TRANSMIT_BUF_SIZE ) 
        return( -1 );		                            // MTU exceeded.
	      
	if ( NET_NO_ERROR != TransmitAPacket( (UINT16 *)pack_addr, num_msg_bytes / 2 ) )
		return( -1 );
	
	return( 0 );
}


/*
Name:        Net_Lisr
Description: Low level interrupt service of MAC controller 88796.
Parameter:   None
Return:      None
Test and revision:
             Ason. 2001.7
*/
void Net_Lisr(void)
{
	MacInt();
	outportb(0x10000010,0x00);            // clear the interrupt. this
	                                      // is not necessary actually 
	                                      // when hardware changed.
} 



// following are debug functions.
// restart autonegotiation.
INT16 RestartAutoNeg(void)
{
    
	INT16 return_value;    
	UINT16 tempus;
	
    return_value = ReadMiiRegister(0x10,0x00,&tempus);
	   if (  NET_NO_ERROR != return_value )
		     return( -1 );

    tempus |= 0x0200;    // restart autonegotiation.

	WriteMiiRegister(0x10,0x00,tempus);
	return(0);
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91麻豆精品国产91久久久资源速度| 国产午夜亚洲精品理论片色戒| 亚洲自拍偷拍综合| 婷婷中文字幕综合| 午夜欧美电影在线观看| 国产精品一级在线| 中文字幕一区日韩精品欧美| 欧美精选一区二区| 极品销魂美女一区二区三区| 欧美综合在线视频| 国产成人精品一区二| 首页国产丝袜综合| 一区二区三区影院| 欧美激情一区在线观看| 日韩免费一区二区三区在线播放| 91浏览器打开| 国产一区欧美二区| 久久天天做天天爱综合色| 亚洲www啪成人一区二区麻豆| 日本乱码高清不卡字幕| 亚洲素人一区二区| 成人av网址在线| 亚洲国产精品t66y| 色婷婷综合久色| 日日骚欧美日韩| 91精品国产综合久久蜜臀| 蜜芽一区二区三区| 国产日韩视频一区二区三区| 不卡一区中文字幕| 一个色在线综合| 精品久久久久久无| 91片在线免费观看| 午夜久久电影网| 国产亚洲精品7777| 欧美色图天堂网| 久久国产精品区| 一区二区三区美女| 国产丝袜在线精品| 在线观看中文字幕不卡| 国产一区不卡视频| 中文字幕一区二区三区乱码在线| 欧美三级电影网站| 久久久国产午夜精品| 亚洲另类色综合网站| 一区二区视频在线看| 亚洲国产中文字幕| 中文字幕日韩一区| av资源网一区| 夜夜嗨av一区二区三区网页| 久久精品夜夜夜夜久久| 精品国产免费一区二区三区四区| 亚洲欧美在线另类| 久久久久久免费网| 一本大道久久a久久精二百| gogogo免费视频观看亚洲一| av一区二区三区黑人| 色综合视频在线观看| 91女厕偷拍女厕偷拍高清| 色猫猫国产区一区二在线视频| 色哟哟精品一区| 欧美日韩精品一区二区三区蜜桃| 男人的天堂久久精品| 国产日韩综合av| 国产精品欧美精品| 亚洲精品在线免费观看视频| 日韩一区二区视频| 欧美一级高清片在线观看| 日韩精品一区二| 精品三级在线观看| 日韩一区二区三区免费看| 这里只有精品免费| 狠狠久久亚洲欧美| 理论电影国产精品| 国产一区二三区好的| 美日韩一区二区| 亚洲综合成人网| 亚洲国产aⅴ天堂久久| 国产精品你懂的在线欣赏| 久久综合av免费| 国产清纯白嫩初高生在线观看91| 欧美精品久久99| 欧美一级高清片| 56国语精品自产拍在线观看| 欧美色图片你懂的| 91精品在线观看入口| 亚洲激情自拍视频| 亚洲另类在线制服丝袜| 亚洲va国产va欧美va观看| 视频一区免费在线观看| 99精品久久99久久久久| 国产日韩亚洲欧美综合| 极品少妇一区二区三区精品视频| 成人黄动漫网站免费app| 经典三级在线一区| 蜜桃视频一区二区| 黑人巨大精品欧美一区| 欧美亚洲免费在线一区| 国产一区日韩二区欧美三区| 中文乱码免费一区二区| 色乱码一区二区三区88 | 极品销魂美女一区二区三区| 国产精品中文字幕欧美| 欧美日韩国产在线播放网站| 久久综合狠狠综合久久激情 | 亚洲一区二区视频在线观看| 国产电影精品久久禁18| 欧美午夜不卡视频| www国产成人| 亚洲午夜一区二区三区| 国产一区二区美女诱惑| 色婷婷一区二区三区四区| 亚洲精品一区二区三区福利| 国产精品午夜免费| 日韩制服丝袜av| 91一区二区在线| 欧美性生交片4| 亚洲国产精品精华液2区45| 久久久久99精品一区| 奇米在线7777在线精品| 成人免费毛片a| 国产日韩欧美一区二区三区综合| 日韩电影网1区2区| 91看片淫黄大片一级| 国产精品成人免费精品自在线观看 | 亚洲人成网站精品片在线观看 | 国产激情偷乱视频一区二区三区| 欧美在线观看禁18| 欧美日韩卡一卡二| 91久久久免费一区二区| 久久久噜噜噜久噜久久综合| 国产一区 二区 三区一级| 国产精品妹子av| 337p粉嫩大胆色噜噜噜噜亚洲| 一本一本久久a久久精品综合麻豆| 成人免费va视频| 波多野结衣中文字幕一区二区三区| 亚洲一区二区在线免费看| 久久久久亚洲综合| 日韩一二三区不卡| 国产一区二区美女| 国产99久久久国产精品潘金网站| 日韩一区二区高清| 亚洲电影欧美电影有声小说| 欧美变态凌虐bdsm| 26uuu亚洲| 亚洲国产日产av| 欧美视频一区二区三区四区| 91精品国产高清一区二区三区蜜臀| 亚洲国产欧美在线| 欧美日韩综合不卡| 天堂av在线一区| 欧美一区二区三区播放老司机| 日本亚洲欧美天堂免费| 欧美日韩高清一区二区三区| 奇米777欧美一区二区| 制服丝袜日韩国产| 国产精品色一区二区三区| 高清久久久久久| 亚洲精品精品亚洲| 欧美va日韩va| 欧美日韩一区二区三区四区| 岛国一区二区在线观看| 亚洲123区在线观看| 欧美成人欧美edvon| 成人免费高清在线| 麻豆精品视频在线观看视频| 久久精品欧美一区二区三区不卡| 国产精品99久久久久| 亚州成人在线电影| 亚洲精品高清在线| 国产午夜精品一区二区| 欧美一卡在线观看| 一本一道综合狠狠老| 懂色av一区二区三区免费看| 五月婷婷综合激情| 亚洲精品免费播放| 国产精品色呦呦| 国产精品人妖ts系列视频| 日韩视频一区在线观看| 色婷婷综合久久久| av高清不卡在线| 日本韩国欧美一区二区三区| 日韩高清在线一区| 天天色 色综合| 亚洲mv大片欧洲mv大片精品| 亚洲一区二三区| 亚洲制服丝袜在线| 成人午夜视频网站| 91精品国产91久久久久久一区二区 | 国产suv精品一区二区883| 国产在线看一区| 日韩制服丝袜先锋影音| 天天综合网 天天综合色| 日韩av电影天堂| 国产成人午夜精品5599| 国产精品免费视频观看| 欧美日韩高清一区| 蜜臀av一区二区在线观看 | 韩国一区二区在线观看| 一区精品在线播放|