#ifndef _MINIHAL_
static KEVENT HalpDmaLock;
+static KSPIN_LOCK HalpDmaAdapterListLock;
static LIST_ENTRY HalpDmaAdapterList;
static PADAPTER_OBJECT HalpEisaAdapter[8];
#endif
* first map buffers.
*/
InitializeListHead(&HalpDmaAdapterList);
+ KeInitializeSpinLock(&HalpDmaAdapterListLock);
KeInitializeEvent(&HalpDmaLock, NotificationEvent, TRUE);
HalpMasterAdapter = HalpDmaAllocateMasterAdapter();
BOOLEAN EisaAdapter;
ULONG MapRegisters;
ULONG MaximumLength;
+ KIRQL OldIrql;
/* Validate parameters in device description */
if (DeviceDescription->Version > DEVICE_DESCRIPTION_VERSION2) return NULL;
}
/*
- * Acquire the DMA lock that is used to protect adapter lists and
- * EISA adapter array.
+ * Acquire the DMA lock that is used to protect the EISA adapter array.
*/
KeWaitForSingleObject(&HalpDmaLock, Executive, KernelMode, FALSE, NULL);
}
}
- if (!EisaAdapter) InsertTailList(&HalpDmaAdapterList, &AdapterObject->AdapterList);
-
/*
- * Release the DMA lock. HalpDmaAdapterList and HalpEisaAdapter will
- * no longer be touched, so we don't need it.
+ * Release the DMA lock. HalpEisaAdapter will no longer be touched,
+ * so we don't need it.
*/
KeSetEvent(&HalpDmaLock, 0, 0);
+ if (!EisaAdapter)
+ {
+ /* If it's not one of the static adapters, add it to the list */
+ KeAcquireSpinLock(&HalpDmaAdapterListLock, &OldIrql);
+ InsertTailList(&HalpDmaAdapterList, &AdapterObject->AdapterList);
+ KeReleaseSpinLock(&HalpDmaAdapterListLock, OldIrql);
+ }
+
/*
* Setup the values in the adapter object that are common for all
* types of buses.
NTAPI
HalPutDmaAdapter(IN PADAPTER_OBJECT AdapterObject)
{
+ KIRQL OldIrql;
if (AdapterObject->ChannelNumber == 0xFF)
{
- KeWaitForSingleObject(&HalpDmaLock, Executive, KernelMode, FALSE, NULL);
+ KeAcquireSpinLock(&HalpDmaAdapterListLock, &OldIrql);
RemoveEntryList(&AdapterObject->AdapterList);
- KeSetEvent(&HalpDmaLock, 0, 0);
+ KeReleaseSpinLock(&HalpDmaAdapterListLock, OldIrql);
}
ObDereferenceObject(AdapterObject);