VOID NE3200DisableInterrupt( IN NDIS_HANDLE Context ) /*++ Routine Description: This routine is used to turn off the interrupt mask. Arguments: Context - The adapter for the NE3200 to start. Return Value: None. --*/ { PNE3200_ADAPTER Adapter = (PNE3200_ADAPTER)Context; // // Initialize the doorbell mask // Adapter->InterruptsDisabled = TRUE; NE3200_WRITE_SYSTEM_DOORBELL_MASK( Adapter, 0 ); IF_LOG('D'); }
VOID NE3200EnableAdapter( IN NDIS_HANDLE Context ) /*++ Routine Description: This routine is used to start an already initialized NE3200. Arguments: Context - The adapter for the NE3200 to start. Return Value: None. --*/ { PNE3200_ADAPTER Adapter = (PNE3200_ADAPTER)Context; IF_LOG('#'); // // Initialize the doorbell & system interrupt masks // NE3200_WRITE_SYSTEM_INTERRUPT( Adapter, NE3200_SYSTEM_INTERRUPT_ENABLE ); if (!Adapter->InterruptsDisabled) { NE3200_WRITE_SYSTEM_DOORBELL_MASK( Adapter, NE3200_SYSTEM_DOORBELL_MASK ); } NE3200_WRITE_SYSTEM_DOORBELL_INTERRUPT( Adapter, NE3200_SYSTEM_DOORBELL_MASK ); NE3200_WRITE_MAILBOX_UCHAR( Adapter, NE3200_MAILBOX_STATUS, 0 ); }
VOID NE3200EnableInterrupt( IN NDIS_HANDLE Context ) /*++ Routine Description: This routine is used to turn on the interrupt mask. Arguments: Context - The adapter for the NE3200 to start. Return Value: None. --*/ { PNE3200_ADAPTER Adapter = (PNE3200_ADAPTER)Context; IF_LOG('E'); // // Enable further interrupts. // Adapter->InterruptsDisabled = FALSE; NE3200_WRITE_SYSTEM_DOORBELL_MASK( Adapter, NE3200_SYSTEM_DOORBELL_MASK ); }
NDIS_STATUS TOK162Send( IN NDIS_HANDLE MiniportAdapterContext, IN PNDIS_PACKET Packet, IN UINT Flags ) /*++ Routine Description: The TOK162Send request instructs a Miniport to transmit a packet through the adapter onto the medium. Arguments: MiniportAdapterContext - The context value returned by the Miniport when the adapter was initialized. In reality, it is a pointer to TOK162_ADAPTER. Packet - A pointer to a descriptor for the packet that is to be transmitted. Return Value: The function value is the status of the operation. --*/ { // // Pointer to the adapter. // PTOK162_ADAPTER Adapter = PTOK162_ADAPTER_FROM_CONTEXT_HANDLE(MiniportAdapterContext); // // Pointer to transmit block // PTOK162_SUPER_TRANSMIT_LIST temp; // // The number of NDIS buffers in the entire packet. // UINT NdisBufferCount; // // The total amount of data in the ndis packet. // UINT TotalDataLength; // // Points to the current ndis buffer being walked. // PNDIS_BUFFER CurrentBuffer; // // Aux pointer to number of available transmit blocks // PUINT AvailBlocks; // // log send called // IF_LOG('h'); // // Get original count // AvailBlocks = &Adapter->NumberOfAvailableTransmitBlocks; // // See if we have any transmits available // if (*AvailBlocks > 0) { (*AvailBlocks)--; temp = Adapter->AvailableTransmit; Adapter->AvailableTransmit = temp->NextEntry; temp->NextActive = NULL; // // Timestamp the transmit block // temp->Timeout = FALSE; // // If the adapter is currently executing a transmit, add this to the // end of the waiting list. Otherwise, download it. // if (Adapter->ActiveTransmitHead != NULL) { Adapter->ActiveTransmitTail->NextActive = temp; Adapter->ActiveTransmitTail = temp; } else { Adapter->ActiveTransmitHead = temp; Adapter->ActiveTransmitTail = temp; } // // Another transmit is being queued // Adapter->TransmitsQueued++; // // Number of sends since last reset increments by one // Adapter->TotalSends++; // // Assign the packet to the block // temp->Packet = Packet; // // Figure out if we need to constrain the packet. // NdisQueryPacket( Packet, &temp->NumberOfBuffers, &NdisBufferCount, &CurrentBuffer, &TotalDataLength ); // // See if the packet exceeds MAX_BUFFERS_PER_TRANSMIT or is too short. // We will have to constrain in either event. // if ( (temp->NumberOfBuffers <= MAX_BUFFERS_PER_TRANSMIT) && (TotalDataLength >= MINIMUM_TOKENRING_PACKET_SIZE) ) { // // Need to constrain the packet, increment the counter // TOK162DownLoadPacket(Adapter,temp,CurrentBuffer); // // log leaving send // IF_LOG('H'); // // We are pending. // return(NDIS_STATUS_PENDING); } else { // // Need to constrain the packet, increment the counter // TOK162ConstrainPacket(Adapter, temp, CurrentBuffer, NdisBufferCount, TotalDataLength ); // // log leaving send // IF_LOG('H'); // // We are pending. // return(NDIS_STATUS_PENDING); } // // If no transmit block was available, return RESOURCE error // } else { // // log resource error // IF_LOG('*'); // // Restart the transmits // WRITE_ADAPTER_USHORT(Adapter, PORT_OFFSET_COMMAND, ENABLE_TRANSMIT_VALID ); return NDIS_STATUS_RESOURCES; } }
__inline #endif NDIS_STATUS TOK162ConstrainPacket( IN PTOK162_ADAPTER Adapter, OUT PTOK162_SUPER_TRANSMIT_LIST TransmitBlock, IN PNDIS_BUFFER SourceBuffer, IN UINT NdisBufferCount, IN UINT TotalVirtualLength ) /*++ Routine Description: Given a packet and if necessary attempt to acquire adapter buffer resources so that the packet meets TOK162 hardware constraints. Arguments: Adapter - The adapter the packet is coming through. Packet - The packet whose buffers are to be constrained. The packet reserved section is filled with information detailing how the packet needs to be adjusted. CommandBlock - Command block describing the packet to be sent. Return Value: Status - SUCCESS. --*/ { // // Will point into the virtual address space addressed // by the adapter buffer if one was successfully allocated. // PCHAR CurrentDestination; // // Will hold the total amount of data copied to the // adapter buffer. // UINT TotalDataMoved = 0; // // Points to the virtual address of the source buffers data. // PVOID SourceData; // // Will point to the number of bytes of data in the source // buffer. // UINT SourceLength; // // Log that we entered TOK162ConstrainPacket // IF_LOG('g'); // // Set transmit block to show we constrained. // TransmitBlock->UsedBuffer = TRUE; // // Set the first entry variable // TransmitBlock->FirstEntry = Adapter->AdapterTransmitIndex; CURRENT_DEBUG(DbgPrint("Constrain FirstEntry = %u\n",TransmitBlock->FirstEntry);)
VOID ElnkStagedAllocation( IN PELNK_ADAPTER Adapter ) /*++ Routine Description: This routine attempts to take a packet through a stage of allocation. Arguments: Adapter - The adapter that the packets are coming through. Return Value: None. --*/ { UINT CbIndex; PNDIS_PACKET FirstPacket = Adapter->FirstStagePacket; if ELNKDEBUG DPrint1("StagedAllocation\n"); // // For each stage, we check to see that it is open, // that somebody else isn't already processing, // and that there is some work from the previous // stage to do. // ASSERT (Adapter->StageOpen && !Adapter->AlreadyProcessingStage && Adapter->FirstStagePacket); // // If we successfully acquire a command block, this // is the index to it. // Adapter->AlreadyProcessingStage = TRUE; // // We look to see if there is an available Command Block. // If there isn't then stage 2 will close. // IF_LOG('p'); if (ElnkAcquireCommandBlock( Adapter, &CbIndex )) { IF_LOG('a'); // // Remove from queue // Adapter->FirstStagePacket = PELNK_RESERVED_FROM_PACKET(FirstPacket)->Next; if (!Adapter->FirstStagePacket) { Adapter->LastStagePacket = NULL; } NdisReleaseSpinLock(&Adapter->Lock); // // We have a command block. Assign all packet // buffers to the command block. // ElnkAssignPacketToCommandBlock( Adapter, FirstPacket, CbIndex ); // // We need exclusive access to the Command Queue so // that we can move this packet on to the next stage. // NdisAcquireSpinLock(&Adapter->Lock); ElnkPutPacketOnFinishTrans( Adapter, FirstPacket ); ElnkSubmitCommandBlock( Adapter, CbIndex ); Adapter->AlreadyProcessingStage = FALSE; } else { Adapter->AlreadyProcessingStage = FALSE; Adapter->StageOpen = FALSE; IF_LOG('P'); return; } IF_LOG('P'); }
int main() { plog::init(plog::debug, "Demo.csv", 5000, 3); // Initialize the logger. // Log macro types. LOGD << "Hello log!"; // short macro LOG_DEBUG << "Hello log!"; // long macro LOG(plog::debug) << "Hello log!"; // function-style macro // Log severity levels. LOG_VERBOSE << "This is a VERBOSE message"; LOG_DEBUG << "This is a DEBUG message"; LOG_INFO << "This is an INFO message"; LOG_WARNING << "This is a WARNING message"; LOG_ERROR << "This is an ERROR message"; LOG_FATAL << "This is a FATAL message"; LOG_NONE << "This is a NONE message"; // Integers demo. LOG_INFO << "This is a bool: " << std::boolalpha << true; LOG_INFO << "This is a char: " << 'x'; LOG_INFO << "This is an unsigned char: " << (unsigned char)40; LOG_INFO << "This is a short: " << (short)-1000; LOG_INFO << "This is an unsigned short: " << (unsigned short)1000; LOG_INFO << "This is an int: " << (int)-1000000; LOG_INFO << "This is an unsigned int: " << (unsigned int)1000000; LOG_INFO << "This is a long(hex): " << std::hex << (long)100000000; LOG_INFO << "This is an unsigned long: " << (unsigned long)100000000; LOG_INFO << "This is a float: " << 1.2345f; LOG_INFO << "This is a double: " << std::setprecision(15) << 1.234512345; // Managed string. #ifdef __cplusplus_cli System::String^ managedStr = "This is a managed string"; LOG_INFO << managedStr; #endif // Null strings are safe. LOG_DEBUG << static_cast<char*>(NULL); LOG_DEBUG << static_cast<const char*>(NULL); #if PLOG_ENABLE_WCHAR_INPUT LOG_DEBUG << static_cast<wchar_t*>(NULL); LOG_DEBUG << static_cast<const wchar_t*>(NULL); #endif // Plog handles unicode and std::string/wstring. #ifndef _WIN32 // On Windows the following code produces a warning C4566 if the codepage is not Cyrillic. LOG_DEBUG << "Cat - котэ"; LOG_DEBUG << std::string("test - тест"); #endif #if PLOG_ENABLE_WCHAR_INPUT LOG_DEBUG << L"Cat - котэ"; LOG_DEBUG << std::wstring(L"test - тест"); LOG_DEBUG << L'ы'; #endif // Multiline. LOG_INFO << "This\nis\na" << std::endl << "multiline\nmessage!"; // Quotes. LOG_INFO << "This is a message with \"quotes\"!"; // Conditional logging. int var = 0; LOG_DEBUG_IF(var != 0) << "You shouldn't see this message"; LOG_DEBUG_IF(var == 0) << "This is a conditional log message"; // Executed only on log level >= debug. IF_LOG(plog::debug) var = 5; // one line IF_LOG(plog::debug) // block { var++; } // Log macros don't break then-else clause without braces. if (var == 0) LOGI << "then clause (condition is false, so it is skipped)"; else LOGI << "else clase (should be visible)"; // Log in a class (capture this pointer, c++ function names). MyClass obj; obj.method(); obj.inlineMethod(); MyClass::staticMethod(); // Implicit cast to string. LOG_INFO << obj; // ostream operator<< (on Windows wostream operator<< has priority but not required) Customer customer = { 10, "John" }; LOG_INFO << customer; return 0; }
VOID NE3200StopChip( IN PNE3200_ADAPTER Adapter ) /*++ Routine Description: This routine is used to stop the NE3200. Arguments: Adapter - The NE3200 adapter to stop. Return Value: None. --*/ { IF_LOG('h'); // // Packet reception can be stopped by writing a // (ULONG)-1 to the Receive Packet Mailbox port. // Also, commands can be stopped by writing a -1 // to the Command Pointer Mailbox port. // NE3200_WRITE_RECEIVE_POINTER( Adapter, NE3200_NULL ); NE3200_WRITE_COMMAND_POINTER( Adapter, NE3200_NULL ); // // Ack any outstanding interrupts // NE3200_WRITE_LOCAL_DOORBELL_INTERRUPT( Adapter, NE3200_LOCAL_DOORBELL_NEW_RECEIVE | NE3200_LOCAL_DOORBELL_NEW_COMMAND ); // // Disable the doorbell & system interrupt masks. // NE3200_WRITE_SYSTEM_INTERRUPT( Adapter, 0 ); NE3200_WRITE_SYSTEM_DOORBELL_MASK( Adapter, 0 ); NE3200_WRITE_SYSTEM_DOORBELL_INTERRUPT( Adapter, 0 ); }
VOID NE3200StartChipAndDisableInterrupts( IN PNE3200_ADAPTER Adapter, IN PNE3200_SUPER_RECEIVE_ENTRY FirstReceiveEntry ) /*++ Routine Description: This routine is used to start an already initialized NE3200, but to keep the interrupt line masked. Arguments: Adapter - The adapter for the NE3200 to start. FirstReceiveEntry - Pointer to the first receive entry to be used by the adapter. Return Value: None. --*/ { IF_LOG('%'); // // Write the new receive pointer. // NE3200_WRITE_RECEIVE_POINTER( Adapter, NdisGetPhysicalAddressLow(FirstReceiveEntry->Self) ); NE3200_WRITE_LOCAL_DOORBELL_INTERRUPT( Adapter, NE3200_LOCAL_DOORBELL_NEW_RECEIVE ); // // Initialize the doorbell & system interrupt masks // NE3200_WRITE_SYSTEM_DOORBELL_MASK( Adapter, 0 ); NE3200_WRITE_SYSTEM_INTERRUPT( Adapter, NE3200_SYSTEM_INTERRUPT_ENABLE ); NE3200_WRITE_MAILBOX_UCHAR( Adapter, NE3200_MAILBOX_STATUS, 0 ); }