1 /* $Id: dma.c,v 1.2 2002/09/07 15:12:10 chorns Exp $
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 *****************************************************************/
17 #include <internal/debug.h>
20 ADAPTER_OBJECT AdapterObjects
[] = {
21 { 0, (PVOID
)0x87, (PVOID
)0x1, (PVOID
)0x0, 0, NULL
},
22 { 1, (PVOID
)0x83, (PVOID
)0x3, (PVOID
)0x2, 0, NULL
},
23 { 2, (PVOID
)0x81, (PVOID
)0x5, (PVOID
)0x4, 0, NULL
},
24 { 3, (PVOID
)0x82, (PVOID
)0x7, (PVOID
)0x6, 0, NULL
} };
27 /* FUNCTIONS *****************************************************************/
30 HalAllocateCommonBuffer (PADAPTER_OBJECT AdapterObject
,
32 PPHYSICAL_ADDRESS LogicalAddress
,
35 * FUNCTION: Allocates memory that is visible to both the processor(s) and
38 * AdapterObject = Adapter object representing the bus master or
39 * system dma controller
40 * Length = Number of bytes to allocate
41 * LogicalAddress = Logical address the driver can use to access the
43 * CacheEnabled = Specifies if the memory can be cached
44 * RETURNS: The base virtual address of the memory allocated
52 HalFlushCommonBuffer (ULONG Unknown1
,
65 HalFreeCommonBuffer (PADAPTER_OBJECT AdapterObject
,
67 PHYSICAL_ADDRESS LogicalAddress
,
71 MmFreeContiguousMemory(VirtualAddress
);
74 PADAPTER_OBJECT STDCALL
75 HalGetAdapter (PDEVICE_DESCRIPTION DeviceDescription
,
76 PULONG NumberOfMapRegisters
)
78 * FUNCTION: Returns a pointer to an adapter object for the DMA device
79 * defined in the device description structure
81 * DeviceDescription = Structure describing the attributes of the device
82 * NumberOfMapRegisters (OUT) = Returns the maximum number of map
83 * registers the device driver can
84 * allocate for DMA transfer operations
85 * RETURNS: The allocated adapter object on success
89 /* Validate parameters in device description, and return a pointer to
90 the adapter object for the requested dma channel */
91 if( DeviceDescription
->Version
!= DEVICE_DESCRIPTION_VERSION
)
93 if( DeviceDescription
->Master
)
95 if( DeviceDescription
->ScatterGather
)
97 if( DeviceDescription
->AutoInitialize
)
99 if( DeviceDescription
->Dma32BitAddresses
)
101 if( DeviceDescription
->InterfaceType
!= Isa
)
103 /* if( DeviceDescription->DmaWidth != Width8Bits )
105 *NumberOfMapRegisters
= 0x10;
106 AdapterObjects
[DeviceDescription
->DmaChannel
].Buffer
= 0;
107 return &AdapterObjects
[DeviceDescription
->DmaChannel
];
111 HalReadDmaCounter (PADAPTER_OBJECT AdapterObject
)