void _rtw_udelay_os(int us, const char *func, const int line) { #if 0 if(us > 1000) { DBG_871X("%s:%d %s(%d)\n", func, line, __FUNCTION__, us); rtw_usleep_os(us); return; } #endif DBG_871X("%s:%d %s(%d)\n", func, line, __FUNCTION__, us); #if defined(PLATFORM_LINUX) udelay((unsigned long)us); #elif defined(PLATFORM_WINDOWS) NdisStallExecution(us); //(us) #endif }
U16 C_DM9000::DeviceWriteEeprom( U32 uWordAddress, U16 uValue) { // assign the register offset DeviceWritePort(DM9_EPADDR,uWordAddress); // put data DeviceWritePort(DM9_EPLOW, LOW_BYTE(uValue)); DeviceWritePort(DM9_EPHIGH,HIGH_BYTE(uValue)); // issue EEPROM write enable<4> and write command<1> DeviceWritePort(DM9_EPCNTL,MAKE_MASK2(4,1)); // wait until status bit<0> cleared DevicePolling(DM9_EPCNTL,MAKE_MASK(0),0x00); // stop command DeviceWritePort(DM9_EPCNTL,0); // extra delay NdisStallExecution(1000); return uValue; }
void rtw_udelay_os(int us) { #ifdef PLATFORM_LINUX udelay((unsigned long)us); #endif #ifdef PLATFORM_WINDOWS NdisStallExecution(us); //(us) #endif }
void rtw_mdelay_os(int ms) { #ifdef PLATFORM_LINUX mdelay((unsigned long)ms); #endif #ifdef PLATFORM_WINDOWS NdisStallExecution(ms*1000); //(us)*1000=(ms) #endif }
void rtw_udelay_os(int us) { #ifdef PLATFORM_LINUX udelay((unsigned long)us); #endif #ifdef PLATFORM_FREEBSD //Delay for delay microseconds DELAY(us); return ; #endif #ifdef PLATFORM_WINDOWS NdisStallExecution(us); //(us) #endif }
// Called at PASSIVE or DISPATCH BOOLEAN HwSetRFOn( _In_ PHW Hw, _In_ UCHAR MaxRetries ) { UCHAR RetryCount = 0; // // This is at dispatch, dont spin for long // while (RetryCount < MaxRetries) { if (HwSetRFState(Hw, RF_ON) == FALSE) { // If radio is OFF, hw awake can fail. It can also fail // if something else is changing radio state, in which case, we try // try again if (Hw->PhyState.SoftwareRadioOff == TRUE) { // Failed because radio was OFF break; } else { // // Something else is toggling RF state // NdisStallExecution(10); // Stall for 10 microseconds } } else { // Hw awake OK return TRUE; } RetryCount++; } return FALSE; }
void _rtw_mdelay_os(int ms, const char *func, const int line) { if(ms>10) DBG_871X("%s:%d %s(%d)\n", func, line, __FUNCTION__, ms); rtw_msleep_os(ms); return; DBG_871X("%s:%d %s(%d)\n", func, line, __FUNCTION__, ms); #if defined(PLATFORM_LINUX) mdelay((unsigned long)ms); #elif defined(PLATFORM_WINDOWS) NdisStallExecution(ms*1000); //(us)*1000=(ms) #endif }
void sirBusyWaitIntern(void *pMacGlobal, tANI_U32 duration) { NdisStallExecution((duration+999)/1000); // This routine takes the duration in uSecs. } // sirBusyWaitIntern()
/* ************************************************************************* * PortReadyForWrite ************************************************************************* * * Called when COM port is ready for another write packet. * Send the first frame in the send queue. * * Return TRUE iff send succeeded. * * NOTE: Do not call inside of interrupt context. * */ BOOLEAN PortReadyForWrite(IrDevice *thisDev, BOOLEAN isSynchronousSend) { BOOLEAN sendSucceeded = FALSE; DBGOUT(("PortReadyForWrite(dev=0x%x, %xh, %s)", (UINT)thisDev, thisDev->portInfo.ioBase, (CHAR *)(isSynchronousSend ? "sync" : "async"))); if (thisDev->firstSendPacket){ PNDIS_PACKET packetToSend; PNDIS_IRDA_PACKET_INFO packetInfo; /* * Dequeue the first send packet and step the send queue. * (We use the packet's MiniportReserved field is a 'next' pointer). */ packetToSend = thisDev->firstSendPacket; thisDev->firstSendPacket = *(PNDIS_PACKET *)thisDev->firstSendPacket->MiniportReserved; if (!thisDev->firstSendPacket){ thisDev->lastSendPacket = NULL; } *(PNDIS_PACKET *)packetToSend->MiniportReserved = NULL; /* * Enforce the minimum turnaround time that must transpire * after the last receive. */ packetInfo = GetPacketInfo(packetToSend); if (packetInfo->MinTurnAroundTime){ /* * Don't want to call NdisStallExecution with more than * 8 msec or it will cause a task switch. * Make a series of calls with 8 msec or less. */ UINT usecToWait = packetInfo->MinTurnAroundTime; do { UINT usec = (usecToWait > 8000) ? 8000 : usecToWait; NdisStallExecution(usec); usecToWait -= usec; } while (usecToWait > 0); } /* * See if this was the last packet before we need to change speed. */ if (packetToSend == thisDev->lastPacketAtOldSpeed){ thisDev->lastPacketAtOldSpeed = NULL; thisDev->setSpeedAfterCurrentSendPacket = TRUE; } /* * Send one packet to the COMM port. */ DBGPKT(("Sending packet 0x%x (0x%x).", thisDev->packetsSent++, (UINT)packetToSend)); sendSucceeded = DoSend(thisDev, packetToSend); /* * If the buffer we just sent was pending * (i.e. we returned NDIS_STATUS_PENDING for it in MiniportSend), * then hand the sent packet back to the protocol. * Otherwise, we're just delivering it synchronously from MiniportSend. */ if (!isSynchronousSend){ DBGOUT(("Calling NdisMSendComplete")); NdisMSendComplete(thisDev->ndisAdapterHandle, packetToSend, (NDIS_STATUS)(sendSucceeded ? NDIS_STATUS_SUCCESS : NDIS_STATUS_FAILURE)); } } DBGOUT(("PortReadyForWrite done.")); return sendSucceeded; }
NDIS_STATUS CardInitialize( IN PHTDSU_ADAPTER Adapter, IN BOOLEAN PerformSelfTest ) /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Functional Description: This routine will attempt to initialize the controller, but will not enable transmits or receives. Parameters: Adapter _ A pointer ot our adapter information structure. PerformSelfTest _ TRUE if caller wants to run selftest diagnostics. This normally takes about 4 seconds to complete, so you wouldn't want to do it every time you start up. Return Values: NDIS_STATUS_HARD_ERRORS NDIS_STATUS_SUCCESS ---------------------------------------------------------------------------*/ { DBG_FUNC("CardInitialize") NDIS_STATUS Status; USHORT SelfTestStatus; UINT TimeOut; DBG_ENTER(Adapter); /* // First we make sure the adapter is where we think it is. */ Status = CardIdentify(Adapter); if (Status != NDIS_STATUS_SUCCESS) { return (Status); } /* // Reset the hardware to make sure we're in a known state. */ Status = CardDoCommand(Adapter, 0, HTDSU_CMD_RESET); if (PerformSelfTest) { /* // Wait for the reset to complete before starting the self-test. // Then issue the self-test command to see if the adapter firmware // is happy with the situation. */ Status = CardDoCommand(Adapter, 0, HTDSU_CMD_SELFTEST); if (Status != NDIS_STATUS_SUCCESS) { DBG_ERROR(Adapter,("Failed HTDSU_CMD_RESET\n")); /* // Log error message and return. */ NdisWriteErrorLogEntry( Adapter->MiniportAdapterHandle, NDIS_ERROR_CODE_HARDWARE_FAILURE, 3, Status, __FILEID__, __LINE__ ); return (Status); } /* // Wait for the self test to complete, but don't wait forever. */ TimeOut = 0; while (Status == NDIS_STATUS_SUCCESS && READ_REGISTER_USHORT(&Adapter->AdapterRam->Command) != HTDSU_CMD_NOP) { if (TimeOut++ > HTDSU_SELFTEST_TIMEOUT) { DBG_ERROR(Adapter,("Timeout waiting for SELFTEST to complete\n")); Status = NDIS_STATUS_HARD_ERRORS; } else { NdisStallExecution(_100_MICROSECONDS); } } if (Status != NDIS_STATUS_SUCCESS) { DBG_ERROR(Adapter,("Failed HTDSU_CMD_SELFTEST\n")); /* // Log error message and return. */ NdisWriteErrorLogEntry( Adapter->MiniportAdapterHandle, NDIS_ERROR_CODE_HARDWARE_FAILURE, 3, Status, __FILEID__, __LINE__ ); return (Status); } /* // Verify that self test was successful. */ SelfTestStatus = READ_REGISTER_USHORT(&Adapter->AdapterRam->SelfTestStatus); if (SelfTestStatus != 0 && SelfTestStatus != HTDSU_SELFTEST_OK) { DBG_ERROR(Adapter,("Failed HTDSU_CMD_SELFTEST (Status=%X)\n", SelfTestStatus)); /* // Log error message and return. */ NdisWriteErrorLogEntry( Adapter->MiniportAdapterHandle, NDIS_ERROR_CODE_HARDWARE_FAILURE, 3, SelfTestStatus, __FILEID__, __LINE__ ); return (NDIS_STATUS_HARD_ERRORS); } } DBG_LEAVE(Adapter); return (NDIS_STATUS_SUCCESS); }
NDIS_STATUS CardDoCommand( IN PHTDSU_ADAPTER Adapter, IN USHORT CardLine, /* HTDSU_CMD_LINE1 or HTDSU_CMD_LINE2 */ IN USHORT CommandValue ) /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Functional Description: This routine routine will execute a command on the card after making sure the previous command has completed properly. Parameters: Adapter _ A pointer ot our adapter information structure. CardLine _ Specifies which line to use for the transmit (HTDSU_LINEx_ID). CommandValue _ HTDSU_CMD_??? command to be executed. Return Values: NDIS_STATUS_SUCCESS NDIS_STATUS_HARD_ERRORS ---------------------------------------------------------------------------*/ { DBG_FUNC("CardDoCommand") ULONG TimeOut = 0; DBG_ENTER(Adapter); DBG_FILTER(Adapter, DBG_PARAMS_ON,("Line=%d, Command=%04X, LineStatus=%Xh\n", CardLine, CommandValue, READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine1) )); /* // Wait for command register to go idle - but don't wait too long. // If we timeout here, there's gotta be something wrong with the adapter. */ while ((READ_REGISTER_USHORT(&Adapter->AdapterRam->Command) != HTDSU_CMD_NOP) || (READ_REGISTER_USHORT(&Adapter->AdapterRam->CoProcessorId) != HTDSU_COPROCESSOR_ID)) { if (TimeOut++ > HTDSU_SELFTEST_TIMEOUT) { DBG_ERROR(Adapter,("Timeout waiting for %04X command to clear\n", READ_REGISTER_USHORT(&Adapter->AdapterRam->Command))); /* // Ask for reset, and disable interrupts until we get it. */ Adapter->NeedReset = TRUE; Adapter->InterruptEnableFlag = HTDSU_INTR_DISABLE; CardDisableInterrupt(Adapter); return (NDIS_STATUS_HARD_ERRORS); } NdisStallExecution(_100_MICROSECONDS); } DBG_NOTICE(Adapter,("Timeout=%d waiting to submit %04X\n", TimeOut, CommandValue)); /* // Before starting a reset command, we clear the the co-processor ID // which then gets set to the proper value when the reset is complete. */ if (CommandValue == HTDSU_CMD_RESET) { WRITE_REGISTER_USHORT(&Adapter->AdapterRam->CoProcessorId, 0); } /* // Send the command to the adapter. */ WRITE_REGISTER_USHORT( &Adapter->AdapterRam->Command, (USHORT) (CommandValue + CardLine) ); DBG_LEAVE(Adapter); return (NDIS_STATUS_SUCCESS); }
BOOLEAN LtFirmInitialize( IN PLT_ADAPTER Adapter, IN UCHAR SuggestedNodeId ) /*++ Routine Description: This routine initializes the card, downloads the firmware to it. Arguments: Adapter : Pointer to the adapter structure. Return Value: TRUE : If successful, false otherwise --*/ { PUCHAR Firmware; UINT FirmwareLen; UINT RetryCount; UCHAR Data; BOOLEAN Result = FALSE; // Clear the request Latch NdisRawReadPortUchar(XFER_PORT, &Data); // Clear the TX_READY FLOP NdisRawWritePortUchar(XFER_PORT, (UCHAR)0); // Reset the card. NdisRawWritePortUchar(RESET_PORT, (UCHAR)0); NdisStallExecution(LT_FIRM_INIT_STALL_TIME*5); for (RetryCount = 0; RetryCount < MAX_READ_RETRY_COUNT; RetryCount++) { // Get Card Status. NdisRawReadPortUchar(SC_PORT, &Data); if (Data & TX_READY) { break; } else DBGPRINT(DBG_COMP_INIT, DBG_LEVEL_WARN, ("LtFirmInitialize: Waiting for card ready SC_PORT %x\n", Data)); NdisStallExecution(LT_FIRM_INIT_STALL_TIME); } // BUGBUG: // !!!!!! // For DAYNA, it will not be ready at this point. DCH is going to // send information to fix this. do { if (RetryCount == MAX_READ_RETRY_COUNT) { LOGERROR( Adapter->NdisAdapterHandle, NDIS_ERROR_CODE_HARDWARE_FAILURE); DBGPRINT(DBG_COMP_INIT, DBG_LEVEL_FATAL, ("LtFirmInitialize: Card Not Ready after Reset\n")); break; } // Copy the firmware to the card. Firmware = LtMicroCode; FirmwareLen = sizeof(LtMicroCode); DBGPRINT(DBG_COMP_INIT, DBG_LEVEL_INFO, ("LtFirmInitialize: DownLoad %d bytes of firmware\n", FirmwareLen)); // Well... the card is alive and well and in a reset state. // Next we need to output the first byte of the firmware and // check for TX_READY. NdisRawWritePortUchar(XFER_PORT, *Firmware); DBGPRINT(DBG_COMP_INIT, DBG_LEVEL_INFO, ("LtFirmInitialize: First byte of Firmware on card\n")); NdisRawReadPortUchar(SC_PORT, &Data); if (Data & TX_READY) { DBGPRINT(DBG_COMP_INIT, DBG_LEVEL_FATAL, ("LtFirmInitialize: Card Not Ready During Download\n")); LOGERROR( Adapter->NdisAdapterHandle, NDIS_ERROR_CODE_HARDWARE_FAILURE); break; } // Skip over the first byte because it already out there. Firmware ++; FirmwareLen --; NdisRawWritePortBufferUchar(XFER_PORT, Firmware, FirmwareLen); // Tell the card to start NdisRawReadPortUchar(XFER_PORT, &Data); // Wait for the card to start for (RetryCount = 0; RetryCount < MAX_START_RETRY_COUNT; RetryCount++) { NdisStallExecution(LT_FIRM_INIT_STALL_TIME); // Get Status NdisRawReadPortUchar(SC_PORT, &Data); DBGPRINT(DBG_COMP_INIT, DBG_LEVEL_WARN, ("LtFirmInitialize: Waiting for start - SC_PORT Data %x\n", (UCHAR)Data)); if (Data & RX_READY) { break; } } // !!! This seems to be the only way the MCA card works according to // !!! Dave Hornbaker. It seems that the MCA card doesnt get ready at // !!! this point, but works later on. if (RetryCount == MAX_START_RETRY_COUNT) { ASSERT(Adapter->BusType != NdisInterfaceMca); DBGPRINT(DBG_COMP_INIT, DBG_LEVEL_FATAL, ("LtFirmInitialize: Card Not Ready, could not get status\n")); LOGERROR( Adapter->NdisAdapterHandle, NDIS_ERROR_CODE_INVALID_VALUE_FROM_ADAPTER); break; } // Clear the initial ready signal. NdisRawReadPortUchar(XFER_PORT, &Data); // Now loop here for a finite time till the card acquires a node id. // If it fails to do so in the specified time, fail the load. if (!LtInitGetAddressSetPoll(Adapter, SuggestedNodeId)) { break; } // We need to catch the card fast after it acquire the node id and before it // receives any packets. If it does receive any packets, then ask it acquire // the node id again. The stall happens ONLY IF A PACKET IS RECVD. for (RetryCount = 0; RetryCount < MAX_START_RETRY_COUNT*200; RetryCount++) { USHORT ResponseLength; UCHAR ResponseType; LT_INIT_RESPONSE InitPacket; // Check for receive data NdisRawReadPortUchar(SC_PORT, &Data); if (Data & RX_READY) { // Get the length of the response on the card NdisRawReadPortUchar(XFER_PORT, &Data); ResponseLength = (USHORT)(Data & 0xFF); NdisRawReadPortUchar(XFER_PORT, &Data); ResponseLength |= (Data << 8); // Now get the IO code. NdisRawReadPortUchar(XFER_PORT, &ResponseType); DBGPRINT(DBG_COMP_INIT, DBG_LEVEL_INFO, ("LtFirmInitialize: RespType = %x, RespLength = %d\n", ResponseType, ResponseLength)); if ((ResponseType == LT_RSP_LAP_INIT) && (ResponseLength == sizeof(LT_INIT_RESPONSE))) { NdisRawReadPortBufferUchar(XFER_PORT, (PUCHAR)&InitPacket, ResponseLength); Adapter->NodeId = InitPacket.NodeId; Adapter->Flags |= ADAPTER_NODE_ID_VALID; // This should start off a worker thread to write the // node id into the pram. // BUGBUG: Implement using worker threads. // LtRegWritePramNodeId(Adapter); DBGPRINT(DBG_COMP_INIT, DBG_LEVEL_INFO, ("LtFirmInitailize: Node id acquired %x\n", InitPacket.NodeId)); break; } DBGPRINT(DBG_COMP_INIT, DBG_LEVEL_WARN, ("LtFirmInitailize: Node id not valid yet !!\n")); // Suck in the packet and throw it away while (ResponseLength-- > 0) { NdisRawReadPortUchar(XFER_PORT, &Data); } // The response was probably over-written by incoming packet. // Try again. NdisStallExecution(LT_FIRM_INIT_STALL_TIME); DBGPRINT(DBG_COMP_INIT, DBG_LEVEL_WARN, ("LtFirmInitailize: Re-acquire node after packet recv\n")); if (!LtInitGetAddressSetPoll(Adapter, SuggestedNodeId)) { break; } } else { DBGPRINT(DBG_COMP_INIT, DBG_LEVEL_WARN, ("LtFirmInitialize: Waiting for node - SC_PORT Data %x\n", (UCHAR)Data)); } NdisStallExecution(500); // 500us } Result = ((Adapter->Flags & ADAPTER_NODE_ID_VALID) != 0); } while (FALSE); return(Result); }
VOID NE3200ResetHandler( IN PVOID SystemSpecific1, IN PNE3200_ADAPTER Adapter, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3 ) /*++ Routine Description: This manages the reset/download process. It is responsible for resetting the adapter, waiting for proper status, downloading MAC.BIN, waiting for MAC.BIN initialization, and optionally sending indications to the appropriate protocol. Since the NE3200's status registers must be polled during the reset/download process, this is implemented as a state machine. Arguments: Adapter - The adapter whose hardware is to be initialized. Return Value: None. --*/ { // // Physical address of the MAC.BIN buffer. // NDIS_PHYSICAL_ADDRESS MacBinPhysicalAddress; // // Status from the adapter. // UCHAR Status; // // Simple iteration counter. // UINT i; // // Loop until the reset has completed. // while (Adapter->ResetState != NE3200ResetStateComplete) { switch (Adapter->ResetState) { // // The first stage of resetting an NE3200 // case NE3200ResetStateStarting : // // Unfortunately, a hardware reset to the NE3200 does *not* // reset the BMIC chip. To ensure that we read a proper status, // we'll clear all of the BMIC's registers. // NE3200_WRITE_SYSTEM_INTERRUPT( Adapter, 0 ); // // I changed this to ff since the original 0 didn't work for // some cases. since we don't have the specs.... // NE3200_WRITE_LOCAL_DOORBELL_INTERRUPT( Adapter, 0xff ); NE3200_WRITE_SYSTEM_DOORBELL_MASK( Adapter, 0 ); NE3200_SYNC_CLEAR_SYSTEM_DOORBELL_INTERRUPT( Adapter ); for (i = 0 ; i < 16 ; i += 4 ) { NE3200_WRITE_MAILBOX_ULONG( Adapter, i, 0L ); } // // Toggle the NE3200's reset line. // NE3200_WRITE_RESET( Adapter, NE3200_RESET_BIT_ON ); NE3200_WRITE_RESET( Adapter, NE3200_RESET_BIT_OFF ); // // Switch to the next state. // Adapter->ResetState = NE3200ResetStateResetting; Adapter->ResetTimeoutCounter = NE3200_TIMEOUT_RESET; // // Loop to the next processing // break; // // Part Deux. The actual downloading of the software. // case NE3200ResetStateResetting : // // Read the status mailbox. // NE3200_READ_MAILBOX_UCHAR(Adapter, NE3200_MAILBOX_RESET_STATUS, &Status); if (Status == NE3200_RESET_PASSED) { // // We have good reset. Initiate the MAC.BIN download. // // // The station address for this adapter can be forced to // a specific value at initialization time. When MAC.BIN // first gets control, it reads mailbox 10. If this mailbox // contains a 0xFF, then the burned-in PROM station address // is used. If this mailbox contains any value other than // 0xFF, then mailboxes 10-15 are read. The six bytes // stored in these mailboxes then become the station address. // // Since we have no need for this feature, we will always // initialize mailbox 10 with a 0xFF. // NE3200_WRITE_MAILBOX_UCHAR( Adapter, NE3200_MAILBOX_STATION_ID, 0xFF ); // // Get the MAC.BIN buffer. // MacBinPhysicalAddress = NE3200Globals.MacBinPhysicalAddress; // // Download MAC.BIN to the card. // NE3200_WRITE_MAILBOX_USHORT( Adapter, NE3200_MAILBOX_MACBIN_LENGTH, NE3200Globals.MacBinLength ); NE3200_WRITE_MAILBOX_UCHAR( Adapter, NE3200_MAILBOX_MACBIN_DOWNLOAD_MODE, NE3200_MACBIN_DIRECT ); NE3200_WRITE_MAILBOX_ULONG( Adapter, NE3200_MAILBOX_MACBIN_POINTER, NdisGetPhysicalAddressLow(MacBinPhysicalAddress) ); NE3200_WRITE_MAILBOX_USHORT( Adapter, NE3200_MAILBOX_MACBIN_TARGET, NE3200_MACBIN_TARGET_ADDRESS >> 1 ); // // This next OUT "kicks" the loader into action. // NE3200_WRITE_MAILBOX_UCHAR( Adapter, NE3200_MAILBOX_RESET_STATUS, 0 ); // // Switch to the next state. // Adapter->ResetState = NE3200ResetStateDownloading; Adapter->ResetTimeoutCounter = NE3200_TIMEOUT_DOWNLOAD; // // Loop to the next state. // } else if (Status == NE3200_RESET_FAILED) { // // Reset failure. Notify the authorities and // next of kin. // Adapter->ResetResult = NE3200ResetResultResetFailure; Adapter->ResetState = NE3200ResetStateComplete; NE3200DoResetIndications(Adapter, NDIS_STATUS_HARD_ERRORS); } else { // // Still waiting for results, check if we have // timed out waiting. // Adapter->ResetTimeoutCounter--; if (Adapter->ResetTimeoutCounter == 0) { // // We've timed-out. Bad news. Notify the death. // Adapter->ResetResult = NE3200ResetResultResetTimeout; Adapter->ResetState = NE3200ResetStateComplete; NE3200DoResetIndications(Adapter, NDIS_STATUS_HARD_ERRORS); } else { // // For Synchronous resets, we stall. For async, // we set a timer to check later. // if (!Adapter->ResetAsynchronous) { // // Otherwise, wait and try again. // NdisStallExecution(10000); } else{ // // Try again later. // NdisMSetTimer(&Adapter->ResetTimer, 100); return; } } } break; // // Part Three: The download was started. Check for completion, // and reload the current station address. // case NE3200ResetStateDownloading : // // Read the download status. // NE3200_READ_MAILBOX_UCHAR(Adapter, NE3200_MAILBOX_STATUS, &Status); if (Status == NE3200_INITIALIZATION_PASSED) { // // According to documentation from Compaq, this next port // write will (in a future MAC.BIN) tell MAC.BIN whether or // not to handle loopback internally. This value is currently // not used, but must still be written to the port. // NE3200_WRITE_MAILBOX_UCHAR( Adapter, NE3200_MAILBOX_STATUS, 1 ); // // Initialization is good, the card is ready. // NE3200StartChipAndDisableInterrupts(Adapter, Adapter->ReceiveQueueHead ); { // // Do the work for updating the current address // // // This points to the public Command Block. // PNE3200_SUPER_COMMAND_BLOCK CommandBlock; // // This points to the adapter's configuration block. // PNE3200_CONFIGURATION_BLOCK ConfigurationBlock = Adapter->ConfigurationBlock; // // Get a public command block. // NE3200AcquirePublicCommandBlock(Adapter, &CommandBlock ); Adapter->ResetHandlerCommandBlock = CommandBlock; // // Setup the command block. // CommandBlock->NextCommand = NULL; CommandBlock->Hardware.State = NE3200_STATE_WAIT_FOR_ADAPTER; CommandBlock->Hardware.Status = 0; CommandBlock->Hardware.NextPending = NE3200_NULL; CommandBlock->Hardware.CommandCode = NE3200_COMMAND_CONFIGURE_82586; CommandBlock->Hardware.PARAMETERS.CONFIGURE.ConfigurationBlock = NdisGetPhysicalAddressLow(Adapter->ConfigurationBlockPhysical); // // Now that we've got the command block built, // let's do it! // NE3200SubmitCommandBlock(Adapter, CommandBlock); Adapter->ResetState = NE3200ResetStateReloadAddress; Adapter->ResetTimeoutCounter = NE3200_TIMEOUT_DOWNLOAD; } } else if (Status == NE3200_INITIALIZATION_FAILED) { // // Initialization failed. Notify the wrapper. // Adapter->ResetResult = NE3200ResetResultInitializationFailure; Adapter->ResetState = NE3200ResetStateComplete; NE3200DoResetIndications(Adapter, NDIS_STATUS_HARD_ERRORS); } else { // // See if we've timed-out waiting for the download to // complete. // Adapter->ResetTimeoutCounter--; if (Adapter->ResetTimeoutCounter == 0) { // // We've timed-out. Bad news. // Adapter->ResetResult = NE3200ResetResultInitializationTimeout; Adapter->ResetState = NE3200ResetStateComplete; NE3200DoResetIndications(Adapter, NDIS_STATUS_HARD_ERRORS); } else { // // For Synchronous resets, we stall. For async, // we set a timer to check later. // if (!Adapter->ResetAsynchronous) { // // Otherwise, wait and try again. // NdisStallExecution(10000); } else{ // // Try again later. // NdisMSetTimer(&Adapter->ResetTimer, 100); return; } } } break; // // Part Last: Waiting for the configuring of the adapter // to complete // case NE3200ResetStateReloadAddress : // // Read the command block status. // if (Adapter->ResetHandlerCommandBlock->Hardware.State == NE3200_STATE_EXECUTION_COMPLETE) { // // return this command block // NE3200RelinquishCommandBlock(Adapter, Adapter->ResetHandlerCommandBlock ); // // Reset is complete. Do those indications. // Adapter->ResetResult = NE3200ResetResultSuccessful; Adapter->ResetState = NE3200ResetStateComplete; NE3200DoResetIndications(Adapter, NDIS_STATUS_SUCCESS); } else { // // See if we've timed-out. // Adapter->ResetTimeoutCounter--; if (Adapter->ResetTimeoutCounter == 0) { // // We've timed-out. Bad news. // // // return this command block // NE3200RelinquishCommandBlock(Adapter, Adapter->ResetHandlerCommandBlock ); Adapter->ResetResult = NE3200ResetResultInitializationTimeout; Adapter->ResetState = NE3200ResetStateComplete; NE3200DoResetIndications(Adapter, NDIS_STATUS_HARD_ERRORS); } else { if ( Adapter->ResetTimeoutCounter == (NE3200_TIMEOUT_DOWNLOAD/2) ) { // // The command may have stalled, try again. // NE3200_WRITE_LOCAL_DOORBELL_INTERRUPT( Adapter, NE3200_LOCAL_DOORBELL_NEW_COMMAND ); } // // For Synchronous resets, we stall. For async, // we set a timer to check later. // if (!Adapter->ResetAsynchronous) { // // Otherwise, wait and try again. // NdisStallExecution(10000); } else{ // // Check again later // NdisMSetTimer(&Adapter->ResetTimer, 100); return; } } } break; default : // // Somehow, we reached an invalid state. // // // We'll try to salvage our way out of this. // Adapter->ResetResult = NE3200ResetResultInvalidState; Adapter->ResetState = NE3200ResetStateComplete; NE3200DoResetIndications(Adapter, NDIS_STATUS_HARD_ERRORS); NdisWriteErrorLogEntry( Adapter->MiniportAdapterHandle, NDIS_ERROR_CODE_HARDWARE_FAILURE, 3, resetDpc, NE3200_ERRMSG_BAD_STATE, (ULONG)(Adapter->ResetState) ); break; }
static uint cfbus_read(void *context) { #ifdef PLATFORM_WINDOWS u32 iobase_addr, len, addr, HAARValue, Read_Data; u8 *pdata; USHORT readCF_HAAR; u32 counter=0; struct _SyncContext *psynccontext = (struct _SyncContext *)context; struct intf_priv *pintfpriv = (struct intf_priv *)psynccontext->pintfpriv; struct dvobj_priv * pcfiodev = (struct dvobj_priv *)pintfpriv->intf_dev; //u8 *rwmem = (u8 *)pintfpriv->rw_mem; iobase_addr = pcfiodev->io_base_address; len = psynccontext ->bytecnt; addr = psynccontext->lbusaddr; pdata = psynccontext->pdata; _func_enter_; //if the address is in HCI local register, to skip it if( addr >= RTL8711_HCICTRL_ && addr <= (RTL8711_HCICTRL_+0x1FFFF) ) { _func_exit_; return _FAIL; } HAARValue = HAARSetting(len, IO_READ, addr); // 1.Write HAAR NdisRawWritePortUlong( (ULONG)(iobase_addr+HAAR), HAARValue); // 2.Polling HAAR Ready do { if(counter > HAAR_POLLING_CNT){ //RT_TRACE(COMP_DBG, DBG_LOUD, ("\n\nCFIOReadReg: Poll HAAR Ready too long, LBus = 0x%X checkRegRWCnt(1) = %d currentIRQL = %x, read HAAR=%x, HAARValue=%x.\n\n",c->LexraBusAddr, checkRegRWCnt, currentIRQL, test32, HAARValue )); _func_exit_; return _FAIL; } if(addr == CR9346) NdisStallExecution(50); //Considering CFIO default mode is 16-bit mode, we use 16-bit reading NdisRawReadPortUshort( (ULONG)(iobase_addr+HAAR+0x0002), &readCF_HAAR); counter++; }while(((readCF_HAAR >> 14) & 0x3) != 0x3); //while READY has not been set // 3.Read HRADR NdisRawReadPortUlong( (ULONG)(iobase_addr+HRADR), (ULONG *)&Read_Data); NdisMoveMemory(pdata , (u8 *)&Read_Data, len); #endif _func_exit_; return _SUCCESS; }
void C_DM9000::EDeviceInitialize( int nResetCounts) { U32 val; // reset member varialbes m_uLastAddressPort = (U32)-1; DeviceWritePort(0x1f, 0x00); NdisStallExecution(20); // software reset the device DeviceWritePort(DM9_NCR, 0x03); NdisStallExecution(20); DeviceWritePort(DM9_NCR, 0x03); NdisStallExecution(20); //DeviceWritePort(DM9_NCR, 0x00); // read the io orgnization // ISR<7:6> == x1, dword // ISR<7:6> == 0x, word // ISR<7:6> == 10, byte mode val = DeviceReadPort(DM9_ISR); if(val & MAKE_MASK(6)) { m_nIoMode = DWORD_MODE; m_nIoMaxPad = 3; } else if(!(val & MAKE_MASK(7))) { m_nIoMode = WORD_MODE; m_nIoMaxPad = 1; } else { m_nIoMode = BYTE_MODE; m_nIoMaxPad = 0; } // activate internal phy // select GPIO 0<0>, set it to output DeviceWritePort(DM9_GPCR, (1<<0)); // output zero to activate internal phy DeviceWritePort(DM9_GPR, 0x00); // clear TX status DeviceWritePort(DM9_NSR, 0x00); // Enable memory chain DeviceWritePort(DM9_IMR, (1<<7)); #ifdef IMPL_STORE_AND_INDICATION if(nResetCounts) return; /* init rx buffers */ U32 m,uaddr; if(!(uaddr = (U32)malloc(sizeof(DATA_BLOCK)* (m=m_szConfigures[CID_RXBUFFER_NUMBER]*2)))) THROW((ERR_STRING("Insufficient memory"))); for(;m--;uaddr+=sizeof(DATA_BLOCK)) m_RQueue.Enqueue((PCQUEUE_GEN_HEADER)uaddr); /* set indication timer */ DeviceInitializeTimer(); #endif // v3.2.9 m_nMaxTxPending = (DeviceReadPort(DM9_CHIPREV) >= 0x10)?2:1; m_nTxPendings = 0; }