mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
- Create a VdmpInitialize function for NtVdmControl's initialize command.
- Remove NtEarlyVdmInitialize hack and csrss IVT/BDA copying hack, instead, copy the first page of physical memory to the beginning of process's virtual address space like NT does. svn path=/trunk/; revision=36459
This commit is contained in:
parent
200665fb89
commit
f05e50b409
5 changed files with 87 additions and 31 deletions
|
@ -68,8 +68,6 @@ KiGetFeatureBits(VOID);
|
||||||
ULONG KeAllocateGdtSelector(ULONG Desc[2]);
|
ULONG KeAllocateGdtSelector(ULONG Desc[2]);
|
||||||
VOID KeFreeGdtSelector(ULONG Entry);
|
VOID KeFreeGdtSelector(ULONG Entry);
|
||||||
VOID
|
VOID
|
||||||
NtEarlyInitVdm(VOID);
|
|
||||||
VOID
|
|
||||||
KeApplicationProcessorInitDispatcher(VOID);
|
KeApplicationProcessorInitDispatcher(VOID);
|
||||||
VOID
|
VOID
|
||||||
KeCreateApplicationProcessorIdleThread(ULONG Id);
|
KeCreateApplicationProcessorIdleThread(ULONG Id);
|
||||||
|
|
|
@ -54,8 +54,6 @@ VOID
|
||||||
KiPPCSetProcessorFeatures(VOID);
|
KiPPCSetProcessorFeatures(VOID);
|
||||||
ULONG KeAllocateGdtSelector(ULONG Desc[2]);
|
ULONG KeAllocateGdtSelector(ULONG Desc[2]);
|
||||||
VOID KeFreeGdtSelector(ULONG Entry);
|
VOID KeFreeGdtSelector(ULONG Entry);
|
||||||
VOID
|
|
||||||
NtEarlyInitVdm(VOID);
|
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
#define LOCK "isync ; "
|
#define LOCK "isync ; "
|
||||||
|
|
|
@ -1332,11 +1332,6 @@ KiRosPrepareForSystemStartup(IN ULONG Dummy,
|
||||||
LoaderBlock->MmapAddr = (ULONG)KeMemoryMap;
|
LoaderBlock->MmapAddr = (ULONG)KeMemoryMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_M_IX86)
|
|
||||||
/* Set up the VDM Data */
|
|
||||||
NtEarlyInitVdm();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Convert the loader block */
|
/* Convert the loader block */
|
||||||
KiRosFrldrLpbToNtLpb(KeRosLoaderBlock, &NtLoaderBlock);
|
KiRosFrldrLpbToNtLpb(KeRosLoaderBlock, &NtLoaderBlock);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* FILE: ntoskrnl/vdm/vdmmain.c
|
* FILE: ntoskrnl/vdm/vdmmain.c
|
||||||
* PURPOSE: VDM Support Services
|
* PURPOSE: VDM Support Services
|
||||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||||
|
* Aleksey Bragin (aleksey@reactos.org)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
@ -14,21 +15,9 @@
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
static UCHAR OrigIVT[1024];
|
|
||||||
static UCHAR OrigBDA[256];
|
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS *********************************************************/
|
/* PRIVATE FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
VOID
|
|
||||||
INIT_FUNCTION
|
|
||||||
NtEarlyInitVdm(VOID)
|
|
||||||
{
|
|
||||||
PCHAR start = MmCreateHyperspaceMapping(0);
|
|
||||||
memcpy(OrigIVT, start, 1024);
|
|
||||||
memcpy(OrigBDA, start+0x400, 256);
|
|
||||||
MmDeleteHyperspaceMapping(start);
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
Ki386VdmEnablePentiumExtentions(VOID)
|
Ki386VdmEnablePentiumExtentions(VOID)
|
||||||
|
@ -82,6 +71,90 @@ KeI386VdmInitialize(VOID)
|
||||||
ZwClose(RegHandle);
|
ZwClose(RegHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
VdmpInitialize(PVOID ControlData)
|
||||||
|
{
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
UNICODE_STRING PhysMemName = RTL_CONSTANT_STRING(L"\\Device\\PhysicalMemory");
|
||||||
|
NTSTATUS Status;
|
||||||
|
HANDLE PhysMemHandle;
|
||||||
|
PVOID BaseAddress;
|
||||||
|
PVOID NullAddress = NULL;
|
||||||
|
LARGE_INTEGER Offset;
|
||||||
|
ULONG ViewSize;
|
||||||
|
|
||||||
|
/* Open the physical memory section */
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&PhysMemName,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
Status = ZwOpenSection(&PhysMemHandle,
|
||||||
|
SECTION_ALL_ACCESS,
|
||||||
|
&ObjectAttributes);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("Couldn't open \\Device\\PhysicalMemory\n");
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Map the BIOS and device registers into the address space */
|
||||||
|
Offset.QuadPart = 0;
|
||||||
|
ViewSize = PAGE_SIZE;
|
||||||
|
BaseAddress = 0;
|
||||||
|
Status = ZwMapViewOfSection(PhysMemHandle,
|
||||||
|
NtCurrentProcess(),
|
||||||
|
&BaseAddress,
|
||||||
|
0,
|
||||||
|
ViewSize,
|
||||||
|
&Offset,
|
||||||
|
&ViewSize,
|
||||||
|
ViewUnmap,
|
||||||
|
0,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("Couldn't map physical memory (%x)\n", Status);
|
||||||
|
ZwClose(PhysMemHandle);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now, copy the first physical pagee into the first virtual page */
|
||||||
|
_SEH_TRY
|
||||||
|
{
|
||||||
|
RtlMoveMemory(NullAddress, BaseAddress, ViewSize);
|
||||||
|
}
|
||||||
|
_SEH_HANDLE
|
||||||
|
{
|
||||||
|
/* Get the status */
|
||||||
|
Status = _SEH_GetExceptionCode();
|
||||||
|
}
|
||||||
|
_SEH_END;
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("Couldn't copy first page (%x)\n", Status);
|
||||||
|
ZwClose(PhysMemHandle);
|
||||||
|
ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close physical memory section handle */
|
||||||
|
ZwClose(PhysMemHandle);
|
||||||
|
|
||||||
|
/* Unmap the section */
|
||||||
|
Status = ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("Couldn't unmap the section (%x)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS **********************************************************/
|
/* PUBLIC FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -107,10 +180,8 @@ NtVdmControl(IN ULONG ControlCode,
|
||||||
|
|
||||||
case VdmInitialize:
|
case VdmInitialize:
|
||||||
|
|
||||||
/* Pretty much a hack, since a lot more needs to happen */
|
/* Call the init sub-function */
|
||||||
memcpy(ControlData, OrigIVT, 1024);
|
Status = VdmpInitialize(ControlData);
|
||||||
memcpy((PVOID)((ULONG_PTR)ControlData + 1024), OrigBDA, 256);
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -23,7 +23,6 @@ InitializeVideoAddressSpace(VOID)
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
HANDLE PhysMemHandle;
|
HANDLE PhysMemHandle;
|
||||||
PVOID BaseAddress;
|
PVOID BaseAddress;
|
||||||
PVOID NullAddress;
|
|
||||||
LARGE_INTEGER Offset;
|
LARGE_INTEGER Offset;
|
||||||
ULONG ViewSize;
|
ULONG ViewSize;
|
||||||
CHAR IVTAndBda[1024+256];
|
CHAR IVTAndBda[1024+256];
|
||||||
|
@ -105,11 +104,6 @@ InitializeVideoAddressSpace(VOID)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy the IVT and BDA into the right place */
|
|
||||||
NullAddress = (PVOID)0x0; /* Workaround for GCC 3.4 */
|
|
||||||
memcpy(NullAddress, IVTAndBda, 1024);
|
|
||||||
memcpy((PVOID)0x400, &IVTAndBda[1024], 256);
|
|
||||||
|
|
||||||
/* Return success */
|
/* Return success */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue