mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 12:29:56 +00:00
[VIDEOPRT] [FORMATTING] No code change
This commit is contained in:
parent
9ab3246d43
commit
e7b3c66a42
1 changed files with 126 additions and 95 deletions
|
@ -41,7 +41,7 @@ IntInitializeVideoAddressSpace(VOID)
|
||||||
LARGE_INTEGER Offset;
|
LARGE_INTEGER Offset;
|
||||||
SIZE_T ViewSize;
|
SIZE_T ViewSize;
|
||||||
#ifdef _M_IX86
|
#ifdef _M_IX86
|
||||||
CHAR IVTAndBda[1024+256];
|
CHAR IVTAndBda[1024 + 256];
|
||||||
#endif // _M_IX86
|
#endif // _M_IX86
|
||||||
|
|
||||||
/* Free the 1MB pre-reserved region. In reality, ReactOS should simply support us mapping the view into the reserved area, but it doesn't. */
|
/* Free the 1MB pre-reserved region. In reality, ReactOS should simply support us mapping the view into the reserved area, but it doesn't. */
|
||||||
|
@ -151,124 +151,134 @@ IntInitializeVideoAddressSpace(VOID)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_M_IX86)
|
#if defined(_M_IX86)
|
||||||
VP_STATUS NTAPI
|
VP_STATUS
|
||||||
|
NTAPI
|
||||||
IntInt10AllocateBuffer(
|
IntInt10AllocateBuffer(
|
||||||
IN PVOID Context,
|
IN PVOID Context,
|
||||||
OUT PUSHORT Seg,
|
OUT PUSHORT Seg,
|
||||||
OUT PUSHORT Off,
|
OUT PUSHORT Off,
|
||||||
IN OUT PULONG Length)
|
IN OUT PULONG Length)
|
||||||
{
|
{
|
||||||
PVOID MemoryAddress;
|
PVOID MemoryAddress;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
|
PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
|
||||||
KAPC_STATE ApcState;
|
KAPC_STATE ApcState;
|
||||||
|
|
||||||
TRACE_(VIDEOPRT, "IntInt10AllocateBuffer\n");
|
TRACE_(VIDEOPRT, "IntInt10AllocateBuffer\n");
|
||||||
|
|
||||||
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
MemoryAddress = (PVOID)0x20000;
|
MemoryAddress = (PVOID)0x20000;
|
||||||
Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &MemoryAddress, 0,
|
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
||||||
Length, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
&MemoryAddress,
|
||||||
|
0,
|
||||||
|
Length,
|
||||||
|
MEM_COMMIT,
|
||||||
|
PAGE_EXECUTE_READWRITE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
WARN_(VIDEOPRT, "- ZwAllocateVirtualMemory failed\n");
|
||||||
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
|
return ERROR_NOT_ENOUGH_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (MemoryAddress > (PVOID)(0x100000 - *Length))
|
||||||
{
|
{
|
||||||
WARN_(VIDEOPRT, "- ZwAllocateVirtualMemory failed\n");
|
ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, Length,
|
||||||
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
MEM_RELEASE);
|
||||||
return ERROR_NOT_ENOUGH_MEMORY;
|
WARN_(VIDEOPRT, "- Unacceptable memory allocated\n");
|
||||||
}
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
|
return ERROR_NOT_ENOUGH_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
if (MemoryAddress > (PVOID)(0x100000 - *Length))
|
*Seg = (USHORT)((ULONG)MemoryAddress >> 4);
|
||||||
{
|
*Off = (USHORT)((ULONG)MemoryAddress & 0xF);
|
||||||
ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, Length,
|
|
||||||
MEM_RELEASE);
|
|
||||||
WARN_(VIDEOPRT, "- Unacceptable memory allocated\n");
|
|
||||||
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
|
||||||
return ERROR_NOT_ENOUGH_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
*Seg = (USHORT)((ULONG)MemoryAddress >> 4);
|
INFO_(VIDEOPRT, "- Segment: %x\n", (ULONG)MemoryAddress >> 4);
|
||||||
*Off = (USHORT)((ULONG)MemoryAddress & 0xF);
|
INFO_(VIDEOPRT, "- Offset: %x\n", (ULONG)MemoryAddress & 0xF);
|
||||||
|
INFO_(VIDEOPRT, "- Length: %x\n", *Length);
|
||||||
|
|
||||||
INFO_(VIDEOPRT, "- Segment: %x\n", (ULONG)MemoryAddress >> 4);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
INFO_(VIDEOPRT, "- Offset: %x\n", (ULONG)MemoryAddress & 0xF);
|
|
||||||
INFO_(VIDEOPRT, "- Length: %x\n", *Length);
|
|
||||||
|
|
||||||
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
return NO_ERROR;
|
||||||
|
|
||||||
return NO_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VP_STATUS NTAPI
|
VP_STATUS
|
||||||
|
NTAPI
|
||||||
IntInt10FreeBuffer(
|
IntInt10FreeBuffer(
|
||||||
IN PVOID Context,
|
IN PVOID Context,
|
||||||
IN USHORT Seg,
|
IN USHORT Seg,
|
||||||
IN USHORT Off)
|
IN USHORT Off)
|
||||||
{
|
{
|
||||||
PVOID MemoryAddress = (PVOID)((Seg << 4) | Off);
|
PVOID MemoryAddress = (PVOID)((Seg << 4) | Off);
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
|
PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
|
||||||
KAPC_STATE ApcState;
|
KAPC_STATE ApcState;
|
||||||
SIZE_T Size = 0;
|
SIZE_T Size = 0;
|
||||||
|
|
||||||
TRACE_(VIDEOPRT, "IntInt10FreeBuffer\n");
|
TRACE_(VIDEOPRT, "IntInt10FreeBuffer\n");
|
||||||
INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
|
INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
|
||||||
INFO_(VIDEOPRT, "- Offset: %x\n", Off);
|
INFO_(VIDEOPRT, "- Offset: %x\n", Off);
|
||||||
|
|
||||||
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
||||||
Status = ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, &Size,
|
Status = ZwFreeVirtualMemory(NtCurrentProcess(),
|
||||||
MEM_RELEASE);
|
&MemoryAddress,
|
||||||
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
&Size,
|
||||||
|
MEM_RELEASE);
|
||||||
|
|
||||||
return Status;
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
VP_STATUS NTAPI
|
VP_STATUS
|
||||||
|
NTAPI
|
||||||
IntInt10ReadMemory(
|
IntInt10ReadMemory(
|
||||||
IN PVOID Context,
|
IN PVOID Context,
|
||||||
IN USHORT Seg,
|
IN USHORT Seg,
|
||||||
IN USHORT Off,
|
IN USHORT Off,
|
||||||
OUT PVOID Buffer,
|
OUT PVOID Buffer,
|
||||||
IN ULONG Length)
|
IN ULONG Length)
|
||||||
{
|
{
|
||||||
PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
|
PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
|
||||||
KAPC_STATE ApcState;
|
KAPC_STATE ApcState;
|
||||||
|
|
||||||
TRACE_(VIDEOPRT, "IntInt10ReadMemory\n");
|
TRACE_(VIDEOPRT, "IntInt10ReadMemory\n");
|
||||||
INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
|
INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
|
||||||
INFO_(VIDEOPRT, "- Offset: %x\n", Off);
|
INFO_(VIDEOPRT, "- Offset: %x\n", Off);
|
||||||
INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer);
|
INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer);
|
||||||
INFO_(VIDEOPRT, "- Length: %x\n", Length);
|
INFO_(VIDEOPRT, "- Length: %x\n", Length);
|
||||||
|
|
||||||
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
||||||
RtlCopyMemory(Buffer, (PVOID)((Seg << 4) | Off), Length);
|
RtlCopyMemory(Buffer, (PVOID)((Seg << 4) | Off), Length);
|
||||||
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
VP_STATUS NTAPI
|
VP_STATUS
|
||||||
|
NTAPI
|
||||||
IntInt10WriteMemory(
|
IntInt10WriteMemory(
|
||||||
IN PVOID Context,
|
IN PVOID Context,
|
||||||
IN USHORT Seg,
|
IN USHORT Seg,
|
||||||
IN USHORT Off,
|
IN USHORT Off,
|
||||||
IN PVOID Buffer,
|
IN PVOID Buffer,
|
||||||
IN ULONG Length)
|
IN ULONG Length)
|
||||||
{
|
{
|
||||||
PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
|
PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
|
||||||
KAPC_STATE ApcState;
|
KAPC_STATE ApcState;
|
||||||
|
|
||||||
TRACE_(VIDEOPRT, "IntInt10WriteMemory\n");
|
TRACE_(VIDEOPRT, "IntInt10WriteMemory\n");
|
||||||
INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
|
INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
|
||||||
INFO_(VIDEOPRT, "- Offset: %x\n", Off);
|
INFO_(VIDEOPRT, "- Offset: %x\n", Off);
|
||||||
INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer);
|
INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer);
|
||||||
INFO_(VIDEOPRT, "- Length: %x\n", Length);
|
INFO_(VIDEOPRT, "- Length: %x\n", Length);
|
||||||
|
|
||||||
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
||||||
RtlCopyMemory((PVOID)((Seg << 4) | Off), Buffer, Length);
|
RtlCopyMemory((PVOID)((Seg << 4) | Off), Buffer, Length);
|
||||||
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
VP_STATUS
|
VP_STATUS
|
||||||
|
@ -286,7 +296,7 @@ IntInt10CallBios(
|
||||||
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
/* Clear the context */
|
/* Clear the context */
|
||||||
RtlZeroMemory(&BiosContext, sizeof(CONTEXT));
|
RtlZeroMemory(&BiosContext, sizeof(BiosContext));
|
||||||
|
|
||||||
/* Fill out the bios arguments */
|
/* Fill out the bios arguments */
|
||||||
BiosContext.Eax = BiosArguments->Eax;
|
BiosContext.Eax = BiosArguments->Eax;
|
||||||
|
@ -300,8 +310,14 @@ IntInt10CallBios(
|
||||||
BiosContext.SegEs = BiosArguments->SegEs;
|
BiosContext.SegEs = BiosArguments->SegEs;
|
||||||
|
|
||||||
/* Do the ROM BIOS call */
|
/* Do the ROM BIOS call */
|
||||||
(void)KeWaitForMutexObject(&VideoPortInt10Mutex, Executive, KernelMode, FALSE, NULL);
|
(void)KeWaitForMutexObject(&VideoPortInt10Mutex,
|
||||||
|
Executive,
|
||||||
|
KernelMode,
|
||||||
|
FALSE,
|
||||||
|
NULL);
|
||||||
|
|
||||||
Status = Ke386CallBios(0x10, &BiosContext);
|
Status = Ke386CallBios(0x10, &BiosContext);
|
||||||
|
|
||||||
KeReleaseMutex(&VideoPortInt10Mutex, FALSE);
|
KeReleaseMutex(&VideoPortInt10Mutex, FALSE);
|
||||||
|
|
||||||
/* Return the arguments */
|
/* Return the arguments */
|
||||||
|
@ -317,7 +333,12 @@ IntInt10CallBios(
|
||||||
|
|
||||||
/* Detach and return status */
|
/* Detach and return status */
|
||||||
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
if (NT_SUCCESS(Status)) return NO_ERROR;
|
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
return ERROR_INVALID_PARAMETER;
|
return ERROR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -328,7 +349,8 @@ IntInt10CallBios(
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VP_STATUS NTAPI
|
VP_STATUS
|
||||||
|
NTAPI
|
||||||
VideoPortInt10(
|
VideoPortInt10(
|
||||||
IN PVOID HwDeviceExtension,
|
IN PVOID HwDeviceExtension,
|
||||||
IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments)
|
IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments)
|
||||||
|
@ -341,7 +363,7 @@ VideoPortInt10(
|
||||||
|
|
||||||
if (!CsrssInitialized)
|
if (!CsrssInitialized)
|
||||||
{
|
{
|
||||||
return ERROR_INVALID_PARAMETER;
|
return ERROR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attach to CSRSS */
|
/* Attach to CSRSS */
|
||||||
|
@ -360,7 +382,11 @@ VideoPortInt10(
|
||||||
BiosContext.Ebp = BiosArguments->Ebp;
|
BiosContext.Ebp = BiosArguments->Ebp;
|
||||||
|
|
||||||
/* Do the ROM BIOS call */
|
/* Do the ROM BIOS call */
|
||||||
(void)KeWaitForMutexObject(&VideoPortInt10Mutex, Executive, KernelMode, FALSE, NULL);
|
(void)KeWaitForMutexObject(&VideoPortInt10Mutex,
|
||||||
|
Executive,
|
||||||
|
KernelMode,
|
||||||
|
FALSE,
|
||||||
|
NULL);
|
||||||
Status = Ke386CallBios(0x10, &BiosContext);
|
Status = Ke386CallBios(0x10, &BiosContext);
|
||||||
KeReleaseMutex(&VideoPortInt10Mutex, FALSE);
|
KeReleaseMutex(&VideoPortInt10Mutex, FALSE);
|
||||||
|
|
||||||
|
@ -375,7 +401,12 @@ VideoPortInt10(
|
||||||
|
|
||||||
/* Detach from CSRSS */
|
/* Detach from CSRSS */
|
||||||
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
if (NT_SUCCESS(Status)) return NO_ERROR;
|
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
return ERROR_INVALID_PARAMETER;
|
return ERROR_INVALID_PARAMETER;
|
||||||
#else
|
#else
|
||||||
/* Not implemented for anything else than X86*/
|
/* Not implemented for anything else than X86*/
|
||||||
|
|
Loading…
Reference in a new issue