mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
DMA support added
svn path=/trunk/; revision=1760
This commit is contained in:
parent
f56e6b7e9e
commit
137c93f9c6
9 changed files with 180 additions and 29 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: halddk.h,v 1.8 2001/01/14 15:35:56 ekohl Exp $
|
||||
/* $Id: halddk.h,v 1.9 2001/03/31 16:01:03 phreak Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -304,9 +304,10 @@ NTSTATUS
|
|||
STDCALL
|
||||
HalAllocateAdapterChannel (
|
||||
IN PADAPTER_OBJECT AdapterObject,
|
||||
ULONG Unknown2,
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN ULONG NumberOfMapRegisters,
|
||||
IN PDRIVER_CONTROL ExecutionRoutine
|
||||
IN PDRIVER_CONTROL ExecutionRoutine,
|
||||
IN PVOID Context
|
||||
);
|
||||
|
||||
PVOID
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: iotypes.h,v 1.23 2001/02/10 22:51:07 dwelch Exp $
|
||||
/* $Id: iotypes.h,v 1.24 2001/03/31 16:01:03 phreak Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -84,9 +84,7 @@ typedef VOID (*PIO_APC_ROUTINE) (PVOID ApcContext,
|
|||
|
||||
/* STRUCTURE TYPES ***********************************************************/
|
||||
|
||||
typedef struct _ADAPTER_OBJECT
|
||||
{
|
||||
} ADAPTER_OBJECT, *PADAPTER_OBJECT;
|
||||
typedef struct _ADAPTER_OBJECT ADAPTER_OBJECT, *PADAPTER_OBJECT;
|
||||
|
||||
/*
|
||||
* PURPOSE: Special timer associated with each device
|
||||
|
|
|
@ -8,6 +8,3 @@
|
|||
#include <ddk/extypes.h>
|
||||
#include <ddk/pstypes.h>
|
||||
|
||||
typedef struct _ADAPTER_OBJECT
|
||||
{
|
||||
} ADAPTER_OBJECT, *PADAPTER_OBJECT;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: adapter.c,v 1.3 2000/12/30 01:41:29 ekohl Exp $
|
||||
/* $Id: adapter.c,v 1.4 2001/03/31 15:58:24 phreak Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -12,8 +12,9 @@
|
|||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <ddk/iotypes.h>
|
||||
#include <internal/debug.h>
|
||||
#include <internal/i386/hal.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
@ -21,11 +22,46 @@
|
|||
|
||||
NTSTATUS STDCALL
|
||||
HalAllocateAdapterChannel(PADAPTER_OBJECT AdapterObject,
|
||||
ULONG Unknown2,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
ULONG NumberOfMapRegisters,
|
||||
PDRIVER_CONTROL ExecutionRoutine)
|
||||
PDRIVER_CONTROL ExecutionRoutine,
|
||||
PVOID Context )
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
KIRQL OldIrql;
|
||||
PVOID Buffer;
|
||||
int ret;
|
||||
LARGE_INTEGER MaxAddress;
|
||||
|
||||
MaxAddress.QuadPart = 0x1000000;
|
||||
Buffer = MmAllocateContiguousAlignedMemory( NumberOfMapRegisters * PAGESIZE,
|
||||
MaxAddress,
|
||||
0x10000 );
|
||||
if( !Buffer )
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
KeAcquireSpinLock( &AdapterObject->SpinLock, &OldIrql );
|
||||
if( AdapterObject->Inuse )
|
||||
{
|
||||
// someone is already using it, we need to wait
|
||||
// create a wait block, and add it to the chain
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
else {
|
||||
AdapterObject->Inuse = TRUE;
|
||||
KeReleaseSpinLock( &AdapterObject->SpinLock, OldIrql );
|
||||
ret = ExecutionRoutine( DeviceObject,
|
||||
NULL,
|
||||
Buffer,
|
||||
Context );
|
||||
KeAcquireSpinLock( &AdapterObject->SpinLock, &OldIrql );
|
||||
if( ret == DeallocateObject )
|
||||
{
|
||||
MmFreeContiguousMemory( Buffer );
|
||||
AdapterObject->Inuse = FALSE;
|
||||
}
|
||||
else AdapterObject->Buffer = Buffer;
|
||||
}
|
||||
KeReleaseSpinLock( &AdapterObject->SpinLock, OldIrql );
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,14 +73,31 @@ IoFlushAdapterBuffers (PADAPTER_OBJECT AdapterObject,
|
|||
ULONG Length,
|
||||
BOOLEAN WriteToDevice)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
// if this was a read from device, copy data back to caller buffer, otherwise, do nothing
|
||||
if( !WriteToDevice )
|
||||
memcpy( MmGetSystemAddressForMdl( Mdl ), MapRegisterBase, Length );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
VOID STDCALL
|
||||
IoFreeAdapterChannel (PADAPTER_OBJECT AdapterObject)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
KIRQL OldIrql;
|
||||
|
||||
KeAcquireSpinLock( &AdapterObject->SpinLock, &OldIrql );
|
||||
if( AdapterObject->Inuse == FALSE )
|
||||
{
|
||||
DbgPrint( "Attempting to IoFreeAdapterChannel on a channel not in use\n" );
|
||||
KeBugCheck(0);
|
||||
}
|
||||
AdapterObject->Inuse = FALSE;
|
||||
if( AdapterObject->Buffer )
|
||||
{
|
||||
MmFreeContiguousMemory( AdapterObject->Buffer );
|
||||
AdapterObject->Buffer = 0;
|
||||
}
|
||||
KeReleaseSpinLock( &AdapterObject->SpinLock, OldIrql );
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,8 +118,36 @@ IoMapTransfer (PADAPTER_OBJECT AdapterObject,
|
|||
PULONG Length,
|
||||
BOOLEAN WriteToDevice)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
LARGE_INTEGER Address;
|
||||
// program up the dma controller, and return
|
||||
// if it is a write to the device, copy the caller buffer to the low buffer
|
||||
if( WriteToDevice )
|
||||
memcpy( MapRegisterBase,
|
||||
MmGetSystemAddressForMdl( Mdl ) + ( (DWORD)CurrentVa - (DWORD)MmGetMdlVirtualAddress( Mdl ) ),
|
||||
*Length );
|
||||
// port 0xA is the dma mask register, or a 0x10 on to the channel number to mask it
|
||||
WRITE_PORT_UCHAR( (PVOID)0x0A, AdapterObject->Channel | 0x10 );
|
||||
// write zero to the reset register
|
||||
WRITE_PORT_UCHAR( (PVOID)0x0C, 0 );
|
||||
// mode register, or channel with 0x4 for write memory, 0x8 for read memory, 0x10 for non auto initialize
|
||||
WRITE_PORT_UCHAR( (PVOID)0x0B, AdapterObject->Channel | ( WriteToDevice ? 0x8 : 0x4 ) );
|
||||
// set the 64k page register for the channel
|
||||
WRITE_PORT_UCHAR( AdapterObject->PagePort, (UCHAR)(((ULONG)MapRegisterBase)>>16) );
|
||||
// low, then high address byte, which is always 0 for us, because we have a 64k alligned address
|
||||
WRITE_PORT_UCHAR( AdapterObject->OffsetPort, 0 );
|
||||
WRITE_PORT_UCHAR( AdapterObject->OffsetPort, 0 );
|
||||
// count is 1 less than length, low then high
|
||||
WRITE_PORT_UCHAR( AdapterObject->CountPort, (UCHAR)(*Length - 1) );
|
||||
WRITE_PORT_UCHAR( AdapterObject->CountPort, (UCHAR)((*Length - 1)>>8) );
|
||||
// unmask the channel to let it rip
|
||||
WRITE_PORT_UCHAR( (PVOID)0x0A, AdapterObject->Channel );
|
||||
Address.QuadPart = (DWORD)MapRegisterBase;
|
||||
return Address;
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: dma.c,v 1.9 2000/12/30 01:41:29 ekohl Exp $
|
||||
/* $Id: dma.c,v 1.10 2001/03/31 15:58:24 phreak Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -14,6 +14,14 @@
|
|||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
#include <internal/i386/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 } };
|
||||
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
@ -67,9 +75,9 @@ HalGetAdapter (PDEVICE_DESCRIPTION DeviceDescription,
|
|||
PULONG NumberOfMapRegisters)
|
||||
/*
|
||||
* FUNCTION: Returns a pointer to an adapter object for the DMA device
|
||||
* defined the device description structure
|
||||
* defined in the device description structure
|
||||
* ARGUMENTS:
|
||||
* DeviceObject = Structure describing the attributes of the device
|
||||
* DeviceDescription = Structure describing the attributes of the device
|
||||
* NumberOfMapRegisters (OUT) = Returns the maximum number of map
|
||||
* registers the device driver can
|
||||
* allocate for DMA transfer operations
|
||||
|
@ -77,10 +85,27 @@ HalGetAdapter (PDEVICE_DESCRIPTION DeviceDescription,
|
|||
* NULL on failure
|
||||
*/
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
/* 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->Master )
|
||||
return NULL;
|
||||
if( DeviceDescription->ScatterGather )
|
||||
return NULL;
|
||||
if( DeviceDescription->AutoInitialize )
|
||||
return NULL;
|
||||
if( DeviceDescription->Dma32BitAddress )
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
ULONG STDCALL
|
||||
HalReadDmaCounter (PADAPTER_OBJECT AdapterObject)
|
||||
{
|
||||
|
|
45
reactos/ntoskrnl/include/internal/i386/hal.h
Normal file
45
reactos/ntoskrnl/include/internal/i386/hal.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __INTERNAL_HAL_HAL_H
|
||||
#define __INTERNAL_HAL_HAL_H
|
||||
|
||||
#include <ddk/service.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
|
||||
/*
|
||||
* FUNCTION: Probes for a BIOS32 extension
|
||||
*/
|
||||
VOID Hal_bios32_probe(VOID);
|
||||
|
||||
/*
|
||||
* FUNCTION: Determines if a a bios32 service is present
|
||||
*/
|
||||
BOOLEAN Hal_bios32_is_service_present(ULONG service);
|
||||
|
||||
VOID HalInitializeDisplay (PLOADER_PARAMETER_BLOCK LoaderBlock);
|
||||
VOID HalResetDisplay (VOID);
|
||||
|
||||
VOID HalpInitBusHandlers (VOID);
|
||||
|
||||
/* irql.c */
|
||||
VOID HalpInitPICs(VOID);
|
||||
|
||||
/* udelay.c */
|
||||
VOID HalpCalibrateStallExecution(VOID);
|
||||
|
||||
/* pci.c */
|
||||
VOID HalpInitPciBus (VOID);
|
||||
|
||||
struct _ADAPTER_OBJECT {
|
||||
int Channel;
|
||||
PVOID PagePort;
|
||||
PVOID CountPort;
|
||||
PVOID OffsetPort;
|
||||
KSPIN_LOCK SpinLock;
|
||||
PVOID Buffer;
|
||||
BOOLEAN Inuse;
|
||||
};
|
||||
|
||||
#endif /* __INTERNAL_HAL_HAL_H */
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: adapter.c,v 1.4 2000/07/19 14:18:18 dwelch Exp $
|
||||
/* $Id: adapter.c,v 1.5 2001/03/31 15:58:24 phreak Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -30,7 +30,11 @@ IoAllocateAdapterChannel (PADAPTER_OBJECT AdapterObject,
|
|||
PDRIVER_CONTROL ExecutionRoutine,
|
||||
PVOID Context)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return HalAllocateAdapterChannel( AdapterObject,
|
||||
DeviceObject,
|
||||
NumberOfMapRegisters,
|
||||
ExecutionRoutine,
|
||||
Context );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.def,v 1.101 2001/03/25 02:34:27 dwelch Exp $
|
||||
; $Id: ntoskrnl.def,v 1.102 2001/03/31 15:58:23 phreak Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -1014,7 +1014,7 @@ ExTryToAcquireFastMutex@4
|
|||
HalAcquireDisplayOwnership@4
|
||||
HalAdjustResourceList@4
|
||||
HalAllProcessorsStarted@0
|
||||
HalAllocateAdapterChannel@16
|
||||
HalAllocateAdapterChannel@20
|
||||
HalAllocateCommonBuffer@16
|
||||
;HalAllocateCrashDumpRegisters@8
|
||||
HalAssignSlotResources@32
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.edf,v 1.88 2001/03/25 02:34:27 dwelch Exp $
|
||||
; $Id: ntoskrnl.edf,v 1.89 2001/03/31 15:58:24 phreak Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -1012,7 +1012,7 @@ ExTryToAcquireFastMutex=ExTryToAcquireFastMutex@4
|
|||
HalAcquireDisplayOwnership=HalAcquireDisplayOwnership@4
|
||||
HalAdjustResourceList=HalAdjustResourceList@4
|
||||
HalAllProcessorsStarted=HalAllProcessorsStarted@0
|
||||
HalAllocateAdapterChannel=HalAllocateAdapterChannel@16
|
||||
HalAllocateAdapterChannel=HalAllocateAdapterChannel@20
|
||||
HalAllocateCommonBuffer=HalAllocateCommonBuffer@16
|
||||
;HalAllocateCrashDumpRegisters=HalAllocateCrashDumpRegisters@8
|
||||
HalAssignSlotResource=HalAssignSlotResources@32
|
||||
|
|
Loading…
Reference in a new issue