From daae8270b7f71850cab99cbbb5432bce1d48b8b0 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 9 Mar 2004 17:28:49 +0000 Subject: [PATCH] - Implemented VideoPortQueryPerformanceCounter and all video port spinlock functions. - Added more debug info to VideoPortGetAccessRanges. svn path=/trunk/; revision=8611 --- reactos/drivers/video/videoprt/Makefile | 5 +- reactos/drivers/video/videoprt/spinlock.c | 109 ++++++++++++++++++++ reactos/drivers/video/videoprt/videoprt.c | 63 +++++------ reactos/drivers/video/videoprt/videoprt.edf | 42 +++++++- 4 files changed, 181 insertions(+), 38 deletions(-) create mode 100644 reactos/drivers/video/videoprt/spinlock.c diff --git a/reactos/drivers/video/videoprt/Makefile b/reactos/drivers/video/videoprt/Makefile index 01f031c07a3..a7bbc0a056e 100644 --- a/reactos/drivers/video/videoprt/Makefile +++ b/reactos/drivers/video/videoprt/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.2 2004/03/04 18:51:58 navaraf Exp $ +# $Id: Makefile,v 1.3 2004/03/09 17:28:49 navaraf Exp $ PATH_TO_TOP = ../../.. @@ -12,7 +12,8 @@ TARGET_OBJECTS = \ int10.o \ interrupt.o \ videoprt.o \ - services.o + services.o \ + spinlock.o include $(PATH_TO_TOP)/rules.mak diff --git a/reactos/drivers/video/videoprt/spinlock.c b/reactos/drivers/video/videoprt/spinlock.c new file mode 100644 index 00000000000..3aa4721d37f --- /dev/null +++ b/reactos/drivers/video/videoprt/spinlock.c @@ -0,0 +1,109 @@ +/* + * VideoPort driver + * + * Copyright (C) 2002, 2003, 2004 ReactOS Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; see the file COPYING.LIB. + * If not, write to the Free Software Foundation, + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id: spinlock.c,v 1.1 2004/03/09 17:28:49 navaraf Exp $ + */ + +#include "videoprt.h" + +/* + * @implemented + */ + +VP_STATUS STDCALL +VideoPortCreateSpinLock( + IN PVOID HwDeviceExtension, + OUT PSPIN_LOCK *SpinLock) +{ + DPRINT("VideoPortCreateSpinLock\n"); + *SpinLock = ExAllocatePool(NonPagedPool, sizeof(KSPIN_LOCK)); + if (*SpinLock == NULL) + return STATUS_UNSUCCESSFUL; + KeInitializeSpinLock((PKSPIN_LOCK)*SpinLock); + return STATUS_SUCCESS; +} + +/* + * @implemented + */ + +VP_STATUS STDCALL +VideoPortDeleteSpinLock( + IN PVOID HwDeviceExtension, + IN PSPIN_LOCK SpinLock) +{ + DPRINT("VideoPortDeleteSpinLock\n"); + ExFreePool(SpinLock); + return STATUS_SUCCESS; +} + +/* + * @implemented + */ + +VOID STDCALL +VideoPortAcquireSpinLock( + IN PVOID HwDeviceExtension, + IN PSPIN_LOCK SpinLock, + OUT PUCHAR OldIrql) +{ + DPRINT("VideoPortAcquireSpinLock\n"); + KeAcquireSpinLock((PKSPIN_LOCK)SpinLock, OldIrql); +} + +/* + * @implemented + */ + +VOID STDCALL +VideoPortAcquireSpinLockAtDpcLevel( + IN PVOID HwDeviceExtension, + IN PSPIN_LOCK SpinLock) +{ + DPRINT("VideoPortAcquireSpinLockAtDpcLevel\n"); + KefAcquireSpinLockAtDpcLevel((PKSPIN_LOCK)SpinLock); +} + +/* + * @implemented + */ + +VOID STDCALL +VideoPortReleaseSpinLock( + IN PVOID HwDeviceExtension, + IN PSPIN_LOCK SpinLock, + IN UCHAR NewIrql) +{ + DPRINT("VideoPortReleaseSpinLock\n"); + KeReleaseSpinLock((PKSPIN_LOCK)SpinLock, NewIrql); +} + +/* + * @implemented + */ + +VOID STDCALL +VideoPortReleaseSpinLockFromDpcLevel( + IN PVOID HwDeviceExtension, + IN PSPIN_LOCK SpinLock) +{ + DPRINT("VideoPortReleaseSpinLockFromDpcLevel\n"); + KefReleaseSpinLockFromDpcLevel((PKSPIN_LOCK)SpinLock); +} diff --git a/reactos/drivers/video/videoprt/videoprt.c b/reactos/drivers/video/videoprt/videoprt.c index 7981bd02604..aa77e78be73 100644 --- a/reactos/drivers/video/videoprt/videoprt.c +++ b/reactos/drivers/video/videoprt/videoprt.c @@ -18,7 +18,7 @@ * If not, write to the Free Software Foundation, * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Id: videoprt.c,v 1.16 2004/03/09 14:16:39 navaraf Exp $ + * $Id: videoprt.c,v 1.17 2004/03/09 17:28:49 navaraf Exp $ */ #include "videoprt.h" @@ -211,26 +211,10 @@ VideoPortGetAccessRanges(IN PVOID HwDeviceExtension, PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; USHORT VendorIdToFind; USHORT DeviceIdToFind; + ULONG SlotIdToFind; DPRINT("VideoPortGetAccessRanges\n"); - if (VendorId != NULL) - { - VendorIdToFind = *(PUSHORT)VendorId; - } - else - { - VendorIdToFind = 0; - } - if (DeviceId != NULL) - { - DeviceIdToFind = *(PUSHORT)DeviceId; - } - else - { - DeviceIdToFind = 0; - } - DeviceExtension = CONTAINING_RECORD(HwDeviceExtension, VIDEO_PORT_DEVICE_EXTENSION, MiniPortDeviceExtension); @@ -238,10 +222,14 @@ VideoPortGetAccessRanges(IN PVOID HwDeviceExtension, if (0 == NumRequestedResources && PCIBus == DeviceExtension->AdapterInterfaceType) { - DPRINT("Looking for VendorId 0x%04x DeviceId 0x%04x\n", - VendorIdToFind, DeviceIdToFind); + VendorIdToFind = VendorId != NULL ? *(PUSHORT)VendorId : 0; + DeviceIdToFind = DeviceId != NULL ? *(PUSHORT)DeviceId : 0; + SlotIdToFind = Slot != NULL ? *Slot : 0; - PciSlotNumber.u.AsULONG = *Slot; + DPRINT("Looking for VendorId 0x%04x DeviceId 0x%04x SlotId 0x%04x\n", + VendorIdToFind, DeviceIdToFind, SlotIdToFind); + + PciSlotNumber.u.AsULONG = SlotIdToFind; /* Search for the device id and vendor id on this bus. @@ -249,23 +237,23 @@ VideoPortGetAccessRanges(IN PVOID HwDeviceExtension, for (FunctionNumber = 0; FunctionNumber < 8; FunctionNumber++) { ULONG ReturnedLength; + DPRINT("- Function number: %d\n", FunctionNumber); PciSlotNumber.u.bits.FunctionNumber = FunctionNumber; ReturnedLength = HalGetBusData(PCIConfiguration, DeviceExtension->SystemIoBusNumber, PciSlotNumber.u.AsULONG, &Config, sizeof(PCI_COMMON_CONFIG)); - if (sizeof(PCI_COMMON_CONFIG) == ReturnedLength) + DPRINT("- Length of data: %x\n", ReturnedLength); + if (sizeof(PCI_COMMON_CONFIG) == ReturnedLength) { - if (DeviceId != NULL && VendorId != NULL) - { - DPRINT("Slot 0x%02x (Device %d Function %d) VendorId 0x%04x " - "DeviceId 0x%04x\n", - PciSlotNumber.u.AsULONG, - PciSlotNumber.u.bits.DeviceNumber, - PciSlotNumber.u.bits.FunctionNumber, Config.VendorID, - Config.DeviceID); - } + DPRINT("- Slot 0x%02x (Device %d Function %d) VendorId 0x%04x " + "DeviceId 0x%04x\n", + PciSlotNumber.u.AsULONG, + PciSlotNumber.u.bits.DeviceNumber, + PciSlotNumber.u.bits.FunctionNumber, + Config.VendorID, + Config.DeviceID); if ((VendorIdToFind == 0 || Config.VendorID == VendorIdToFind) && (DeviceIdToFind == 0 || Config.DeviceID == DeviceIdToFind)) @@ -1857,3 +1845,16 @@ VideoPortGetProcAddress(IN PVOID HwDeviceExtension, DPRINT("VideoPortGetProcAddress: Can't resolve symbol %s\n", FunctionName); return(NULL); } + +LONGLONG STDCALL +VideoPortQueryPerformanceCounter( + IN PVOID HwDeviceExtension, + OUT PLONGLONG PerformanceFrequency OPTIONAL) +{ + LARGE_INTEGER Result; + + DPRINT("VideoPortQueryPerformanceCounter\n"); + Result = KeQueryPerformanceCounter((PLARGE_INTEGER)PerformanceFrequency); + return Result.QuadPart; +} + diff --git a/reactos/drivers/video/videoprt/videoprt.edf b/reactos/drivers/video/videoprt/videoprt.edf index bce89b97afb..5aedc3bfd61 100644 --- a/reactos/drivers/video/videoprt/videoprt.edf +++ b/reactos/drivers/video/videoprt/videoprt.edf @@ -1,45 +1,66 @@ -; $Id: videoprt.edf,v 1.7 2004/03/08 20:27:33 dwelch Exp $ +; $Id: videoprt.edf,v 1.8 2004/03/09 17:28:49 navaraf Exp $ ; -; vidport.def - export definition file for ReactOS +; videoprt.def - export definition file for ReactOS ; EXPORTS +;VideoPortAcquireDeviceLock +VideoPortAcquireSpinLock=VideoPortAcquireSpinLock@12 +VideoPortAcquireSpinLockAtDpcLevel=VideoPortAcquireSpinLockAtDpcLevel@8 VideoPortAllocateBuffer=VideoPortAllocateBuffer@12 VideoPortAllocateCommonBuffer=VideoPortAllocateCommonBuffer@24 +;VideoPortAllocateContiguousMemory VideoPortAllocatePool=VideoPortAllocatePool@16 +;VideoPortAssociateEventsWithDmaHandle VideoPortCheckForDeviceExistence=VideoPortCheckForDeviceExistence@28 -VideoPortCompareMemory=NTOSKRNL.RtlCompareMemory VideoPortClearEvent=VideoPortClearEvent@8 +VideoPortCompareMemory=NTOSKRNL.RtlCompareMemory +;VideoPortCompleteDma VideoPortCreateEvent=VideoPortCreateEvent@16 VideoPortCreateSecondaryDisplay=VideoPortCreateSecondaryDisplay@12 +VideoPortCreateSpinLock=VideoPortCreateSpinLock@8 VideoPortDDCMonitorHelper=VideoPortDDCMonitorHelper@16 VideoPortDebugPrint VideoPortDeleteEvent=VideoPortDeleteEvent@8 +VideoPortDeleteSpinLock=VideoPortDeleteSpinLock@8 VideoPortDisableInterrupt=VideoPortDisableInterrupt@4 +;VideoPortDoDma VideoPortEnableInterrupt=VideoPortEnableInterrupt@4 VideoPortEnumerateChildren=VideoPortEnumerateChildren@8 +;VideoPortFlushRegistry +;VideoPortFreeCommonBuffer VideoPortFreeDeviceBase=VideoPortFreeDeviceBase@8 VideoPortFreePool=VideoPortFreePool@8 -VideoPortGetBusData=VideoPortGetBusData@24 +VideoPortGetAccessRanges=VideoPortGetAccessRanges@32 VideoPortGetAgpServices=VideoPortGetAgpServices@8 VideoPortGetAssociatedDeviceExtension=VideoPortGetAssociatedDeviceExtension@4 +;VideoPortGetAssociatedDeviceID +VideoPortGetBusData=VideoPortGetBusData@24 +;VideoPortGetBytesUsed +;VideoPortGetCommonBuffer VideoPortGetCurrentIrql=VideoPortGetCurrentIrql@0 VideoPortGetDeviceBase=VideoPortGetDeviceBase@20 VideoPortGetDeviceData=VideoPortGetDeviceData@16 VideoPortGetDmaAdapter=VideoPortGetDmaAdapter@8 -VideoPortGetAccessRanges=VideoPortGetAccessRanges@32 +;VideoPortGetDmaContext +;VideoPortGetMdl VideoPortGetRegistryParameters=VideoPortGetRegistryParameters@20 VideoPortGetRomImage=VideoPortGetRomImage@16 VideoPortGetVersion=VideoPortGetVersion@8 VideoPortGetVgaStatus=VideoPortGetVgaStatus@8 VideoPortInitialize=VideoPortInitialize@16 VideoPortInt10=VideoPortInt10@8 +VideoPortInterlockedDecrement=NTOSKRNL.InterlockedDecrement VideoPortInterlockedExchange=NTOSKRNL.InterlockedExchange +VideoPortInterlockedIncrement=NTOSKRNL.InterlockedIncrement VideoPortLockBuffer=VideoPortLockBuffer@16 +;VideoPortLockPages VideoPortLogError=VideoPortLogError@16 VideoPortMapBankedMemory=VideoPortMapBankedMemory@40 +;VideoPortMapDmaMemory VideoPortMapMemory=VideoPortMapMemory@24 VideoPortMoveMemory=NTOSKRNL.RtlMoveMemory VideoPortPutDmaAdapter=VideoPortPutDmaAdapter@8 +VideoPortQueryPerformanceCounter=VideoPortQueryPerformanceCounter@8 VideoPortQueryServices=VideoPortQueryServices@12 VideoPortQuerySystemTime=NTOSKRNL.KeQuerySystemTime VideoPortQueueDpc=VideoPortQueueDpc@12 @@ -55,19 +76,29 @@ VideoPortReadRegisterUlong=NTOSKRNL.READ_REGISTER_ULONG VideoPortReadRegisterBufferUchar=NTOSKRNL.READ_REGISTER_BUFFER_UCHAR VideoPortReadRegisterBufferUshort=NTOSKRNL.READ_REGISTER_BUFFER_USHORT VideoPortReadRegisterBufferUlong=NTOSKRNL.READ_REGISTER_BUFFER_ULONG +;VideoPortReadStateEvent VideoPortRegisterBugcheckCallBack=VideoPortRegisterBugcheckCallback@16 VideoPortReleaseBuffer=VideoPortReleaseBuffer@8 VideoPortReleaseCommonBuffer=VideoPortReleaseCommonBuffer@28 +;VideoPortReleaseDeviceLock +VideoPortReleaseSpinLock@12 +VideoPortReleaseSpinLockFromDpcLevel@8 VideoPortScanRom=VideoPortScanRom@16 VideoPortSetBusData=VideoPortSetBusData@24 +;VideoPortSetBytesUsed +;VideoPortSetDmaContext VideoPortSetEvent=VideoPortSetEvent@8 VideoPortSetRegistryParameters=VideoPortSetRegistryParameters@16 VideoPortSetTrappedEmulatorPorts=VideoPortSetTrappedEmulatorPorts@12 +;VideoPortSignalDmaComplete VideoPortStallExecution=HAL.KeStallExecutionProcessor +;VideoPortStartDma VideoPortStartTimer=VideoPortStartTimer@4 VideoPortStopTimer=VideoPortStopTimer@4 VideoPortSynchronizeExecution=VideoPortSynchronizeExecution@16 VideoPortUnlockBuffer=VideoPortUnlockBuffer@8 +;VideoPortUnlockPages +;VideoPortUnmapDmaMemory VideoPortUnmapMemory=VideoPortUnmapMemory@12 VideoPortVerifyAccessRanges=VideoPortVerifyAccessRanges@12 VideoPortWaitForSingleObject=VideoPortWaitForSingleObject@12 @@ -85,3 +116,4 @@ VideoPortWriteRegisterBufferUshort=NTOSKRNL.WRITE_REGISTER_BUFFER_USHORT VideoPortWriteRegisterBufferUlong=NTOSKRNL.WRITE_REGISTER_BUFFER_ULONG VideoPortZeroMemory=NTOSKRNL.RtlZeroMemory VideoPortZeroDeviceMemory=NTOSKRNL.RtlZeroMemory +;VpNotifyEaData