diff --git a/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.cpp b/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.cpp index 481dd29d1f..624a372b23 100644 --- a/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.cpp +++ b/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.cpp @@ -63,7 +63,6 @@ status_t BeceemCPU::CPUReset() { unsigned int value = 0; - unsigned int uiResetValue = 0; if (fWmxDevice->deviceChipID >= T3LPB) { BizarroReadRegister(SYS_CFG, sizeof(value), &value); @@ -115,6 +114,8 @@ BeceemCPU::CPUReset() } // TODO : ELSE OLDER CHIP ID's < T3LP see Misc.c:1048 + unsigned int uiResetValue = 0; + if (fWmxDevice->CPUFlashBoot) { // In flash boot mode MIPS state register has reverse polarity. // So just or with setting bit 30. diff --git a/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemDevice.cpp b/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemDevice.cpp index 77fcfb3092..a73c192661 100644 --- a/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemDevice.cpp +++ b/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemDevice.cpp @@ -41,7 +41,7 @@ mutex gUSBLock; // auto-release helper class class USBSmartLock { public: - USBSmartLock() { mutex_lock(&gUSBLock); } + USBSmartLock() { mutex_lock(&gUSBLock); } ~USBSmartLock() { mutex_unlock(&gUSBLock); } }; @@ -1005,8 +1005,6 @@ BeceemDevice::StartDevice() status_t BeceemDevice::LoadConfig() { - int dtaread = 0; - int fh = open(FIRM_CFG, O_RDONLY); struct stat cfgStat; @@ -1024,9 +1022,7 @@ BeceemDevice::LoadConfig() return B_ERROR; } - dtaread = read(fh, buffer, MAX_USB_TRANSFER); - - if (dtaread < 0) { + if (read(fh, buffer, MAX_USB_TRANSFER) < 0) { TRACE_ALWAYS("Error: Error reading from vendor configuration.\n"); close(fh); free(buffer); diff --git a/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemNVM.cpp b/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemNVM.cpp index 329bcdede6..987e83cca4 100644 --- a/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemNVM.cpp +++ b/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemNVM.cpp @@ -57,13 +57,12 @@ BeceemNVM::NVMInit(WIMAX_DEVICE* swmxdevice) status_t BeceemNVM::NVMFlush() { - unsigned int value = 0; - /* Chipset Bug : Clear the Avail bits on the Read queue. The default * value on this register is supposed to be 0x00001102. * But we get 0x00001122. */ TRACE("Debug: Fixing reset value on 0x0f003004\n"); - value = NVM_READ_DATA_AVAIL; + + unsigned int value = NVM_READ_DATA_AVAIL; BizarroWriteRegister(NVM_SPI_Q_STATUS1_REG, sizeof(value), &value); /* Flush the all of the NVM queues. */ @@ -73,18 +72,17 @@ BeceemNVM::NVMFlush() value = 0; BizarroWriteRegister(SPI_FLUSH_REG, sizeof(value), &value); -return B_OK; + return B_OK; } status_t BeceemNVM::NVMDetect() { - unsigned int uiData = 0; + unsigned int uiData = 0; EEPROMBulkRead(0x0, 4, &uiData); - if (uiData == BECM) - { + if (uiData == BECM) { TRACE_ALWAYS("Info: EEPROM nvm detected.\n"); pwmxdevice->nvmType = NVM_EEPROM; pwmxdevice->nvmDSDSize = EEPROMGetSize(); @@ -96,8 +94,7 @@ BeceemNVM::NVMDetect() return B_ERROR; FlashBulkRead(0x0 + pwmxdevice->nvmFlashCalStart, 4, &uiData); - if (uiData == BECM) - { + if (uiData == BECM) { TRACE_ALWAYS("Info: Flash nvm detected.\n"); pwmxdevice->nvmType = NVM_FLASH; pwmxdevice->nvmDSDSize = FlashGetSize(); @@ -107,7 +104,8 @@ BeceemNVM::NVMDetect() pwmxdevice->nvmType = NVM_UNKNOWN; TRACE_ALWAYS("Error: Couldn't detect nvm storage method, found 0x%X\n", - uiData); + uiData); + return B_ERROR; } @@ -115,63 +113,61 @@ BeceemNVM::NVMDetect() status_t BeceemNVM::NVMChipSelect(unsigned int offset) { - int ChipIndex = 0; - unsigned int PartNum = 0; - unsigned int FlashConfig = 0; - unsigned int GPIOConfig = 0; - - ChipIndex = offset / FLASH_PART_SIZE; + int chipIndex = offset / FLASH_PART_SIZE; // Chip to be selected is already selected - if (bSelectedChip == ChipIndex) + if (bSelectedChip == chipIndex) return B_OK; TRACE("Debug: Selecting chip %d for transaction at 0x%x\n", - ChipIndex, offset); + chipIndex, offset); // Migrate selected chip to new selection - bSelectedChip = ChipIndex; + bSelectedChip = chipIndex; - BizarroReadRegister(FLASH_CONFIG_REG, 4, &FlashConfig); - BizarroReadRegister(FLASH_GPIO_CONFIG_REG, 4, &GPIOConfig); + unsigned int flashConfig = 0; + BizarroReadRegister(FLASH_CONFIG_REG, 4, &flashConfig); + + unsigned int gpioConfig = 0; + BizarroReadRegister(FLASH_GPIO_CONFIG_REG, 4, &gpioConfig); // TRACE("Reading GPIO config 0x%x\n", &GPIOConfig); // TRACE("Reading Flash config 0x%x\n", &FlashConfig); - switch (ChipIndex) - { + unsigned int partitionNumber = 0; + switch (chipIndex) { case 0: - PartNum = 0; + partitionNumber = 0; break; case 1: - PartNum = 3; - GPIOConfig |= (0x4 << 12); + partitionNumber = 3; + gpioConfig |= 0x4 << 12; break; case 2: - PartNum = 1; - GPIOConfig |= (0x1 << 12); + partitionNumber = 1; + gpioConfig |= 0x1 << 12; break; case 3: - PartNum = 2; - GPIOConfig |= (0x2 << 12); + partitionNumber = 2; + gpioConfig |= 0x2 << 12; break; } - if (PartNum == ((FlashConfig >> 12) & 0x3)) + if (partitionNumber == ((flashConfig >> 12) & 0x3)) return B_OK; - FlashConfig &= 0xFFFFCFFF; - FlashConfig = (FlashConfig | (PartNum<<12)); + flashConfig &= 0xFFFFCFFF; + flashConfig = (flashConfig | (partitionNumber<<12)); - // TRACE("Writing GPIO config 0x%x\n", &GPIOConfig); - // TRACE("Writing Flash config 0x%x\n", &FlashConfig); + // TRACE("Writing GPIO config 0x%x\n", &gpioConfig); + // TRACE("Writing Flash config 0x%x\n", &flashConfig); TRACE("Debug: Selecting chip %x.\n", bSelectedChip); - BizarroWriteRegister(FLASH_GPIO_CONFIG_REG, 4, &GPIOConfig); + BizarroWriteRegister(FLASH_GPIO_CONFIG_REG, 4, &gpioConfig); snooze(100); - BizarroWriteRegister(FLASH_CONFIG_REG, 4, &FlashConfig); + BizarroWriteRegister(FLASH_CONFIG_REG, 4, &flashConfig); snooze(100); return B_OK; @@ -183,7 +179,7 @@ BeceemNVM::NVMRead(unsigned int offset, unsigned int size, unsigned int* buffer) { unsigned int temp = 0; unsigned int value = 0; - int Status = 0; + int status = 0; unsigned int myOffset = 0; if (pwmxdevice->nvmType == NVM_FLASH) { @@ -203,9 +199,7 @@ BeceemNVM::NVMRead(unsigned int offset, unsigned int size, unsigned int* buffer) BizarroWriteRegister(0x0f000C80, sizeof(value), &value); } - Status = FlashBulkRead(myOffset, - size, - buffer); + status = FlashBulkRead(myOffset, size, buffer); if (pwmxdevice->driverFwPushed == true) { // Write stored value back @@ -214,21 +208,22 @@ BeceemNVM::NVMRead(unsigned int offset, unsigned int size, unsigned int* buffer) } else if (pwmxdevice->nvmType == NVM_EEPROM) { TRACE_ALWAYS("TODO: NVM_EEPROM Read\n"); - Status = -1; + status = -1; } else { - Status = -1; + status = -1; } - return Status; + return status; } int -BeceemNVM::NVMWrite(unsigned int offset, unsigned int size, unsigned int* buffer) +BeceemNVM::NVMWrite(unsigned int offset, unsigned int size, + unsigned int* buffer) { unsigned int temp = 0; unsigned int value = 0; - int Status = 0; + int status = 0; if (pwmxdevice->nvmType == NVM_FLASH) { // Save data at register @@ -237,21 +232,19 @@ BeceemNVM::NVMWrite(unsigned int offset, unsigned int size, unsigned int* buffer // Flash register with 0 BizarroWriteRegister(0x0f000C80, sizeof(value), &value); - Status = FlashBulkWrite(offset, - size, - buffer); + status = FlashBulkWrite(offset, size, buffer); // Write stored value back BizarroWriteRegister(0x0f000C80, sizeof(temp), &temp); } else if (pwmxdevice->nvmType == NVM_EEPROM) { TRACE_ALWAYS("Todo: NVM_EEPROM Write\n"); - Status = -1; + status = -1; } else { - Status = -1; + status = -1; } - return Status; + return status; } @@ -295,28 +288,25 @@ BeceemNVM::FlashGetSize() unsigned long BeceemNVM::FlashReadID() { - unsigned long RDID = 0; - unsigned int value; // Read the ID from FLASH_CMD_READ_ID - value = (FLASH_CMD_READ_ID<<24); + unsigned int value = FLASH_CMD_READ_ID << 24; BizarroWriteRegister(FLASH_SPI_CMDQ_REG, sizeof(value), &value); snooze(10); // Read SPI READQ Register, The output will be 4 bytes long // The ID is the first 3 bytes. - BizarroReadRegister(FLASH_SPI_READQ_REG, sizeof(RDID), - (unsigned int*)&RDID); + unsigned long readQID = 0; + BizarroReadRegister(FLASH_SPI_READQ_REG, sizeof(readQID), + (unsigned int*)&readQID); - return (RDID >>8); + return readQID >> 8; } status_t BeceemNVM::FlashReadCS() { - unsigned int value; - // Set initial start addresses pwmxdevice->nvmFlashCSStart = FLASH_CS_INFO_START_ADDR; pwmxdevice->nvmFlashBaseAddr = 0; @@ -328,7 +318,7 @@ BeceemNVM::FlashReadCS() if (pwmxdevice->driverDDRinit == false) { - value = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT; + unsigned int value = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT; BizarroWriteRegister(0xAF00A080, sizeof(value), &value); } @@ -340,8 +330,8 @@ BeceemNVM::FlashReadCS() = ntohl(pwmxdevice->nvmFlashCSInfo->FlashLayoutVersion); TRACE_ALWAYS("Info: Flash CS Version/Signature: 0x%X/0x%X\n", - (pwmxdevice->nvmFlashCSInfo->FlashLayoutVersion), - ntohl(pwmxdevice->nvmFlashCSInfo->MagicNumber)); + (pwmxdevice->nvmFlashCSInfo->FlashLayoutVersion), + ntohl(pwmxdevice->nvmFlashCSInfo->MagicNumber)); if (ntohl(pwmxdevice->nvmFlashCSInfo->MagicNumber) == FLASH_CS_SIGNATURE) { pwmxdevice->nvmFlashMajor @@ -368,32 +358,12 @@ BeceemNVM::FlashReadCS() = (pwmxdevice->nvmFlashCSInfo->OffsetFromZeroForCalibrationStart); if (!((pwmxdevice->nvmFlashMajor == 1) - && (pwmxdevice->nvmFlashMinor == 1))) - { + && (pwmxdevice->nvmFlashMinor == 1))) { pwmxdevice->nvmFlashCSStart - = (pwmxdevice->nvmFlashCSInfo->OffsetFromZeroForControlSectionStart); + = pwmxdevice->nvmFlashCSInfo->OffsetFromZeroForControlSectionStart; } // TODO : Flash Write sizes.. no write support atm - #if 0 - if((FLASH_CS_SIGNATURE == (pwmxdevice->nvmFlashCSInfo->MagicNumber)) && - (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(pwmxdevice->nvmFlashCSInfo->SCSIFirmwareVersion)) && - (FLASH_SECTOR_SIZE_SIG == (pwmxdevice->nvmFlashCSInfo->FlashSectorSizeSig)) && - (BYTE_WRITE_SUPPORT == (pwmxdevice->nvmFlashCSInfo->FlashWriteSupportSize))) - { - pwmxdevice->ulFlashWriteSize = (pwmxdevice->nvmFlashCSInfo->FlashWriteSupportSize); - pwmxdevice->fpFlashWrite = flashByteWrite; - pwmxdevice->fpFlashWriteWithStatusCheck = flashByteWriteStatus; - } else { - pwmxdevice->ulFlashWriteSize = MAX_RW_SIZE; - pwmxdevice->fpFlashWrite = flashWrite; - pwmxdevice->fpFlashWriteWithStatusCheck = flashWriteStatus; - } - */ - - //BcmGetFlashSectorSize(Adapter, (Adapter->psFlashCSInfo->FlashSectorSizeSig), - // (Adapter->psFlashCSInfo->FlashSectorSize)); - #endif pwmxdevice->nvmFlashBaseAddr = pwmxdevice->nvmFlashCSInfo->FlashBaseAddr & 0xFCFFFFFF; @@ -414,33 +384,53 @@ BeceemNVM::FlashReadCS() status_t BeceemNVM::FlashCSFlip(PFLASH_CS_INFO FlashCSInfo) { - FlashCSInfo->MagicNumber = ntohl(FlashCSInfo->MagicNumber); - FlashCSInfo->FlashLayoutVersion = ntohl(FlashCSInfo->FlashLayoutVersion); - FlashCSInfo->ISOImageVersion = ntohl(FlashCSInfo->ISOImageVersion); + FlashCSInfo->MagicNumber = ntohl(FlashCSInfo->MagicNumber); + FlashCSInfo->FlashLayoutVersion = ntohl(FlashCSInfo->FlashLayoutVersion); + FlashCSInfo->ISOImageVersion = ntohl(FlashCSInfo->ISOImageVersion); // won't convert according to old assumption - FlashCSInfo->SCSIFirmwareVersion = (FlashCSInfo->SCSIFirmwareVersion); + FlashCSInfo->SCSIFirmwareVersion = FlashCSInfo->SCSIFirmwareVersion; - FlashCSInfo->OffsetFromZeroForPart1ISOImage = ntohl(FlashCSInfo->OffsetFromZeroForPart1ISOImage); - FlashCSInfo->OffsetFromZeroForScsiFirmware = ntohl(FlashCSInfo->OffsetFromZeroForScsiFirmware); - FlashCSInfo->SizeOfScsiFirmware = ntohl(FlashCSInfo->SizeOfScsiFirmware); - FlashCSInfo->OffsetFromZeroForPart2ISOImage = ntohl(FlashCSInfo->OffsetFromZeroForPart2ISOImage); - FlashCSInfo->OffsetFromZeroForCalibrationStart = ntohl(FlashCSInfo->OffsetFromZeroForCalibrationStart); - FlashCSInfo->OffsetFromZeroForCalibrationEnd = ntohl(FlashCSInfo->OffsetFromZeroForCalibrationEnd); - FlashCSInfo->OffsetFromZeroForVSAStart = ntohl(FlashCSInfo->OffsetFromZeroForVSAStart); - FlashCSInfo->OffsetFromZeroForVSAEnd = ntohl(FlashCSInfo->OffsetFromZeroForVSAEnd); - FlashCSInfo->OffsetFromZeroForControlSectionStart = ntohl(FlashCSInfo->OffsetFromZeroForControlSectionStart); - FlashCSInfo->OffsetFromZeroForControlSectionData = ntohl(FlashCSInfo->OffsetFromZeroForControlSectionData); - FlashCSInfo->CDLessInactivityTimeout = ntohl(FlashCSInfo->CDLessInactivityTimeout); - FlashCSInfo->NewImageSignature = ntohl(FlashCSInfo->NewImageSignature); - FlashCSInfo->FlashSectorSizeSig = ntohl(FlashCSInfo->FlashSectorSizeSig); - FlashCSInfo->FlashSectorSize = ntohl(FlashCSInfo->FlashSectorSize); - FlashCSInfo->FlashWriteSupportSize = ntohl(FlashCSInfo->FlashWriteSupportSize); - FlashCSInfo->TotalFlashSize = ntohl(FlashCSInfo->TotalFlashSize); - FlashCSInfo->FlashBaseAddr = ntohl(FlashCSInfo->FlashBaseAddr); - FlashCSInfo->FlashPartMaxSize = ntohl(FlashCSInfo->FlashPartMaxSize); - FlashCSInfo->IsCDLessDeviceBootSig = ntohl(FlashCSInfo->IsCDLessDeviceBootSig); - FlashCSInfo->MassStorageTimeout = ntohl(FlashCSInfo->MassStorageTimeout); + FlashCSInfo->OffsetFromZeroForPart1ISOImage + = ntohl(FlashCSInfo->OffsetFromZeroForPart1ISOImage); + FlashCSInfo->OffsetFromZeroForScsiFirmware + = ntohl(FlashCSInfo->OffsetFromZeroForScsiFirmware); + FlashCSInfo->SizeOfScsiFirmware + = ntohl(FlashCSInfo->SizeOfScsiFirmware); + FlashCSInfo->OffsetFromZeroForPart2ISOImage + = ntohl(FlashCSInfo->OffsetFromZeroForPart2ISOImage); + FlashCSInfo->OffsetFromZeroForCalibrationStart + = ntohl(FlashCSInfo->OffsetFromZeroForCalibrationStart); + FlashCSInfo->OffsetFromZeroForCalibrationEnd + = ntohl(FlashCSInfo->OffsetFromZeroForCalibrationEnd); + FlashCSInfo->OffsetFromZeroForVSAStart + = ntohl(FlashCSInfo->OffsetFromZeroForVSAStart); + FlashCSInfo->OffsetFromZeroForVSAEnd + = ntohl(FlashCSInfo->OffsetFromZeroForVSAEnd); + FlashCSInfo->OffsetFromZeroForControlSectionStart + = ntohl(FlashCSInfo->OffsetFromZeroForControlSectionStart); + FlashCSInfo->OffsetFromZeroForControlSectionData + = ntohl(FlashCSInfo->OffsetFromZeroForControlSectionData); + FlashCSInfo->CDLessInactivityTimeout + = ntohl(FlashCSInfo->CDLessInactivityTimeout); + FlashCSInfo->NewImageSignature + = ntohl(FlashCSInfo->NewImageSignature); + FlashCSInfo->FlashSectorSizeSig + = ntohl(FlashCSInfo->FlashSectorSizeSig); + FlashCSInfo->FlashSectorSize + = ntohl(FlashCSInfo->FlashSectorSize); + FlashCSInfo->FlashWriteSupportSize + = ntohl(FlashCSInfo->FlashWriteSupportSize); + FlashCSInfo->TotalFlashSize + = ntohl(FlashCSInfo->TotalFlashSize); + FlashCSInfo->FlashBaseAddr + = ntohl(FlashCSInfo->FlashBaseAddr); + FlashCSInfo->FlashPartMaxSize + = ntohl(FlashCSInfo->FlashPartMaxSize); + FlashCSInfo->IsCDLessDeviceBootSig + = ntohl(FlashCSInfo->IsCDLessDeviceBootSig); + FlashCSInfo->MassStorageTimeout + = ntohl(FlashCSInfo->MassStorageTimeout); return B_OK; } @@ -450,30 +440,54 @@ status_t BeceemNVM::FlashCSDump(PFLASH_CS_INFO FlashCSInfo) { TRACE_ALWAYS("************Debug dump of Flash CS Info map************\n"); - TRACE_ALWAYS(" MagicNumber is 0x%x\n", FlashCSInfo->MagicNumber); - TRACE_ALWAYS(" FlashLayoutVersion is 0x%x\n", FlashCSInfo->FlashLayoutVersion); - TRACE_ALWAYS(" ISOImageVersion is 0x%x\n", FlashCSInfo->ISOImageVersion); - TRACE_ALWAYS(" SCSIFirmwareVersion is 0x%x\n", FlashCSInfo->SCSIFirmwareVersion); - TRACE_ALWAYS(" OffsetFromZeroForPart1ISOImage is 0x%x\n", FlashCSInfo->OffsetFromZeroForPart1ISOImage); - TRACE_ALWAYS(" OffsetFromZeroForScsiFirmware is 0x%x\n", FlashCSInfo->OffsetFromZeroForScsiFirmware); - TRACE_ALWAYS(" SizeOfScsiFirmware is 0x%x\n", FlashCSInfo->SizeOfScsiFirmware); - TRACE_ALWAYS(" OffsetFromZeroForPart2ISOImage is 0x%x\n", FlashCSInfo->OffsetFromZeroForPart2ISOImage); - TRACE_ALWAYS(" OffsetFromZeroForCalibrationStart is 0x%x\n", FlashCSInfo->OffsetFromZeroForCalibrationStart); - TRACE_ALWAYS(" OffsetFromZeroForCalibrationEnd is 0x%x\n", FlashCSInfo->OffsetFromZeroForCalibrationEnd); - TRACE_ALWAYS(" OffsetFromZeroForVSAStart is 0x%x\n", FlashCSInfo->OffsetFromZeroForVSAStart); - TRACE_ALWAYS(" OffsetFromZeroForVSAEnd is 0x%x\n", FlashCSInfo->OffsetFromZeroForVSAEnd); - TRACE_ALWAYS("OffsetFromZeroForControlSectionStart is 0x%x\n", FlashCSInfo->OffsetFromZeroForControlSectionStart); - TRACE_ALWAYS(" OffsetFromZeroForControlSectionData is 0x%x\n", FlashCSInfo->OffsetFromZeroForControlSectionData); - TRACE_ALWAYS(" CDLessInactivityTimeout is 0x%x\n", FlashCSInfo->CDLessInactivityTimeout); - TRACE_ALWAYS(" NewImageSignature is 0x%x\n", FlashCSInfo->NewImageSignature); - TRACE_ALWAYS(" FlashSectorSizeSig is 0x%x\n", FlashCSInfo->FlashSectorSizeSig); - TRACE_ALWAYS(" FlashSectorSize is 0x%x\n", FlashCSInfo->FlashSectorSize); - TRACE_ALWAYS(" FlashWriteSupportSize is 0x%x\n", FlashCSInfo->FlashWriteSupportSize); - TRACE_ALWAYS(" TotalFlashSize is 0x%x\n", FlashCSInfo->TotalFlashSize); - TRACE_ALWAYS(" FlashBaseAddr is 0x%x\n", FlashCSInfo->FlashBaseAddr); - TRACE_ALWAYS(" FlashPartMaxSize is 0x%x\n", FlashCSInfo->FlashPartMaxSize); - TRACE_ALWAYS(" IsCDLessDeviceBootSig is 0x%x\n", FlashCSInfo->IsCDLessDeviceBootSig); - TRACE_ALWAYS(" MassStorageTimeout is 0x%x\n", FlashCSInfo->MassStorageTimeout); + TRACE_ALWAYS(" MagicNumber is 0x%x\n", + FlashCSInfo->MagicNumber); + TRACE_ALWAYS(" FlashLayoutVersion is 0x%x\n", + FlashCSInfo->FlashLayoutVersion); + TRACE_ALWAYS(" ISOImageVersion is 0x%x\n", + FlashCSInfo->ISOImageVersion); + TRACE_ALWAYS(" SCSIFirmwareVersion is 0x%x\n", + FlashCSInfo->SCSIFirmwareVersion); + TRACE_ALWAYS(" OffsetFromZeroForPart1ISOImage is 0x%x\n", + FlashCSInfo->OffsetFromZeroForPart1ISOImage); + TRACE_ALWAYS(" OffsetFromZeroForScsiFirmware is 0x%x\n", + FlashCSInfo->OffsetFromZeroForScsiFirmware); + TRACE_ALWAYS(" SizeOfScsiFirmware is 0x%x\n", + FlashCSInfo->SizeOfScsiFirmware); + TRACE_ALWAYS(" OffsetFromZeroForPart2ISOImage is 0x%x\n", + FlashCSInfo->OffsetFromZeroForPart2ISOImage); + TRACE_ALWAYS(" OffsetFromZeroForCalibrationStart is 0x%x\n", + FlashCSInfo->OffsetFromZeroForCalibrationStart); + TRACE_ALWAYS(" OffsetFromZeroForCalibrationEnd is 0x%x\n", + FlashCSInfo->OffsetFromZeroForCalibrationEnd); + TRACE_ALWAYS(" OffsetFromZeroForVSAStart is 0x%x\n", + FlashCSInfo->OffsetFromZeroForVSAStart); + TRACE_ALWAYS(" OffsetFromZeroForVSAEnd is 0x%x\n", + FlashCSInfo->OffsetFromZeroForVSAEnd); + TRACE_ALWAYS("OffsetFromZeroForControlSectionStart is 0x%x\n", + FlashCSInfo->OffsetFromZeroForControlSectionStart); + TRACE_ALWAYS(" OffsetFromZeroForControlSectionData is 0x%x\n", + FlashCSInfo->OffsetFromZeroForControlSectionData); + TRACE_ALWAYS(" CDLessInactivityTimeout is 0x%x\n", + FlashCSInfo->CDLessInactivityTimeout); + TRACE_ALWAYS(" NewImageSignature is 0x%x\n", + FlashCSInfo->NewImageSignature); + TRACE_ALWAYS(" FlashSectorSizeSig is 0x%x\n", + FlashCSInfo->FlashSectorSizeSig); + TRACE_ALWAYS(" FlashSectorSize is 0x%x\n", + FlashCSInfo->FlashSectorSize); + TRACE_ALWAYS(" FlashWriteSupportSize is 0x%x\n", + FlashCSInfo->FlashWriteSupportSize); + TRACE_ALWAYS(" TotalFlashSize is 0x%x\n", + FlashCSInfo->TotalFlashSize); + TRACE_ALWAYS(" FlashBaseAddr is 0x%x\n", + FlashCSInfo->FlashBaseAddr); + TRACE_ALWAYS(" FlashPartMaxSize is 0x%x\n", + FlashCSInfo->FlashPartMaxSize); + TRACE_ALWAYS(" IsCDLessDeviceBootSig is 0x%x\n", + FlashCSInfo->IsCDLessDeviceBootSig); + TRACE_ALWAYS(" MassStorageTimeout is 0x%x\n", + FlashCSInfo->MassStorageTimeout); TRACE_ALWAYS("*******************************************************\n"); return B_OK; @@ -481,14 +495,9 @@ BeceemNVM::FlashCSDump(PFLASH_CS_INFO FlashCSInfo) status_t -BeceemNVM::FlashBulkRead(unsigned int offset, unsigned int size, unsigned int* buffer) +BeceemNVM::FlashBulkRead(unsigned int offset, unsigned int size, + unsigned int* buffer) { - unsigned int workOffset = offset; // our work offset - unsigned int partOffset = 0; // register we will read - unsigned int workBytes = 0; // bytes we are working on - unsigned int bytesLeft = size; // counter holding bytes left - unsigned int outputOffset = 0; // where we are in the output - if (pwmxdevice->driverHalt == true) return -ENODEV; @@ -499,21 +508,27 @@ BeceemNVM::FlashBulkRead(unsigned int offset, unsigned int size, unsigned int* b TRACE("Debug: About to read %d bytes from 0x%x \n", size, offset); + unsigned int workOffset = offset; // our scratch work offset + unsigned int bytesLeft = size; // counter holding bytes left + unsigned int outputOffset = 0; // where we are in the output + while (bytesLeft > 0) { NVMChipSelect(workOffset); - partOffset = (workOffset & (FLASH_PART_SIZE - 1)) + FlashGetBaseAddr(); - workBytes = MIN(MAX_RW_SIZE,bytesLeft); + unsigned int partOffset = (workOffset & (FLASH_PART_SIZE - 1)) + + FlashGetBaseAddr(); + unsigned int workBytes = MIN(MAX_RW_SIZE, bytesLeft); // We read the max RW size or whats left TRACE("Debug: reading %d bytes from 0x%x to 0x%x (output offset %d)\n", workBytes, partOffset, partOffset + workBytes, outputOffset); if (ReadRegister(partOffset, workBytes, - (unsigned int*)((unsigned char*)buffer+outputOffset)) != B_OK) { + (unsigned int*)((unsigned char*)buffer + outputOffset)) != B_OK) { // I've only done this once before. - TRACE_ALWAYS("Error: Read error at 0x%x. Read of %d bytes failed.\n", + TRACE_ALWAYS("Error: Read error at 0x%x." + " Read of %d bytes failed.\n", partOffset, workBytes); bSelectedChip = RESET_CHIP_SELECT; return B_ERROR; @@ -535,8 +550,7 @@ BeceemNVM::FlashBulkRead(unsigned int offset, unsigned int size, unsigned int* b status_t BeceemNVM::RestoreBlockProtect(unsigned long writestatus) { - unsigned int value; - value = (FLASH_CMD_WRITE_ENABLE<< 24); + unsigned int value = (FLASH_CMD_WRITE_ENABLE<< 24); BizarroWriteRegister(FLASH_SPI_CMDQ_REG, sizeof(value), &value); snooze(20); @@ -556,196 +570,40 @@ BeceemNVM::DisableBlockProtect(unsigned int offset, size_t size) status_t -BeceemNVM::FlashBulkWrite(unsigned int offset, unsigned int size, unsigned int* buffer) +BeceemNVM::FlashBulkWrite(unsigned int offset, unsigned int size, + unsigned int* buffer) { - unsigned long BPStatus = 0; - unsigned int OffsetFromSectStart = 0; - unsigned int CurrSectOffsetAddr = 0; - unsigned int NumSectTobeRead = 0; - unsigned int SectAlignAddr = 0; - unsigned int SectBoundary = 0; - unsigned int PartOffset = 0; - // unsigned int uiIndex = 0; // used in validation - - status_t Status = B_ERROR; - - unsigned char* ucBuffer = (unsigned char*)buffer; - // unsigned char ucReadBk[16] = {0}; // used in validation - char* TempBuffer = NULL; - - // if (fRemoved == true) - // return -ENODEV; - - OffsetFromSectStart = offset & ~(NVM_SECTOR_SIZE - 1); - SectAlignAddr = offset & ~(NVM_SECTOR_SIZE - 1); - SectBoundary = SectAlignAddr + NVM_SECTOR_SIZE; - - TempBuffer = (char*)malloc(NVM_SECTOR_SIZE); - - if (TempBuffer == NULL) { - TRACE_ALWAYS("Error: Couldn't allocate temporary buffer.\n"); - Status = B_ERROR; - goto FlashBulkWriteEND; - } - - // See if data to be written goes over sector boundry - if (offset + size < SectBoundary) { - NumSectTobeRead = 1; - } else { - // Number of sectors = Last sector start address/First sector start address - NumSectTobeRead = (CurrSectOffsetAddr + size) / NVM_SECTOR_SIZE; - if ((CurrSectOffsetAddr + size)%NVM_SECTOR_SIZE) - { - NumSectTobeRead++; - } - } - - // TODO : Flash2x? - - bSelectedChip = RESET_CHIP_SELECT; - - while (NumSectTobeRead) - { - NVMChipSelect(offset); - PartOffset = (offset & (FLASH_PART_SIZE - 1)) + FlashGetBaseAddr(); - - if (FlashBulkRead(OffsetFromSectStart, - NVM_SECTOR_SIZE, - (unsigned int*)TempBuffer) != B_OK ) - { - TRACE_ALWAYS("Error: Couldn't perform FlashBulkRead\n"); - Status = B_ERROR; - goto FlashBulkWriteEND; - } - - BPStatus = DisableBlockProtect(SectAlignAddr, NVM_SECTOR_SIZE); - - if (NumSectTobeRead > 1) - { - memcpy(&TempBuffer[CurrSectOffsetAddr], ucBuffer, - SectBoundary - (SectAlignAddr + CurrSectOffsetAddr)); - ucBuffer += ((SectBoundary-(SectAlignAddr + CurrSectOffsetAddr))); - size -= (SectBoundary-(SectAlignAddr + CurrSectOffsetAddr)); - } else { - memcpy(&TempBuffer[CurrSectOffsetAddr], ucBuffer, size); - } - - // TODO : SaveHeaderIfPresent if IsFlash2x? - - FlashSectorErase(PartOffset, 1); - - #if 0 - //for(uiIndex = 0; uiIndex < NVM_SECTOR_SIZE; uiIndex += MAX_RW_SIZE) - //{ - //if(devicePresent == false) - //{ - // free(TempBuffer); - // Status = B_ERROR; - // return Status; - //} - //if(B_OK != (*Adapter->fpFlashWrite)(Adapter,uiPartOffset+uiIndex,(&pTempBuff[uiIndex]))) - //{ - // free(TempBuffer); - // Status = B_ERROR; - // return Status; - //} - //} - - // TODO: Data verification needs structs not yet implimented.. this is optional - // add verify boolean option to function in future - for(uiIndex = 0;uiIndex < NVM_SECTOR_SIZE ;uiIndex += MAX_RW_SIZE) - { - if(FlashBulkRead(OffsetFromSectStart+uiIndex, MAX_RW_SIZE ,(unsigned int*)ucReadBk)) - { - if(Adapter->ulFlashWriteSize == 1) - { - unsigned int uiReadIndex = 0; - for(uiReadIndex = 0; uiReadIndex < 16; uiReadIndex++) - { - if(ucReadBk[uiReadIndex] != TempBuff[uiIndex+uiReadIndex]) - { - if(B_OK != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex+uiReadIndex,&pTempBuff[uiIndex+uiReadIndex])) - { - Status = STATUS_FAILURE; - goto BeceemFlashBulkWrite_EXIT; - } - } - } - } - else - { - if(OsalMemCompare(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE)) - { - if(STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex,&pTempBuff[uiIndex])) - { - Status = STATUS_FAILURE; - goto BeceemFlashBulkWrite_EXIT; - } - } - } - } - } - #endif - - if (BPStatus) - { - RestoreBlockProtect(BPStatus); - BPStatus = 0; - } - - CurrSectOffsetAddr = 0; - SectAlignAddr = SectBoundary; - SectBoundary += NVM_SECTOR_SIZE; - OffsetFromSectStart += NVM_SECTOR_SIZE; - NumSectTobeRead--; - } - -FlashBulkWriteEND: - - if (BPStatus) - { - RestoreBlockProtect(BPStatus); - } - - if (TempBuffer) - free(TempBuffer); - - bSelectedChip = RESET_CHIP_SELECT; - return Status; + // TODO : Implement flash writing, not really needed for normal use + TRACE_ALWAYS("%s: Not yet implemented\n", __func__); + return B_ERROR; } status_t BeceemNVM::FlashSectorErase(unsigned int addr, unsigned int numOfSectors) { - unsigned int iIndex = 0, iRetries = 0; - unsigned int uiStatus = 0; - unsigned int value; - TRACE("Debug: Erasing %d sectors at 0x%x\n", numOfSectors, addr); - for (iIndex = 0 ; iIndex < numOfSectors ; iIndex++) - { - value = 0x06000000; + unsigned int uiStatus = 0; + unsigned int iIndex; + for (iIndex = 0 ; iIndex < numOfSectors ; iIndex++) { + unsigned int value = 0x06000000; BizarroWriteRegister(FLASH_SPI_CMDQ_REG, sizeof(value), &value); value = (0xd8000000 | (addr & 0xFFFFFF)); BizarroWriteRegister(FLASH_SPI_CMDQ_REG, sizeof(value), &value); - iRetries = 0; + unsigned int iRetries = 0; - do - { + do { value = (FLASH_CMD_STATUS_REG_READ << 24); if ( BizarroWriteRegister(FLASH_SPI_CMDQ_REG, - sizeof(value), &value) != B_OK ) - { + sizeof(value), &value) != B_OK ) { TRACE_ALWAYS("Error: Failure writing FLASH_SPI_CMDQ_REG\n"); return B_ERROR; } if ( BizarroReadRegister(FLASH_SPI_READQ_REG, - sizeof(uiStatus), &uiStatus) != B_OK) - { + sizeof(uiStatus), &uiStatus) != B_OK) { TRACE_ALWAYS("Error: Failure reading FLASH_SPI_READQ_REG\n"); return B_ERROR; } @@ -756,8 +614,7 @@ BeceemNVM::FlashSectorErase(unsigned int addr, unsigned int numOfSectors) snooze(10); } while ((uiStatus & 0x1) && (iRetries < 400)); - if (uiStatus & 0x1) - { + if (uiStatus & 0x1) { TRACE_ALWAYS("Error: sector erase retry loop exhausted"); return B_ERROR; } @@ -772,44 +629,33 @@ BeceemNVM::FlashSectorErase(unsigned int addr, unsigned int numOfSectors) status_t BeceemNVM::ReadMACFromNVM(ether_address *address) { - status_t Status = B_ERROR; - unsigned char MacAddr[6] = {0}; - - Status = NVMRead(MAC_ADDR_OFFSET, - 6, - (unsigned int*)&MacAddr[0]); - + unsigned char MacAddr[6] = {0}; + status_t status = NVMRead(MAC_ADDR_OFFSET, 6, (unsigned int*)&MacAddr[0]); memcpy(address, MacAddr, 6); - return (Status); + return (status); } unsigned int BeceemNVM::EEPROMGetSize() { - unsigned int uiData = 0; - unsigned int uiIndex = 0; - // To find the EEPROM size read the possible boundaries of the // EEPROM like 4K,8K etc..accessing the EEPROM beyond its size will // result in wrap around. So when we get the End of the EEPROM we will // get 'BECM' string which is indeed at offset 0. + unsigned int uiData = 0; EEPROMBulkRead(0x0, 4, &uiData); - if (ntohl(uiData) == BECM) - { + if (ntohl(uiData) == BECM) { // If EEPROM is present, it will have 'BECM' string at 0th offset. - - for (uiIndex = 1 ; uiIndex <= 256; uiIndex *= 2) - { + unsigned int uiIndex; + for (uiIndex = 1 ; uiIndex <= 256; uiIndex *= 2) { EEPROMBulkRead(uiIndex * 1024, 4, &uiData); if (ntohl(uiData) == BECM) - { return uiIndex * 1024; - } } } @@ -822,28 +668,24 @@ BeceemNVM::EEPROMRead(unsigned int offset, unsigned int *pdwData) { // Read 4 bytes from EEPROM - unsigned int dwReadValue = 0; - unsigned int dwRetries = 16; - unsigned int Value = 0; - // read 0x0f003020 until bit 2 of 0x0f003008 is set. + unsigned int regValue = 0; BizarroReadRegister(EEPROM_SPI_Q_STATUS_REG, - sizeof(unsigned int), &Value); + sizeof(unsigned int), ®Value); - while ((( Value >>2 )&1)==0 ) - { - dwRetries--; + unsigned int retries = 16; + while (((regValue >> 2) & 1) == 0) { + retries--; snooze(200); - if (dwRetries == 0) - { + if (retries == 0) { TRACE_ALWAYS("Error: CMD FIFO is not empty\n"); return B_ERROR; } BizarroReadRegister(EEPROM_SPI_Q_STATUS_REG, - sizeof(unsigned int), &Value); + sizeof(unsigned int), ®Value); } // wrm (0x0f003018, 0xNbXXXXXX) @@ -857,41 +699,40 @@ BeceemNVM::EEPROMRead(unsigned int offset, unsigned int *pdwData) BizarroWriteRegister(EEPROM_CMDQ_SPI_REG, sizeof(unsigned int), &offset); - dwRetries = 50; + retries = 50; - BizarroReadRegister(EEPROM_SPI_Q_STATUS_REG, sizeof(unsigned int), &Value); + BizarroReadRegister(EEPROM_SPI_Q_STATUS_REG, sizeof(unsigned int), + ®Value); - while ((( Value >>1)&1)==1 ) - { - dwRetries--; + while (((regValue >> 1) & 1) == 1) { + retries--; snooze(200); - if (dwRetries == 0) - { + if (retries == 0) { TRACE_ALWAYS("Error: READ FIFO is empty\n"); return B_ERROR; } BizarroReadRegister(EEPROM_SPI_Q_STATUS_REG, sizeof(unsigned int), - &Value); + ®Value); } - BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), &Value); + BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), ®Value); - dwReadValue = Value; + unsigned int dwReadValue = regValue; - BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), &Value); + BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), ®Value); - dwReadValue |= (Value<<8); + dwReadValue |= regValue << 8; - BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), &Value); + BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), ®Value); - dwReadValue |= (Value<<16); + dwReadValue |= regValue << 16; - BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), &Value); + BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), ®Value); - dwReadValue |= (Value<<24); + dwReadValue |= regValue << 24; *pdwData = dwReadValue; @@ -900,7 +741,8 @@ BeceemNVM::EEPROMRead(unsigned int offset, unsigned int *pdwData) status_t -BeceemNVM::EEPROMBulkRead( unsigned int offset, size_t numBytes, unsigned int* buffer) +BeceemNVM::EEPROMBulkRead(unsigned int offset, size_t numBytes, + unsigned int* buffer) { unsigned int uiData[4] = {0}; unsigned int uiBytesRemaining = numBytes; @@ -910,18 +752,15 @@ BeceemNVM::EEPROMBulkRead( unsigned int offset, size_t numBytes, unsigned int* b unsigned int uiExtraBytes = 0; unsigned char* pcBuff = (unsigned char*)buffer; - TRACE("Debug: Reading %x bytes at offset %x.\n", numBytes, offset); - if (offset%16 && uiBytesRemaining) - { + if (offset%16 && uiBytesRemaining) { uiTempOffset = offset - (offset%16); uiExtraBytes = offset - uiTempOffset; EEPROMBulkRead(uiTempOffset, 16, (unsigned int*)&uiData[0]); - if (uiBytesRemaining >= (16 - uiExtraBytes)) - { + if (uiBytesRemaining >= (16 - uiExtraBytes)) { memcpy(buffer, (((unsigned char*)&uiData[0])+uiExtraBytes), 16 - uiExtraBytes); @@ -938,14 +777,13 @@ BeceemNVM::EEPROMBulkRead( unsigned int offset, size_t numBytes, unsigned int* b } } - while (uiBytesRemaining) - { - if (uiBytesRemaining >= 16) - { // for the requests more than or equal to 16 bytes, + while (uiBytesRemaining) { + if (uiBytesRemaining >= 16) { + // for the requests more than or equal to 16 bytes, // use bulk read function to make the access faster. - // TODO : Impliment function to read more data faster - //ReadBeceemEEPROMBulk(offset, &uiData[0]); + // TODO : Implement function to read more data faster + // ReadBeceemEEPROMBulk(offset, &uiData[0]); EEPROMRead(offset, &uiData[0]); memcpy(pcBuff + uiIndex, &uiData[0], 16); // yes requested. offset += 16; @@ -975,13 +813,7 @@ BeceemNVM::EEPROMBulkRead( unsigned int offset, size_t numBytes, unsigned int* b status_t BeceemNVM::ValidateDSD(unsigned long hwParam) { - unsigned long dwReadValue = hwParam; - unsigned short HwParamLen = 0; - unsigned char* puBuffer = NULL; - unsigned short usChksmCalc = 0; - unsigned short usChksmOrg = 0; - - dwReadValue = (dwReadValue + DSD_START_OFFSET); + unsigned long dwReadValue = hwParam + DSD_START_OFFSET; // Get DSD start offset // DSD @@ -994,17 +826,18 @@ BeceemNVM::ValidateDSD(unsigned long hwParam) // +---+ /* Read the Length of structure */ - NVMRead(dwReadValue, 2, (unsigned int*)&HwParamLen); - HwParamLen = ntohs(HwParamLen); + unsigned short hwParamLen = 0; + NVMRead(dwReadValue, 2, (unsigned int*)&hwParamLen); + hwParamLen = ntohs(hwParamLen); /* Validate length */ - if (0==HwParamLen || HwParamLen > MAX_NVM_SIZE) { - TRACE_ALWAYS("Error: Param length is invalid! (%d)\n", HwParamLen); + if (0==hwParamLen || hwParamLen > MAX_NVM_SIZE) { + TRACE_ALWAYS("Error: Param length is invalid! (%d)\n", hwParamLen); return B_ERROR; } else - TRACE("Debug: Found valid param length. (%d)\n", HwParamLen); + TRACE("Debug: Found valid param length. (%d)\n", hwParamLen); - puBuffer = (unsigned char*)malloc(HwParamLen); + unsigned char* puBuffer = (unsigned char*)malloc(hwParamLen); // Allocate memory to calculate checksum on if (!puBuffer) { @@ -1013,13 +846,15 @@ BeceemNVM::ValidateDSD(unsigned long hwParam) return B_ERROR; } - NVMRead(dwReadValue, HwParamLen, (unsigned int*)puBuffer); + NVMRead(dwReadValue, hwParamLen, (unsigned int*)puBuffer); // Populate allocated memory with string for checksum - usChksmCalc = CalculateHWChecksum(puBuffer, HwParamLen); + unsigned short usChksmCalc = 0; + usChksmCalc = CalculateHWChecksum(puBuffer, hwParamLen); // Perform checksum on values - NVMRead(dwReadValue + HwParamLen, 2, (unsigned int*)&usChksmOrg); + unsigned short usChksmOrg = 0; + NVMRead(dwReadValue + hwParamLen, 2, (unsigned int*)&usChksmOrg); // Read what the device thinks the checksum should be usChksmOrg = ntohs(usChksmOrg); @@ -1027,7 +862,7 @@ BeceemNVM::ValidateDSD(unsigned long hwParam) if (usChksmCalc ^ usChksmOrg) { TRACE_ALWAYS("Error: Param checksum mismatch!\n"); - TRACE_ALWAYS(" HW Param Length = %d\n", HwParamLen); + TRACE_ALWAYS(" HW Param Length = %d\n", hwParamLen); TRACE_ALWAYS(" Calculated checksum = %x\n", usChksmCalc); TRACE_ALWAYS(" Stored checksum = %x\n", usChksmOrg); free(puBuffer); diff --git a/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/Driver.cpp b/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/Driver.cpp index 7888003326..ea14436d12 100644 --- a/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/Driver.cpp +++ b/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/Driver.cpp @@ -72,19 +72,24 @@ create_beceem_device(usb_device device) return NULL; } -#define IDS(__vendor, __product) (((__vendor) << 16) | (__product)) - + #define IDS(__vendor, __product) (((__vendor) << 16) | (__product)) + switch(IDS(deviceDescriptor->vendor_id, deviceDescriptor->product_id)) { case IDS(0x0489, 0xe016): - return new BeceemDevice(device, "Ubee WiMAX Mobile USB - PXU1900 (Clear)"); + return new BeceemDevice(device, + "Ubee WiMAX Mobile USB - PXU1900 (Clear)"); case IDS(0x0489, 0xe017): - return new BeceemDevice(device, "Ubee WiMAX Mobile USB - PXU1901 (Sprint)"); + return new BeceemDevice(device, + "Ubee WiMAX Mobile USB - PXU1901 (Sprint)"); case IDS(0x198f, 0x0210): - return new BeceemDevice(device, "Motorola USBw 100 WiMAX CPE"); + return new BeceemDevice(device, + "Motorola USBw 100 WiMAX CPE"); case IDS(0x198f, 0x0220): - return new BeceemDevice(device, "Beceem Mobile USB WiMAX CPE"); + return new BeceemDevice(device, + "Beceem Mobile USB WiMAX CPE"); case IDS(0x19d2, 0x0007): - return new BeceemDevice(device, "ZTE TU25 WiMAX Adapter [Beceem BCS200]"); + return new BeceemDevice(device, + "ZTE TU25 WiMAX Adapter [Beceem BCS200]"); } return NULL; } @@ -159,7 +164,7 @@ usb_beceem_device_removed(void *cookie) if (gBeceemDevices[i] == device) { if (device->IsOpen()) { // the device will be deleted upon being freed - TRACE("Debug: Device %ld will be deleted upon being freed.\n", i); + TRACE("Debug: Device %ld will be deleted when freed.\n", i); device->Removed(); } else { TRACE("Debug: Device at %ld will be deleted.\n", i); @@ -194,9 +199,9 @@ init_driver() return status; load_settings(); - + TRACE_ALWAYS("%s\n", kVersion); - + for (int32 i = 0; i < MAX_DEVICES; i++) gBeceemDevices[i] = NULL; @@ -208,7 +213,7 @@ init_driver() &usb_beceem_device_removed }; - gUSBModule->register_driver(DRIVER_NAME, gSupportedDevices, + gUSBModule->register_driver(DRIVER_NAME, gSupportedDevices, sizeof(gSupportedDevices) / sizeof(usb_support_descriptor), NULL); gUSBModule->install_notify(DRIVER_NAME, ¬ifyHooks); return B_OK; @@ -235,7 +240,7 @@ uninit_driver() mutex_destroy(&gDriverLock); put_module(B_USB_MODULE_NAME); - + release_settings(); } @@ -295,9 +300,9 @@ usb_beceem_free(void *cookie) { TRACE("Debug: Device to be freed\n"); BeceemDevice *device = (BeceemDevice *)cookie; - + DriverSmartLock driverLock; // released on exit - + status_t status = device->Free(); for (int32 i = 0; i < MAX_DEVICES; i++) { if (gBeceemDevices[i] == device) { @@ -324,7 +329,7 @@ publish_devices() } DriverSmartLock driverLock; // released on exit - + int32 deviceCount = 0; for (int32 i = 0; i < MAX_DEVICES; i++) { if (gBeceemDevices[i] == NULL) @@ -336,7 +341,7 @@ publish_devices() TRACE("Debug: publishing %s\n", gDeviceNames[deviceCount]); deviceCount++; } else - TRACE_ALWAYS("Error: out of memory during allocating device name.\n"); + TRACE_ALWAYS("Error: out of memory allocating device name.\n"); } gDeviceNames[deviceCount] = NULL;