void CTEInitEvent( CTEEvent *Event, CTEEventRtn Handler ) /*++ Routine Description: Initializes a CTE Event variable. Arguments: Event - Event variable to initialize. Handler - Handler routine for this event variable. Return Value: None. --*/ { ASSERT(Handler != NULL); Event->ce_handler = Handler; Event->ce_scheduled = 0; CTEInitLock(&(Event->ce_lock)); ExInitializeWorkItem(&(Event->ce_workitem), CTEpEventHandler, Event); }
NTSTATUS SpxTimerInit( VOID ) /*++ Routine Description: Initialize the timer component for the appletalk stack. Arguments: Return Value: --*/ { #if !defined(_PNP_POWER) BOOLEAN TimerStarted; #endif !_PNP_POWER // Initialize the timer and its associated Dpc. timer will be kicked // off when we get the first card arrival notification from ipx KeInitializeTimer(&spxTimer); CTEInitLock(&spxTimerLock); KeInitializeDpc(&spxTimerDpc, spxTimerDpcRoutine, NULL); spxTimerTick = RtlConvertLongToLargeInteger(SPX_TIMER_TICK); #if !defined(_PNP_POWER) TimerStarted = KeSetTimer(&spxTimer, spxTimerTick, &spxTimerDpc); CTEAssert(!TimerStarted); #endif !_PNP_POWER return STATUS_SUCCESS; }
NTSTATUS IpxCreateAdapter( IN PDEVICE Device, IN PUNICODE_STRING AdapterName, IN OUT PADAPTER *AdapterPtr ) /*++ Routine Description: This routine creates and initializes a device context structure. Arguments: DriverObject - pointer to the IO subsystem supplied driver object. Adapter - Pointer to a pointer to a transport device context object. AdapterName - pointer to the name of the device this device object points to. Return Value: STATUS_SUCCESS if all is well; STATUS_INSUFFICIENT_RESOURCES otherwise. --*/ { PADAPTER Adapter; #if 0 UINT i, j; #endif Adapter = (PADAPTER)IpxAllocateMemory (sizeof(ADAPTER) + AdapterName->Length + sizeof(WCHAR), MEMORY_ADAPTER, "Adapter"); #ifdef _PNP_POWER if (Adapter == NULL) { if (KeGetCurrentIrql() == 0) { IPX_DEBUG (ADAPTER, ("Create adapter %ws failed\n", AdapterName)); } else { IPX_DEBUG (ADAPTER, ("Create adapter %lx failed\n", AdapterName)); } return STATUS_INSUFFICIENT_RESOURCES; } IPX_DEBUG (ADAPTER, ("Create adapter %lx %lx succeeded\n", Adapter, AdapterName)); #else if (Adapter == NULL) { IPX_DEBUG (ADAPTER, ("Create adapter %ws failed\n", AdapterName->Buffer)); return STATUS_INSUFFICIENT_RESOURCES; } IPX_DEBUG (ADAPTER, ("Create adapter %ws succeeded\n", AdapterName->Buffer)); #endif RtlZeroMemory(Adapter, sizeof(ADAPTER)); // // Copy over the adapter name. // Adapter->AdapterNameLength = AdapterName->Length + sizeof(WCHAR); Adapter->AdapterName = (PWCHAR)(Adapter+1); RtlCopyMemory( Adapter->AdapterName, AdapterName->Buffer, AdapterName->Length); Adapter->AdapterName[AdapterName->Length/sizeof(WCHAR)] = UNICODE_NULL; #if DBG RtlCopyMemory(Adapter->Signature1, "IAD1", 4); #endif Adapter->Type = IPX_ADAPTER_SIGNATURE; Adapter->Size = sizeof(ADAPTER); CTEInitLock (&Adapter->Lock); InitializeListHead (&Adapter->RequestCompletionQueue); InitializeListHead (&Adapter->ReceiveBufferPoolList); ExInitializeSListHead (&Adapter->ReceiveBufferList); Adapter->Device = Device; Adapter->DeviceLock = &Device->Lock; IpxReferenceDevice (Device, DREF_ADAPTER); #if 0 Adapter->ReceiveBufferPool.Next = NULL; for (i = 0; i < ISN_FRAME_TYPE_MAX; i++) { Adapter->Bindings[i] = NULL; } Adapter->BindingCount = 0; for (i = 0; i < IDENTIFIER_TOTAL; i++) { for (j = 0; j < SOURCE_ROUTE_HASH_SIZE; j++) { Adapter->SourceRoutingHeads[i][j] = (PSOURCE_ROUTE)NULL; } } #endif // // BUGBUG: For the moment, we have to do the source // routing operation on any type where broadcast // may not be used for discovery -- improve this // hopefully. // Adapter->SourceRoutingEmpty[IDENTIFIER_RIP] = FALSE; Adapter->SourceRoutingEmpty[IDENTIFIER_IPX] = FALSE; Adapter->SourceRoutingEmpty[IDENTIFIER_SPX] = FALSE; Adapter->SourceRoutingEmpty[IDENTIFIER_NB] = TRUE; #ifdef _PNP_POWER // // Lock here? [BUGBUGZZ] // Adapter->ReferenceCount = 1; #endif *AdapterPtr = Adapter; return STATUS_SUCCESS; } /* IpxCreateAdapter */
//---------------------------------------------------------------------------- NTSTATUS InitNotOs( void ) /*++ Routine Description: This is the initialization routine for the Non-OS Specific side of the NBT device driver. pNbtGlobConfig must be initialized before this is called! Arguments: Return Value: NTSTATUS - The function value is the final status from the initialization operation. --*/ { NTSTATUS status = STATUS_SUCCESS; ULONG i; CTEPagedCode(); // // for multihomed hosts, this tracks the number of adapters as each one // is created. // NbtConfig.AdapterCount = 0; NbtConfig.MultiHomed = FALSE; NbtConfig.SingleResponse = FALSE; // // Initialize the name statistics // CTEZeroMemory( &NameStatsInfo,sizeof(tNAMESTATS_INFO) ); InitializeListHead(&pNbtGlobConfig->DeviceContexts); #ifndef _IO_DELETE_DEVICE_SUPPORTED InitializeListHead(&pNbtGlobConfig->FreeDevCtx); #endif InitializeListHead(&NbtConfig.AddressHead); InitializeListHead(&NbtConfig.PendingNameQueries); #ifdef VXD InitializeListHead(&NbtConfig.DNSDirectNameQueries); #endif // initialize the spin lock CTEInitLock(&pNbtGlobConfig->SpinLock); CTEInitLock(&pNbtGlobConfig->JointLock.SpinLock); NbtConfig.LockNumber = NBTCONFIG_LOCK; NbtConfig.JointLock.LockNumber = JOINT_LOCK; NbtMemoryAllocated = 0; #if DBG for (i=0;i<MAXIMUM_PROCESSORS ;i++ ) { NbtConfig.CurrentLockNumber[i] = 0; } #endif InitializeListHead(&UsedTrackers); InitializeListHead(&UsedIrps); // create the hash tables for storing names in. status = CreateHashTable(&pNbtGlobConfig->pLocalHashTbl, pNbtGlobConfig->uNumBucketsLocal, NBT_LOCAL); if ( !NT_SUCCESS( status ) ) { ASSERTMSG("NBT:Unable to create hash tables for Netbios Names\n", (status == STATUS_SUCCESS)); return status ; } // we always have a remote hash table, but if we are a Proxy, it is // a larger table. In the Non-proxy case the remote table just caches // names resolved with the NS. In the Proxy case it also holds names // resolved for all other clients on the local broadcast area. // The node size registry parameter controls the number of remote buckets. status = InitRemoteHashTable(pNbtGlobConfig, pNbtGlobConfig->uNumBucketsRemote, pNbtGlobConfig->uNumRemoteNames); if ( !NT_SUCCESS( status ) ) return status ; // // initialize the linked lists associated with the global configuration // data structures // InitializeListHead(&NbtConfig.NodeStatusHead); InitializeListHead(&NbtConfig.DgramTrackerFreeQ); #ifndef VXD InitializeListHead(&NbtConfig.IrpFreeList); pWinsInfo = 0; { // // Setup the default disconnect timeout - 10 seconds - convert // to negative 100 Ns. // DefaultDisconnectTimeout.QuadPart = Int32x32To64(DEFAULT_DISC_TIMEOUT, MILLISEC_TO_100NS); DefaultDisconnectTimeout.QuadPart = -(DefaultDisconnectTimeout.QuadPart); } #else DefaultDisconnectTimeout = DEFAULT_DISC_TIMEOUT * 1000; // convert to milliseconds InitializeListHead(&NbtConfig.SendTimeoutHead) ; InitializeListHead(&NbtConfig.SessionBufferFreeList) ; InitializeListHead(&NbtConfig.SendContextFreeList) ; InitializeListHead(&NbtConfig.RcvContextFreeList) ; // // For session headers, since they are only four bytes and we can't // change the size of the structure, we'll covertly add enough for // a full LIST_ENTRY and treat it like a standalone LIST_ENTRY structure // when adding and removing from the list. // NbtConfig.iBufferSize[eNBT_SESSION_HDR] = sizeof(tSESSIONHDR) + sizeof( LIST_ENTRY ) - sizeof(tSESSIONHDR) ; NbtConfig.iBufferSize[eNBT_SEND_CONTEXT] = sizeof(TDI_SEND_CONTEXT); NbtConfig.iBufferSize[eNBT_RCV_CONTEXT] = sizeof(RCV_CONTEXT); NbtConfig.iCurrentNumBuff[eNBT_SESSION_HDR] = NBT_INITIAL_NUM; status = NbtInitQ( &NbtConfig.SessionBufferFreeList, NbtConfig.iBufferSize[eNBT_SESSION_HDR], NBT_INITIAL_NUM); if ( !NT_SUCCESS( status ) ) return status ; NbtConfig.iCurrentNumBuff[eNBT_SEND_CONTEXT] = NBT_INITIAL_NUM; status = NbtInitQ( &NbtConfig.SendContextFreeList, sizeof( TDI_SEND_CONTEXT ), NBT_INITIAL_NUM); if ( !NT_SUCCESS( status ) ) return status ; NbtConfig.iCurrentNumBuff[eNBT_RCV_CONTEXT] = NBT_INITIAL_NUM; status = NbtInitQ( &NbtConfig.RcvContextFreeList, sizeof( RCV_CONTEXT ), NBT_INITIAL_NUM); if ( !NT_SUCCESS( status ) ) return status ; #endif // // create trackers List // pNbtGlobConfig->iBufferSize[eNBT_DGRAM_TRACKER] = sizeof(tDGRAM_SEND_TRACKING); NbtConfig.iCurrentNumBuff[eNBT_DGRAM_TRACKER] = 0; status = NbtInitTrackerQ( &NbtConfig.DgramTrackerFreeQ,NBT_INITIAL_NUM); if ( !NT_SUCCESS( status ) ) return status ; CTEZeroMemory(&LmHostQueries,sizeof(tLMHOST_QUERIES)); InitializeListHead(&DomainNames.DomainList); InitializeListHead(&LmHostQueries.ToResolve); #ifndef VXD // set up a list for connections when we run out of resources and need to // disconnect these connections. An Irp is also needed for this list, and // it is allocated in Driver.C after we have created the connections to the // transport and therefore know our Irp Stack Size. // InitializeListHead(&NbtConfig.OutOfRsrc.ConnectionHead); // use this resources to synchronize access to the security info between // assigning security and checking it - when adding names to the // name local name table through NbtregisterName. This also insures // that the name is in the local hash table (from a previous Registration) // before the next registration is allowed to proceed and check for // the name in the table. // ExInitializeResource(&NbtConfig.Resource); // // this resource is used to synchronize access to the Dns structure // CTEZeroMemory(&DnsQueries,sizeof(tDNS_QUERIES)); InitializeListHead(&DnsQueries.ToResolve); // // this resource is used to synchronize access to the Dns structure // CTEZeroMemory(&CheckAddr,sizeof(tCHECK_ADDR)); InitializeListHead(&CheckAddr.ToResolve); #endif // VXD return status ; }