Author: fireball Date: Thu Sep 27 22:07:44 2007 New Revision: 29254
URL: http://svn.reactos.org/svn/reactos?rev=29254&view=rev Log: - Add missing KERNEL_LARGE_STACK_COMMIT definition to DDK. - Fix typo in MMWSL. - Add RtlRandom to NDK. - Add MEMORY_PRIORITY values to NDK. - Add KeAcquireSpinLockRaiseToSynch to NDK. - Make MmInitializeProcessAddressSpace take two more parameters: one to specify flags, such as large page support, and another one to define the process being cloned, when fork() support will be added. - Add KeInvalidAccessAllowed to deal with page faults in the special S-List code. The assembly code currently handles simple faults, but our MmAccessFault handler needs to start verifying the fault too. - Mark LoaderReserve pages as LoaderFree, it seems they end up this way in Windows. - Use MmNumberOfPhysicalPages instead of MmStats.NrTotalPages.
All NDK changes are discussed with Alex.
Modified: trunk/reactos/include/ddk/winddk.h trunk/reactos/include/ndk/kefuncs.h trunk/reactos/include/ndk/mmtypes.h trunk/reactos/include/ndk/pstypes.h trunk/reactos/include/ndk/rtlfuncs.h trunk/reactos/ntoskrnl/ex/init.c trunk/reactos/ntoskrnl/include/internal/ke.h trunk/reactos/ntoskrnl/include/internal/mm.h trunk/reactos/ntoskrnl/ke/bug.c trunk/reactos/ntoskrnl/ke/freeldr.c trunk/reactos/ntoskrnl/ke/i386/exp.c trunk/reactos/ntoskrnl/ke/i386/ldt.c trunk/reactos/ntoskrnl/mm/mminit.c trunk/reactos/ntoskrnl/mm/procsup.c trunk/reactos/ntoskrnl/ps/process.c (contents, props changed)
Modified: trunk/reactos/include/ddk/winddk.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/winddk.h?rev=29... ============================================================================== --- trunk/reactos/include/ddk/winddk.h (original) +++ trunk/reactos/include/ddk/winddk.h Thu Sep 27 22:07:44 2007 @@ -231,7 +231,7 @@
#define KERNEL_STACK_SIZE 12288 #define KERNEL_LARGE_STACK_SIZE 61440 - +#define KERNEL_LARGE_STACK_COMMIT 12288
#define DPFLTR_ERROR_LEVEL 0 #define DPFLTR_WARNING_LEVEL 1
Modified: trunk/reactos/include/ndk/kefuncs.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/kefuncs.h?rev=2... ============================================================================== --- trunk/reactos/include/ndk/kefuncs.h (original) +++ trunk/reactos/include/ndk/kefuncs.h Thu Sep 27 22:07:44 2007 @@ -133,6 +133,11 @@ IN PKLOCK_QUEUE_HANDLE LockHandle );
+KIRQL +FASTCALL +KeAcquireSpinLockRaiseToSynch( + IN OUT PKSPIN_LOCK SpinLock +);
// // Interrupt Functions
Modified: trunk/reactos/include/ndk/mmtypes.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/mmtypes.h?rev=2... ============================================================================== --- trunk/reactos/include/ndk/mmtypes.h (original) +++ trunk/reactos/include/ndk/mmtypes.h Thu Sep 27 22:07:44 2007 @@ -548,7 +548,7 @@ ULONG NextSlot; PMMWSLE Wsle; ULONG LastInitializedWsle; - ULONG NonDirectcout; + ULONG NonDirectCount; PMMWSLE_HASH HashTable; ULONG HashTableSize; ULONG NumberOfCommittedPageTables;
Modified: trunk/reactos/include/ndk/pstypes.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/pstypes.h?rev=2... ============================================================================== --- trunk/reactos/include/ndk/pstypes.h (original) +++ trunk/reactos/include/ndk/pstypes.h Thu Sep 27 22:07:44 2007 @@ -97,6 +97,13 @@ #define PROCESS_PRIORITY_IDLE 3 #define PROCESS_PRIORITY_NORMAL 8 #define PROCESS_PRIORITY_NORMAL_FOREGROUND 9 + +// +// Process memory priorities +// +#define MEMORY_PRIORITY_BACKGROUND 0 +#define MEMORY_PRIORITY_UNKNOWN 1 +#define MEMORY_PRIORITY_FOREGROUND 2
// // Process Priority Separation Values (OR)
Modified: trunk/reactos/include/ndk/rtlfuncs.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/rtlfuncs.h?rev=... ============================================================================== --- trunk/reactos/include/ndk/rtlfuncs.h (original) +++ trunk/reactos/include/ndk/rtlfuncs.h Thu Sep 27 22:07:44 2007 @@ -2923,6 +2923,13 @@ NTSYSAPI ULONG NTAPI +RtlRandom( + IN OUT PULONG Seed +); + +NTSYSAPI +ULONG +NTAPI RtlComputeCrc32( IN USHORT PartialCrc, IN PUCHAR Buffer,
Modified: trunk/reactos/ntoskrnl/ex/init.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=2925... ============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c (original) +++ trunk/reactos/ntoskrnl/ex/init.c Thu Sep 27 22:07:44 2007 @@ -1483,7 +1483,7 @@ &MsgEntry);
/* Get total RAM size */ - Size = MmStats.NrTotalPages * PAGE_SIZE / 1024 / 1024; + Size = MmNumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024;
/* Create the string */ StringBuffer = InitBuffer->VersionBuffer;
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/k... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ke.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ke.h Thu Sep 27 22:07:44 2007 @@ -760,6 +760,10 @@ KeZeroPages(IN PVOID Address, IN ULONG Size);
+BOOLEAN +FASTCALL +KeInvalidAccessAllowed(IN PVOID TrapInformation OPTIONAL); + VOID NTAPI KeRosDumpStackFrames(
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/m... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/mm.h (original) +++ trunk/reactos/ntoskrnl/include/internal/mm.h Thu Sep 27 22:07:44 2007 @@ -13,6 +13,7 @@ extern ULONG MmTotalPagedPoolQuota; extern ULONG MmTotalNonPagedPoolQuota; extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress; +extern ULONG MmNumberOfPhysicalPages;
extern PVOID MmPagedPoolBase; extern ULONG MmPagedPoolSize; @@ -614,7 +615,9 @@ NTAPI MmInitializeProcessAddressSpace( IN PEPROCESS Process, + IN PEPROCESS Clone OPTIONAL, IN PVOID Section OPTIONAL, + IN OUT PULONG Flags, IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL );
Modified: trunk/reactos/ntoskrnl/ke/bug.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/bug.c?rev=29254... ============================================================================== --- trunk/reactos/ntoskrnl/ke/bug.c (original) +++ trunk/reactos/ntoskrnl/ke/bug.c Thu Sep 27 22:07:44 2007 @@ -249,7 +249,7 @@ &KeRosBiosVersion, &KeRosVideoBiosDate, &KeRosVideoBiosVersion, - MmStats.NrTotalPages * PAGE_SIZE); + MmNumberOfPhysicalPages * PAGE_SIZE); #endif }
@@ -971,12 +971,6 @@ } }
- /* ROS HACK: Unlock the Kernel Address Space if we own it */ - if (KernelAddressSpaceLock.Owner == KeGetCurrentThread()) - { - MmUnlockAddressSpace(MmGetKernelAddressSpace()); - } - /* Raise IRQL to HIGH_LEVEL */ _disable(); KfRaiseIrql(HIGH_LEVEL);
Modified: trunk/reactos/ntoskrnl/ke/freeldr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/freeldr.c?rev=2... ============================================================================== --- trunk/reactos/ntoskrnl/ke/freeldr.c (original) +++ trunk/reactos/ntoskrnl/ke/freeldr.c Thu Sep 27 22:07:44 2007 @@ -427,8 +427,8 @@ { /* It's over 16MB, so that memory gets marked as reserve */ Status = KiRosConfigureArcDescriptor(PageStart, - PageEnd, - LoaderReserve); + PageEnd, + LoaderFree); } else { @@ -448,7 +448,7 @@ /* Any code in the memory hole region ends up as reserve */ Status = KiRosConfigureArcDescriptor(PageStart, PageEnd, - LoaderReserve); + LoaderFree); }
/* If we failed, break out, otherwise, go to the next BIOS block */
Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/exp.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/exp.c (original) +++ trunk/reactos/ntoskrnl/ke/i386/exp.c Thu Sep 27 22:07:44 2007 @@ -799,6 +799,45 @@ if (OldIrql < APC_LEVEL) KeLowerIrql(OldIrql); }
+BOOLEAN +FASTCALL +KeInvalidAccessAllowed(IN PVOID TrapInformation OPTIONAL) +{ + ULONG Eip; + PKTRAP_FRAME TrapFrame = TrapInformation; + VOID NTAPI ExpInterlockedPopEntrySListFault(VOID); + + /* Don't do anything if we didn't get a trap frame */ + if (!TrapInformation) return FALSE; + + /* Check where we came from */ + switch (TrapFrame->SegCs) + { + /* Kernel mode */ + case KGDT_R0_CODE: + + /* Allow S-LIST Routine to fail */ + Eip = (ULONG)&ExpInterlockedPopEntrySListFault; + break; + + /* User code */ + case KGDT_R3_CODE | RPL_MASK: + + /* Allow S-LIST Routine to fail */ + //Eip = (ULONG)KeUserPopEntrySListFault; + Eip = 0; + break; + + default: + + /* Anything else gets a bugcheck */ + Eip = 0; + } + + /* Return TRUE if we want to keep the system up */ + return (TrapFrame->Eip == Eip) ? TRUE : FALSE; +} + VOID NTAPI KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
Modified: trunk/reactos/ntoskrnl/ke/i386/ldt.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/ldt.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/ldt.c (original) +++ trunk/reactos/ntoskrnl/ke/i386/ldt.c Thu Sep 27 22:07:44 2007 @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/ldt.c @@ -221,3 +220,4 @@ return STATUS_SUCCESS; }
+
Modified: trunk/reactos/ntoskrnl/mm/mminit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mminit.c?rev=29... ============================================================================== --- trunk/reactos/ntoskrnl/mm/mminit.c (original) +++ trunk/reactos/ntoskrnl/mm/mminit.c Thu Sep 27 22:07:44 2007 @@ -37,6 +37,8 @@
PVOID MiNonPagedPoolStart; ULONG MiNonPagedPoolLength; + +ULONG MmNumberOfPhysicalPages;
VOID INIT_FUNCTION NTAPI MmInitVirtualMemory(ULONG_PTR LastKernelAddress, ULONG KernelLength);
@@ -347,6 +349,7 @@ * Free physical memory not used by the kernel */ MmStats.NrTotalPages = MmFreeLdrMemHigher/4; + MmNumberOfPhysicalPages = MmStats.NrTotalPages; if (!MmStats.NrTotalPages) { DbgPrint("Memory not detected, default to 8 MB\n"); @@ -427,13 +430,18 @@ MmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock) { + ULONG Flags = 0; if (Phase == 0) { /* Initialize the Loader Lock */ KeInitializeMutant(&MmSystemLoadLock, FALSE);
/* Initialize the address space for the system process */ - MmInitializeProcessAddressSpace(PsGetCurrentProcess(), NULL, NULL); + MmInitializeProcessAddressSpace(PsGetCurrentProcess(), + NULL, + NULL, + &Flags, + NULL);
/* Reload boot drivers */ MiReloadBootLoadedDrivers(LoaderBlock);
Modified: trunk/reactos/ntoskrnl/mm/procsup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/procsup.c?rev=2... ============================================================================== --- trunk/reactos/ntoskrnl/mm/procsup.c (original) +++ trunk/reactos/ntoskrnl/mm/procsup.c Thu Sep 27 22:07:44 2007 @@ -498,7 +498,9 @@ NTSTATUS NTAPI MmInitializeProcessAddressSpace(IN PEPROCESS Process, + IN PEPROCESS ProcessClone OPTIONAL, IN PVOID Section OPTIONAL, + IN OUT PULONG Flags, IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL) { NTSTATUS Status;
Modified: trunk/reactos/ntoskrnl/ps/process.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/process.c?rev=2... ============================================================================== --- trunk/reactos/ntoskrnl/ps/process.c (original) +++ trunk/reactos/ntoskrnl/ps/process.c Thu Sep 27 22:07:44 2007 @@ -555,7 +555,7 @@
/* Set default exit code */ Process->ExitStatus = STATUS_TIMEOUT; - + /* Check if this is the initial process being built */ if (Parent) { @@ -576,7 +576,7 @@ Status = MmInitializeHandBuiltProcess(Process, &DirectoryTableBase); if (!NT_SUCCESS(Status)) goto CleanupWithRef; } - + /* We now have an address space */ InterlockedOr((PLONG)&Process->Flags, PSF_HAS_ADDRESS_SPACE_BIT);
@@ -596,7 +596,7 @@
/* Set default priority class */ Process->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL; - + /* Check if we have a parent */ if (Parent) { @@ -628,7 +628,9 @@ { /* Initialize the address space */ Status = MmInitializeProcessAddressSpace(Process, + NULL, SectionObject, + &Flags, &Process-> SeAuditProcessCreationInfo. ImageFileName); @@ -644,13 +646,13 @@ } else { - /* This is a system process other than the boot one (MmInit1) */ + /* This is the initial system process */ Flags &= ~PS_LARGE_PAGES; Status = MmInitializeProcessAddressSpace(Process, NULL, - &Process-> - SeAuditProcessCreationInfo. - ImageFileName); + NULL, + &Flags, + NULL); if (!NT_SUCCESS(Status)) goto CleanupWithRef;
/* Create a dummy image file name */ @@ -670,7 +672,7 @@ sizeof(OBJECT_NAME_INFORMATION)); } } - + /* Check if we have a section object and map the system DLL */ if (SectionObject) PspMapSystemDll(Process, NULL, FALSE);
@@ -680,6 +682,7 @@ Process->UniqueProcessId = ExCreateHandle(PspCidTable, &CidEntry); if (!Process->UniqueProcessId) { + /* Fail */ Status = STATUS_INSUFFICIENT_RESOURCES; goto CleanupWithRef; } @@ -701,6 +704,7 @@ /* Create PEB only for User-Mode Processes */ if (Parent) { + /* Create it */ Status = MmCreatePeb(Process); if (!NT_SUCCESS(Status)) goto CleanupWithRef; }
Propchange: trunk/reactos/ntoskrnl/ps/process.c ------------------------------------------------------------------------------ --- svn:needs-lock (original) +++ svn:needs-lock (removed) @@ -1,1 +1,0 @@ -*