3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/hal/x86/dma.c
6 * PURPOSE: DMA functions
7 * PROGRAMMER: David Welch (welch@mcmail.com)
12 /* INCLUDES *****************************************************************/
14 #include <ddk/ntddk.h>
16 #include <internal/debug.h>
19 ADAPTER_OBJECT AdapterObjects[] = {
20 { 0, (PVOID)0x87, (PVOID)0x1, (PVOID)0x0, { 0 }, NULL },
21 { 1, (PVOID)0x83, (PVOID)0x3, (PVOID)0x2, { 0 }, NULL },
22 { 2, (PVOID)0x81, (PVOID)0x5, (PVOID)0x4, { 0 }, NULL },
23 { 3, (PVOID)0x82, (PVOID)0x7, (PVOID)0x6, { 0 }, NULL } };
26 /* FUNCTIONS *****************************************************************/
29 HalAllocateCommonBuffer (PADAPTER_OBJECT AdapterObject,
31 PPHYSICAL_ADDRESS LogicalAddress,
34 * FUNCTION: Allocates memory that is visible to both the processor(s) and
37 * AdapterObject = Adapter object representing the bus master or
38 * system dma controller
39 * Length = Number of bytes to allocate
40 * LogicalAddress = Logical address the driver can use to access the
42 * CacheEnabled = Specifies if the memory can be cached
43 * RETURNS: The base virtual address of the memory allocated
51 HalFlushCommonBuffer (ULONG Unknown1,
64 HalFreeCommonBuffer (PADAPTER_OBJECT AdapterObject,
66 PHYSICAL_ADDRESS LogicalAddress,
70 MmFreeContiguousMemory(VirtualAddress);
73 PADAPTER_OBJECT STDCALL
74 HalGetAdapter (PDEVICE_DESCRIPTION DeviceDescription,
75 PULONG NumberOfMapRegisters)
77 * FUNCTION: Returns a pointer to an adapter object for the DMA device
78 * defined in the device description structure
80 * DeviceDescription = Structure describing the attributes of the device
81 * NumberOfMapRegisters (OUT) = Returns the maximum number of map
82 * registers the device driver can
83 * allocate for DMA transfer operations
84 * RETURNS: The allocated adapter object on success
88 /* Validate parameters in device description, and return a pointer to
89 the adapter object for the requested dma channel */
90 if( DeviceDescription->Version != DEVICE_DESCRIPTION_VERSION )
92 if( DeviceDescription->Master )
94 if( DeviceDescription->ScatterGather )
96 if( DeviceDescription->AutoInitialize )
98 if( DeviceDescription->Dma32BitAddress )
100 if( DeviceDescription->InterfaceType != Isa )
102 /* if( DeviceDescription->DmaWidth != Width8Bits )
104 *NumberOfMapRegisters = 0x10;
105 AdapterObjects[DeviceDescription->DmaChannel].Buffer = 0;
106 return &AdapterObjects[DeviceDescription->DmaChannel];
110 HalReadDmaCounter (PADAPTER_OBJECT AdapterObject)