資源描述:
《網(wǎng)卡設備驅(qū)動.doc》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、網(wǎng)卡設備驅(qū)動1.8139too網(wǎng)卡設備簡介一個PCI設備,總共有三個地址空間:內(nèi)存,端口和配置。內(nèi)存和端口其實是同一個內(nèi)容的不同訪問路徑而已。PCI設備的配置空間是標準化的,每個PCI設備的配置空間的前64個字節(jié)的含義都是一樣的。但各個設備的內(nèi)存和端口空間是完全不一樣的。在硬件概念上,設備的I/O內(nèi)存和I/O端口空間沒有區(qū)別,其實都是設備擁用的一些讀寫寄存器。???8139too網(wǎng)卡擁有256字節(jié)的讀寫寄存器空間。它的整個布局如下:???????/*Symbolicoffsetstoregisters.*/???????enumRTL8139_registers{?
2、??????????MAC0=0,??????/*Ethernethardwareaddress.*/???????????MAR0=8,??????/*Multicastfilter.*/???????????TxStatus0=0x10,??/*Transmitstatus(Four32bitregisters).*/???????????TxAddr0=0x20,????/*Txdescriptors(alsofour32bit).*/???????????RxBuf=0x30,???????????ChipCmd=0x37,???????????RxBufP
3、tr=0x38,???????????RxBufAddr=0x3A,???????????IntrMask=0x3C,???????????IntrStatus=0x3E,???????????TxConfig=0x40,???????????RxConfig=0x44,???????????Timer=0x48,??????/*Ageneral-purposecounter.*/???????????RxMissed=0x4C,???/*24bitsvalid,writeclears.*/???????????Cfg9346=0x50,???????????Con
4、fig0=0x51,???????????Config1=0x52,???????????FlashReg=0x54,???????????MediaStatus=0x58,???????????Config3=0x59,???????????Config4=0x5A,????/*absentonRTL-8139A*/???????????HltClk=0x5B,???????????MultiIntr=0x5C,?????????TxSummary=0x60,???????????BasicModeCtrl=0x62,???????????BasicModeSta
5、tus=0x64,???????????NWayAdvert=0x66,???????????NWayLPAR=0x68,???????????NWayExpansion=0x6A,???????????/*Undocumentedregisters,butrequiredforproperoperation.*/???????????FIFOTMS=0x70,????/*FIFOControlandtest.*/???????????CSCR=0x74,???????/*ChipStatusandConfigurationRegister.*/??????????
6、?PARA78=0x78,???????????PARA7c=0x7c,?????/*Magictransceiverparameterregister.*/???????????Config5=0xD8,????/*absentonRTL-8139A*/???????};???每個寄存器都有它特殊的含義和用途。舉個例子(我們假設使用I/O內(nèi)存的方式,ioaddr為設備內(nèi)存映射在CPU內(nèi)存地址空間的起始地址,下述代碼能讀取板卡的版本號):???????#defineHW_REVID(b30,b29,b28,b27,b26,b23,b22)???????????(b
7、30<<30
8、b29<<29
9、b28<<28
10、b27<<27
11、b26<<26
12、b23<<23
13、b22<<22)???????#defineHW_REVID_MASK??HW_REVID(1,1,1,1,1,1,1)???????/*identifychipattachedtoboard*/???????version=ioread32(ioaddr+TxConfig)&HW_REVID_MASK;???在我的電腦上,version讀出來的值的0x74400000,經(jīng)過比對,板卡名稱為:RTL-8100B/8139D。???下面是整個系例版本號的表格:???enu