Author: siarzhuk Date: 2010-06-01 20:55:37 +0200 (Tue, 01 Jun 2010) New Revision: 36992 Changeset: http://dev.haiku-os.org/changeset/36992/haiku Modified: haiku/branches/developer/siarzhuk/sis19x/DataRing.cpp haiku/branches/developer/siarzhuk/sis19x/DataRing.h haiku/branches/developer/siarzhuk/sis19x/Device.cpp haiku/branches/developer/siarzhuk/sis19x/Device.h haiku/branches/developer/siarzhuk/sis19x/Driver.cpp haiku/branches/developer/siarzhuk/sis19x/Driver.h haiku/branches/developer/siarzhuk/sis19x/MIIBus.cpp haiku/branches/developer/siarzhuk/sis19x/MIIBus.h haiku/branches/developer/siarzhuk/sis19x/Registers.h haiku/branches/developer/siarzhuk/sis19x/Settings.cpp haiku/branches/developer/siarzhuk/sis19x/Settings.h Log: Fixed Haiku coding style violations mostly pointed by FuncHaikuCheck vim script. Modified: haiku/branches/developer/siarzhuk/sis19x/DataRing.cpp =================================================================== --- haiku/branches/developer/siarzhuk/sis19x/DataRing.cpp 2010-06-01 18:50:04 UTC (rev 36991) +++ haiku/branches/developer/siarzhuk/sis19x/DataRing.cpp 2010-06-01 18:55:37 UTC (rev 36992) @@ -15,27 +15,27 @@ // -// Tx stuff implementation +// Tx stuff implementation // -template<> +template<> void -DataRing<TxDescriptor, TxDescriptorsCount>::_SetBaseAddress(void* address) +DataRing<TxDescriptor, TxDescriptorsCount>::_SetBaseAddress(phys_addr_t address) { fDevice->WritePCI32(TxBase, (uint32)address); } -template<> +template<> status_t -DataRing<TxDescriptor, TxDescriptorsCount>::Write(const uint8* buffer, +DataRing<TxDescriptor, TxDescriptorsCount>::Write(const uint8* buffer, size_t* numBytes) { *numBytes = min_c(*numBytes, MaxFrameSize); // wait for available tx descriptor status_t status = acquire_sem_etc(fSemaphore, 1, B_TIMEOUT, TransmitTimeout); - if(status < B_NO_ERROR) { + if (status < B_NO_ERROR) { TRACE_ALWAYS("Cannot acquire sem:%#010x\n", status); return status; } @@ -48,7 +48,7 @@ // check if the buffer not owned by hardware uint32 descriptorStatus = Descriptor.fCommandStatus; - if((descriptorStatus & TDC_TXOWN) == 0) { + if ((descriptorStatus & TDC_TXOWN) == 0) { // copy data into buffer status = user_memcpy((void*)fBuffers[index], buffer, *numBytes); @@ -56,11 +56,11 @@ // take care about tx descriptor Descriptor.fPacketSize = *numBytes; Descriptor.fEOD |= *numBytes; - Descriptor.fCommandStatus = TDC_PADEN | TDC_CRCEN + Descriptor.fCommandStatus = TDC_PADEN | TDC_CRCEN | TDC_DEFEN | TDC_THOL3 | TDC_TXINT; - if((fDevice->LinkState().media & IFM_HALF_DUPLEX) != 0) { + if ((fDevice->LinkState().media & IFM_HALF_DUPLEX) != 0) { Descriptor.fCommandStatus |= TDC_BKFEN | TDC_CRSEN | TDC_COLSEN; - if(fDevice->LinkState().speed == 1000000) { + if (fDevice->LinkState().speed == 1000000) { Descriptor.fCommandStatus |= TDC_BSTEN | TDC_EXTEN; } } @@ -75,7 +75,7 @@ restore_interrupts(cpuStatus); // if buffer was owned by hardware - notify about it - if((descriptorStatus & TDC_TXOWN) != 0) { + if ((descriptorStatus & TDC_TXOWN) != 0) { release_sem_etc(fSemaphore, 1, B_DO_NOT_RESCHEDULE); TRACE_ALWAYS("Buffer is still owned by the card.\n"); status = B_BUSY; @@ -95,7 +95,7 @@ acquire_spinlock(&fSpinlock); - while(fTail != fHead) { + while (fTail != fHead) { uint32 index = fTail % TxDescriptorsCount; volatile TxDescriptor& Descriptor = fDescriptors[index]; @@ -105,7 +105,7 @@ fDevice->fStatistics.PutTxStatus(status, Descriptor.fEOD/*PacketSize*/); #endif - /*if(status & TDC_TXOWN) { + /*if (status & TDC_TXOWN) { //fDevice->WritePCI32(TxControl, fDevice->ReadPCI32(TxControl) | TxControlPoll); break; //still owned by hardware - poll again ... }*/ @@ -121,7 +121,7 @@ release_spinlock(&fSpinlock); - if(releasedFrames > 0) { + if (releasedFrames > 0) { release_sem_etc(fSemaphore, releasedFrames, B_DO_NOT_RESCHEDULE); return B_INVOKE_SCHEDULER; } @@ -131,7 +131,7 @@ template<> -void +void DataRing<TxDescriptor, TxDescriptorsCount>::CleanUp() { cpu_status cpuStatus = disable_interrupts(); @@ -147,26 +147,26 @@ uint32 droppedFrames = fHead - fTail; /* - for(;fHead != fTail; fHead--, droppedFrames++) { - uint32 index = fHead % TxDescriptorsCount; - volatile TxDescriptor& Descriptor = fDescriptors[index]; + for (;fHead != fTail; fHead--, droppedFrames++) { + uint32 index = fHead % TxDescriptorsCount; + volatile TxDescriptor& Descriptor = fDescriptors[index]; - / * if(Descriptor.fCommandStatus & TDC_TXOWN) { - continue; //still owned by hardware - ignore? - }* / + / * if (Descriptor.fCommandStatus & TDC_TXOWN) { + continue; //still owned by hardware - ignore? + }* / - Descriptor.fPacketSize = 0; - Descriptor.fCommandStatus = 0; - Descriptor.fEOD &= TxDescriptorEOD; - } - */ + Descriptor.fPacketSize = 0; + Descriptor.fCommandStatus = 0; + Descriptor.fEOD &= TxDescriptorEOD; + } + */ #if STATISTICS fDevice->fStatistics.fDropped += droppedFrames; #endif fHead = fTail = 0; - for(size_t i = 0; i < TxDescriptorsCount; i++) { + for (size_t i = 0; i < TxDescriptorsCount; i++) { fDescriptors[i].fPacketSize = 0; fDescriptors[i].fCommandStatus = 0; fDescriptors[i].fEOD &= TxDescriptorEOD;; @@ -177,7 +177,7 @@ //fDevice->WritePCI32(TxStatus, txBase + 8 /*+ index * sizeof(TxDescriptor)*/); //fDevice->WritePCI32(TxBase, txBase); - if(droppedFrames > 0) { + if (droppedFrames > 0) { release_sem_etc(fSemaphore, droppedFrames, B_DO_NOT_RESCHEDULE); } @@ -192,17 +192,17 @@ template<> -void +void DataRing<TxDescriptor, TxDescriptorsCount>::Dump() { int32 count = 0; get_sem_count(fSemaphore, &count); - kprintf("Tx:[count:%ld] head:%lu tail:%lu dirty:%lu\n", + kprintf("Tx:[count:%ld] head:%lu tail:%lu dirty:%lu\n", count, fHead, fTail, fHead - fTail); kprintf("\tPktSize\t\tCmdStat\t\tBufPtr\t\tEOD\n"); - for(size_t i = 0; i < TxDescriptorsCount; i++) { + for (size_t i = 0; i < TxDescriptorsCount; i++) { volatile TxDescriptor& D = fDescriptors[i]; char marker = ((fTail % TxDescriptorsCount) == i) ? '=' : ' '; marker = ((fHead % TxDescriptorsCount) == i) ? '>' : marker; @@ -213,18 +213,18 @@ // -// Rx stuff implementation +// Rx stuff implementation // -template<> +template<> void -DataRing<RxDescriptor, RxDescriptorsCount>::_SetBaseAddress(void* address) +DataRing<RxDescriptor, RxDescriptorsCount>::_SetBaseAddress(phys_addr_t address) { fDevice->WritePCI32(RxBase, (uint32)address); } -template<> +template<> int32 DataRing<RxDescriptor, RxDescriptorsCount>::InterruptHandler() { @@ -232,11 +232,11 @@ acquire_spinlock(&fSpinlock); - uint32 index = fHead % RxDescriptorsCount; - uint32 status = fDescriptors[index].fStatusSize; - uint32 info = fDescriptors[index].fPacketInfo; + uint32 index = fHead % RxDescriptorsCount; + uint32 status = fDescriptors[index].fStatusSize; + uint32 info = fDescriptors[index].fPacketInfo; - while(((info & RDI_RXOWN) == 0) && (fHead - fTail) <= RxDescriptorsCount) { + while (((info & RDI_RXOWN) == 0) && (fHead - fTail) <= RxDescriptorsCount) { #if STATISTICS fDevice->fStatistics.PutRxStatus(status); @@ -252,7 +252,7 @@ release_spinlock(&fSpinlock); - if(receivedFrames > 0) { + if (receivedFrames > 0) { release_sem_etc(fSemaphore, receivedFrames, B_DO_NOT_RESCHEDULE); return B_INVOKE_SCHEDULER; } @@ -261,7 +261,7 @@ } -template<> +template<> status_t DataRing<RxDescriptor, RxDescriptorsCount>::Read(uint8* buffer, size_t* numBytes) { @@ -271,7 +271,7 @@ // wait for received rx descriptor uint32 flags = B_CAN_INTERRUPT | fDevice->fBlockFlag; status_t acquireStatus = acquire_sem_etc(fSemaphore, 1, flags, 0); - if(acquireStatus != B_NO_ERROR) { + if (acquireStatus != B_NO_ERROR) { TRACE_ALWAYS("Cannot acquire sem:%#010x\n", acquireStatus); return acquireStatus; } @@ -279,7 +279,7 @@ cpu_status cpuStatus = disable_interrupts(); acquire_spinlock(&fSpinlock); - uint32 index = fTail % RxDescriptorsCount; + uint32 index = fTail % RxDescriptorsCount; volatile RxDescriptor& Descriptor = fDescriptors[index]; // check if the buffer owned by hardware - should never occure! @@ -289,13 +289,13 @@ bool isFrameValid = false; //status_t rstatus = B_ERROR; - if((info & RDI_RXOWN) == 0) { + if ((info & RDI_RXOWN) == 0) { isFrameValid = (status & rxErrorStatusBits) == 0 && (status & RDS_CRCOK) != 0; - if(isFrameValid) { + if (isFrameValid) { // frame is OK - copy it into buffer *numBytes = status & RDS_SIZE; rstatus = user_memcpy(buffer, (void*)fBuffers[index], *numBytes); - } + } } // take care about rx descriptor @@ -307,10 +307,10 @@ release_spinlock(&fSpinlock); restore_interrupts(cpuStatus); - if((info & RDI_RXOWN) != 0) { + if ((info & RDI_RXOWN) != 0) { TRACE_ALWAYS("Buffer is still owned by the card.\n"); } else { - if(!isFrameValid) { + if (!isFrameValid) { TRACE_ALWAYS("Invalid frame received, status:%#010x;info:%#010x!\n", status, info); } /*else { TRACE_ALWAYS("Read:%d bytes;st:%#010x;info:%#010x!\n", *numBytes, status, info); @@ -319,39 +319,39 @@ fDevice->WritePCI32(RxControl, fDevice->ReadPCI32(RxControl) | RxControlPoll | RxControlEnable); } - if(count > 1) { + if (count > 1) { TRACE_ALWAYS("Warning:Descriptors count is %d!\n", count); } - } while(rstatus != B_OK); + } while (rstatus != B_OK); return rstatus; } -template<> -void +template<> +void DataRing<RxDescriptor, RxDescriptorsCount>::Dump() { int32 count = 0; get_sem_count(fSemaphore, &count); - kprintf("Rx:[count:%ld] head:%lu tail:%lu dirty:%lu\n", + kprintf("Rx:[count:%ld] head:%lu tail:%lu dirty:%lu\n", count, fHead, fTail, fHead - fTail); - for(size_t i = 0; i < 2; i++) { - kprintf("\tStatSize\tPktInfo\t\tBufPtr\t\tEOD %c", + for (size_t i = 0; i < 2; i++) { + kprintf("\tStatSize\tPktInfo\t\tBufPtr\t\tEOD %c", i == 0 ? '|' : '\n'); } - for(size_t i = 0; i < RxDescriptorsCount / 2; i++) { + for (size_t i = 0; i < RxDescriptorsCount / 2; i++) { const char* mask = "%02lx %c\t%08lx\t%08lx\t%08lx\t%08lx %c"; - for(size_t ii = 0; ii < 2; ii++) { + for (size_t ii = 0; ii < 2; ii++) { size_t index = ii == 0 ? i : (i + RxDescriptorsCount / 2); volatile RxDescriptor& D = fDescriptors[index]; char marker = ((fTail % RxDescriptorsCount) == index) ? '=' : ' '; marker = ((fHead % RxDescriptorsCount) == index) ? '>' : marker; - kprintf(mask, index, marker, D.fStatusSize, D.fPacketInfo, + kprintf(mask, index, marker, D.fStatusSize, D.fPacketInfo, D.fBufferPointer, D.fEOD, ii == 0 ? '|' : '\n' ); } } Modified: haiku/branches/developer/siarzhuk/sis19x/DataRing.h =================================================================== --- haiku/branches/developer/siarzhuk/sis19x/DataRing.h 2010-06-01 18:50:04 UTC (rev 36991) +++ haiku/branches/developer/siarzhuk/sis19x/DataRing.h 2010-06-01 18:55:37 UTC (rev 36992) @@ -20,7 +20,7 @@ template<typename __type, uint32 __count> class DataRing { public: - DataRing(Device* device, bool isTx); + DataRing(Device* device, bool isTx); ~DataRing(); status_t Open(); @@ -37,7 +37,7 @@ private: status_t _InitArea(); - void _SetBaseAddress(void* address); + void _SetBaseAddress(phys_addr_t address); Device* fDevice; bool fIsTx; @@ -56,7 +56,7 @@ template<typename __type, uint32 __count> DataRing<__type, __count>::DataRing(Device* device, bool isTx) - : + : fDevice(device), fIsTx(isTx), fStatus(B_NO_INIT), @@ -65,7 +65,7 @@ fSemaphore(0), fHead(0), fTail(0), - fDescriptors(NULL) + fDescriptors(NULL) { memset(fBuffers, 0, sizeof(fBuffers)); } @@ -80,35 +80,35 @@ template<typename __type, uint32 __count> -status_t -DataRing<__type, __count>::_InitArea() +status_t +DataRing<__type, __count>::_InitArea() { // create area for xfer data descriptors and buffers... - // - // layout is following: - // | descriptors array | buffers array | // + // layout is following: + // | descriptors array | buffers array | + // uint32 buffSize = BufferSize + sizeof(__type); - buffSize *= __count; + buffSize *= __count; buffSize = (buffSize + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); - fArea = create_area(DRIVER_NAME "_data_ring", (void**)&fDescriptors, - B_ANY_KERNEL_ADDRESS, buffSize, + fArea = create_area(DRIVER_NAME "_data_ring", (void**)&fDescriptors, + B_ANY_KERNEL_ADDRESS, buffSize, B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); - if(fArea < 0) { - TRACE_ALWAYS("Cannot create area with size %d bytes:%#010x\n", + if (fArea < 0) { + TRACE_ALWAYS("Cannot create area with size %d bytes:%#010x\n", buffSize, fArea); return fStatus = fArea; } - // setup descriptors and buffers layout + // setup descriptors and buffers layout uint8* buffersData = (uint8*)fDescriptors; uint32 descriptorsSize = sizeof(__type) * __count; buffersData += descriptorsSize; physical_entry table = {0}; - for(size_t i = 0; i < __count; i++) { - fBuffers[i] = buffersData + BufferSize * i; + for (size_t i = 0; i < __count; i++) { + fBuffers[i] = buffersData + BufferSize * i; get_memory_map((void*)fBuffers[i], BufferSize, &table, 1); fDescriptors[i].Init(table.address, i == (__count - 1)); @@ -126,18 +126,18 @@ status_t DataRing<__type, __count>::Open() { - if(fStatus != B_OK && _InitArea() != B_OK) { + if (fStatus != B_OK && _InitArea() != B_OK) { return fStatus; } - if(fIsTx) { + if (fIsTx) { fSemaphore = create_sem(__count, "SiS19X Transmit"); } else { fSemaphore = create_sem(0, "SiS19X Receive"); } - if(fSemaphore < 0) { - TRACE_ALWAYS("Cannot create %s semaphore:%#010x\n", + if (fSemaphore < 0) { + TRACE_ALWAYS("Cannot create %s semaphore:%#010x\n", fIsTx ? "transmit" : "receive", fSemaphore); return fStatus = fSemaphore; } Modified: haiku/branches/developer/siarzhuk/sis19x/Device.cpp =================================================================== --- haiku/branches/developer/siarzhuk/sis19x/Device.cpp 2010-06-01 18:50:04 UTC (rev 36991) +++ haiku/branches/developer/siarzhuk/sis19x/Device.cpp 2010-06-01 18:55:37 UTC (rev 36992) @@ -32,10 +32,10 @@ fHasConnection(false), fTxDataRing(this, true), fRxDataRing(this, false) -{ +{ memset((struct timer*)this, 0, sizeof(struct timer)); - uint32 cmdRegister = gPCIModule->read_pci_config(PCIInfo.bus, + uint32 cmdRegister = gPCIModule->read_pci_config(PCIInfo.bus, PCIInfo.device, PCIInfo.function, PCI_command, 2); TRACE_ALWAYS("cmdRegister:%#010x\n", cmdRegister); cmdRegister |= PCI_command_io | PCI_command_memory | PCI_command_master; @@ -64,16 +64,16 @@ } status_t result = fMII.Init(); - if(result != B_OK) { + if (result != B_OK) { TRACE_ALWAYS("MII initialization failed: %#010x.\n", result); return result; } _Reset(); - if((fMII.LinkState().media & IFM_ACTIVE) == 0/*fNegotiationComplete*/) { + if ((fMII.LinkState().media & IFM_ACTIVE) == 0/*fNegotiationComplete*/) { fMII.UpdateLinkState(); - } + } fMII.SetMedia(); @@ -83,10 +83,10 @@ fRxDataRing.Open(); fTxDataRing.Open(); - if(atomic_add(&fInterruptsNest, 1) == 0) { - install_io_interrupt_handler(fPCIInfo.u.h0.interrupt_line, + if (atomic_add(&fInterruptsNest, 1) == 0) { + install_io_interrupt_handler(fPCIInfo.u.h0.interrupt_line, InterruptHandler, this, 0); - TRACE("Interrupt handler installed at line %d.\n", + TRACE("Interrupt handler installed at line %d.\n", fPCIInfo.u.h0.interrupt_line); } @@ -108,7 +108,7 @@ //fNonBlocking = (flags & O_NONBLOCK) == O_NONBLOCK; fOpen = true; - return B_OK; + return B_OK; } @@ -121,7 +121,7 @@ WritePCI32(IntMask, 0); spin(2000); - // Stop Tx/Rx status machine + // Stop Tx / Rx status machine uint32 status = ReadPCI32(IntControl); status |= 0x00008000; WritePCI32(IntControl, status); @@ -129,10 +129,10 @@ status &= ~0x00008000; WritePCI32(IntControl, status); - if(atomic_add(&fInterruptsNest, -1) == 1) { - remove_io_interrupt_handler(fPCIInfo.u.h0.interrupt_line, + if (atomic_add(&fInterruptsNest, -1) == 1) { + remove_io_interrupt_handler(fPCIInfo.u.h0.interrupt_line, InterruptHandler, this); - TRACE("Interrupt handler at line %d uninstalled.\n", + TRACE("Interrupt handler at line %d uninstalled.\n", fPCIInfo.u.h0.interrupt_line); } @@ -170,7 +170,7 @@ status_t Device::Write(const uint8 *buffer, size_t *numBytes) { - if((fMII.LinkState().media & IFM_ACTIVE) == 0) { + if ((fMII.LinkState().media & IFM_ACTIVE) == 0) { TRACE_ALWAYS("Write failed. link is inactive!\n"); return B_OK; // return OK because of well-known DHCP "moustreap"! } @@ -190,8 +190,8 @@ case ETHER_GETADDR: memcpy(buffer, &fMACAddress, sizeof(fMACAddress)); TRACE("ETHER_GETADDR %#02x:%#02x:%#02x:%#02x:%#02x:%#02x\n", - fMACAddress.ebyte[0], fMACAddress.ebyte[1], - fMACAddress.ebyte[2], fMACAddress.ebyte[3], + fMACAddress.ebyte[0], fMACAddress.ebyte[1], + fMACAddress.ebyte[2], fMACAddress.ebyte[3], fMACAddress.ebyte[4], fMACAddress.ebyte[5]); return B_OK; @@ -200,12 +200,12 @@ TRACE("ETHER_ETHER_GETFRAMESIZE:%d\n",fFrameSize); return B_OK; - case ETHER_NONBLOCK: + case ETHER_NONBLOCK: TRACE("ETHER_NONBLOCK\n"); fBlockFlag = *((uint32*)buffer) ? B_TIMEOUT : 0; return B_OK; - case ETHER_SETPROMISC: + case ETHER_SETPROMISC: TRACE("ETHER_SETPROMISC\n"); return _SetRxMode(*((uint8*)buffer)); @@ -235,13 +235,13 @@ { ether_address address; status_t result = ReadMACAddress(address); - if(result != B_OK) { + if (result != B_OK) { TRACE_ALWAYS("Error of reading MAC address:%#010x\n", result); return result; } TRACE("MAC address is:%02x:%02x:%02x:%02x:%02x:%02x\n", - address.ebyte[0], address.ebyte[1], address.ebyte[2], + address.ebyte[0], address.ebyte[1], address.ebyte[2], address.ebyte[3], address.ebyte[4], address.ebyte[5]); fMACAddress = address; @@ -254,7 +254,7 @@ fMII.SetGigagbitCapable(fInfo.Id() == SiS191); - return B_OK; + return B_OK; } @@ -265,7 +265,7 @@ } -uint8 +uint8 Device::ReadPCI8(int offset) { return gPCIModule->read_io_8(fIOBase + offset); @@ -287,7 +287,7 @@ void -Device::WritePCI8(int offset, uint8 value) +Device::WritePCI8(int offset, uint8 value) { gPCIModule->write_io_8(fIOBase + offset, value); } @@ -350,29 +350,29 @@ #endif device->WritePCI32(IntSource, status); - if((status & knownInterruptsMask) != 0) { + if ((status & knownInterruptsMask) != 0) { //break; //} // XXX: ???? result = B_HANDLED_INTERRUPT; - if((status & (/*INT_TXIDLE |*/ INT_TXDONE)) != 0 ) { + if ((status & (/*INT_TXIDLE |*/ INT_TXDONE)) != 0 ) { result = device->fTxDataRing.InterruptHandler(); } - if((status & (/*INT_RXIDLE |*/ INT_RXDONE)) != 0 ) { + if ((status & (/*INT_RXIDLE |*/ INT_RXDONE)) != 0 ) { result = device->fRxDataRing.InterruptHandler(); } - /*if((status & (INT_LINK)) != 0 ) { - //if(!device->fMII.isLinkUp()) { + /*if ((status & (INT_LINK)) != 0 ) { + //if (!device->fMII.isLinkUp()) { device->fTxDataRing.CleanUp(); //} }*/ } - //} while(--maxWorks > 0); + //} while (--maxWorks > 0); // enable interrupts... device->WritePCI32(IntMask, knownInterruptsMask); @@ -386,7 +386,7 @@ status_t Device::GetLinkState(ether_link_state *linkState) { - status_t result = user_memcpy(linkState, &fMII.LinkState(), + status_t result = user_memcpy(linkState, &fMII.LinkState(), sizeof(ether_link_state)); #if STATISTICS @@ -414,7 +414,7 @@ WritePCI16(RxMACControl, (ReadPCI16(RxMACControl) & ~RXM_Mask)); uint16 rxMode = RXM_Broadcast | RXM_Multicast | RXM_Physical; - if(isPromiscuousModeOn) { + if (isPromiscuousModeOn) { rxMode |= RXM_AllPhysical; } @@ -425,7 +425,7 @@ // update rx mode WritePCI16(RxMACControl, ReadPCI16(RxMACControl) | rxMode); - return B_OK; + return B_OK; } @@ -437,17 +437,17 @@ bool linkChanged = false; int32 result = device->fMII.TimerHandler(&linkChanged); - if(linkChanged) { - if(device->fMII.IsLinkUp()) { + if (linkChanged) { + if (device->fMII.IsLinkUp()) { device->fTxDataRing.CleanUp(); //device->WritePCI32(IntControl, 0x8000); //device->ReadPCI32(IntControl); //spin(100); //device->WritePCI32(IntControl, 0x0); - } + } } - if(linkChanged && device->fLinkStateChangeSem > B_OK) { + if (linkChanged && device->fLinkStateChangeSem > B_OK) { release_sem_etc(device->fLinkStateChangeSem, 1, B_DO_NOT_RESCHEDULE); } @@ -515,7 +515,7 @@ // disable disable packet filtering before address is set WritePCI32(RxMACControl, (filter & ~RXM_Mask)); - for(size_t i = 0; i < _countof(fMACAddress.ebyte); i++) { + for (size_t i = 0; i < _countof(fMACAddress.ebyte); i++) { WritePCI8(RxMACAddress + i, fMACAddress.ebyte[i]); } @@ -527,7 +527,7 @@ uint16 Device::_ReadEEPROM(uint32 address) { - if(address > EIOffset) { + if (address > EIOffset) { TRACE_ALWAYS("EEPROM address %#08x is invalid.\n", address); return EIInvalid; } @@ -536,9 +536,9 @@ spin(500); // 500 ms? - for(size_t i = 0; i < 1000; i++) { + for (size_t i = 0; i < 1000; i++) { uint32 data = ReadPCI32(EEPROMInterface); - if((data & EIReq) == 0) { + if ((data & EIReq) == 0) { return (data & EIData) >> EIDataShift; } spin(100); // 100 ms? @@ -554,14 +554,14 @@ Device::ReadMACAddress(ether_address_t& address) { uint16 signature = _ReadEEPROM(EEPROMSignature); - if(signature == 0x0000 || signature == EIInvalid) { + if (signature == 0x0000 || signature == EIInvalid) { TRACE_ALWAYS("EEPROM signature %#06x is invalid.\n", signature); return B_ERROR; } TRACE("EEPROM Signature: %#06x\n", signature); - for(size_t i = 0; i < _countof(address.ebyte) / 2; i++) { + for (size_t i = 0; i < _countof(address.ebyte) / 2; i++) { uint16 addr = _ReadEEPROM(EEPROMAddress + i); address.ebyte[i * 2 + 0] = (uint8)addr; address.ebyte[i * 2 + 1] = (uint8)(addr >> 8); @@ -579,15 +579,15 @@ const char* Name; bool writeBack; } RegisterEntries[] = { - { TxControl, "TxControl", false }, - { TxBase, "TxBase\t", false }, + { TxControl, "TxControl", false }, + { TxBase, "TxBase\t", false }, { TxStatus, "TxStatus", false }, { TxReserved, "TxReserved", false }, { RxControl, "RxControl", false }, { RxBase, "RxBase\t", false }, { RxStatus, "RxStatus", false }, { RxReserved, "RxReserved", false }, - { IntSource, "IntSource", true }, + { IntSource, "IntSource", true }, { IntMask, "IntMask", false }, { IntControl, "IntControl", false }, { IntTimer, "IntTimer", false }, @@ -613,10 +613,10 @@ { Reserved2, "Reserved2", false } }; - for(size_t i = 0; i < _countof(RegisterEntries); i++) { + for (size_t i = 0; i < _countof(RegisterEntries); i++) { uint32 registerContents = ReadPCI32(RegisterEntries[i].Base); kprintf("%s:\t%08lx\n", RegisterEntries[i].Name, registerContents); - if(RegisterEntries[i].writeBack) { + if (RegisterEntries[i].writeBack) { WritePCI32(RegisterEntries[i].Base, registerContents); } } Modified: haiku/branches/developer/siarzhuk/sis19x/Device.h =================================================================== --- haiku/branches/developer/siarzhuk/sis19x/Device.h 2010-06-01 18:50:04 UTC (rev 36991) +++ haiku/branches/developer/siarzhuk/sis19x/Device.h 2010-06-01 18:55:37 UTC (rev 36992) @@ -37,11 +37,11 @@ const uint32 fId; const char* fName; const char* fDescription; - inline const char* Name() { return fName; } - inline const char* Description() { return fName; } - inline uint16 DeviceId() { return DEVICEID(fId); } - inline uint16 VendorId() { return VENDORID(fId); } - inline uint32 Id() { return fId; } + inline const char* Name() { return fName; } + inline const char* Description() { return fName; } + inline uint16 DeviceId() { return DEVICEID(fId); } + inline uint16 VendorId() { return VENDORID(fId); } + inline uint32 Id() { return fId; } }; Device(Info &DeviceInfo, pci_info &PCIInfo); @@ -67,7 +67,7 @@ uint8 ReadPCI8(int offset); uint16 ReadPCI16(int offset); uint32 ReadPCI32(int offset); - void WritePCI8(int offset, uint8 value); + void WritePCI8(int offset, uint8 value); void WritePCI16(int offset, uint16 value); void WritePCI32(int offset, uint32 value); @@ -116,7 +116,7 @@ TxDataRing fTxDataRing; RxDataRing fRxDataRing; - void DumpRegisters(); + void DumpRegisters(); #if STATISTICS Statistics fStatistics; Modified: haiku/branches/developer/siarzhuk/sis19x/Driver.cpp =================================================================== --- haiku/branches/developer/siarzhuk/sis19x/Driver.cpp 2010-06-01 18:50:04 UTC (rev 36991) +++ haiku/branches/developer/siarzhuk/sis19x/Driver.cpp 2010-06-01 18:55:37 UTC (rev 36992) @@ -19,7 +19,7 @@ // TODO: Optimize buffers - use size 1536 instead of 2048 and dynamically determine count of descriptors. // TODO: implement tx ring cleanup on reconnect (?) -// TODO: Tx speed is extremely low!!! Only 200 K/sek :-( +// TODO: Tx speed is extremely low!!! Only 200 K/sek :-( int32 api_version = B_CUR_DRIVER_API_VERSION; @@ -73,23 +73,23 @@ uint64 cardId = 0; int cmdIndex = 1; - if(argc < 2) { + if (argc < 2) { kprintf(usageInfo); return 0; } else - if(argc > 2) { + if (argc > 2) { cardId = parse_expression(argv[2]); cmdIndex++; } - if(cardId >= numCards) { + if (cardId >= numCards) { kprintf("%lld - invalid index.\n", cardId); kprintf(usageInfo); return 0; } Device* device = gDevices[cardId]; - if(device == NULL) { + if (device == NULL) { kprintf("Invalid device pointer!!!.\n"); return 0; } @@ -98,7 +98,7 @@ case 'g': device->DumpRegisters(); break; case 't': device->fTxDataRing.Dump(); break; case 'r': device->fRxDataRing.Dump(); break; - default: + default: kprintf("'%s' - invalid parameter\n", argv[cmdIndex]); kprintf(usageInfo); break; @@ -123,13 +123,13 @@ pci_info info = {0}; for (long i = 0; B_OK == (*gPCIModule->get_nth_pci_info)(i, &info); i++) { for (size_t idx = 0; idx < _countof(cardInfos); idx++) { - if (info.vendor_id == cardInfos[idx].VendorId() + if (info.vendor_id == cardInfos[idx].VendorId() && info.device_id == cardInfos[idx].DeviceId()) { TRACE_ALWAYS("Found:%s %#010x\n", cardInfos[idx].Description(), cardInfos[idx].Id()); - if(numCards == MAX_DEVICES) { + if (numCards == MAX_DEVICES) { break; } @@ -158,7 +158,7 @@ } } - if(numCards == 0) { + if (numCards == 0) { put_module(B_PCI_MODULE_NAME); return ENODEV; } @@ -256,7 +256,7 @@ if (gDevices[i] == NULL) continue; - if (gDeviceNames[i]) + if (gDeviceNames[i]) TRACE("%s\n", gDeviceNames[i]); } Modified: haiku/branches/developer/siarzhuk/sis19x/Driver.h =================================================================== --- haiku/branches/developer/siarzhuk/sis19x/Driver.h 2010-06-01 18:50:04 UTC (rev 36991) +++ haiku/branches/developer/siarzhuk/sis19x/Driver.h 2010-06-01 18:55:37 UTC (rev 36992) @@ -18,15 +18,15 @@ #define CARDID(vendor_id, device_id)\ (((uint32)(vendor_id) << 16) | (device_id)) -#define VENDORID(card_id) (((card_id) >> 16) & 0xffff) -#define DEVICEID(card_id) ((card_id) & 0xffff) +#define VENDORID(card_id) (((card_id) >> 16) & 0xffff) +#define DEVICEID(card_id) ((card_id) & 0xffff) const char* const kVersion = "ver.1.0.0"; // ids for supported hardware -const uint32 SiS190 = CARDID(0x1039, 0x0190); -const uint32 SiS191 = CARDID(0x1039, 0x0191); +const uint32 SiS190 = CARDID(0x1039, 0x0190); +const uint32 SiS191 = CARDID(0x1039, 0x0191); extern pci_module_info* gPCIModule; Modified: haiku/branches/developer/siarzhuk/sis19x/MIIBus.cpp =================================================================== --- haiku/branches/developer/siarzhuk/sis19x/MIIBus.cpp 2010-06-01 18:50:04 UTC (rev 36991) +++ haiku/branches/developer/siarzhuk/sis19x/MIIBus.cpp 2010-06-01 18:55:37 UTC (rev 36992) @@ -16,9 +16,9 @@ #include "Registers.h" -#define MII_OUI(id) ((id >> 10) & 0xffff) -#define MII_MODEL(id) ((id >> 4) & 0x003f) -#define MII_REV(id) ((id) & 0x000f) +#define MII_OUI(id) ((id >> 10) & 0xffff) +#define MII_MODEL(id) ((id >> 4) & 0x003f) +#define MII_REV(id) ((id) & 0x000f) #define ISVALID(__address) ((__address) < 32) @@ -66,10 +66,10 @@ fPHYs.MakeEmpty(); // iterate through all possible MII addresses - for(uint8 addr = 0; ISVALID(addr); addr++) { + for (uint8 addr = 0; ISVALID(addr); addr++) { uint16 miiStatus = _Read(MII_BMSR, addr); - if(miiStatus == 0xffff || miiStatus == 0) + if (miiStatus == 0xffff || miiStatus == 0) continue; uint32 Id = CARDID(_Read(MII_PHYID0, addr), _Read(MII_PHYID1, addr)); @@ -77,10 +77,10 @@ TRACE("MII Info(addr:%d,id:%#010x): OUI:%04x; Model:%04x; rev:%02x.\n", addr, Id, MII_OUI(Id), MII_MODEL(Id), MII_REV(Id)); - for(size_t i = 0; i < _countof(miiChipTable); i++){ + for (size_t i = 0; i < _countof(miiChipTable); i++){ ChipInfo& info = miiChipTable[i]; - if(info.fId != UnknownPHY && info.fId != (Id & 0xfffffff0)) + if (info.fId != UnknownPHY && info.fId != (Id & 0xfffffff0)) continue; fPHYs.Put(addr, info); @@ -89,7 +89,7 @@ } } - if(fPHYs.IsEmpty()) { + if (fPHYs.IsEmpty()) { TRACE_ALWAYS("No PHYs found.\n"); return B_ENTRY_NOT_FOUND; } @@ -98,7 +98,7 @@ Select(); // Marvell 88E1111 requires extra initialization - if(fPHYs.Get(fSelectedPHY).fId == Marvell88E1111) { + if (fPHYs.Get(fSelectedPHY).fId == Marvell88E1111) { _Write(0x1b, (fHasRGMII ? 0x808b : 0x808f), fSelectedPHY); spin(200); _Write(0x14, (fHasRGMII ? 0x0ce1 : 0x0c60), fSelectedPHY); @@ -115,22 +115,22 @@ status_t MIIBus::Select(uint16* currentStatus /*= NULL*/) { - if(fPHYs.IsEmpty()) { + if (fPHYs.IsEmpty()) { TRACE_ALWAYS("Error: No PHYs found or available.\n"); return B_ENTRY_NOT_FOUND; } - uint8 lanPHY = NotInitPHY; - uint8 homePHY = NotInitPHY; - fSelectedPHY = NotInitPHY; + uint8 lanPHY = NotInitPHY; + uint8 homePHY = NotInitPHY; + fSelectedPHY = NotInitPHY; - for(ChipInfoMap::Iterator i = fPHYs.Begin(); i != fPHYs.End(); i++) { [... truncated: 629 lines follow ...]