⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nicdriver.c

📁 3com3c905网卡驱动程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************
*** Note: Copy rights resevered to Beijing Pacific Linkair Communications Co. 
***
*** File Name: NICDriver.c
*** Purpose  : Supply the NIC Driver Interface Routines
***
*** Author   : Guangzhao Tian
*** Modified : By Guangzhao Tian at 2000/9/7
***
**/

#include "pcilib.h" 

 /* #include "iv.h"      */

#include "memLib.h"
#include "semLib.h"
#include "cacheLib.h"

#include "NICMacro.h"
#include "NICWinReg.h"
#include "NICCommand.h"
#include "NICEeprom.h"
#include "NICMemory.h"
#include "NICData.h"
#include "NICHelper.h"
#include "NICExport.h"
#include "NIC_DPDTest.h"

/**********Global variables***********************/

/*** this are the model global variable storeged those information of 
     NIC , which should be avaible in all fuction modules ***/
   NIC_INFORMATION  gNic_Information, 
	              * pNic_Information;

/************End of Global Variables section********/
void Drv_ShowBMInfo(IN PNIC_INFORMATION pAdapter) ;
BOOLEAN Drv_CacheMemTest(IN PNIC_INFORMATION pAdapter);
void Drv_VortexTxTest() ;/*IN PNIC_INFORMATION pAdapter); */
void Drv_IntTest();
/**************************************************************************
***Drv_Load -- Device Driver Load Module
***
   This is the driver entry , maybe called by sysHwInit() from BSP.

   When calling, the BSP should supply some parameters that driver 
	   cannot get itself, which the BSP can read from the Broad Hardware
	   by some means when boot up.
	   
   Those parameter include IoBaseAddr , and Intrruptor Number, they 
	   are shiped as pNIC_PCI_INFORMATION structure;
***/
NIC_STATUS  Drv_Load ( ) /*IN pNIC_PCI_INFORMATION pPCIInfoSys )   */
{ 
/*  int nNICIoBaseAddr ;
     INT nInterruptor;
     int nNICMemBaseAddr;

    nNICIoBaseAddr= getIoAddrOf3c905b();
    nInterruptor  = getIntNumOf3c905b();
    nNICMemBaseAddr = getMemAddrOf3c905b(); */

    pNic_Information = &gNic_Information;

    DebugMsg("\n\n Device Driver Module Loading ... \n\n");

    /*Get the PCI Parameters to Driver Module Globals    */
    if( ! PCI_CongfigInfoGet (pNic_Information ) )
      {
         DebugMsg("\n Failure to get PCI Parameters! Cannot continue. \n");
        return NIC_STATUS_FAILURE;
      }     

   /*        pNic_Information->IoBaseAddress   = nNICIoBaseAddr;
	   pNic_Information->InterruptVector = nInterruptor;
       pNic_Information->MemBaseAddress  = nNICMemBaseAddr; 
	   pNic_Information->PCIInfo.IoBaseAddress   = nNICIoBaseAddr;
       pNic_Information->PCIInfo.InterruptVector = nInterruptor;

 	   pNic_Information->IoBaseAddress   =0x00004000;  */

       pNic_Information->IoBaseAddress   = pNic_Information->PCIInfo.IoBaseAddress;
	   pNic_Information->InterruptVector = pNic_Information->PCIInfo.InterruptVector;
       pNic_Information->MemBaseAddress  = pNic_Information->PCIInfo.MemBaseAddress;

   /*  Stop the Device*/
     if( NIC_STATUS_FAILURE==NIC_DeviceStop( pNic_Information))
      {
        DebugMsg("Driver Load Failed ! \n");
        return NIC_STATUS_FAILURE;
      }  

    /* Reset the NIC Card.  */
     if( NIC_STATUS_FAILURE== NIC_DeviceReset(pNic_Information) )
      {
        DebugMsg("Driver Load Failed ! \n");
        return NIC_STATUS_FAILURE;
      } 

    /* Start the NIC Card  */
       if( NIC_STATUS_FAILURE== NIC_DeviceStart(pNic_Information) )
      {
        DebugMsg("Driver Load Failed ! \n");
        return NIC_STATUS_FAILURE;
      } 
 
    /* Read EEPROM Registers Value,fill into Global Controlling Information Block   */
     if( NIC_STATUS_FAILURE == NIC_EEPROMFillGlobal (pNic_Information) )
     {
         DebugMsg("Driver Load Failed ! \n");
         return NIC_STATUS_FAILURE;
     } 

    /*Set the Receive Mode */

    if( NIC_STATUS_FAILURE == NIC_RxModeSet(pNic_Information, RX_FILTER_PROMISCUOUS) )
    {
         DebugMsg("Driver Load Failed ! \n");
         return NIC_STATUS_FAILURE;
     }  

     /* Setup the media used 
    if( NIC_STATUS_FAILURE == NIC_MediaSetup(pNic_Information) )
    {
         DebugMsg("Driver Load Failed ! \n");
         return NIC_STATUS_FAILURE;
     }   
*/
     /*allocated shared memory in host mem space, and carve it out

    if( NIC_STATUS_FAILURE == Drv_MemSharedAlloc(pNic_Information) )
    {
         DebugMsg("Driver Load Failed ! \n");
         
         Drv_MemSharedFree(pNic_Information);

         return NIC_STATUS_FAILURE;
     }

     DebugMsg("Driver Load Succeed ! \n");
      
     DebugMsg("\n\nHit a number to exit ! \n ");
     scanf("%d",&x);

     Drv_MemSharedFree(pNic_Information);*/


    if( NIC_STATUS_FAILURE ==  Drv_InterruptHook(pNic_Information) )
    {
       DebugMsg("\n Hook Interrrupt Handler Failed  ! \n ");
    } 
 
  
   /*  Drv_LoopBackPacket( pNic_Information);
       Drv_CacheMemTest(pNic_Information);  
     Drv_VortexTxTest(); */

	Drv_IntTest();

    DebugMsg("\n************\n Driver Load Done ! \n");

     return NIC_STATUS_SUCCESS;
} 


void Drv_IntTest()
{
   int x,y= 0;
  
   	while(1)
	{
      DebugMsg("\n ***************\n This is the %d th times to test INT!\n************\n", ++y);
      DebugMsg(" Hit a Number:"); scanf("%d",&x);  DebugMsg(" \t\t\t x= %d \n", x);
       
      if(x==0) break;

      DebugMsg("  Try to stop download engine ! \n");
 	NIC_COMMAND_WAIT(pNic_Information, COMMAND_DOWN_STALL);

      DebugMsg("  Try to write to download register ! \n");
	NIC_WRITE_PORT_ULONG(pNic_Information->IoBaseAddress, DOWN_LIST_POINTER_REGISTER,(ULONG) 0x03ffff40 ); 

       DebugMsg("  Try to reStart download engine to tick the INT ! \n");  
	NIC_COMMAND(pNic_Information->IoBaseAddress, COMMAND_DOWN_UNSTALL);  
       DebugMsg("   download engine reStarted! \n"); 
	}
   
}

void Drv_ShowBMInfo(IN PNIC_INFORMATION pAdapter) 
{
   DebugMsg("\n*************\n");

   DebugMsg(" UpPacket Status Register Value : 0x%08X. \n",
                        NIC_READ_PORT_ULONG(pAdapter->IoBaseAddress,UP_PACKET_STATUS_REGISTER) ); 

    DebugMsg(" DMA Control Register Value : 0x%08X. \n",
                        NIC_READ_PORT_ULONG(pAdapter->IoBaseAddress,DMA_CONTROL_REGISTER) ); 

    DebugMsg(" Bus Master FragAddress Register Value : 0x%08X. \n",
                        NIC_READ_PORT_ULONG(pAdapter->IoBaseAddress,BUS_MASTER_FRAGMENT_ADDRESS) ); 

    DebugMsg(" Bus Master FragLength  Register Value : 0x%08X. \n",
                        NIC_READ_PORT_ULONG(pAdapter->IoBaseAddress,BUS_MASTER_FRAGMENT_LENGTH) ); 

	DebugMsg(" PCI Status Register Value : 0x%08X. \n",PCI_RegRead16(pAdapter,PCI_STATUS) ); 

	DebugMsg(" PCI Command Register Value : 0x%08X. \n",PCI_RegRead16(pAdapter,PCI_COMMAND) ); 

	DebugMsg(" Now the UPD List Pointer Register Value : 0x%08X. \n",
                        NIC_READ_PORT_ULONG(pAdapter->IoBaseAddress,UP_LIST_POINTER_REGISTER) ); 

    DebugMsg(" Now the DPD List Pointer Register Value : 0x%08X. \n",
                        NIC_READ_PORT_ULONG(pAdapter->IoBaseAddress,DOWN_LIST_POINTER_REGISTER) ); 

   /*   NIC_COMMAND( pAdapter->IoBaseAddress ,COMMAND_SELECT_REGISTER_WINDOW |REGISTER_WINDOW_7);

    DebugMsg(" BM_FRAGMENT_ADDRESS_WIN7 in Reg Win 7 Value : 0x%08X. \n",
                        NIC_READ_PORT_ULONG(pAdapter->IoBaseAddress,BM_FRAGMENT_ADDRESS_WIN7) ); 

    DebugMsg(" BM_FRAGMENT_LENGTH_WIN7 in Reg Win 7 Value : 0x%08X. \n",
                        NIC_READ_PORT_ULONG(pAdapter->IoBaseAddress,BM_FRAGMENT_LENGTH_WIN7) ); 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -