[VIDEOPRT] Implement support for INT10 on x64 using the newly implemented HAL functions.

This commit is contained in:
Timo Kreuzer 2018-02-11 19:22:30 +01:00
parent eba27d5856
commit 826704ba6b
3 changed files with 43 additions and 17 deletions

View file

@ -103,6 +103,7 @@ IntVideoPortDispatchOpen(
{ {
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension; PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension; PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
NTSTATUS Status;
TRACE_(VIDEOPRT, "IntVideoPortDispatchOpen\n"); TRACE_(VIDEOPRT, "IntVideoPortDispatchOpen\n");
@ -117,7 +118,12 @@ IntVideoPortDispatchOpen(
Csrss = (PKPROCESS)PsGetCurrentProcess(); Csrss = (PKPROCESS)PsGetCurrentProcess();
INFO_(VIDEOPRT, "Csrss %p\n", Csrss); INFO_(VIDEOPRT, "Csrss %p\n", Csrss);
IntInitializeVideoAddressSpace(); Status = IntInitializeVideoAddressSpace();
if (!NT_SUCCESS(Status))
{
ERR_(VIDEOPRT, "IntInitializeVideoAddressSpace() failed: 0x%lx\n", Status);
return Status;
}
CsrssInitialized = TRUE; CsrssInitialized = TRUE;
} }

View file

@ -22,6 +22,7 @@
#include "videoprt.h" #include "videoprt.h"
#include <ndk/kefuncs.h> #include <ndk/kefuncs.h>
#include <ndk/halfuncs.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -158,8 +159,9 @@ IntInt10AllocateBuffer(
OUT PUSHORT Off, OUT PUSHORT Off,
IN OUT PULONG Length) IN OUT PULONG Length)
{ {
PVOID MemoryAddress;
NTSTATUS Status; NTSTATUS Status;
#ifdef _M_IX86
PVOID MemoryAddress;
PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess(); PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
KAPC_STATE ApcState; KAPC_STATE ApcState;
SIZE_T Size; SIZE_T Size;
@ -205,6 +207,10 @@ IntInt10AllocateBuffer(
IntDetachFromCSRSS(&CallingProcess, &ApcState); IntDetachFromCSRSS(&CallingProcess, &ApcState);
return NO_ERROR; return NO_ERROR;
#else
Status = x86BiosAllocateBuffer(Length, Seg, Off);
return NT_SUCCESS(Status) ? NO_ERROR : ERROR_NOT_ENOUGH_MEMORY;
#endif
} }
VP_STATUS VP_STATUS
@ -214,8 +220,9 @@ IntInt10FreeBuffer(
IN USHORT Seg, IN USHORT Seg,
IN USHORT Off) IN USHORT Off)
{ {
PVOID MemoryAddress = (PVOID)((ULONG_PTR)(Seg << 4) | Off);
NTSTATUS Status; NTSTATUS Status;
#ifdef _M_IX86
PVOID MemoryAddress = (PVOID)((ULONG_PTR)(Seg << 4) | Off);
PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess(); PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
KAPC_STATE ApcState; KAPC_STATE ApcState;
SIZE_T Size = 0; SIZE_T Size = 0;
@ -233,6 +240,10 @@ IntInt10FreeBuffer(
IntDetachFromCSRSS(&CallingProcess, &ApcState); IntDetachFromCSRSS(&CallingProcess, &ApcState);
return Status; return Status;
#else
Status = x86BiosFreeBuffer(Seg, Off);
return NT_SUCCESS(Status) ? NO_ERROR : ERROR_INVALID_PARAMETER;
#endif
} }
VP_STATUS VP_STATUS
@ -244,6 +255,7 @@ IntInt10ReadMemory(
OUT PVOID Buffer, OUT PVOID Buffer,
IN ULONG Length) IN ULONG Length)
{ {
#ifdef _M_IX86
PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess(); PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
KAPC_STATE ApcState; KAPC_STATE ApcState;
@ -258,6 +270,12 @@ IntInt10ReadMemory(
IntDetachFromCSRSS(&CallingProcess, &ApcState); IntDetachFromCSRSS(&CallingProcess, &ApcState);
return NO_ERROR; return NO_ERROR;
#else
NTSTATUS Status;
Status = x86BiosReadMemory(Seg, Off, Buffer, Length);
return NT_SUCCESS(Status) ? NO_ERROR : ERROR_INVALID_PARAMETER;
#endif
} }
VP_STATUS VP_STATUS
@ -269,6 +287,7 @@ IntInt10WriteMemory(
IN PVOID Buffer, IN PVOID Buffer,
IN ULONG Length) IN ULONG Length)
{ {
#ifdef _M_IX86
PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess(); PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
KAPC_STATE ApcState; KAPC_STATE ApcState;
@ -283,16 +302,25 @@ IntInt10WriteMemory(
IntDetachFromCSRSS(&CallingProcess, &ApcState); IntDetachFromCSRSS(&CallingProcess, &ApcState);
return NO_ERROR; return NO_ERROR;
#else
NTSTATUS Status;
Status = x86BiosWriteMemory(Seg, Off, Buffer, Length);
return NT_SUCCESS(Status) ? NO_ERROR : ERROR_INVALID_PARAMETER;
#endif
} }
#if defined(_M_IX86)
VP_STATUS VP_STATUS
NTAPI NTAPI
IntInt10CallBios( IntInt10CallBios(
IN PVOID Context, IN PVOID Context,
IN OUT PINT10_BIOS_ARGUMENTS BiosArguments) IN OUT PINT10_BIOS_ARGUMENTS BiosArguments)
{ {
#ifdef _M_AMD64
X86_BIOS_REGISTERS BiosContext;
#else
CONTEXT BiosContext; CONTEXT BiosContext;
#endif
NTSTATUS Status; NTSTATUS Status;
PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess(); PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
KAPC_STATE ApcState; KAPC_STATE ApcState;
@ -321,7 +349,11 @@ IntInt10CallBios(
FALSE, FALSE,
NULL); NULL);
#ifdef _M_AMD64
Status = x86BiosCall(0x10, &BiosContext) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
#else
Status = Ke386CallBios(0x10, &BiosContext); Status = Ke386CallBios(0x10, &BiosContext);
#endif
KeReleaseMutex(&VideoPortInt10Mutex, FALSE); KeReleaseMutex(&VideoPortInt10Mutex, FALSE);
@ -346,17 +378,6 @@ IntInt10CallBios(
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
} }
#else
VP_STATUS
NTAPI
IntInt10CallBios(
IN PVOID Context,
IN OUT PINT10_BIOS_ARGUMENTS BiosArguments)
{
DPRINT1("Int10 not available on non-x86!\n");
return ERROR_INVALID_FUNCTION;
}
#endif
/* PUBLIC FUNCTIONS ***********************************************************/ /* PUBLIC FUNCTIONS ***********************************************************/

View file

@ -46,7 +46,6 @@ VideoPortQueryServices(
switch (ServicesType) switch (ServicesType)
{ {
#if defined(_M_IX86)
case VideoPortServicesInt10: case VideoPortServicesInt10:
if (Interface->Version >= VIDEO_PORT_INT10_INTERFACE_VERSION_1 || if (Interface->Version >= VIDEO_PORT_INT10_INTERFACE_VERSION_1 ||
Interface->Size >= sizeof(VIDEO_PORT_INT10_INTERFACE)) Interface->Size >= sizeof(VIDEO_PORT_INT10_INTERFACE))
@ -64,7 +63,7 @@ VideoPortQueryServices(
return NO_ERROR; return NO_ERROR;
} }
break; break;
#endif
case VideoPortServicesAGP: case VideoPortServicesAGP:
if ((Interface->Version == VIDEO_PORT_AGP_INTERFACE_VERSION_2 && if ((Interface->Version == VIDEO_PORT_AGP_INTERFACE_VERSION_2 &&
Interface->Size >= sizeof(VIDEO_PORT_AGP_INTERFACE_2)) || Interface->Size >= sizeof(VIDEO_PORT_AGP_INTERFACE_2)) ||