Author: tkreuzer
Date: Wed Mar 24 21:36:12 2010
New Revision: 46404
URL:
http://svn.reactos.org/svn/reactos?rev=46404&view=rev
Log:
[NTOS]
- Multiple ULONG -> SIZE_T fixes
- Use SLIST_ENTRY, not SINGLE_LIST_ENTRY in InterlockedPushEntrySList, they are not the
same!
- Fix InterlockedCompareExchangePointer usage
- _1MB is 1024 KB, not 1000
- Rename PDE_SIZE to PD_SIZE to reflect it's purpose (size of a page directory, not a
page directory entry)
- Add PD_COUNT, PDE_COUNT and PTE_COUNT for amd64 (should rather use PTE_PER_PAGE etc and
move them to arch specific files.
- Some more PFN_TYPE -> PFN_NUMBER
Modified:
branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/mm.h
branches/ros-amd64-bringup/reactos/ntoskrnl/io/iomgr/iocomp.c
branches/ros-amd64-bringup/reactos/ntoskrnl/io/iomgr/irp.c
branches/ros-amd64-bringup/reactos/ntoskrnl/ke/bug.c
branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/contmem.c
branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/iosup.c
branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/miarm.h
branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/mminit.c
branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/ncache.c
branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/procsup.c
branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/virtual.c
branches/ros-amd64-bringup/reactos/ntoskrnl/mm/balance.c
branches/ros-amd64-bringup/reactos/ntoskrnl/mm/pagefile.c
branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ppool.c
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/mm.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1]
(original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Wed Mar
24 21:36:12 2010
@@ -6,22 +6,22 @@
struct _EPROCESS;
-extern ULONG MiFreeSwapPages;
-extern ULONG MiUsedSwapPages;
-extern ULONG MmPagedPoolSize;
-extern ULONG MmTotalPagedPoolQuota;
-extern ULONG MmTotalNonPagedPoolQuota;
+extern PFN_NUMBER MiFreeSwapPages;
+extern PFN_NUMBER MiUsedSwapPages;
+extern SIZE_T MmPagedPoolSize;
+extern SIZE_T MmTotalPagedPoolQuota;
+extern SIZE_T MmTotalNonPagedPoolQuota;
extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
-extern ULONG MmNumberOfPhysicalPages;
+extern PFN_NUMBER MmNumberOfPhysicalPages;
extern UCHAR MmDisablePagingExecutive;
-extern ULONG MmLowestPhysicalPage;
-extern ULONG MmHighestPhysicalPage;
-extern ULONG MmAvailablePages;
-extern ULONG MmResidentAvailablePages;
-extern ULONG MmNumberOfSystemPtes;
+extern PFN_NUMBER MmLowestPhysicalPage;
+extern PFN_NUMBER MmHighestPhysicalPage;
+extern PFN_NUMBER MmAvailablePages;
+extern PFN_NUMBER MmResidentAvailablePages;
+extern ULONG_PTR MmNumberOfSystemPtes;
extern PVOID MmPagedPoolBase;
-extern ULONG MmPagedPoolSize;
+extern SIZE_T MmPagedPoolSize;
extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/io/iomgr/iocomp.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/io/iomgr/iocomp.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/io/iomgr/iocomp.c [iso-8859-1] Wed Mar 24
21:36:12 2010
@@ -92,7 +92,7 @@
}
/* The free was within dhe Depth */
- InterlockedPushEntrySList(&List->L.ListHead, (PSINGLE_LIST_ENTRY)Packet);
+ InterlockedPushEntrySList(&List->L.ListHead, (PSLIST_ENTRY)Packet);
}
VOID
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/io/iomgr/irp.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/io/iomgr/irp.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/io/iomgr/irp.c [iso-8859-1] Wed Mar 24
21:36:12 2010
@@ -1553,7 +1553,7 @@
if (Irp)
{
InterlockedPushEntrySList(&List->L.ListHead,
- (PSINGLE_LIST_ENTRY)Irp);
+ (PSLIST_ENTRY)Irp);
}
}
}
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/ke/bug.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/ke/bug.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/ke/bug.c [iso-8859-1] Wed Mar 24 21:36:12
2010
@@ -1411,7 +1411,7 @@
//
KiAcquireNmiListLock(&OldIrql);
NmiData->Next = KiNmiCallbackListHead;
- Next = InterlockedCompareExchangePointer(&KiNmiCallbackListHead,
+ Next = InterlockedCompareExchangePointer((PVOID*)&KiNmiCallbackListHead,
NmiData,
NmiData->Next);
ASSERT(Next == NmiData->Next);
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/contmem.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/contmem.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/contmem.c [iso-8859-1] Wed Mar 24
21:36:12 2010
@@ -391,7 +391,7 @@
*/
PVOID
NTAPI
-MmAllocateContiguousMemory(IN ULONG NumberOfBytes,
+MmAllocateContiguousMemory(IN SIZE_T NumberOfBytes,
IN PHYSICAL_ADDRESS HighestAcceptableAddress)
{
PFN_NUMBER HighestPfn;
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/iosup.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/iosup.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/iosup.c [iso-8859-1] Wed Mar 24
21:36:12 2010
@@ -46,7 +46,7 @@
PVOID
NTAPI
MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress,
- IN ULONG NumberOfBytes,
+ IN SIZE_T NumberOfBytes,
IN MEMORY_CACHING_TYPE CacheType)
{
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/miarm.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] Wed Mar 24
21:36:12 2010
@@ -33,6 +33,8 @@
#define MI_NONPAGED_POOL_END (PVOID)0xFFBE0000
#define MI_DEBUG_MAPPING (PVOID)0xFFBFF000
+#endif /* !_M_AMD64 */
+
#define MI_MIN_SECONDARY_COLORS 8
#define MI_SECONDARY_COLORS 64
#define MI_MAX_SECONDARY_COLORS 1024
@@ -42,10 +44,10 @@
/* Make the code cleaner with some definitions for size multiples */
#define _1KB (1024)
-#define _1MB (1000 * _1KB)
-
-/* Size of a PDE directory, and size of a page table */
-#define PDE_SIZE (PDE_COUNT * sizeof(MMPDE))
+#define _1MB (1024 * _1KB)
+
+/* Size of a page directory, and size of a page table */
+#define PD_SIZE (PDE_COUNT * sizeof(MMPDE))
#define PT_SIZE (PTE_COUNT * sizeof(MMPTE))
/* Architecture specific count of PDEs in a directory, and count of PTEs in a PT */
@@ -53,7 +55,11 @@
#define PD_COUNT 1
#define PDE_COUNT 1024
#define PTE_COUNT 1024
-#elif _M_ARM
+#elif defined(_M_AMD64)
+#define PD_COUNT (512 * 512)
+#define PDE_COUNT 512
+#define PTE_COUNT 512
+#elif defined(_M_ARM)
#define PD_COUNT 1
#define PDE_COUNT 4096
#define PTE_COUNT 256
@@ -72,8 +78,6 @@
#define POOL_LISTS_PER_PAGE (PAGE_SIZE / sizeof(LIST_ENTRY))
#define BASE_POOL_TYPE_MASK 1
#define POOL_MAX_ALLOC (PAGE_SIZE - (sizeof(POOL_HEADER) + sizeof(LIST_ENTRY)))
-
-#endif
typedef struct _POOL_DESCRIPTOR
{
@@ -196,24 +200,24 @@
extern MMPTE ValidKernelPde;
extern MMPTE ValidKernelPte;
-extern ULONG_PTR MmSizeOfNonPagedPoolInBytes;
-extern ULONG_PTR MmMaximumNonPagedPoolInBytes;
+extern SIZE_T MmSizeOfNonPagedPoolInBytes;
+extern SIZE_T MmMaximumNonPagedPoolInBytes;
extern PFN_NUMBER MmMaximumNonPagedPoolInPages;
extern PFN_NUMBER MmSizeOfPagedPoolInPages;
extern PVOID MmNonPagedSystemStart;
extern PVOID MmNonPagedPoolStart;
extern PVOID MmNonPagedPoolExpansionStart;
extern PVOID MmNonPagedPoolEnd;
-extern ULONG_PTR MmSizeOfPagedPoolInBytes;
+extern SIZE_T MmSizeOfPagedPoolInBytes;
extern PVOID MmPagedPoolStart;
extern PVOID MmPagedPoolEnd;
extern PVOID MmSessionBase;
-extern ULONG_PTR MmSessionSize;
+extern SIZE_T MmSessionSize;
extern PMMPTE MmFirstReservedMappingPte, MmLastReservedMappingPte;
extern PMMPTE MiFirstReservedZeroingPte;
extern MI_PFN_CACHE_ATTRIBUTE MiPlatformCacheAttributes[2][MmMaximumCacheType];
extern PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock;
-extern ULONG_PTR MmBootImageSize;
+extern SIZE_T MmBootImageSize;
extern PMMPTE MmSystemPtesStart[MaximumPtePoolTypes];
extern PMMPTE MmSystemPtesEnd[MaximumPtePoolTypes];
extern PMEMORY_ALLOCATION_DESCRIPTOR MxFreeDescriptor;
@@ -226,10 +230,9 @@
extern PVOID MmPagedPoolEnd;
extern PVOID MmNonPagedSystemStart;
extern PVOID MiSystemViewStart;
-extern ULONG_PTR MmSystemViewSize;
+extern SIZE_T MmSystemViewSize;
extern PVOID MmSessionBase;
extern PVOID MiSessionSpaceEnd;
-extern ULONG_PTR MmSizeOfPagedPoolInBytes;
extern PMMPTE MmSystemPagePtes;
extern PVOID MmSystemCacheStart;
extern PVOID MmSystemCacheEnd;
@@ -239,13 +242,12 @@
extern ULONG MmSpecialPoolTag;
extern PVOID MmHyperSpaceEnd;
extern PMMWSL MmSystemCacheWorkingSetList;
-extern ULONG MmMinimumNonPagedPoolSize;
+extern SIZE_T MmMinimumNonPagedPoolSize;
extern ULONG MmMinAdditionNonPagedPoolPerMb;
-extern ULONG MmDefaultMaximumNonPagedPool;
+extern SIZE_T MmDefaultMaximumNonPagedPool;
extern ULONG MmMaxAdditionNonPagedPoolPerMb;
extern ULONG MmSecondaryColors;
extern ULONG MmSecondaryColorMask;
-extern ULONG MmNumberOfSystemPtes;
extern ULONG MmMaximumNonPagedPoolPercent;
extern ULONG MmLargeStackSize;
extern PMMCOLOR_TABLES MmFreePagesByColor[FreePageList + 1];
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/mminit.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/mminit.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/mminit.c [iso-8859-1] Wed Mar 24
21:36:12 2010
@@ -23,8 +23,8 @@
// figure out the most appropriate values.
//
ULONG MmMaximumNonPagedPoolPercent;
-ULONG MmSizeOfNonPagedPoolInBytes;
-ULONG MmMaximumNonPagedPoolInBytes;
+SIZE_T MmSizeOfNonPagedPoolInBytes;
+SIZE_T MmMaximumNonPagedPoolInBytes;
/* Some of the same values, in pages */
PFN_NUMBER MmMaximumNonPagedPoolInPages;
@@ -36,9 +36,9 @@
// They are described on
http://support.microsoft.com/default.aspx/kb/126402/ja
// along with the algorithm that uses them, which is implemented later below.
//
-ULONG MmMinimumNonPagedPoolSize = 256 * 1024;
+SIZE_T MmMinimumNonPagedPoolSize = 256 * 1024;
ULONG MmMinAdditionNonPagedPoolPerMb = 32 * 1024;
-ULONG MmDefaultMaximumNonPagedPool = 1024 * 1024;
+SIZE_T MmDefaultMaximumNonPagedPool = 1024 * 1024;
ULONG MmMaxAdditionNonPagedPoolPerMb = 400 * 1024;
//
@@ -107,7 +107,7 @@
//
// And this is its default size
//
-ULONG MmSizeOfPagedPoolInBytes = MI_MIN_INIT_PAGED_POOLSIZE;
+SIZE_T MmSizeOfPagedPoolInBytes = MI_MIN_INIT_PAGED_POOLSIZE;
PFN_NUMBER MmSizeOfPagedPoolInPages = MI_MIN_INIT_PAGED_POOLSIZE / PAGE_SIZE;
//
@@ -131,10 +131,10 @@
PVOID MiSessionPoolEnd; // 0xBE000000
PVOID MiSessionPoolStart; // 0xBD000000
PVOID MmSessionBase; // 0xBD000000
-ULONG MmSessionSize;
-ULONG MmSessionViewSize;
-ULONG MmSessionPoolSize;
-ULONG MmSessionImageSize;
+SIZE_T MmSessionSize;
+SIZE_T MmSessionViewSize;
+SIZE_T MmSessionPoolSize;
+SIZE_T MmSessionImageSize;
//
// The system view space, on the other hand, is where sections that are memory
@@ -143,7 +143,7 @@
// By default, it is a 16MB region.
//
PVOID MiSystemViewStart;
-ULONG MmSystemViewSize;
+SIZE_T MmSystemViewSize;
//
// A copy of the system page directory (the page directory associated with the
@@ -167,13 +167,13 @@
// On systems with more than 32MB, this number is then doubled, and further
// aligned up to a PDE boundary (4MB).
//
-ULONG MmNumberOfSystemPtes;
+ULONG_PTR MmNumberOfSystemPtes;
//
// This is how many pages the PFN database will take up
// In Windows, this includes the Quark Color Table, but not in ARM³
//
-ULONG MxPfnAllocation;
+PFN_NUMBER MxPfnAllocation;
//
// Unlike the old ReactOS Memory Manager, ARM³ (and Windows) does not keep track
@@ -197,7 +197,7 @@
//
// This is where we keep track of the most basic physical layout markers
//
-ULONG MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage = -1;
+PFN_NUMBER MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage = -1;
//
// The total number of pages mapped by the boot loader, which include the kernel
@@ -207,13 +207,13 @@
//
// This number is later aligned up to a PDE boundary.
//
-ULONG MmBootImageSize;
+SIZE_T MmBootImageSize;
//
// These three variables keep track of the core separation of address space that
// exists between kernel mode and user mode.
//
-ULONG MmUserProbeAddress;
+ULONG_PTR MmUserProbeAddress;
PVOID MmHighestUserAddress;
PVOID MmSystemRangeStart;
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/ncache.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/ncache.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/ncache.c [iso-8859-1] Wed Mar 24
21:36:12 2010
@@ -23,7 +23,7 @@
*/
PVOID
NTAPI
-MmAllocateNonCachedMemory(IN ULONG NumberOfBytes)
+MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes)
{
PFN_NUMBER PageCount, MdlPageCount, PageFrameIndex;
PHYSICAL_ADDRESS LowAddress, HighAddress, SkipBytes;
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/procsup.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/procsup.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/procsup.c [iso-8859-1] Wed Mar 24
21:36:12 2010
@@ -503,7 +503,7 @@
ImageConfigData = RtlImageDirectoryEntryToData(Peb->ImageBaseAddress,
TRUE,
IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG,
- &ViewSize);
+ (PULONG)&ViewSize);
if (ImageConfigData)
{
//
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/virtual.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/virtual.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ARM3/virtual.c [iso-8859-1] Wed Mar 24
21:36:12 2010
@@ -775,7 +775,7 @@
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
PEPROCESS Process;
NTSTATUS Status = STATUS_SUCCESS;
- ULONG BytesWritten = 0;
+ SIZE_T BytesWritten = 0;
PAGED_CODE();
//
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/balance.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/balance.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/balance.c [iso-8859-1] Wed Mar 24
21:36:12 2010
@@ -228,7 +228,7 @@
PsGetCurrentThread() == MiBalancerThreadId.UniqueThread;
}
-VOID NTAPI MiSetConsumer(IN PFN_TYPE Pfn, IN ULONG Consumer);
+VOID NTAPI MiSetConsumer(IN PFN_NUMBER Pfn, IN ULONG Consumer);
NTSTATUS
NTAPI
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/pagefile.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/pagefile.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/pagefile.c [iso-8859-1] Wed Mar 24
21:36:12 2010
@@ -81,15 +81,15 @@
ULONG MmNumberOfPagingFiles;
/* Number of pages that are available for swapping */
-ULONG MiFreeSwapPages;
+PFN_NUMBER MiFreeSwapPages;
/* Number of pages that have been allocated for swapping */
-ULONG MiUsedSwapPages;
+PFN_NUMBER MiUsedSwapPages;
/*
* Number of pages that have been reserved for swapping but not yet allocated
*/
-static ULONG MiReservedSwapPages;
+static PFN_NUMBER MiReservedSwapPages;
/*
* Ratio between reserved and available swap pages, e.g. setting this to five
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ppool.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ppool.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/ppool.c [iso-8859-1] Wed Mar 24
21:36:12 2010
@@ -159,8 +159,8 @@
R_POOL, *PR_POOL;
PVOID MmPagedPoolBase;
-ULONG MmPagedPoolSize;
-ULONG MmTotalPagedPoolQuota = 0; // TODO FIXME commented out until we use it
+SIZE_T MmPagedPoolSize;
+SIZE_T MmTotalPagedPoolQuota = 0; // TODO FIXME commented out until we use it
static PR_POOL MmPagedPool = NULL;
/* FUNCTIONS*******************************************************************/