Realtek RTL8100 Programming Manual Download Page 5

 
 

RTL8100 

 

2001/12/10 

Rev.1.0 

 
 

1.7 Sample Code 

unsigned char 
NextDesc( 
 

unsigned char CurrentDescriptor 

    ) 

//    (CurrentDescriptor == TX_SW_BUFFER_NUM-1) ? 0 : (1 + CurrentDescriptor); 
    if(CurrentDescriptor == TX_SW_BUFFER_NUM-1) 
    { 
 

return  0; 

    } 
    else 
    { 
 

return ( 1 + CurrentDescriptor); 

    } 

unsigned char 
CheckTSDStatus( 
    unsigned char            Desc 
    ) 

    ULONG       Offset = Desc << 2; 
    ULONG       tmpTSD; 
 
    tmpTSD=inpdw( TSD0 + Offset); 
    switch ( tmpTSD & (TSD_OWN | TSD_TOK) ) 
    { 
 

case (TSD_OWN | TSD_TOK):       

return   TSDSTATUS_BOTH; 

 

case (TSD_TOK)  

 

:       return  TSDSTATUS_TOK; 

 

case (TSD_OWN)  

 

:       return  TSDSTATUS_OWN; 

 case 

 

  : return 

 

TSDSTATUS_0; 

    } 
    return 0; 

void 
IssueCMD(unsigned char descriptor) 

 

unsigned long offset = descriptor << 2; 

 

outpdw( TSAD0 + offset, TxDesc[TxHwSetupPtr].PhysicalAddress); 

 

outpdw( TSD0 + offset , TxDesc[TxHwSetupPtr].PacketLength); 


int 
SendPacket( 
 PPACKET 

pPacket 



    disable(); 
    if( TxHwFreeDesc>0  ) 
    { 
 TxDesc[TxHwSetupPtr].PacketLength= 
  CopyFromPacketToBuffer( 

pPacket 

TxDesc[TxHwSetupPtr].buffer); 

 IssueCMD(TxHwSetupPtr); 
 

TxHwSetupPtr = NextDesc(TxHwSetupPtr); 

 TxHwFreeDesc--; 
 enable(); 
 return 

TRUE;//success 

    } 
    else 
    { 
 enable(); 
 

return FALSE;//out of resource 

    } 

void 
TxInterruptHandler() 

    while( (CheckTSDStatus(TxHwFinishPtr) == TSDSTATUS_BOTH  ) && 
 

   (TxHwFreeDesc < 4    

 

 

)   ) 

    { 
 

//can Release this buffer now 

 

TxHwFinishPtr = NextDesc(TxHwFinishPtr); 

 TxHwF+; 
    } 
}

 

 

Summary of Contents for RTL8100

Page 1: ...2 6 Configuration 8 2 7 Sample Code 9 3 Initialization 10 Additional Notes 10 This document is intended for use by the software engineer when programming for the Realtek RTL8100 series NIC controller...

Page 2: ...on of a packet 28 R CDH CD Heart Beat The same as RTL8029 AS This bit is cleared in the 100Mbps mode 27 24 R NCC3 0 Number of Collision Count Indicates the number of collisions encountered during the...

Page 3: ...mit Status register Also clear the OWN bit in TSD This starts the PCI operation 3 As the data moved into the FIFO meets the early transmit threshold the chip starts to move data from the FIFO to the l...

Page 4: ...ssing a transmit interrupt the following two cases should be managed properly Case 1 More than one interrupt between TOK and when ISR routine called Drivers have to check as many descriptor as possibl...

Page 5: ...S_OWN case 0 return TSDSTATUS_0 return 0 void IssueCMD unsigned char descriptor unsigned long offset descriptor 2 outpdw IOBase TSAD0 offset TxDesc TxHwSetupPtr PhysicalAddress outpdw IOBase TSD0 offs...

Page 6: ...gister CBA keeps the current address of the data moved to the buffer CAPR is then a read pointer which keeps the address of data that the driver had read The receiving packet status is stored in front...

Page 7: ...2 R CRC CRC Error When set indicates that a CRC error occurred on the received packet 1 R FAE Frame Alignment Error When set indicates that a frame alignment error occurred on this received packet 0...

Page 8: ...arly threshold No early FIFO Buffer DMA starts when the whole packet is in the FIFO If an incoming packet is larger than the size of the FIFO 2K RxFIFOOvw will be set but Rx DMA will never start so th...

Page 9: ...CR_BUFE break do RxReadPtr RxBuffer RxReadPtrOffset pPacketHeader PPACKETHEADER RxReadPtr pIncomePacket RxReadPtr 4 PktLength pPacketHeader PacketLength this length include CRC if PacketOK pPacketHead...

Page 10: ...n developed under Borland C 3 0 and the debugging process was accomplished under Softice for DOS All testing is done under DOS win98 2 To enable source code debugging under Softice the compiling linki...

Reviews: