Author: fireball Date: Wed Sep 24 05:06:08 2008 New Revision: 36459
URL: http://svn.reactos.org/svn/reactos?rev=36459&view=rev Log: - 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.
Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h trunk/reactos/ntoskrnl/include/internal/powerpc/ke.h trunk/reactos/ntoskrnl/ke/freeldr.c trunk/reactos/ntoskrnl/vdm/vdmmain.c trunk/reactos/subsystems/win32/csrss/video.c
Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/i... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] Wed Sep 24 05:06:08 2008 @@ -68,8 +68,6 @@ ULONG KeAllocateGdtSelector(ULONG Desc[2]); VOID KeFreeGdtSelector(ULONG Entry); VOID -NtEarlyInitVdm(VOID); -VOID KeApplicationProcessorInitDispatcher(VOID); VOID KeCreateApplicationProcessorIdleThread(ULONG Id);
Modified: trunk/reactos/ntoskrnl/include/internal/powerpc/ke.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/p... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/powerpc/ke.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/powerpc/ke.h [iso-8859-1] Wed Sep 24 05:06:08 2008 @@ -54,8 +54,6 @@ KiPPCSetProcessorFeatures(VOID); ULONG KeAllocateGdtSelector(ULONG Desc[2]); VOID KeFreeGdtSelector(ULONG Entry); -VOID -NtEarlyInitVdm(VOID);
#ifdef CONFIG_SMP #define LOCK "isync ; "
Modified: trunk/reactos/ntoskrnl/ke/freeldr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/freeldr.c?rev=3... ============================================================================== --- trunk/reactos/ntoskrnl/ke/freeldr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/freeldr.c [iso-8859-1] Wed Sep 24 05:06:08 2008 @@ -1332,11 +1332,6 @@ LoaderBlock->MmapAddr = (ULONG)KeMemoryMap; }
-#if defined(_M_IX86) - /* Set up the VDM Data */ - NtEarlyInitVdm(); -#endif - /* Convert the loader block */ KiRosFrldrLpbToNtLpb(KeRosLoaderBlock, &NtLoaderBlock);
Modified: trunk/reactos/ntoskrnl/vdm/vdmmain.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/vdm/vdmmain.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/vdm/vdmmain.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/vdm/vdmmain.c [iso-8859-1] Wed Sep 24 05:06:08 2008 @@ -4,6 +4,7 @@ * FILE: ntoskrnl/vdm/vdmmain.c * PURPOSE: VDM Support Services * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) + * Aleksey Bragin (aleksey@reactos.org) */
/* INCLUDES ******************************************************************/ @@ -14,20 +15,8 @@
/* GLOBALS *******************************************************************/
-static UCHAR OrigIVT[1024]; -static UCHAR OrigBDA[256];
/* PRIVATE FUNCTIONS *********************************************************/ - -VOID -INIT_FUNCTION -NtEarlyInitVdm(VOID) -{ - PCHAR start = MmCreateHyperspaceMapping(0); - memcpy(OrigIVT, start, 1024); - memcpy(OrigBDA, start+0x400, 256); - MmDeleteHyperspaceMapping(start); -}
VOID NTAPI @@ -82,6 +71,90 @@ 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 **********************************************************/
/* @@ -107,10 +180,8 @@
case VdmInitialize:
- /* Pretty much a hack, since a lot more needs to happen */ - memcpy(ControlData, OrigIVT, 1024); - memcpy((PVOID)((ULONG_PTR)ControlData + 1024), OrigBDA, 256); - Status = STATUS_SUCCESS; + /* Call the init sub-function */ + Status = VdmpInitialize(ControlData); break;
default:
Modified: trunk/reactos/subsystems/win32/csrss/video.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/vide... ============================================================================== --- trunk/reactos/subsystems/win32/csrss/video.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/video.c [iso-8859-1] Wed Sep 24 05:06:08 2008 @@ -23,7 +23,6 @@ NTSTATUS Status; HANDLE PhysMemHandle; PVOID BaseAddress; - PVOID NullAddress; LARGE_INTEGER Offset; ULONG ViewSize; CHAR IVTAndBda[1024+256]; @@ -105,11 +104,6 @@ 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 1; }