Merged changes from videoport_pnp_14032004 branch:

- Better support for W2K+ video miniport driver incl. the basic implementation of PnP driver model.
- Return Win32 error codes instead of NT equivalents.
- Fixed a few bugs.

svn path=/trunk/; revision=8796
This commit is contained in:
Filip Navara 2004-03-19 20:58:32 +00:00
parent 91c3d64bf5
commit d621be6ce6
13 changed files with 2475 additions and 1903 deletions

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.3 2004/03/09 17:28:49 navaraf Exp $
# $Id: Makefile,v 1.4 2004/03/19 20:58:31 navaraf Exp $
PATH_TO_TOP = ../../..
@ -9,11 +9,17 @@ TARGET_NAME = videoprt
TARGET_CFLAGS += -Wall -Werror -D__USE_W32API -I$(PATH_TO_TOP)/ntoskrnl/include
TARGET_OBJECTS = \
dispatch.o \
dma.o \
event.o \
int10.o \
interrupt.o \
videoprt.o \
resource.o \
services.o \
spinlock.o
spinlock.o \
timer.o
include $(PATH_TO_TOP)/rules.mak

View file

@ -0,0 +1,316 @@
/*
* 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: dispatch.c,v 1.2 2004/03/19 20:58:32 navaraf Exp $
*/
#include "videoprt.h"
/* EXTERNAL FUNCTIONS *********************************************************/
typedef PVOID PHAL_RESET_DISPLAY_PARAMETERS;
VOID STDCALL HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
VOID STDCALL HalReleaseDisplayOwnership();
/* GLOBAL VARIABLES ***********************************************************/
PVIDEO_PORT_DEVICE_EXTENSION ResetDisplayParametersDeviceExtension = NULL;
/* PRIVATE FUNCTIONS **********************************************************/
/*
* Reset display to blue screen
*/
BOOLEAN STDCALL
IntVideoPortResetDisplayParameters(ULONG Columns, ULONG Rows)
{
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
if (ResetDisplayParametersDeviceExtension == NULL)
return FALSE;
DriverExtension = ResetDisplayParametersDeviceExtension->DriverExtension;
ASSERT(DriverExtension->InitializationData.HwResetHw != NULL);
if (!DriverExtension->InitializationData.HwResetHw(
&ResetDisplayParametersDeviceExtension->MiniPortDeviceExtension,
Columns, Rows))
{
return FALSE;
}
ResetDisplayParametersDeviceExtension = NULL;
return TRUE;
}
NTSTATUS STDCALL
IntVideoPortAddDevice(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject)
{
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
/*
* Get the initialization data we saved in VideoPortInitialize.
*/
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
/*
* Use generic routine to find the adapter and create device object.
*/
return IntVideoPortFindAdapter(
DriverObject,
DriverExtension,
PhysicalDeviceObject);
}
/*
* IntVideoPortDispatchOpen
*
* Answer requests for Open calls.
*
* Run Level
* PASSIVE_LEVEL
*/
NTSTATUS STDCALL
IntVideoPortDispatchOpen(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
DPRINT("IntVideoPortDispatchOpen\n");
if (CsrssInitialized == FALSE)
{
/*
* We know the first open call will be from the CSRSS process
* to let us know its handle.
*/
DPRINT("Referencing CSRSS\n");
Csrss = PsGetCurrentProcess();
DPRINT("Csrss %p\n", Csrss);
CsrssInitialized = TRUE;
Irp->IoStatus.Information = FILE_OPENED;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
DriverExtension = DeviceExtension->DriverExtension;
if (DriverExtension->InitializationData.HwInitialize(&DeviceExtension->MiniPortDeviceExtension))
{
Irp->IoStatus.Status = STATUS_SUCCESS;
/*
* Storing the device extension pointer in a static variable is an
* ugly hack. Unfortunately, we need it in VideoPortResetDisplayParameters
* and HalAcquireDisplayOwnership doesn't allow us to pass a userdata
* parameter. On the bright side, the DISPLAY device is opened
* exclusively, so there can be only one device extension active at
* any point in time.
*/
ResetDisplayParametersDeviceExtension = DeviceExtension;
HalAcquireDisplayOwnership(IntVideoPortResetDisplayParameters);
}
else
{
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
}
Irp->IoStatus.Information = FILE_OPENED;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
/*
* IntVideoPortDispatchClose
*
* Answer requests for Close calls.
*
* Run Level
* PASSIVE_LEVEL
*/
NTSTATUS STDCALL
IntVideoPortDispatchClose(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
DPRINT("IntVideoPortDispatchClose\n");
if (ResetDisplayParametersDeviceExtension != NULL)
HalReleaseDisplayOwnership();
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
/*
* IntVideoPortDispatchDeviceControl
*
* Answer requests for device control calls.
*
* Run Level
* PASSIVE_LEVEL
*/
NTSTATUS STDCALL
IntVideoPortDispatchDeviceControl(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PIO_STACK_LOCATION IrpStack;
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
PVIDEO_REQUEST_PACKET vrp;
NTSTATUS Status;
DPRINT("IntVideoPortDispatchDeviceControl\n");
IrpStack = IoGetCurrentIrpStackLocation(Irp);
DeviceExtension = DeviceObject->DeviceExtension;
DriverExtension = DeviceExtension->DriverExtension;
/* Translate the IRP to a VRP */
vrp = ExAllocatePool(NonPagedPool, sizeof(VIDEO_REQUEST_PACKET));
if (NULL == vrp)
{
return STATUS_NO_MEMORY;
}
vrp->StatusBlock = (PSTATUS_BLOCK)&(Irp->IoStatus);
vrp->IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
DPRINT("- IoControlCode: %x\n", vrp->IoControlCode);
/* We're assuming METHOD_BUFFERED */
vrp->InputBuffer = Irp->AssociatedIrp.SystemBuffer;
vrp->InputBufferLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
vrp->OutputBuffer = Irp->AssociatedIrp.SystemBuffer;
vrp->OutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
/* Call the Miniport Driver with the VRP */
DriverExtension->InitializationData.HwStartIO(
&DeviceExtension->MiniPortDeviceExtension,
vrp);
/* Free the VRP */
ExFreePool(vrp);
DPRINT("- Returned status: %x\n", Irp->IoStatus.Status);
if (Irp->IoStatus.Status != STATUS_SUCCESS)
{
/* Map from win32 error codes to NT status values. */
switch (Irp->IoStatus.Status)
{
case ERROR_NOT_ENOUGH_MEMORY: Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES; break;
case ERROR_MORE_DATA: Irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW; break;
case ERROR_INVALID_FUNCTION: Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; break;
case ERROR_INVALID_PARAMETER: Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; break;
case ERROR_INSUFFICIENT_BUFFER: Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; break;
case ERROR_DEV_NOT_EXIST: Irp->IoStatus.Status = STATUS_DEVICE_DOES_NOT_EXIST; break;
case ERROR_IO_PENDING: Irp->IoStatus.Status = STATUS_PENDING; break;
}
}
Status = Irp->IoStatus.Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
NTSTATUS STDCALL
IntVideoPortDispatchPnp(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PIO_STACK_LOCATION IrpSp;
IrpSp = IoGetCurrentIrpStackLocation(Irp);
switch (IrpSp->MinorFunction)
{
case IRP_MN_START_DEVICE:
case IRP_MN_REMOVE_DEVICE:
case IRP_MN_QUERY_REMOVE_DEVICE:
case IRP_MN_CANCEL_REMOVE_DEVICE:
case IRP_MN_SURPRISE_REMOVAL:
case IRP_MN_STOP_DEVICE:
case IRP_MN_QUERY_STOP_DEVICE:
case IRP_MN_CANCEL_STOP_DEVICE:
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS STDCALL
IntVideoPortDispatchCleanup(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
DeviceExtension = DeviceObject->DeviceExtension;
RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
NTSTATUS STDCALL
IntVideoPortDispatchPower(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
return STATUS_NOT_IMPLEMENTED;
}
VOID STDCALL
IntVideoPortUnload(PDRIVER_OBJECT DriverObject)
{
}

View file

@ -0,0 +1,119 @@
/*
* 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: dma.c,v 1.2 2004/03/19 20:58:32 navaraf Exp $
*/
#include "videoprt.h"
/* PUBLIC FUNCTIONS ***********************************************************/
/*
* @implemented
*/
PVOID STDCALL
VideoPortAllocateCommonBuffer(
IN PVOID HwDeviceExtension,
IN PVP_DMA_ADAPTER VpDmaAdapter,
IN ULONG DesiredLength,
OUT PPHYSICAL_ADDRESS LogicalAddress,
IN BOOLEAN CacheEnabled,
PVOID Reserved)
{
return HalAllocateCommonBuffer(
(PADAPTER_OBJECT)VpDmaAdapter,
DesiredLength,
LogicalAddress,
CacheEnabled);
}
/*
* @implemented
*/
VOID STDCALL
VideoPortReleaseCommonBuffer(
IN PVOID HwDeviceExtension,
IN PVP_DMA_ADAPTER VpDmaAdapter,
IN ULONG Length,
IN PHYSICAL_ADDRESS LogicalAddress,
IN PVOID VirtualAddress,
IN BOOLEAN CacheEnabled)
{
HalFreeCommonBuffer(
(PADAPTER_OBJECT)VpDmaAdapter,
Length,
LogicalAddress,
VirtualAddress,
CacheEnabled);
}
/*
* @unimplemented
*/
VOID STDCALL
VideoPortPutDmaAdapter(
IN PVOID HwDeviceExtension,
IN PVP_DMA_ADAPTER VpDmaAdapter)
{
DPRINT("VideoPortPutDmaAdapter: Unimplemented.\n");
}
/*
* @unimplemented
*/
PVP_DMA_ADAPTER STDCALL
VideoPortGetDmaAdapter(
IN PVOID HwDeviceExtension,
IN PVP_DEVICE_DESCRIPTION VpDeviceExtension)
{
DEVICE_DESCRIPTION DeviceDescription;
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
ULONG NumberOfMapRegisters;
PVP_DMA_ADAPTER Adapter;
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
DPRINT("VideoPortGetDmaAdapter\n");
DeviceDescription.Version = DEVICE_DESCRIPTION_VERSION;
DeviceDescription.Master = TRUE /* ?? */;
DeviceDescription.ScatterGather = VpDeviceExtension->ScatterGather;
DeviceDescription.DemandMode = FALSE /* ?? */;
DeviceDescription.AutoInitialize = FALSE /* ?? */;
DeviceDescription.Dma32BitAddresses = VpDeviceExtension->Dma32BitAddresses;
DeviceDescription.IgnoreCount = FALSE /* ?? */;
DeviceDescription.Reserved1 = FALSE;
DeviceDescription.BusNumber = DeviceExtension->SystemIoBusNumber;
DeviceDescription.DmaChannel = 0 /* ?? */;
DeviceDescription.InterfaceType = DeviceExtension->AdapterInterfaceType;
DeviceDescription.DmaWidth = Width8Bits;
DeviceDescription.DmaSpeed = Compatible;
DeviceDescription.MaximumLength = VpDeviceExtension->MaximumLength;
DeviceDescription.DmaPort = 0;
Adapter =
(PVP_DMA_ADAPTER)HalGetAdapter(&DeviceDescription, &NumberOfMapRegisters);
DPRINT("Adapter %X\n", Adapter);
return(Adapter);
}

View file

@ -0,0 +1,111 @@
/*
* 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: event.c,v 1.2 2004/03/19 20:58:32 navaraf Exp $
*/
#include "videoprt.h"
/* PUBLIC FUNCTIONS ***********************************************************/
/*
* @implemented
*/
VP_STATUS STDCALL
VideoPortCreateEvent(
IN PVOID HwDeviceExtension,
IN ULONG EventFlag,
IN PVOID Unused,
OUT PEVENT *Event)
{
EVENT_TYPE Type;
(*Event) = ExAllocatePoolWithTag(
NonPagedPool,
sizeof(KEVENT),
TAG_VIDEO_PORT);
if ((*Event) == NULL)
return ERROR_NOT_ENOUGH_MEMORY;
if (EventFlag & NOTIFICATION_EVENT)
Type = NotificationEvent;
else
Type = SynchronizationEvent;
KeInitializeEvent((PKEVENT)*Event, Type, EventFlag & INITIAL_EVENT_SIGNALED);
return NO_ERROR;
}
/*
* @implemented
*/
VP_STATUS STDCALL
VideoPortDeleteEvent(
IN PVOID HwDeviceExtension,
IN PEVENT Event)
{
ExFreePool(Event);
return NO_ERROR;
}
/*
* @implemented
*/
LONG STDCALL
VideoPortSetEvent(
IN PVOID HwDeviceExtension,
IN PEVENT Event)
{
return KeSetEvent((PKEVENT)Event, IO_NO_INCREMENT, FALSE);
}
/*
* @implemented
*/
VOID STDCALL
VideoPortClearEvent(
IN PVOID HwDeviceExtension,
IN PEVENT Event)
{
KeClearEvent((PKEVENT)Event);
}
/*
* @implemented
*/
VP_STATUS STDCALL
VideoPortWaitForSingleObject(
IN PVOID HwDeviceExtension,
IN PVOID Object,
IN PLARGE_INTEGER Timeout OPTIONAL)
{
return KeWaitForSingleObject(
Object,
Executive,
KernelMode,
FALSE,
Timeout);
}

View file

@ -18,84 +18,13 @@
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id: int10.c,v 1.4 2004/03/08 21:45:39 navaraf Exp $
* $Id: int10.c,v 1.5 2004/03/19 20:58:31 navaraf Exp $
*/
#include "videoprt.h"
#include "internal/v86m.h"
VOID FASTCALL
IntAttachToCSRSS(PEPROCESS *CallingProcess, PEPROCESS *PrevAttachedProcess)
{
*CallingProcess = PsGetCurrentProcess();
if (*CallingProcess != Csrss)
{
if (NULL != PsGetCurrentThread()->OldProcess)
{
*PrevAttachedProcess = *CallingProcess;
KeDetachProcess();
}
else
{
*PrevAttachedProcess = NULL;
}
KeAttachProcess(Csrss);
}
}
VOID FASTCALL
IntDetachFromCSRSS(PEPROCESS *CallingProcess, PEPROCESS *PrevAttachedProcess)
{
if (*CallingProcess != Csrss)
{
KeDetachProcess();
if (NULL != *PrevAttachedProcess)
{
KeAttachProcess(*PrevAttachedProcess);
}
}
}
/*
* @implemented
*/
VP_STATUS STDCALL
VideoPortInt10(
IN PVOID HwDeviceExtension,
IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments)
{
KV86M_REGISTERS Regs;
NTSTATUS Status;
PEPROCESS CallingProcess;
PEPROCESS PrevAttachedProcess;
DPRINT("VideoPortInt10\n");
IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
memset(&Regs, 0, sizeof(Regs));
DPRINT("- Input register Eax: %x\n", BiosArguments->Eax);
Regs.Eax = BiosArguments->Eax;
DPRINT("- Input register Ebx: %x\n", BiosArguments->Ebx);
Regs.Ebx = BiosArguments->Ebx;
DPRINT("- Input register Ecx: %x\n", BiosArguments->Ecx);
Regs.Ecx = BiosArguments->Ecx;
DPRINT("- Input register Edx: %x\n", BiosArguments->Edx);
Regs.Edx = BiosArguments->Edx;
DPRINT("- Input register Esi: %x\n", BiosArguments->Esi);
Regs.Esi = BiosArguments->Esi;
DPRINT("- Input register Edi: %x\n", BiosArguments->Edi);
Regs.Edi = BiosArguments->Edi;
DPRINT("- Input register Ebp: %x\n", BiosArguments->Ebp);
Regs.Ebp = BiosArguments->Ebp;
Status = Ke386CallBios(0x10, &Regs);
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
return Status;
}
/* PRIVATE FUNCTIONS **********************************************************/
VP_STATUS STDCALL
IntInt10AllocateBuffer(
@ -106,8 +35,8 @@ IntInt10AllocateBuffer(
{
PVOID MemoryAddress;
NTSTATUS Status;
PEPROCESS CallingProcess;
PEPROCESS PrevAttachedProcess;
PEPROCESS CallingProcess;
PEPROCESS PrevAttachedProcess;
DPRINT("IntInt10AllocateBuffer\n");
@ -116,17 +45,21 @@ IntInt10AllocateBuffer(
MemoryAddress = (PVOID)0x20000;
Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &MemoryAddress, 0,
Length, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (!NT_SUCCESS(Status))
{
DPRINT("- ZwAllocateVirtualMemory failed\n");
return STATUS_NO_MEMORY;
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
return ERROR_NOT_ENOUGH_MEMORY;
}
if (MemoryAddress > (PVOID)(0x100000 - *Length))
{
ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, Length,
MEM_RELEASE);
DPRINT("- Unacceptable memory allocated\n");
return STATUS_NO_MEMORY;
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
return ERROR_NOT_ENOUGH_MEMORY;
}
*Seg = (ULONG)MemoryAddress >> 4;
@ -138,7 +71,7 @@ IntInt10AllocateBuffer(
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
return STATUS_SUCCESS;
return NO_ERROR;
}
VP_STATUS STDCALL
@ -149,8 +82,8 @@ IntInt10FreeBuffer(
{
PVOID MemoryAddress = (PVOID)((Seg << 4) + Off);
NTSTATUS Status;
PEPROCESS CallingProcess;
PEPROCESS PrevAttachedProcess;
PEPROCESS CallingProcess;
PEPROCESS PrevAttachedProcess;
DPRINT("IntInt10FreeBuffer\n");
DPRINT("- Segment: %x\n", Seg);
@ -172,8 +105,8 @@ IntInt10ReadMemory(
OUT PVOID Buffer,
IN ULONG Length)
{
PEPROCESS CallingProcess;
PEPROCESS PrevAttachedProcess;
PEPROCESS CallingProcess;
PEPROCESS PrevAttachedProcess;
DPRINT("IntInt10ReadMemory\n");
DPRINT("- Segment: %x\n", Seg);
@ -185,7 +118,7 @@ IntInt10ReadMemory(
RtlCopyMemory(Buffer, (PVOID)((Seg << 4) + Off), Length);
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
return STATUS_SUCCESS;
return NO_ERROR;
}
VP_STATUS STDCALL
@ -196,8 +129,8 @@ IntInt10WriteMemory(
IN PVOID Buffer,
IN ULONG Length)
{
PEPROCESS CallingProcess;
PEPROCESS PrevAttachedProcess;
PEPROCESS CallingProcess;
PEPROCESS PrevAttachedProcess;
DPRINT("IntInt10WriteMemory\n");
DPRINT("- Segment: %x\n", Seg);
@ -209,7 +142,7 @@ IntInt10WriteMemory(
RtlCopyMemory((PVOID)((Seg << 4) + Off), Buffer, Length);
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
return STATUS_SUCCESS;
return NO_ERROR;
}
VP_STATUS STDCALL
@ -219,8 +152,8 @@ IntInt10CallBios(
{
KV86M_REGISTERS Regs;
NTSTATUS Status;
PEPROCESS CallingProcess;
PEPROCESS PrevAttachedProcess;
PEPROCESS CallingProcess;
PEPROCESS PrevAttachedProcess;
DPRINT("IntInt10CallBios\n");
@ -260,3 +193,45 @@ IntInt10CallBios(
return Status;
}
/* PUBLIC FUNCTIONS ***********************************************************/
/*
* @implemented
*/
VP_STATUS STDCALL
VideoPortInt10(
IN PVOID HwDeviceExtension,
IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments)
{
KV86M_REGISTERS Regs;
NTSTATUS Status;
PEPROCESS CallingProcess;
PEPROCESS PrevAttachedProcess;
DPRINT("VideoPortInt10\n");
IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
memset(&Regs, 0, sizeof(Regs));
DPRINT("- Input register Eax: %x\n", BiosArguments->Eax);
Regs.Eax = BiosArguments->Eax;
DPRINT("- Input register Ebx: %x\n", BiosArguments->Ebx);
Regs.Ebx = BiosArguments->Ebx;
DPRINT("- Input register Ecx: %x\n", BiosArguments->Ecx);
Regs.Ecx = BiosArguments->Ecx;
DPRINT("- Input register Edx: %x\n", BiosArguments->Edx);
Regs.Edx = BiosArguments->Edx;
DPRINT("- Input register Esi: %x\n", BiosArguments->Esi);
Regs.Esi = BiosArguments->Esi;
DPRINT("- Input register Edi: %x\n", BiosArguments->Edi);
Regs.Edi = BiosArguments->Edi;
DPRINT("- Input register Ebp: %x\n", BiosArguments->Ebp);
Regs.Ebp = BiosArguments->Ebp;
Status = Ke386CallBios(0x10, &Regs);
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
return Status;
}

View file

@ -18,11 +18,89 @@
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id: interrupt.c,v 1.1 2004/03/04 18:51:58 navaraf Exp $
* $Id: interrupt.c,v 1.2 2004/03/19 20:58:31 navaraf Exp $
*/
#include "videoprt.h"
/* PRIVATE FUNCTIONS **********************************************************/
BOOLEAN STDCALL
IntVideoPortInterruptRoutine(
IN struct _KINTERRUPT *Interrupt,
IN PVOID ServiceContext)
{
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = ServiceContext;
ASSERT(DeviceExtension->DriverExtension->InitializationData.HwInterrupt != NULL);
return DeviceExtension->DriverExtension->InitializationData.HwInterrupt(
&DeviceExtension->MiniPortDeviceExtension);
}
BOOLEAN STDCALL
IntVideoPortSetupInterrupt(
IN PDEVICE_OBJECT DeviceObject,
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
IN PVIDEO_PORT_CONFIG_INFO ConfigInfo)
{
NTSTATUS Status;
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
if (ConfigInfo->BusInterruptVector == 0)
ConfigInfo->BusInterruptVector = DeviceExtension->InterruptVector;
if (ConfigInfo->BusInterruptLevel == 0)
ConfigInfo->BusInterruptLevel = DeviceExtension->InterruptLevel;
if (DriverExtension->InitializationData.HwInterrupt != NULL)
{
ULONG InterruptVector;
KIRQL Irql;
KAFFINITY Affinity;
InterruptVector = HalGetInterruptVector(
ConfigInfo->AdapterInterfaceType,
ConfigInfo->SystemIoBusNumber,
ConfigInfo->BusInterruptLevel,
ConfigInfo->BusInterruptVector,
&Irql,
&Affinity);
if (InterruptVector == 0)
{
DPRINT("HalGetInterruptVector failed\n");
return FALSE;
}
KeInitializeSpinLock(&DeviceExtension->InterruptSpinLock);
Status = IoConnectInterrupt(
&DeviceExtension->InterruptObject,
IntVideoPortInterruptRoutine,
DeviceExtension,
&DeviceExtension->InterruptSpinLock,
InterruptVector,
Irql,
Irql,
ConfigInfo->InterruptMode,
FALSE,
Affinity,
FALSE);
if (!NT_SUCCESS(Status))
{
DPRINT("IoConnectInterrupt failed with status 0x%08x\n", Status);
return FALSE;
}
}
return TRUE;
}
/* PUBLIC FUNCTIONS ***********************************************************/
/*
* @implemented
*/
@ -35,17 +113,14 @@ VideoPortEnableInterrupt(IN PVOID HwDeviceExtension)
DPRINT("VideoPortEnableInterrupt\n");
DeviceExtension = CONTAINING_RECORD(
HwDeviceExtension,
VIDEO_PORT_DEVICE_EXTENSION,
MiniPortDeviceExtension);
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
Status = HalEnableSystemInterrupt(
DeviceExtension->InterruptVector,
0,
DeviceExtension->InterruptLevel);
return Status ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
return Status ? NO_ERROR : ERROR_INVALID_ACCESS;
}
/*
@ -60,14 +135,11 @@ VideoPortDisableInterrupt(IN PVOID HwDeviceExtension)
DPRINT("VideoPortDisableInterrupt\n");
DeviceExtension = CONTAINING_RECORD(
HwDeviceExtension,
VIDEO_PORT_DEVICE_EXTENSION,
MiniPortDeviceExtension);
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
Status = HalDisableSystemInterrupt(
DeviceExtension->InterruptVector,
0);
return Status ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
return Status ? NO_ERROR : ERROR_INVALID_ACCESS;
}

View file

@ -0,0 +1,657 @@
/*
* 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: resource.c,v 1.2 2004/03/19 20:58:32 navaraf Exp $
*/
#include "videoprt.h"
/* PRIVATE FUNCTIONS **********************************************************/
PVOID STDCALL
IntVideoPortMapMemory(
IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
IN PHYSICAL_ADDRESS IoAddress,
IN ULONG NumberOfUchars,
IN UCHAR InIoSpace,
OUT VP_STATUS *Status)
{
PHYSICAL_ADDRESS TranslatedAddress;
PVIDEO_PORT_ADDRESS_MAPPING AddressMapping;
ULONG AddressSpace;
PVOID MappedAddress;
PLIST_ENTRY Entry;
DPRINT("- IoAddress: %lx\n", IoAddress.u.LowPart);
DPRINT("- NumberOfUchars: %lx\n", NumberOfUchars);
DPRINT("- InIoSpace: %x\n", InIoSpace);
InIoSpace &= ~VIDEO_MEMORY_SPACE_DENSE;
if ((InIoSpace & VIDEO_MEMORY_SPACE_P6CACHE) != 0)
{
DPRINT("VIDEO_MEMORY_SPACE_P6CACHE not supported, turning off\n");
InIoSpace &= ~VIDEO_MEMORY_SPACE_P6CACHE;
}
if (!IsListEmpty(&DeviceExtension->AddressMappingListHead))
{
Entry = DeviceExtension->AddressMappingListHead.Flink;
while (Entry != &DeviceExtension->AddressMappingListHead)
{
AddressMapping = CONTAINING_RECORD(
Entry,
VIDEO_PORT_ADDRESS_MAPPING,
List);
if (IoAddress.QuadPart == AddressMapping->IoAddress.QuadPart &&
NumberOfUchars <= AddressMapping->NumberOfUchars)
{
AddressMapping->MappingCount++;
if (Status)
*Status = NO_ERROR;
return AddressMapping->MappedAddress;
}
Entry = Entry->Flink;
}
}
AddressSpace = (ULONG)InIoSpace;
if (HalTranslateBusAddress(
DeviceExtension->AdapterInterfaceType,
DeviceExtension->SystemIoBusNumber,
IoAddress,
&AddressSpace,
&TranslatedAddress) == FALSE)
{
if (Status)
*Status = ERROR_NOT_ENOUGH_MEMORY;
return NULL;
}
/* I/O space */
if (AddressSpace != 0)
{
ASSERT(0 == TranslatedAddress.u.HighPart);
if (Status)
*Status = NO_ERROR;
return (PVOID)TranslatedAddress.u.LowPart;
}
MappedAddress = MmMapIoSpace(
TranslatedAddress,
NumberOfUchars,
FALSE);
if (MappedAddress)
{
if (Status)
{
*Status = NO_ERROR;
}
AddressMapping = ExAllocatePoolWithTag(
PagedPool,
sizeof(VIDEO_PORT_ADDRESS_MAPPING),
TAG_VIDEO_PORT);
if (AddressMapping == NULL)
return MappedAddress;
AddressMapping->MappedAddress = MappedAddress;
AddressMapping->NumberOfUchars = NumberOfUchars;
AddressMapping->IoAddress = IoAddress;
AddressMapping->SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
AddressMapping->MappingCount = 1;
InsertHeadList(
&DeviceExtension->AddressMappingListHead,
&AddressMapping->List);
return MappedAddress;
}
else
{
if (Status)
*Status = NO_ERROR;
return NULL;
}
}
VOID STDCALL
IntVideoPortUnmapMemory(
IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
IN PVOID MappedAddress)
{
PVIDEO_PORT_ADDRESS_MAPPING AddressMapping;
PLIST_ENTRY Entry;
Entry = DeviceExtension->AddressMappingListHead.Flink;
while (Entry != &DeviceExtension->AddressMappingListHead)
{
AddressMapping = CONTAINING_RECORD(
Entry,
VIDEO_PORT_ADDRESS_MAPPING,
List);
if (AddressMapping->MappedAddress == MappedAddress)
{
ASSERT(AddressMapping->MappingCount >= 0);
AddressMapping->MappingCount--;
if (AddressMapping->MappingCount == 0)
{
MmUnmapIoSpace(
AddressMapping->MappedAddress,
AddressMapping->NumberOfUchars);
RemoveEntryList(Entry);
ExFreePool(AddressMapping);
return;
}
}
Entry = Entry->Flink;
}
}
/* PUBLIC FUNCTIONS ***********************************************************/
/*
* @implemented
*/
PVOID STDCALL
VideoPortGetDeviceBase(
IN PVOID HwDeviceExtension,
IN PHYSICAL_ADDRESS IoAddress,
IN ULONG NumberOfUchars,
IN UCHAR InIoSpace)
{
DPRINT("VideoPortGetDeviceBase\n");
return IntVideoPortMapMemory(
VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
IoAddress,
NumberOfUchars,
InIoSpace,
NULL);
}
/*
* @implemented
*/
VOID STDCALL
VideoPortFreeDeviceBase(
IN PVOID HwDeviceExtension,
IN PVOID MappedAddress)
{
DPRINT("VideoPortFreeDeviceBase\n");
IntVideoPortUnmapMemory(
VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
MappedAddress);
}
/*
* @unimplemented
*/
VP_STATUS STDCALL
VideoPortMapBankedMemory(
IN PVOID HwDeviceExtension,
IN PHYSICAL_ADDRESS PhysicalAddress,
IN PULONG Length,
IN PULONG InIoSpace,
OUT PVOID *VirtualAddress,
IN ULONG BankLength,
IN UCHAR ReadWriteBank,
IN PBANKED_SECTION_ROUTINE BankRoutine,
IN PVOID Context)
{
DPRINT("VideoPortMapBankedMemory\n");
UNIMPLEMENTED;
return ERROR_CALL_NOT_IMPLEMENTED;
}
/*
* @implemented
*/
VP_STATUS STDCALL
VideoPortMapMemory(
IN PVOID HwDeviceExtension,
IN PHYSICAL_ADDRESS PhysicalAddress,
IN PULONG Length,
IN PULONG InIoSpace,
OUT PVOID *VirtualAddress)
{
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
DPRINT("VideoPortMapMemory\n");
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
*VirtualAddress = IntVideoPortMapMemory(
DeviceExtension,
PhysicalAddress,
*Length,
*InIoSpace,
&Status);
return Status;
}
/*
* @implemented
*/
VP_STATUS STDCALL
VideoPortUnmapMemory(
IN PVOID HwDeviceExtension,
IN PVOID VirtualAddress,
IN HANDLE ProcessHandle)
{
DPRINT("VideoPortFreeDeviceBase\n");
IntVideoPortUnmapMemory(
VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension),
VirtualAddress);
return NO_ERROR;
}
/*
* @implemented
*/
VP_STATUS STDCALL
VideoPortGetAccessRanges(
IN PVOID HwDeviceExtension,
IN ULONG NumRequestedResources,
IN PIO_RESOURCE_DESCRIPTOR RequestedResources OPTIONAL,
IN ULONG NumAccessRanges,
IN PVIDEO_ACCESS_RANGE AccessRanges,
IN PVOID VendorId,
IN PVOID DeviceId,
IN PULONG Slot)
{
PCI_SLOT_NUMBER PciSlotNumber;
ULONG FunctionNumber;
PCI_COMMON_CONFIG Config;
PCM_RESOURCE_LIST AllocatedResources;
NTSTATUS Status;
UINT AssignedCount;
CM_FULL_RESOURCE_DESCRIPTOR *FullList;
CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor;
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
USHORT VendorIdToFind;
USHORT DeviceIdToFind;
ULONG SlotIdToFind;
ULONG ReturnedLength;
DPRINT("VideoPortGetAccessRanges\n");
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
if (NumRequestedResources == 0 &&
DeviceExtension->AdapterInterfaceType == PCIBus)
{
if (DeviceExtension->PhysicalDeviceObject != NULL)
{
PciSlotNumber.u.AsULONG = DeviceExtension->SystemIoSlotNumber;
ReturnedLength = HalGetBusData(
PCIConfiguration,
DeviceExtension->SystemIoBusNumber,
PciSlotNumber.u.AsULONG,
&Config,
sizeof(PCI_COMMON_CONFIG));
if (ReturnedLength != sizeof(PCI_COMMON_CONFIG))
{
return ERROR_NO_SYSTEM_RESOURCES;
}
}
else
{
VendorIdToFind = VendorId != NULL ? *(PUSHORT)VendorId : 0;
DeviceIdToFind = DeviceId != NULL ? *(PUSHORT)DeviceId : 0;
SlotIdToFind = Slot != NULL ? *Slot : 0;
PciSlotNumber.u.AsULONG = SlotIdToFind;
DPRINT("Looking for VendorId 0x%04x DeviceId 0x%04x\n",
VendorIdToFind, DeviceIdToFind);
/*
* Search for the device id and vendor id on this bus.
*/
for (FunctionNumber = 0; FunctionNumber < 8; FunctionNumber++)
{
DPRINT("- Function number: %d\n", FunctionNumber);
PciSlotNumber.u.bits.FunctionNumber = FunctionNumber;
ReturnedLength = HalGetBusData(
PCIConfiguration,
DeviceExtension->SystemIoBusNumber,
PciSlotNumber.u.AsULONG,
&Config,
sizeof(PCI_COMMON_CONFIG));
DPRINT("- Length of data: %x\n", ReturnedLength);
if (ReturnedLength == sizeof(PCI_COMMON_CONFIG))
{
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))
{
break;
}
}
}
if (FunctionNumber == 8)
{
DPRINT("Didn't find device.\n");
return ERROR_NO_SYSTEM_RESOURCES;
}
}
Status = HalAssignSlotResources(
NULL, NULL, NULL, NULL,
DeviceExtension->AdapterInterfaceType,
DeviceExtension->SystemIoBusNumber,
PciSlotNumber.u.AsULONG,
&AllocatedResources);
if (!NT_SUCCESS(Status))
{
return Status;
}
AssignedCount = 0;
for (FullList = AllocatedResources->List;
FullList < AllocatedResources->List + AllocatedResources->Count;
FullList++)
{
ASSERT(FullList->InterfaceType == PCIBus &&
FullList->BusNumber == DeviceExtension->SystemIoBusNumber &&
1 == FullList->PartialResourceList.Version &&
1 == FullList->PartialResourceList.Revision);
for (Descriptor = FullList->PartialResourceList.PartialDescriptors;
Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
Descriptor++)
{
if ((Descriptor->Type == CmResourceTypeMemory ||
Descriptor->Type == CmResourceTypePort) &&
AssignedCount >= NumAccessRanges)
{
DPRINT1("Too many access ranges found\n");
ExFreePool(AllocatedResources);
return ERROR_NO_SYSTEM_RESOURCES;
}
if (Descriptor->Type == CmResourceTypeMemory)
{
if (NumAccessRanges <= AssignedCount)
{
DPRINT1("Too many access ranges found\n");
ExFreePool(AllocatedResources);
return ERROR_NO_SYSTEM_RESOURCES;
}
DPRINT("Memory range starting at 0x%08x length 0x%08x\n",
Descriptor->u.Memory.Start.u.LowPart, Descriptor->u.Memory.Length);
AccessRanges[AssignedCount].RangeStart = Descriptor->u.Memory.Start;
AccessRanges[AssignedCount].RangeLength = Descriptor->u.Memory.Length;
AccessRanges[AssignedCount].RangeInIoSpace = 0;
AccessRanges[AssignedCount].RangeVisible = 0; /* FIXME: Just guessing */
AccessRanges[AssignedCount].RangeShareable =
(Descriptor->ShareDisposition == CmResourceShareShared);
AssignedCount++;
}
else if (Descriptor->Type == CmResourceTypePort)
{
DPRINT("Port range starting at 0x%04x length %d\n",
Descriptor->u.Memory.Start.u.LowPart, Descriptor->u.Memory.Length);
AccessRanges[AssignedCount].RangeStart = Descriptor->u.Port.Start;
AccessRanges[AssignedCount].RangeLength = Descriptor->u.Port.Length;
AccessRanges[AssignedCount].RangeInIoSpace = 1;
AccessRanges[AssignedCount].RangeVisible = 0; /* FIXME: Just guessing */
AccessRanges[AssignedCount].RangeShareable = 0;
AssignedCount++;
}
else if (Descriptor->Type == CmResourceTypeInterrupt)
{
DeviceExtension->InterruptLevel = Descriptor->u.Interrupt.Level;
DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
}
}
}
ExFreePool(AllocatedResources);
}
else
{
UNIMPLEMENTED
}
return NO_ERROR;
}
/*
* @unimplemented
*/
VP_STATUS STDCALL
VideoPortVerifyAccessRanges(
IN PVOID HwDeviceExtension,
IN ULONG NumAccessRanges,
IN PVIDEO_ACCESS_RANGE AccessRanges)
{
DPRINT1("VideoPortVerifyAccessRanges not implemented\n");
return NO_ERROR;
}
/*
* @unimplemented
*/
VP_STATUS STDCALL
VideoPortGetDeviceData(
IN PVOID HwDeviceExtension,
IN VIDEO_DEVICE_DATA_TYPE DeviceDataType,
IN PMINIPORT_QUERY_DEVICE_ROUTINE CallbackRoutine,
IN PVOID Context)
{
DPRINT("VideoPortGetDeviceData\n");
UNIMPLEMENTED;
return ERROR_CALL_NOT_IMPLEMENTED;
}
/*
* @implemented
*/
PVOID STDCALL
VideoPortAllocatePool(
IN PVOID HwDeviceExtension,
IN VP_POOL_TYPE PoolType,
IN SIZE_T NumberOfBytes,
IN ULONG Tag)
{
DPRINT("VideoPortAllocatePool\n");
return ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag);
}
/*
* @implemented
*/
VOID STDCALL
VideoPortFreePool(
IN PVOID HwDeviceExtension,
IN PVOID Ptr)
{
ExFreePool(Ptr);
}
/*
* @implemented
*/
VP_STATUS STDCALL
VideoPortAllocateBuffer(
IN PVOID HwDeviceExtension,
IN ULONG Size,
OUT PVOID *Buffer)
{
DPRINT("VideoPortAllocateBuffer\n");
*Buffer = ExAllocatePool(PagedPool, Size);
return *Buffer == NULL ? ERROR_NOT_ENOUGH_MEMORY : NO_ERROR;
}
/*
* @implemented
*/
VOID STDCALL
VideoPortReleaseBuffer(
IN PVOID HwDeviceExtension,
IN PVOID Ptr)
{
DPRINT("VideoPortReleaseBuffer\n");
ExFreePool(Ptr);
}
/*
* @unimplemented
*/
PVOID STDCALL
VideoPortLockBuffer(
IN PVOID HwDeviceExtension,
IN PVOID BaseAddress,
IN ULONG Length,
IN VP_LOCK_OPERATION Operation)
{
DPRINT1("VideoPortLockBuffer: Unimplemented.\n");
return NULL;
}
/*
* @unimplemented
*/
VOID STDCALL
VideoPortUnlockBuffer(
IN PVOID HwDeviceExtension,
IN PVOID Mdl)
{
DPRINT1("VideoPortUnlockBuffer: Unimplemented.\n");
}
/*
* @unimplemented
*/
VP_STATUS STDCALL
VideoPortSetTrappedEmulatorPorts(
IN PVOID HwDeviceExtension,
IN ULONG NumAccessRanges,
IN PVIDEO_ACCESS_RANGE AccessRange)
{
DPRINT("VideoPortSetTrappedEmulatorPorts\n");
/* Should store the ranges in the device extension for use by ntvdm. */
return NO_ERROR;
}
/*
* @implemented
*/
ULONG STDCALL
VideoPortGetBusData(
IN PVOID HwDeviceExtension,
IN BUS_DATA_TYPE BusDataType,
IN ULONG SlotNumber,
OUT PVOID Buffer,
IN ULONG Offset,
IN ULONG Length)
{
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
DPRINT("VideoPortGetBusData\n");
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
if (BusDataType != Cmos)
{
/* Legacy vs. PnP behaviour */
if (DeviceExtension->PhysicalDeviceObject != NULL)
SlotNumber = DeviceExtension->SystemIoSlotNumber;
}
return HalGetBusDataByOffset(
BusDataType,
DeviceExtension->SystemIoBusNumber,
SlotNumber,
Buffer,
Offset,
Length);
}
/*
* @implemented
*/
ULONG STDCALL
VideoPortSetBusData(
IN PVOID HwDeviceExtension,
IN BUS_DATA_TYPE BusDataType,
IN ULONG SlotNumber,
IN PVOID Buffer,
IN ULONG Offset,
IN ULONG Length)
{
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
DPRINT("VideoPortSetBusData\n");
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
if (BusDataType != Cmos)
{
/* Legacy vs. PnP behaviour */
if (DeviceExtension->PhysicalDeviceObject != NULL)
SlotNumber = DeviceExtension->SystemIoSlotNumber;
}
return HalSetBusDataByOffset(
BusDataType,
DeviceExtension->SystemIoBusNumber,
SlotNumber,
Buffer,
Offset,
Length);
}

View file

@ -18,7 +18,7 @@
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id: services.c,v 1.2 2004/03/06 08:39:06 jimtabor Exp $
* $Id: services.c,v 1.3 2004/03/19 20:58:32 navaraf Exp $
*/
#include "videoprt.h"
@ -35,8 +35,7 @@ IntInterfaceDereference(PVOID Context)
/* Do nothing */
}
VP_STATUS
STDCALL
VP_STATUS STDCALL
VideoPortQueryServices(
IN PVOID HwDeviceExtension,
IN VIDEO_PORT_SERVICES ServicesType,
@ -58,32 +57,28 @@ VideoPortQueryServices(
Int10Interface->Int10ReadMemory = IntInt10ReadMemory;
Int10Interface->Int10WriteMemory = IntInt10WriteMemory;
Int10Interface->Int10CallBios = IntInt10CallBios;
return STATUS_SUCCESS;
return NO_ERROR;
}
break;
case VideoPortServicesAGP:
case VideoPortServicesI2C:
case VideoPortServicesHeadless:
return STATUS_NOT_IMPLEMENTED;
return ERROR_CALL_NOT_IMPLEMENTED;
default:
break;
}
return STATUS_UNSUCCESSFUL;
return ERROR_INVALID_FUNCTION;
}
BOOLEAN
STDCALL
VideoPortGetAgpServices(IN PVOID HwDeviceExtension,
IN PVIDEO_PORT_AGP_SERVICES AgpServices)
BOOLEAN STDCALL
VideoPortGetAgpServices(
IN PVOID HwDeviceExtension,
IN PVIDEO_PORT_AGP_SERVICES AgpServices)
{
DPRINT("VideoPortGetAgpServices\n");
UNIMPLEMENTED;
return FALSE;
DPRINT("VideoPortGetAgpServices\n");
UNIMPLEMENTED;
return FALSE;
}

View file

@ -18,7 +18,7 @@
* 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 $
* $Id: spinlock.c,v 1.2 2004/03/19 20:58:32 navaraf Exp $
*/
#include "videoprt.h"
@ -35,9 +35,9 @@ VideoPortCreateSpinLock(
DPRINT("VideoPortCreateSpinLock\n");
*SpinLock = ExAllocatePool(NonPagedPool, sizeof(KSPIN_LOCK));
if (*SpinLock == NULL)
return STATUS_UNSUCCESSFUL;
return ERROR_NOT_ENOUGH_MEMORY;
KeInitializeSpinLock((PKSPIN_LOCK)*SpinLock);
return STATUS_SUCCESS;
return NO_ERROR;
}
/*
@ -51,7 +51,7 @@ VideoPortDeleteSpinLock(
{
DPRINT("VideoPortDeleteSpinLock\n");
ExFreePool(SpinLock);
return STATUS_SUCCESS;
return NO_ERROR;
}
/*

View file

@ -0,0 +1,92 @@
/*
* 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: timer.c,v 1.2 2004/03/19 20:58:32 navaraf Exp $
*/
#include "videoprt.h"
/* PRIVATE FUNCTIONS **********************************************************/
VOID STDCALL
IntVideoPortTimerRoutine(
IN PDEVICE_OBJECT DeviceObject,
IN PVOID ServiceContext)
{
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = ServiceContext;
ASSERT(DeviceExtension->DriverExtension->InitializationData.HwTimer != NULL);
DeviceExtension->DriverExtension->InitializationData.HwTimer(
&DeviceExtension->MiniPortDeviceExtension);
}
BOOLEAN STDCALL
IntVideoPortSetupTimer(
IN PDEVICE_OBJECT DeviceObject,
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension)
{
NTSTATUS Status;
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
if (DriverExtension->InitializationData.HwTimer != NULL)
{
DPRINT("Initializing timer\n");
Status = IoInitializeTimer(
DeviceObject,
IntVideoPortTimerRoutine,
DeviceExtension);
if (!NT_SUCCESS(Status))
{
DPRINT("IoInitializeTimer failed with status 0x%08x\n", Status);
return FALSE;
}
}
return TRUE;
}
/* PUBLIC FUNCTIONS ***********************************************************/
/*
* @implemented
*/
VOID STDCALL
VideoPortStartTimer(IN PVOID HwDeviceExtension)
{
DPRINT("VideoPortStartTimer\n");
IoStartTimer(VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->FunctionalDeviceObject);
}
/*
* @implemented
*/
VOID STDCALL
VideoPortStopTimer(IN PVOID HwDeviceExtension)
{
DPRINT("VideoPortStopTimer\n");
IoStopTimer(VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->FunctionalDeviceObject);
}

File diff suppressed because it is too large Load diff

View file

@ -18,7 +18,7 @@
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id: videoprt.h,v 1.6 2004/03/09 18:56:32 navaraf Exp $
* $Id: videoprt.h,v 1.7 2004/03/19 20:58:32 navaraf Exp $
*/
#ifndef VIDEOPRT_H
@ -27,25 +27,19 @@
#include <ddk/miniport.h>
#include <ddk/video.h>
#include <ddk/ntddvdeo.h>
#include "internal/ps.h"
#define NDEBUG
#include <ddk/ntapi.h>
/* #define NDEBUG */
#include <debug.h>
/*
* FIXME: Definition missing from w32api!
*/
#ifndef SYNCH_LEVEL
#define SYNCH_LEVEL (IPI_LEVEL - 2)
#endif
VOID FASTCALL KfLowerIrql(IN KIRQL NewIrql);
#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
KIRQL FASTCALL KfRaiseIrql(IN KIRQL NewIrql);
NTKERNELAPI VOID HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
int swprintf(wchar_t *buf, const wchar_t *fmt, ...);
int vsprintf(char *buf, const char *fmt, va_list args);
BOOLEAN STDCALL HalDisableSystemInterrupt(ULONG Vector, ULONG Unknown2);
BOOLEAN STDCALL HalEnableSystemInterrupt(ULONG Vector, ULONG Unknown2, ULONG Unknown3);
PIMAGE_NT_HEADERS STDCALL RtlImageNtHeader(IN PVOID BaseAddress);
#define NtCurrentProcess() ((HANDLE)0xFFFFFFFF)
#define TAG_VIDEO_PORT TAG('V', 'I', 'D', 'P')
extern PEPROCESS Csrss;
typedef struct _VIDEO_PORT_ADDRESS_MAPPING
{
LIST_ENTRY List;
@ -56,46 +50,115 @@ typedef struct _VIDEO_PORT_ADDRESS_MAPPING
UINT MappingCount;
} VIDEO_PORT_ADDRESS_MAPPING, *PVIDEO_PORT_ADDRESS_MAPPING;
typedef struct _VIDEO_PORT_DRIVER_EXTENSION
{
VIDEO_HW_INITIALIZATION_DATA InitializationData;
PVOID HwContext;
UNICODE_STRING RegistryPath;
} VIDEO_PORT_DRIVER_EXTENSION, *PVIDEO_PORT_DRIVER_EXTENSION;
typedef struct _VIDEO_PORT_DEVICE_EXTENSTION
{
PDEVICE_OBJECT DeviceObject;
PDEVICE_OBJECT PhysicalDeviceObject;
PDEVICE_OBJECT FunctionalDeviceObject;
UNICODE_STRING RegistryPath;
PKINTERRUPT InterruptObject;
KSPIN_LOCK InterruptSpinLock;
ULONG InterruptVector;
ULONG InterruptLevel;
PVIDEO_HW_INITIALIZE HwInitialize;
PVIDEO_HW_RESET_HW HwResetHw;
PVIDEO_HW_TIMER HwTimer;
PVIDEO_HW_INTERRUPT HwInterrupt;
LIST_ENTRY AddressMappingListHead;
INTERFACE_TYPE AdapterInterfaceType;
ULONG AdapterInterfaceType;
ULONG SystemIoBusNumber;
UNICODE_STRING RegistryPath;
ULONG SystemIoSlotNumber;
LIST_ENTRY AddressMappingListHead;
KDPC DpcObject;
UCHAR MiniPortDeviceExtension[1]; /* must be the last entry */
VIDEO_PORT_DRIVER_EXTENSION *DriverExtension;
CHAR MiniPortDeviceExtension[1];
} VIDEO_PORT_DEVICE_EXTENSION, *PVIDEO_PORT_DEVICE_EXTENSION;
NTSTATUS STDCALL
VidDispatchOpen(IN PDEVICE_OBJECT pDO, IN PIRP Irp);
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension) \
CONTAINING_RECORD( \
HwDeviceExtension, \
VIDEO_PORT_DEVICE_EXTENSION, \
MiniPortDeviceExtension)
/* dispatch.c */
NTSTATUS STDCALL
VidDispatchClose(IN PDEVICE_OBJECT pDO, IN PIRP Irp);
IntVideoPortAddDevice(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject);
NTSTATUS STDCALL
VidDispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
IntVideoPortDispatchOpen(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
PVOID STDCALL
InternalMapMemory(
IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
IN PHYSICAL_ADDRESS IoAddress,
IN ULONG NumberOfUchars,
IN UCHAR InIoSpace,
OUT NTSTATUS *Status);
NTSTATUS STDCALL
IntVideoPortDispatchClose(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
NTSTATUS STDCALL
IntVideoPortDispatchCleanup(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
NTSTATUS STDCALL
IntVideoPortDispatchDeviceControl(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
NTSTATUS STDCALL
IntVideoPortDispatchPnp(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
NTSTATUS STDCALL
IntVideoPortDispatchPower(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
VOID STDCALL
InternalUnmapMemory(
IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension,
IN PVOID MappedAddress);
IntVideoPortUnload(PDRIVER_OBJECT DriverObject);
/* timer.c */
BOOLEAN STDCALL
IntVideoPortSetupTimer(
IN PDEVICE_OBJECT DeviceObject,
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension);
/* interrupt.c */
BOOLEAN STDCALL
IntVideoPortSetupInterrupt(
IN PDEVICE_OBJECT DeviceObject,
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
IN PVIDEO_PORT_CONFIG_INFO ConfigInfo);
/* videoprt.c */
extern ULONG CsrssInitialized;
extern PEPROCESS Csrss;
PVOID STDCALL
VideoPortGetProcAddress(
IN PVOID HwDeviceExtension,
IN PUCHAR FunctionName);
VOID FASTCALL
IntAttachToCSRSS(PEPROCESS *CallingProcess, PEPROCESS *PrevAttachedProcess);
VOID FASTCALL
IntDetachFromCSRSS(PEPROCESS *CallingProcess, PEPROCESS *PrevAttachedProcess);
NTSTATUS STDCALL
IntVideoPortFindAdapter(
IN PDRIVER_OBJECT DriverObject,
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
IN PDEVICE_OBJECT PhysicalDeviceObject);
/* int10.c */
VP_STATUS STDCALL
IntInt10AllocateBuffer(
@ -131,4 +194,9 @@ IntInt10CallBios(
IN PVOID Context,
IN OUT PINT10_BIOS_ARGUMENTS BiosArguments);
VP_STATUS STDCALL
VideoPortInt10(
IN PVOID HwDeviceExtension,
IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments);
#endif /* VIDEOPRT_H */

View file

@ -24,9 +24,9 @@ BEGIN
VALUE "CompanyName", RES_STR_COMPANY_NAME
VALUE "FileDescription", "Videoport Driver\0"
VALUE "FileVersion", "0.0.0\0"
VALUE "InternalName", "vidport\0"
VALUE "InternalName", "videoprt\0"
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
VALUE "OriginalFilename", "vidport.sys\0"
VALUE "OriginalFilename", "videoprt.sys\0"
VALUE "ProductName", RES_STR_PRODUCT_NAME
VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
END