* PROJECT: ReactOS kernel
* FILE: ntoskrnl/hal/x86/dma.c
* PURPOSE: DMA functions
- * PROGRAMMER: David Welch (welch@mcmail.com)
+ * PROGRAMMERS: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 22/05/98
*/
#include <internal/debug.h>
#include <hal.h>
-ADAPTER_OBJECT AdapterObjects[] = {
- { 0, (PVOID)0x87, (PVOID)0x1, (PVOID)0x0, { 0 }, NULL },
- { 1, (PVOID)0x83, (PVOID)0x3, (PVOID)0x2, { 0 }, NULL },
- { 2, (PVOID)0x81, (PVOID)0x5, (PVOID)0x4, { 0 }, NULL },
- { 3, (PVOID)0x82, (PVOID)0x7, (PVOID)0x6, { 0 }, NULL } };
+ADAPTER_OBJECT IsaSlaveAdapterObjects[] = {
+ { Isa, FALSE, 0, (PVOID)0x87, (PVOID)0x1, (PVOID)0x0, 0, NULL },
+ { Isa, FALSE, 1, (PVOID)0x83, (PVOID)0x3, (PVOID)0x2, 0, NULL },
+ { Isa, FALSE, 2, (PVOID)0x81, (PVOID)0x5, (PVOID)0x4, 0, NULL },
+ { Isa, FALSE, 3, (PVOID)0x82, (PVOID)0x7, (PVOID)0x6, 0, NULL } };
+
+ADAPTER_OBJECT PciBusMasterAdapterObjects[] = {
+ { PCIBus, TRUE, 0, (PVOID)0, (PVOID)0, (PVOID)0x0, 0, NULL } };
/* FUNCTIONS *****************************************************************/
PVOID STDCALL
-HalAllocateCommonBuffer (PADAPTER_OBJECT AdapterObject,
- ULONG Length,
- PPHYSICAL_ADDRESS LogicalAddress,
- BOOLEAN CacheEnabled)
+HalAllocateCommonBuffer (PADAPTER_OBJECT AdapterObject,
+ ULONG Length,
+ PPHYSICAL_ADDRESS LogicalAddress,
+ BOOLEAN CacheEnabled)
/*
* FUNCTION: Allocates memory that is visible to both the processor(s) and
* a dma device
* CacheEnabled = Specifies if the memory can be cached
* RETURNS: The base virtual address of the memory allocated
* NULL on failure
+ * NOTES:
+ * CacheEnabled is ignored - it's all cache-disabled (like in NT)
*/
{
- UNIMPLEMENTED;
+ PHYSICAL_ADDRESS HighestAddress;
+ PVOID BaseAddress;
+
+ HighestAddress.u.HighPart = 0;
+ if (AdapterObject->InterfaceType == Isa ||
+ (AdapterObject->InterfaceType == MicroChannel && AdapterObject->Master == FALSE))
+ {
+ HighestAddress.u.LowPart = 0x00FFFFFF; /* 24Bit: 16MB address range */
+ }
+ else
+ {
+ HighestAddress.u.LowPart = 0xFFFFFFFF; /* 32Bit: 4GB address range */
+ }
+
+ BaseAddress = MmAllocateContiguousMemory(Length, HighestAddress);
+ if (!BaseAddress)
+ return 0;
+
+ *LogicalAddress = MmGetPhysicalAddress(BaseAddress);
+
+ return BaseAddress;
}
BOOLEAN STDCALL
* allocate for DMA transfer operations
* RETURNS: The allocated adapter object on success
* NULL on failure
+ * TODO:
+ * Figure out what to do with the commented-out cases
*/
{
/* Validate parameters in device description, and return a pointer to
the adapter object for the requested dma channel */
if( DeviceDescription->Version != DEVICE_DESCRIPTION_VERSION )
return NULL;
+
+ if (DeviceDescription->InterfaceType == PCIBus)
+ {
+ if (DeviceDescription->Master == FALSE)
+ return NULL;
+
+ return &PciBusMasterAdapterObjects[0];
+ }
+
+ /*
if( DeviceDescription->Master )
return NULL;
if( DeviceDescription->ScatterGather )
return NULL;
if( DeviceDescription->AutoInitialize )
return NULL;
- if( DeviceDescription->Dma32BitAddress )
+ if( DeviceDescription->Dma32BitAddresses )
return NULL;
if( DeviceDescription->InterfaceType != Isa )
return NULL;
+ */
/* if( DeviceDescription->DmaWidth != Width8Bits )
return NULL;*/
*NumberOfMapRegisters = 0x10;
- AdapterObjects[DeviceDescription->DmaChannel].Buffer = 0;
- return &AdapterObjects[DeviceDescription->DmaChannel];
+ IsaSlaveAdapterObjects[DeviceDescription->DmaChannel].Buffer = 0;
+ return &IsaSlaveAdapterObjects[DeviceDescription->DmaChannel];
}
ULONG STDCALL