[ros-diffs] [sir_richard] 45566: [NTOS]: Move more functions from the i386 ARM3 directory to the portable/shared directory, since they apply to all architectures. [NTOS]: Refactor the mapping of the PTEs for the PFN database into MiMapPfnDatabase and move the code to portable directory. [NTOS]: Move and refactor some other definitions, and make some numbers more portable by defining arch-specific subvalues. [NTOS]: Make the PFN database actually 2 PFN Databases: MmPfnDatabase[0] which is the ReactOS mapping of PHYSICAL_PAGE structures, and MmPfnDatabase[1] which will be the ARM3 mapping of MMPFN structures. The latter is as-of-yet unused, but memory for it is now being reserved.
sir_richard at svn.reactos.org
sir_richard at svn.reactos.org
Thu Feb 11 01:01:32 CET 2010
- Previous message: [ros-diffs] [tkreuzer] 45565: [REACTOS] Add asm.h containing macros to make assembly code both GAS and ML compatible at the same time. [NTOS/HAL] Move trap entry points from C into a GAS/ML compatile assembly file (might need fine tuning for ML). The entries are generated by a shared assembly macro TRAP_ENTRY. Removed KiTrapStub, KiIsV8086TrapSafe, KiIsUserTrapSafe, KiSetSaneSegments, removed segment handling from KiEnter*Trap. [NTOS] Make KiFastCallEntryHandler and KiSystemServiceHandler FASTCALL and pass the systemcall number in TrapFrame->Eax [HAL] Use _setjmp/longjmp instead of saving a trapframe in HalpBiosCall
- Next message: [ros-diffs] [jcatena] 45567: 20100210 [branch regression] revert branch to 44678 - the msvc port based in 45263 (including new traps etc) is booting to desktop, but contains many hacks and require cleanup. For example new hal initialization enables the timer interrupt before setting the vector, while ntos had a vector to unexpected interrupt -> bugcheck. It is a miracle that trunk boots, just depending that no timer int happens since the int enable to the vector init in a later phase. I'm not building hal yet, so for now I added in ntos the timer interrupt stub that calls KeUpdateSystemTime in a test file. I'll need some time to clean those hacks properly, so I decided to revert to 44678, and later update stuff orderly and in a proper way. Also the new stuff from Sir Richard is WIP and it is being a huge waste of time for me fixing it before it is finished. Anyway while fixing it i made vast improvements to trap, interrupt and mainly syscall handling, so i intend to commit it later. - 44678 is previous to freeldr and hal changes, it needs those from 0.3.11 relase or builds previous to 44678 (probably it is compatible with those until 44900 or so). - The change log for this submit is very long, because it contains everything done fom trunk 44678 to a bootable msvc build of ntoskrnl. An effort has been made to fix incompatibilities in proper ways, improving general portability of the whole system instead of adding unnecessary compiler dependent conditionals spreaded through the sources. Now most of these conditional compilation are replaced by the definitions in a very small set of compiler and platform dependent includes, placed at include\platf. Thanks to this further ports will be greatly simplified, and code is much cleaner. [ntos] msvc projects - added msvc projects, .vcproj and .vsprops files for ntoskrnl and kddll, and libraries used by these. - different sections of ntoskrnl are built as libraries to ease separate testing of updates. It is just how the vcprojs are made, it does not change the tree structure or source files. - msvc projects use forced *_bld.h includes to eliminate the need of changes in the sources as much as possible. - The root.vsprops file sets root properties for all projects. Here you have to set the ros and objrbe macros to match the root path for reactos source tree. objrbe is explained below. - ntoskrnl uses files are autogenerated, for now i'm using those generated by rosbe. Since they are autogerated, i am not commiting them, but are necessary to build. root.vsprops defines the objrbe macro as .\obj_rosbe. you may do either: a) create a .\obj_rosbe junction pointing to where you have the rosbe's object dir. b) redefine the objrbe macro to point to the rosbe's object dir. c) copy the required autogenerated files there from rosbe's object dir. These are: .\include\ .\ntoskrnl\include\ .\ntoskrnl\ex\zw.s - currently the autogenerated zw.s file is not assembled correctly by the as rule, because $KGDT_R0_CODE is not changed to $8 by the preprocessor. So for now i copied it to ntoskrnl\ex\i386, edited it, and added for commit. I'll try to find how to change the as rule so that it behaves as when using gcc as preprocessor. If someone has a better idea... It is the only file that the as rule doesn't assemble well untouched. - The import libraries are searched in libobj\ros first and then in libobj\ms (check the root properties). I have there the rosbe built libraries renamed to .lib. Only hal.lib and bootvid.lib are required. But because ntos imports kdcom and kdcom imports ntoskrnl, intitially you need also one of these two libs there, although the generated ones will take precedence after building the first time, the result of the first link may not be good if the import lib used is not right, but the generated import libs can then be used to link correctly. I also tested linking with ms libs without trouble, (that's why libobj\ms is there), but none from ms is required. - A new folder ntoskrnl\kdw1 contains the kd64 debugger, the one compatible with ms debuggers like windbg. This is a provisional location, basically a copy of kd64 which i didn't want to break during testing. It is working. Now it is a static library, so that the desired debugger can be selected at link time, but could also be built as dll to make it selectable at run time. I'm not motivated to to sync builds of kdbg and dbg, and until a decission is made about this idea of isolating the different debuggers is made or its integration in trunk or any other request, i'll keep it in this location. * [tools] rules files Rules files for msvc added in tools/msvc, adding support for as and nasm. The one to support masm is copied from msvc. * [global] platform abstraction includes - created dir include/platf with includes providing abstraction of compiler- specific directives and platform-specific low level basics. - platf.h has the abstraction for compiler-specific directives and is intended to be inclued in every c project or file before crt, sdk, etc. Some have psdk equivalents, code should use psdk definitions in those cases, while psdk, ddk and crt will define theirs based in platf.h instead of compiler-specific directives. There are separate versions of this file under the msc and gnuc subdirs. The gnuc one is currently untested. - cpu.h has low level definitions for the cpu, and cpu_c.h has the compiler dependent part, intended to replace common inline assempler in conditional blocks. Some of the funtions are equivalent to intrinsics and are just defines for them, while many others are inline or macro implementations for required functions that are not available as intrinsics and were prevously implemented as inline assemply spreaded along the kernel and hal sources. cpu_c.h under msc is complete and tested, the version under gnuc needs to be completed and tested. The defs that have equivalents as intrinsics are there for consistency and convenience, and keep in mind that different compilers may have different intrinsics, and it's better to write a cpu_c.h for a new compiler than having to add inline assembly everywhere... These are used in kernel and driver modules. - utl.h contains some general purpose utility macros. - intrin.h for each compiler contains the intrinsics definitions. For the intrinsics the naming of those of msvc are used, since these are what are used by the ms sdks. For example sdk defines InterlockXX _InterlockXX. inting.h declares, defines or implements these _xx. Currently i have there some that was causing problems, but i will complete it so that sdk and ddk can completely rely in _xx intrinsics being available or defined to define theirs, so eliminating also compiler and platform dependency in the sdks. After fixing a few, everything works, but these defs are a mess, the sdk has implementations for some available as intrinsics, others are lacking or incorrect for some platform. etc. I will be fixing that mess by defining all those based in the compiler and platform specific intrin.h, so the sdks will be much cleaner and portable. - Many occurences of inline assembly inside conditional blocks, where very often the msc part was wrong, and compiler specific directives, have been replaced by instances of the macros defined in these includes. Many in ke\i386\cpu.c but also many others spread among many files. * [ntos] DbgPrint improvements - DbgPrint support moved to ntoskrnl/dbg. - DbgPrint now uses a function pointer to the actual handler, so that it can be changed as necessary in different phases or by the kernel debuggers. The initial DbgPrint handler in ser1.c is a very simple one that writes directly to the com port, allowing early and transparent debug logging right at KiSystemStartup. When enough of the system has been initialized, the pointer is changed to the right handler. The debuggers can also change the pointer to their own handlers, improving debugger module isolation. Note that ser1 assumes that there is a com1 (@0x3f8) present. If this is not the case #define EARLY_DEBUG_PORT 0. If DBG is 0 it won't be used as well. I could add port presence detection very easily, but i don't think it necessary. Let me know otherwise. I use windbg in com2 through named pipe in vmware, and works nicely. Currently the initial mapping to ser1 is not changed later, i have yet to change the pointer when appropiate during the boot, so if the debugger is not activated all DbgPrint output is always handled by ser1, and if the debugger is activated output from kernel goes to com1 and from user to windbg, not a big problem anyway. * [sdk] sdks fixes - some defs like #define NTKERNELAPI DECLSPEC_IMPORT has been made conditional as #ifndef NTKERNELAPI #define NTKERNELAPI DECLSPEC_IMPORT #endif Obviously original ms ones were not intended to build ntoskrnl, but we do so we need to define NTKERNELAPI as empty (or dllexport) when building ntoskrnl, for sdk compatibility. - FAST_MUTEX.Gate changed to FAST_MUTEX.Event, as in ms sdks, for sdk compatibility. - KIPCR.Tib changed to KIPCR.NtTib, as in ms sdks, for sdk compatibility. - KIPCR.Self changed to KIPCR.SelfPcr, as in ms sdks. Actually, i copied the KPCR def from ms, since it coincided but was more complete with an union and better documented. Changed some argument types to match ms definitions. In every case the type is compatible, so the change is safe. Eliminated some warnings. NTSYSAPI ULONG NTAPI vDbgPrintExWithPrefix(PCCH Prefix, ULONG ComponentId, ULONG Level, PCCH Format, va_list arglist); NTSYSAPI ULONG NTAPI vDbgPrintEx(ULONG ComponentId, ULONG Level, PCCH Format, va_list arglist); ULONG _CDECL DbgPrint(PCSTR Format, ...); NTSYSAPI ULONG _CDECL DbgPrintEx(ULONG ComponentId, ULONG Level, PCSTR Format, ...); NTSYSAPI ULONG _CDECL DbgPrintReturnControlC(PCCH Format, ...); NTSYSAPI NTSTATUS NTAPI DbgQueryDebugFilterState(ULONG ComponentId, ULONG Level); NTSYSAPI NTSTATUS NTAPI DbgSetDebugFilterState(ULONG ComponentId, ULONG Level, BOOLEAN State); * [ntos] added lacking global ntoskrnl\cc\cacheman.c BOOLEAN CcPfEnablePrefetcher = 0; * [ntos] ntoskrnl\ex\work.c: Int32x32To64 with all constant arguments is silly, let the compiler do it instead of invoking a runtime multiplication. * [ntos] ntoskrnl\ke\dpc.c FIXME: KiTimerExpiration causes a crash if global optimization (MSVC9) difficult to trace, it works most times, but sometimes make a called dpc routine crash. Added _OPTIMIZE_OFF_GLOBAL and _OPTIMIZE_DFT before and after the function. _OPTIMIZE macros are defined in platf.h, appropiately in msc version and empty in the gnuc one. * [ntos] ntoskrnl\ke\freeldr.c KERNEL_DESCRIPTOR_PAGE macro bug fix // #define KERNEL_DESCRIPTOR_PAGE(x) (((ULONG_PTR)x &~ KSEG0_BASE) >> PAGE_SHIFT) #define KERNEL_DESCRIPTOR_PAGE(x) ( ( (ULONG_PTR)x > KSEG0_BASE ? ((ULONG_PTR)x-KSEG0_BASE) : (ULONG_PTR)x) >> PAGE_SHIFT) * [ntos] TSS needs alignment changed globals definition order _ALIGN(0x80) KTSS KiBootTss; _ALIGN is appropiately defined in platf.h for msc and gnuc * [ntos] mm/arm3 #line 15 in removed in all files These play havoc with msvc and ultracompare. I don't think they are necessary in any case so i removed them. If there is a good reason to have them, plz put them in #ifdef ARM block, or much better, define a macro in the platf.h for arm * [ntos] ntoskrnl\ps\win32.c PsConvertToGuiThread calls KeSwitchKernelStack, which changes the stack and ebp added _OPTIMIZE_OFF_STKF and _OPTIMIZE_DFT before and after the fn, so it works regardless of the optimizations chosen. * [rtl] GetGlobalFlags GetVersion moved to separate files so that are only linked if actually used. * [ntos] ntoskrnl\include\internal\ke_x.h KeGetPreviousMode Changed to macro without outer cast. Don't use wrong cast or inline return type, it is unnecessary and can generate unnecessary rt conversion. * [ntos] use section macros in platf.h instead of compiler specific directives defs of PLACE_IN_SECTION, INIT_FUNCTION, PAGE_LOCKED_FUNCTION, PAGE_UNLOCKED_FUNCTION removed and refereces changed to macros based in platf.h that are suitable for both gnuc and msc, unlike the previous ones that couldn't be defined for msc coz it needs the function name and is used only in definition, not in declaration. * [ntos] msc part in intrin_i.h removed cpu_c.h contains everything intrin_i had, and much more it didn't. gcc doesn't need it either if cpu_c.h is included instead, so this file should dissapear. * [ntos] PETHREAD and PEPROCESS ambiguity ddk may define PETHREAD as KTHREAD * or ETHREAD * depending on what specific includes are used. To avoid the ambiguity i replaced in some places PETHREAD for ETHREAD *, and so removing the need of previous recast hacks. The ambiguity is also in ms ddk, so i don't think we should change it, but be aware of the ambiguity and use * instead of the pointer type to avoid mistakes. [ddk] #define KERNEL_STACK_SIZE this has been put inside an #ifndef KERNEL_STACK_SIZE block we may need to increase the default stack size, i did, since i detected occasional crashes debugging boot due to insufficient stack. [ddk] seg fields in struct _CONTEXT changed to USHORT and USHORT reserved added to keep the same alignment. ms ddk also used ULONG, but it is unforntunate since it may generate unneeded rt size conversions. I can't think any way the change could break anything so i considered the change a safe improvement. [ndk] include\ndk\extypes.h casts in EX_PUSH_LOCK_ defs removed, totally unneeded and undesirable. KGDT_ include\ndk\i386\asm.h removed parentheses in KGDT_ defs, totally unnecessary, and wrong, since depeding on the assembler they can be interpreted as memory addresses instead of immediate values. as was failing to interpret them correctly! [rtl] ROUND_ macros were giving redefinition warnings, as these were implemented differently in different includes added #ifndef block, changed the implemantation, (older used multiplication what's unnefficient), and eliminated unneeded and undesirable casts. #ifndef ROUND_DOWN #define ROUND_DOWN(n, align) \ (n & ~(align-1)) #define ROUND_UP(n, align) \ ((n + (align-1)) & ~(align-1)) #endif [ntos] declaration of KeInvalidateAllCaches lacked NTAPI, necessary since it's an export. The problem manifested only if not using stdcall as compiler default. * [crt] lib\sdk\crt2 - created lib\sdk\crt2, initially a copy of crt, to avoid breaking the current crt while testing changes. This is the one being linked in the msvc ntoskrnl. Many functions have been put in separate files, to avoid linkage of unused functions. A few of them have been improved. vsprintf was taken from the rtl. - currently contains at least all the functions needed and exported by ntoskrnl, some others are missing. * [crt] lib\rtl2 - created lib\rtl2, a copy of rtl, to avoid breaking current rtl while testing changes. - minor changes and some fix. Use diff to check changes, not big deal.
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: sir_richard
Date: Thu Feb 11 01:01:32 2010
New Revision: 45566
URL: http://svn.reactos.org/svn/reactos?rev=45566&view=rev
Log:
[NTOS]: Move more functions from the i386 ARM3 directory to the portable/shared directory, since they apply to all architectures.
[NTOS]: Refactor the mapping of the PTEs for the PFN database into MiMapPfnDatabase and move the code to portable directory.
[NTOS]: Move and refactor some other definitions, and make some numbers more portable by defining arch-specific subvalues.
[NTOS]: Make the PFN database actually 2 PFN Databases: MmPfnDatabase[0] which is the ReactOS mapping of PHYSICAL_PAGE structures, and MmPfnDatabase[1] which will be the ARM3 mapping of MMPFN structures. The latter is as-of-yet unused, but memory for it is now being reserved.
Modified:
trunk/reactos/ntoskrnl/include/internal/mm.h
trunk/reactos/ntoskrnl/mm/ARM3/i386/init.c
trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
trunk/reactos/ntoskrnl/mm/ARM3/mminit.c
trunk/reactos/ntoskrnl/mm/freelist.c
trunk/reactos/ntoskrnl/mm/mminit.c
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/mm.h?rev=45566&r1=45565&r2=45566&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Thu Feb 11 01:01:32 2010
@@ -365,7 +365,7 @@
} u4;
} MMPFN, *PMMPFN;
-extern PMMPFN MmPfnDatabase;
+extern PMMPFN MmPfnDatabase[2];
typedef struct _MMPFNLIST
{
@@ -1098,7 +1098,7 @@
if ((MiPfnBitMap.Buffer) && !(RtlTestBit(&MiPfnBitMap, Pfn))) return NULL;
/* Get the entry */
- Page = &MmPfnDatabase[Pfn];
+ Page = &MmPfnDatabase[0][Pfn];
/* Make sure it's valid */
ASSERT_PFN(Page);
@@ -1114,7 +1114,7 @@
//
// This will return the Page Frame Number (PFN) from the MMPFN
//
- return Pfn1 - MmPfnDatabase;
+ return Pfn1 - MmPfnDatabase[0];
}
PFN_TYPE
Modified: trunk/reactos/ntoskrnl/mm/ARM3/i386/init.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/i386/init.c?rev=45566&r1=45565&r2=45566&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/i386/init.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/i386/init.c [iso-8859-1] Thu Feb 11 01:01:32 2010
@@ -18,41 +18,9 @@
/* GLOBALS ********************************************************************/
-//
-// Before we have a PFN database, memory comes straight from our physical memory
-// blocks, which is nice because it's guaranteed contiguous and also because once
-// we take a page from here, the system doesn't see it anymore.
-// However, once the fun is over, those pages must be re-integrated back into
-// PFN society life, and that requires us keeping a copy of the original layout
-// so that we can parse it later.
-//
-PMEMORY_ALLOCATION_DESCRIPTOR MxFreeDescriptor;
-MEMORY_ALLOCATION_DESCRIPTOR MxOldFreeDescriptor;
-
/* Template PTE and PDE for a kernel page */
MMPTE ValidKernelPde = {.u.Hard.Valid = 1, .u.Hard.Write = 1, .u.Hard.Dirty = 1, .u.Hard.Accessed = 1};
MMPTE ValidKernelPte = {.u.Hard.Valid = 1, .u.Hard.Write = 1, .u.Hard.Dirty = 1, .u.Hard.Accessed = 1};
-
-/*
- * For each page's worth bytes of L2 cache in a given set/way line, the zero and
- * free lists are organized in what is called a "color".
- *
- * This array points to the two lists, so it can be thought of as a multi-dimensional
- * array of MmFreePagesByColor[2][MmSecondaryColors]. Since the number is dynamic,
- * we describe the array in pointer form instead.
- *
- * On a final note, the color tables themselves are right after the PFN database.
- */
-C_ASSERT(FreePageList == 1);
-PMMCOLOR_TABLES MmFreePagesByColor[FreePageList + 1];
-
-/* Make the code cleaner with some definitions for size multiples */
-#define _1KB (1024)
-#define _1MB (1000 * _1KB)
-
-/* Architecture specific size of a PDE directory, and size of a page table */
-#define PDE_SIZE (4096 * sizeof(MMPDE))
-#define PT_SIZE (1024 * sizeof(MMPTE))
/* PRIVATE FUNCTIONS **********************************************************/
@@ -171,109 +139,6 @@
}
}
-VOID
-NTAPI
-MiComputeColorInformation(VOID)
-{
- ULONG L2Associativity;
-
- /* Check if no setting was provided already */
- if (!MmSecondaryColors)
- {
- /* Get L2 cache information */
- L2Associativity = KeGetPcr()->SecondLevelCacheAssociativity;
-
- /* The number of colors is the number of cache bytes by set/way */
- MmSecondaryColors = KeGetPcr()->SecondLevelCacheSize;
- if (L2Associativity) MmSecondaryColors /= L2Associativity;
- }
-
- /* Now convert cache bytes into pages */
- MmSecondaryColors >>= PAGE_SHIFT;
- if (!MmSecondaryColors)
- {
- /* If there was no cache data from the KPCR, use the default colors */
- MmSecondaryColors = MI_SECONDARY_COLORS;
- }
- else
- {
- /* Otherwise, make sure there aren't too many colors */
- if (MmSecondaryColors > MI_MAX_SECONDARY_COLORS)
- {
- /* Set the maximum */
- MmSecondaryColors = MI_MAX_SECONDARY_COLORS;
- }
-
- /* Make sure there aren't too little colors */
- if (MmSecondaryColors < MI_MIN_SECONDARY_COLORS)
- {
- /* Set the default */
- MmSecondaryColors = MI_SECONDARY_COLORS;
- }
-
- /* Finally make sure the colors are a power of two */
- if (MmSecondaryColors & (MmSecondaryColors - 1))
- {
- /* Set the default */
- MmSecondaryColors = MI_SECONDARY_COLORS;
- }
- }
-
- /* Compute the mask and store it */
- MmSecondaryColorMask = MmSecondaryColors - 1;
- KeGetCurrentPrcb()->SecondaryColorMask = MmSecondaryColorMask;
-}
-
-VOID
-NTAPI
-MiInitializeColorTables(VOID)
-{
- ULONG i;
- PMMPTE PointerPte, LastPte;
- MMPTE TempPte = ValidKernelPte;
-
- /* The color table starts after the PFN database */
- MmFreePagesByColor[0] = (PMMCOLOR_TABLES)&MmPfnDatabase[MmHighestPhysicalPage + 1];
-
- /* Loop the PTEs. We have two color tables for each secondary color */
- PointerPte = MiAddressToPte(&MmFreePagesByColor[0][0]);
- LastPte = MiAddressToPte((ULONG_PTR)MmFreePagesByColor[0] +
- (2 * MmSecondaryColors * sizeof(MMCOLOR_TABLES))
- - 1);
- while (PointerPte <= LastPte)
- {
- /* Check for valid PTE */
- if (PointerPte->u.Hard.Valid == 0)
- {
- /* Get a page and map it */
- TempPte.u.Hard.PageFrameNumber = MxGetNextPage(1);
- ASSERT(TempPte.u.Hard.Valid == 1);
- *PointerPte = TempPte;
-
- /* Zero out the page */
- RtlZeroMemory(MiPteToAddress(PointerPte), PAGE_SIZE);
- }
-
- /* Next */
- PointerPte++;
- }
-
- /* Now set the address of the next list, right after this one */
- MmFreePagesByColor[1] = &MmFreePagesByColor[0][MmSecondaryColors];
-
- /* Now loop the lists to set them up */
- for (i = 0; i < MmSecondaryColors; i++)
- {
- /* Set both free and zero lists for each color */
- MmFreePagesByColor[ZeroedPageList][i].Flink = 0xFFFFFFFF;
- MmFreePagesByColor[ZeroedPageList][i].Blink = (PVOID)0xFFFFFFFF;
- MmFreePagesByColor[ZeroedPageList][i].Count = 0;
- MmFreePagesByColor[FreePageList][i].Flink = 0xFFFFFFFF;
- MmFreePagesByColor[FreePageList][i].Blink = (PVOID)0xFFFFFFFF;
- MmFreePagesByColor[FreePageList][i].Count = 0;
- }
-}
-
NTSTATUS
NTAPI
MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
@@ -286,7 +151,6 @@
MMPTE TempPde, TempPte;
PVOID NonPagedPoolExpansionVa;
ULONG OldCount;
- PFN_NUMBER FreePage, FreePageCount, PagesLeft, BasePage, PageCount;
/* Check for kernel stack size that's too big */
if (MmLargeStackSize > (KERNEL_LARGE_STACK_SIZE / _1KB))
@@ -436,10 +300,11 @@
MiComputeColorInformation();
//
- // Calculate the number of bytes for the PFN database, and the color tables,
- // and then convert to pages
+ // Calculate the number of bytes for the PFN database, double it for ARM3,
+ // then add the color tables and convert to pages
//
MxPfnAllocation = (MmHighestPhysicalPage + 1) * sizeof(MMPFN);
+ MxPfnAllocation <<= 1;
MxPfnAllocation += (MmSecondaryColors * sizeof(MMCOLOR_TABLES) * 2);
MxPfnAllocation >>= PAGE_SHIFT;
@@ -513,13 +378,19 @@
// with the old memory manager, so we'll create a "Shadow PFN Database"
// instead, and arbitrarly start it at 0xB0000000.
//
- MmPfnDatabase = (PVOID)0xB0000000;
- ASSERT(((ULONG_PTR)MmPfnDatabase & ((4 * 1024 * 1024) - 1)) == 0);
+ // We actually create two PFN databases, one for ReactOS starting here,
+ // and the next one used for ARM3, which starts right after. The MmPfnAllocation
+ // variable actually holds the size of both (the colored tables come after
+ // the ARM3 PFN database).
+ //
+ MmPfnDatabase[0] = (PVOID)0xB0000000;
+ MmPfnDatabase[1] = &MmPfnDatabase[0][MmHighestPhysicalPage];
+ ASSERT(((ULONG_PTR)MmPfnDatabase[0] & ((4 * 1024 * 1024) - 1)) == 0);
//
// Non paged pool comes after the PFN database
//
- MmNonPagedPoolStart = (PVOID)((ULONG_PTR)MmPfnDatabase +
+ MmNonPagedPoolStart = (PVOID)((ULONG_PTR)MmPfnDatabase[0] +
(MxPfnAllocation << PAGE_SHIFT));
//
@@ -567,7 +438,7 @@
//
// Now we need pages for the page tables which will map initial NP
//
- StartPde = MiAddressToPde(MmPfnDatabase);
+ StartPde = MiAddressToPde(MmPfnDatabase[0]);
EndPde = MiAddressToPde((PVOID)((ULONG_PTR)MmNonPagedPoolStart +
MmSizeOfNonPagedPoolInBytes - 1));
while (StartPde <= EndPde)
@@ -629,134 +500,16 @@
//
MiInitializeArmPool();
- //
- // Get current page data, since we won't be using MxGetNextPage as it
- // would corrupt our state
- //
- FreePage = MxFreeDescriptor->BasePage;
- FreePageCount = MxFreeDescriptor->PageCount;
- PagesLeft = 0;
-
- //
- // Loop the memory descriptors
- //
- NextEntry = KeLoaderBlock->MemoryDescriptorListHead.Flink;
- while (NextEntry != &KeLoaderBlock->MemoryDescriptorListHead)
- {
- //
- // Get the descriptor
- //
- MdBlock = CONTAINING_RECORD(NextEntry,
- MEMORY_ALLOCATION_DESCRIPTOR,
- ListEntry);
- if ((MdBlock->MemoryType == LoaderFirmwarePermanent) ||
- (MdBlock->MemoryType == LoaderBBTMemory) ||
- (MdBlock->MemoryType == LoaderSpecialMemory))
- {
- //
- // These pages are not part of the PFN database
- //
- NextEntry = MdBlock->ListEntry.Flink;
- continue;
- }
-
- //
- // Next, check if this is our special free descriptor we've found
- //
- if (MdBlock == MxFreeDescriptor)
- {
- //
- // Use the real numbers instead
- //
- BasePage = MxOldFreeDescriptor.BasePage;
- PageCount = MxOldFreeDescriptor.PageCount;
- }
- else
- {
- //
- // Use the descriptor's numbers
- //
- BasePage = MdBlock->BasePage;
- PageCount = MdBlock->PageCount;
- }
-
- //
- // Get the PTEs for this range
- //
- PointerPte = MiAddressToPte(&MmPfnDatabase[BasePage]);
- LastPte = MiAddressToPte(((ULONG_PTR)&MmPfnDatabase[BasePage + PageCount]) - 1);
- DPRINT("MD Type: %lx Base: %lx Count: %lx\n", MdBlock->MemoryType, BasePage, PageCount);
-
- //
- // Loop them
- //
- while (PointerPte <= LastPte)
- {
- //
- // We'll only touch PTEs that aren't already valid
- //
- if (PointerPte->u.Hard.Valid == 0)
- {
- //
- // Use the next free page
- //
- TempPte.u.Hard.PageFrameNumber = FreePage;
- ASSERT(FreePageCount != 0);
-
- //
- // Consume free pages
- //
- FreePage++;
- FreePageCount--;
- if (!FreePageCount)
- {
- //
- // Out of memory
- //
- KeBugCheckEx(INSTALL_MORE_MEMORY,
- MmNumberOfPhysicalPages,
- FreePageCount,
- MxOldFreeDescriptor.PageCount,
- 1);
- }
-
- //
- // Write out this PTE
- //
- PagesLeft++;
- ASSERT(PointerPte->u.Hard.Valid == 0);
- ASSERT(TempPte.u.Hard.Valid == 1);
- *PointerPte = TempPte;
-
- //
- // Zero this page
- //
- RtlZeroMemory(MiPteToAddress(PointerPte), PAGE_SIZE);
- }
-
- //
- // Next!
- //
- PointerPte++;
- }
-
- //
- // Do the next address range
- //
- NextEntry = MdBlock->ListEntry.Flink;
- }
-
- //
- // Now update the free descriptors to consume the pages we used up during
- // the PFN allocation loop
- //
- MxFreeDescriptor->BasePage = FreePage;
- MxFreeDescriptor->PageCount = FreePageCount;
+ /* Map the PFN database pages */
+ MiMapPfnDatabase(LoaderBlock);
/* Initialize the color tables */
MiInitializeColorTables();
-
- /* Call back into shitMM to setup the PFN database */
+
+ /* Build the PFN Database */
+ //MiInitializePfnDatabase(LoaderBlock);
+
+ /* Call back into shitMM to setup the ReactOS PFN database */
MmInitializePageList();
//
Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/miarm.h?rev=45566&r1=45565&r2=45566&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] Thu Feb 11 01:01:32 2010
@@ -38,6 +38,26 @@
#define MM_HIGHEST_VAD_ADDRESS \
(PVOID)((ULONG_PTR)MM_HIGHEST_USER_ADDRESS - (16 * PAGE_SIZE))
+/* 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 PT_SIZE (PTE_COUNT * sizeof(MMPTE))
+
+/* Architecture specific count of PDEs in a directory, and count of PTEs in a PT */
+#ifdef _M_IX86
+#define PD_COUNT 1
+#define PDE_COUNT 4096
+#define PTE_COUNT 1024
+#elif _M_ARM
+#define PD_COUNT 1
+#define PDE_COUNT 1024
+#define PTE_COUNT 256
+#else
+#error Define these please!
+#endif
//
// FIXFIX: These should go in ex.h after the pool merge
@@ -190,11 +210,10 @@
extern ULONG MmSecondaryColorMask;
extern ULONG MmNumberOfSystemPtes;
extern ULONG MmMaximumNonPagedPoolPercent;
-
-//
-// Actual (registry-configurable) size of a GUI thread's stack
-//
-ULONG MmLargeStackSize;
+extern ULONG MmLargeStackSize;
+
+#define MI_PFN_TO_PFNENTRY(x) (&MmPfnDatabase[1][x])
+#define MI_PFNENTRY_TO_PFN(x) (Pfn - &MmPfnDatabase[1])
NTSTATUS
NTAPI
@@ -206,6 +225,30 @@
NTSTATUS
NTAPI
MiInitMachineDependent(
+ IN PLOADER_PARAMETER_BLOCK LoaderBlock
+);
+
+VOID
+NTAPI
+MiComputeColorInformation(
+ VOID
+);
+
+VOID
+NTAPI
+MiMapPfnDatabase(
+ IN PLOADER_PARAMETER_BLOCK LoaderBlock
+);
+
+VOID
+NTAPI
+MiInitializeColorTables(
+ VOID
+);
+
+VOID
+NTAPI
+MiInitializePfnDatabase(
IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
Modified: trunk/reactos/ntoskrnl/mm/ARM3/mminit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/mminit.c?rev=45566&r1=45565&r2=45566&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/mminit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/mminit.c [iso-8859-1] Thu Feb 11 01:01:32 2010
@@ -234,6 +234,30 @@
//
ULONG MmLargeStackSize = KERNEL_LARGE_STACK_SIZE;
+//
+// Before we have a PFN database, memory comes straight from our physical memory
+// blocks, which is nice because it's guaranteed contiguous and also because once
+// we take a page from here, the system doesn't see it anymore.
+// However, once the fun is over, those pages must be re-integrated back into
+// PFN society life, and that requires us keeping a copy of the original layout
+// so that we can parse it later.
+//
+PMEMORY_ALLOCATION_DESCRIPTOR MxFreeDescriptor;
+MEMORY_ALLOCATION_DESCRIPTOR MxOldFreeDescriptor;
+
+/*
+ * For each page's worth bytes of L2 cache in a given set/way line, the zero and
+ * free lists are organized in what is called a "color".
+ *
+ * This array points to the two lists, so it can be thought of as a multi-dimensional
+ * array of MmFreePagesByColor[2][MmSecondaryColors]. Since the number is dynamic,
+ * we describe the array in pointer form instead.
+ *
+ * On a final note, the color tables themselves are right after the PFN database.
+ */
+C_ASSERT(FreePageList == 1);
+PMMCOLOR_TABLES MmFreePagesByColor[FreePageList + 1];
+
/* PRIVATE FUNCTIONS **********************************************************/
//
@@ -281,6 +305,264 @@
MxFreeDescriptor->BasePage += PageCount;
MxFreeDescriptor->PageCount -= PageCount;
return Pfn;
+}
+
+VOID
+NTAPI
+MiComputeColorInformation(VOID)
+{
+ ULONG L2Associativity;
+
+ /* Check if no setting was provided already */
+ if (!MmSecondaryColors)
+ {
+ /* Get L2 cache information */
+ L2Associativity = KeGetPcr()->SecondLevelCacheAssociativity;
+
+ /* The number of colors is the number of cache bytes by set/way */
+ MmSecondaryColors = KeGetPcr()->SecondLevelCacheSize;
+ if (L2Associativity) MmSecondaryColors /= L2Associativity;
+ }
+
+ /* Now convert cache bytes into pages */
+ MmSecondaryColors >>= PAGE_SHIFT;
+ if (!MmSecondaryColors)
+ {
+ /* If there was no cache data from the KPCR, use the default colors */
+ MmSecondaryColors = MI_SECONDARY_COLORS;
+ }
+ else
+ {
+ /* Otherwise, make sure there aren't too many colors */
+ if (MmSecondaryColors > MI_MAX_SECONDARY_COLORS)
+ {
+ /* Set the maximum */
+ MmSecondaryColors = MI_MAX_SECONDARY_COLORS;
+ }
+
+ /* Make sure there aren't too little colors */
+ if (MmSecondaryColors < MI_MIN_SECONDARY_COLORS)
+ {
+ /* Set the default */
+ MmSecondaryColors = MI_SECONDARY_COLORS;
+ }
+
+ /* Finally make sure the colors are a power of two */
+ if (MmSecondaryColors & (MmSecondaryColors - 1))
+ {
+ /* Set the default */
+ MmSecondaryColors = MI_SECONDARY_COLORS;
+ }
+ }
+
+ /* Compute the mask and store it */
+ MmSecondaryColorMask = MmSecondaryColors - 1;
+ KeGetCurrentPrcb()->SecondaryColorMask = MmSecondaryColorMask;
+}
+
+VOID
+NTAPI
+MiInitializeColorTables(VOID)
+{
+ ULONG i;
+ PMMPTE PointerPte, LastPte;
+ MMPTE TempPte = ValidKernelPte;
+
+ /* The color table starts after the ARM3 PFN database */
+ MmFreePagesByColor[0] = (PMMCOLOR_TABLES)&MmPfnDatabase[1][MmHighestPhysicalPage + 1];
+
+ /* Loop the PTEs. We have two color tables for each secondary color */
+ PointerPte = MiAddressToPte(&MmFreePagesByColor[0][0]);
+ LastPte = MiAddressToPte((ULONG_PTR)MmFreePagesByColor[0] +
+ (2 * MmSecondaryColors * sizeof(MMCOLOR_TABLES))
+ - 1);
+ while (PointerPte <= LastPte)
+ {
+ /* Check for valid PTE */
+ if (PointerPte->u.Hard.Valid == 0)
+ {
+ /* Get a page and map it */
+ TempPte.u.Hard.PageFrameNumber = MxGetNextPage(1);
+ ASSERT(TempPte.u.Hard.Valid == 1);
+ *PointerPte = TempPte;
+
+ /* Zero out the page */
+ RtlZeroMemory(MiPteToAddress(PointerPte), PAGE_SIZE);
+ }
+
+ /* Next */
+ PointerPte++;
+ }
+
+ /* Now set the address of the next list, right after this one */
+ MmFreePagesByColor[1] = &MmFreePagesByColor[0][MmSecondaryColors];
+
+ /* Now loop the lists to set them up */
+ for (i = 0; i < MmSecondaryColors; i++)
+ {
+ /* Set both free and zero lists for each color */
+ MmFreePagesByColor[ZeroedPageList][i].Flink = 0xFFFFFFFF;
+ MmFreePagesByColor[ZeroedPageList][i].Blink = (PVOID)0xFFFFFFFF;
+ MmFreePagesByColor[ZeroedPageList][i].Count = 0;
+ MmFreePagesByColor[FreePageList][i].Flink = 0xFFFFFFFF;
+ MmFreePagesByColor[FreePageList][i].Blink = (PVOID)0xFFFFFFFF;
+ MmFreePagesByColor[FreePageList][i].Count = 0;
+ }
+}
+
+BOOLEAN
+NTAPI
+MiIsRegularMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
+ IN PFN_NUMBER Pfn)
+{
+ PLIST_ENTRY NextEntry;
+ PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
+
+ /* Loop the memory descriptors */
+ NextEntry = LoaderBlock->MemoryDescriptorListHead.Flink;
+ while (NextEntry != &LoaderBlock->MemoryDescriptorListHead)
+ {
+ /* Get the memory descriptor */
+ MdBlock = CONTAINING_RECORD(NextEntry,
+ MEMORY_ALLOCATION_DESCRIPTOR,
+ ListEntry);
+
+ /* Check if this PFN could be part of the block */
+ if (Pfn >= (MdBlock->BasePage))
+ {
+ /* Check if it really is part of the block */
+ if (Pfn < (MdBlock->BasePage + MdBlock->PageCount))
+ {
+ /* Check if the block is actually memory we don't map */
+ if ((MdBlock->MemoryType == LoaderFirmwarePermanent) ||
+ (MdBlock->MemoryType == LoaderBBTMemory) ||
+ (MdBlock->MemoryType == LoaderSpecialMemory))
+ {
+ /* We don't need PFN database entries for this memory */
+ break;
+ }
+
+ /* This is memory we want to map */
+ return TRUE;
+ }
+ }
+ else
+ {
+ /* Blocks are ordered, so if it's not here, it doesn't exist */
+ break;
+ }
+
+ /* Get to the next descriptor */
+ NextEntry = MdBlock->ListEntry.Flink;
+ }
+
+ /* Check if this PFN is actually from our free memory descriptor */
+ if ((Pfn >= MxOldFreeDescriptor.BasePage) &&
+ (Pfn < MxOldFreeDescriptor.BasePage + MxOldFreeDescriptor.PageCount))
+ {
+ /* We use these pages for initial mappings, so we do want to count them */
+ return TRUE;
+ }
+
+ /* Otherwise this isn't memory that we describe or care about */
+ return FALSE;
+}
+
+VOID
+NTAPI
+MiMapPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+ ULONG FreePage, FreePageCount, PagesLeft, BasePage, PageCount;
+ PLIST_ENTRY NextEntry;
+ PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
+ PMMPTE PointerPte, LastPte;
+ MMPTE TempPte = ValidKernelPte;
+
+ /* Get current page data, since we won't be using MxGetNextPage as it would corrupt our state */
+ FreePage = MxFreeDescriptor->BasePage;
+ FreePageCount = MxFreeDescriptor->PageCount;
+ PagesLeft = 0;
+
+ /* Loop the memory descriptors */
+ NextEntry = LoaderBlock->MemoryDescriptorListHead.Flink;
+ while (NextEntry != &LoaderBlock->MemoryDescriptorListHead)
+ {
+ /* Get the descriptor */
+ MdBlock = CONTAINING_RECORD(NextEntry,
+ MEMORY_ALLOCATION_DESCRIPTOR,
+ ListEntry);
+ if ((MdBlock->MemoryType == LoaderFirmwarePermanent) ||
+ (MdBlock->MemoryType == LoaderBBTMemory) ||
+ (MdBlock->MemoryType == LoaderSpecialMemory))
+ {
+ /* These pages are not part of the PFN database */
+ NextEntry = MdBlock->ListEntry.Flink;
+ continue;
+ }
+
+ /* Next, check if this is our special free descriptor we've found */
+ if (MdBlock == MxFreeDescriptor)
+ {
+ /* Use the real numbers instead */
+ BasePage = MxOldFreeDescriptor.BasePage;
+ PageCount = MxOldFreeDescriptor.PageCount;
+ }
+ else
+ {
+ /* Use the descriptor's numbers */
+ BasePage = MdBlock->BasePage;
+ PageCount = MdBlock->PageCount;
+ }
+
+ /* Get the PTEs for this range */
+ PointerPte = MiAddressToPte(&MmPfnDatabase[0][BasePage]);
+ LastPte = MiAddressToPte(((ULONG_PTR)&MmPfnDatabase[0][BasePage + PageCount]) - 1);
+ DPRINT("MD Type: %lx Base: %lx Count: %lx\n", MdBlock->MemoryType, BasePage, PageCount);
+
+ /* Loop them */
+ while (PointerPte <= LastPte)
+ {
+ /* We'll only touch PTEs that aren't already valid */
+ if (PointerPte->u.Hard.Valid == 0)
+ {
+ /* Use the next free page */
+ TempPte.u.Hard.PageFrameNumber = FreePage;
+ ASSERT(FreePageCount != 0);
+
+ /* Consume free pages */
+ FreePage++;
+ FreePageCount--;
+ if (!FreePageCount)
+ {
+ /* Out of memory */
+ KeBugCheckEx(INSTALL_MORE_MEMORY,
+ MmNumberOfPhysicalPages,
+ FreePageCount,
+ MxOldFreeDescriptor.PageCount,
+ 1);
+ }
+
+ /* Write out this PTE */
+ PagesLeft++;
+ ASSERT(PointerPte->u.Hard.Valid == 0);
+ ASSERT(TempPte.u.Hard.Valid == 1);
+ *PointerPte = TempPte;
+
+ /* Zero this page */
+ RtlZeroMemory(MiPteToAddress(PointerPte), PAGE_SIZE);
+ }
+
+ /* Next! */
+ PointerPte++;
+ }
+
+ /* Do the next address range */
+ NextEntry = MdBlock->ListEntry.Flink;
+ }
+
+ /* Now update the free descriptors to consume the pages we used up during the PFN allocation loop */
+ MxFreeDescriptor->BasePage = FreePage;
+ MxFreeDescriptor->PageCount = FreePageCount;
}
PFN_NUMBER
@@ -788,7 +1070,7 @@
// Sync us up with ReactOS Mm
//
MiSyncARM3WithROS(MmNonPagedSystemStart, (PVOID)((ULONG_PTR)MmNonPagedPoolEnd - 1));
- MiSyncARM3WithROS(MmPfnDatabase, (PVOID)((ULONG_PTR)MmNonPagedPoolStart + MmSizeOfNonPagedPoolInBytes - 1));
+ MiSyncARM3WithROS(MmPfnDatabase[0], (PVOID)((ULONG_PTR)MmNonPagedPoolStart + MmSizeOfNonPagedPoolInBytes - 1));
MiSyncARM3WithROS((PVOID)HYPER_SPACE, (PVOID)(HYPER_SPACE + PAGE_SIZE - 1));
//
Modified: trunk/reactos/ntoskrnl/mm/freelist.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/freelist.c?rev=45566&r1=45565&r2=45566&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/freelist.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/freelist.c [iso-8859-1] Thu Feb 11 01:01:32 2010
@@ -48,7 +48,8 @@
#define PHYSICAL_PAGE MMPFN
#define PPHYSICAL_PAGE PMMPFN
-PPHYSICAL_PAGE MmPfnDatabase;
+/* The first array contains ReactOS PFNs, the second contains ARM3 PFNs */
+PPHYSICAL_PAGE MmPfnDatabase[2];
ULONG MmAvailablePages;
ULONG MmResidentAvailablePages;
@@ -59,7 +60,7 @@
SIZE_T MmDriverCommit;
SIZE_T MmProcessCommit;
SIZE_T MmPagedPoolCommit;
-SIZE_T MmPeakCommitment;
+SIZE_T MmPeakCommitment;
SIZE_T MmtotalCommitLimitMaximum;
MMPFNLIST MmZeroedPageListHead;
@@ -101,7 +102,7 @@
PageDescriptor = CONTAINING_RECORD(NextListEntry, PHYSICAL_PAGE, ListEntry);
ASSERT_PFN(PageDescriptor);
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
- return PageDescriptor - MmPfnDatabase;
+ return PageDescriptor - MmPfnDatabase[0];
}
VOID
@@ -142,7 +143,7 @@
}
PageDescriptor = CONTAINING_RECORD(NextListEntry, PHYSICAL_PAGE, ListEntry);
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
- return PageDescriptor - MmPfnDatabase;
+ return PageDescriptor - MmPfnDatabase[0];
}
VOID
@@ -758,9 +759,9 @@
for (i = 0; i < Md->PageCount; i++)
{
/* Mark it as a free page */
- MmPfnDatabase[Md->BasePage + i].Flags.Type = MM_PHYSICAL_PAGE_FREE;
+ MmPfnDatabase[0][Md->BasePage + i].Flags.Type = MM_PHYSICAL_PAGE_FREE;
InsertTailList(&FreeUnzeroedPageListHead,
- &MmPfnDatabase[Md->BasePage + i].ListEntry);
+ &MmPfnDatabase[0][Md->BasePage + i].ListEntry);
UnzeroedPageCount++;
MmAvailablePages++;
}
@@ -771,7 +772,7 @@
for (i = 0; i < Md->PageCount; i++)
{
/* Everything else is used memory */
- MmPfnDatabase[Md->BasePage + i] = UsedPage;
+ MmPfnDatabase[0][Md->BasePage + i] = UsedPage;
NrSystemPages++;
}
}
@@ -781,10 +782,10 @@
for (i = MxOldFreeDescriptor.BasePage; i < MxFreeDescriptor->BasePage; i++)
{
/* Ensure this page was not added previously */
- ASSERT(MmPfnDatabase[i].Flags.Type == 0);
+ ASSERT(MmPfnDatabase[0][i].Flags.Type == 0);
/* Mark it as used kernel memory */
- MmPfnDatabase[i] = UsedPage;
+ MmPfnDatabase[0][i] = UsedPage;
NrSystemPages++;
}
@@ -1082,7 +1083,7 @@
MmAvailablePages--;
- PfnOffset = PageDescriptor - MmPfnDatabase;
+ PfnOffset = PageDescriptor - MmPfnDatabase[0];
if ((NeedClear) && (Consumer != MC_SYSTEM))
{
MiZeroPage(PfnOffset);
@@ -1155,7 +1156,7 @@
/* We set the page to used, because MmCreateVirtualMapping failed with unused pages */
PageDescriptor->Flags.Type = MM_PHYSICAL_PAGE_USED;
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
- Pfn = PageDescriptor - MmPfnDatabase;
+ Pfn = PageDescriptor - MmPfnDatabase[0];
Status = MiZeroPage(Pfn);
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
Modified: trunk/reactos/ntoskrnl/mm/mminit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mminit.c?rev=45566&r1=45565&r2=45566&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/mminit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/mminit.c [iso-8859-1] Thu Feb 11 01:01:32 2010
@@ -109,7 +109,7 @@
//
// Protect the PFN database
//
- BaseAddress = MmPfnDatabase;
+ BaseAddress = MmPfnDatabase[0];
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
&BaseAddress,
@@ -292,8 +292,8 @@
(ULONG_PTR)MmPagedPoolBase + MmPagedPoolSize,
"Paged Pool");
DPRINT1(" 0x%p - 0x%p\t%s\n",
- MmPfnDatabase,
- (ULONG_PTR)MmPfnDatabase + (MxPfnAllocation << PAGE_SHIFT),
+ MmPfnDatabase[0],
+ (ULONG_PTR)MmPfnDatabase[0] + (MxPfnAllocation << PAGE_SHIFT),
"PFN Database");
DPRINT1(" 0x%p - 0x%p\t%s\n",
MmNonPagedPoolStart,
- Previous message: [ros-diffs] [tkreuzer] 45565: [REACTOS] Add asm.h containing macros to make assembly code both GAS and ML compatible at the same time. [NTOS/HAL] Move trap entry points from C into a GAS/ML compatile assembly file (might need fine tuning for ML). The entries are generated by a shared assembly macro TRAP_ENTRY. Removed KiTrapStub, KiIsV8086TrapSafe, KiIsUserTrapSafe, KiSetSaneSegments, removed segment handling from KiEnter*Trap. [NTOS] Make KiFastCallEntryHandler and KiSystemServiceHandler FASTCALL and pass the systemcall number in TrapFrame->Eax [HAL] Use _setjmp/longjmp instead of saving a trapframe in HalpBiosCall
- Next message: [ros-diffs] [jcatena] 45567: 20100210 [branch regression] revert branch to 44678 - the msvc port based in 45263 (including new traps etc) is booting to desktop, but contains many hacks and require cleanup. For example new hal initialization enables the timer interrupt before setting the vector, while ntos had a vector to unexpected interrupt -> bugcheck. It is a miracle that trunk boots, just depending that no timer int happens since the int enable to the vector init in a later phase. I'm not building hal yet, so for now I added in ntos the timer interrupt stub that calls KeUpdateSystemTime in a test file. I'll need some time to clean those hacks properly, so I decided to revert to 44678, and later update stuff orderly and in a proper way. Also the new stuff from Sir Richard is WIP and it is being a huge waste of time for me fixing it before it is finished. Anyway while fixing it i made vast improvements to trap, interrupt and mainly syscall handling, so i intend to commit it later. - 44678 is previous to freeldr and hal changes, it needs those from 0.3.11 relase or builds previous to 44678 (probably it is compatible with those until 44900 or so). - The change log for this submit is very long, because it contains everything done fom trunk 44678 to a bootable msvc build of ntoskrnl. An effort has been made to fix incompatibilities in proper ways, improving general portability of the whole system instead of adding unnecessary compiler dependent conditionals spreaded through the sources. Now most of these conditional compilation are replaced by the definitions in a very small set of compiler and platform dependent includes, placed at include\platf. Thanks to this further ports will be greatly simplified, and code is much cleaner. [ntos] msvc projects - added msvc projects, .vcproj and .vsprops files for ntoskrnl and kddll, and libraries used by these. - different sections of ntoskrnl are built as libraries to ease separate testing of updates. It is just how the vcprojs are made, it does not change the tree structure or source files. - msvc projects use forced *_bld.h includes to eliminate the need of changes in the sources as much as possible. - The root.vsprops file sets root properties for all projects. Here you have to set the ros and objrbe macros to match the root path for reactos source tree. objrbe is explained below. - ntoskrnl uses files are autogenerated, for now i'm using those generated by rosbe. Since they are autogerated, i am not commiting them, but are necessary to build. root.vsprops defines the objrbe macro as .\obj_rosbe. you may do either: a) create a .\obj_rosbe junction pointing to where you have the rosbe's object dir. b) redefine the objrbe macro to point to the rosbe's object dir. c) copy the required autogenerated files there from rosbe's object dir. These are: .\include\ .\ntoskrnl\include\ .\ntoskrnl\ex\zw.s - currently the autogenerated zw.s file is not assembled correctly by the as rule, because $KGDT_R0_CODE is not changed to $8 by the preprocessor. So for now i copied it to ntoskrnl\ex\i386, edited it, and added for commit. I'll try to find how to change the as rule so that it behaves as when using gcc as preprocessor. If someone has a better idea... It is the only file that the as rule doesn't assemble well untouched. - The import libraries are searched in libobj\ros first and then in libobj\ms (check the root properties). I have there the rosbe built libraries renamed to .lib. Only hal.lib and bootvid.lib are required. But because ntos imports kdcom and kdcom imports ntoskrnl, intitially you need also one of these two libs there, although the generated ones will take precedence after building the first time, the result of the first link may not be good if the import lib used is not right, but the generated import libs can then be used to link correctly. I also tested linking with ms libs without trouble, (that's why libobj\ms is there), but none from ms is required. - A new folder ntoskrnl\kdw1 contains the kd64 debugger, the one compatible with ms debuggers like windbg. This is a provisional location, basically a copy of kd64 which i didn't want to break during testing. It is working. Now it is a static library, so that the desired debugger can be selected at link time, but could also be built as dll to make it selectable at run time. I'm not motivated to to sync builds of kdbg and dbg, and until a decission is made about this idea of isolating the different debuggers is made or its integration in trunk or any other request, i'll keep it in this location. * [tools] rules files Rules files for msvc added in tools/msvc, adding support for as and nasm. The one to support masm is copied from msvc. * [global] platform abstraction includes - created dir include/platf with includes providing abstraction of compiler- specific directives and platform-specific low level basics. - platf.h has the abstraction for compiler-specific directives and is intended to be inclued in every c project or file before crt, sdk, etc. Some have psdk equivalents, code should use psdk definitions in those cases, while psdk, ddk and crt will define theirs based in platf.h instead of compiler-specific directives. There are separate versions of this file under the msc and gnuc subdirs. The gnuc one is currently untested. - cpu.h has low level definitions for the cpu, and cpu_c.h has the compiler dependent part, intended to replace common inline assempler in conditional blocks. Some of the funtions are equivalent to intrinsics and are just defines for them, while many others are inline or macro implementations for required functions that are not available as intrinsics and were prevously implemented as inline assemply spreaded along the kernel and hal sources. cpu_c.h under msc is complete and tested, the version under gnuc needs to be completed and tested. The defs that have equivalents as intrinsics are there for consistency and convenience, and keep in mind that different compilers may have different intrinsics, and it's better to write a cpu_c.h for a new compiler than having to add inline assembly everywhere... These are used in kernel and driver modules. - utl.h contains some general purpose utility macros. - intrin.h for each compiler contains the intrinsics definitions. For the intrinsics the naming of those of msvc are used, since these are what are used by the ms sdks. For example sdk defines InterlockXX _InterlockXX. inting.h declares, defines or implements these _xx. Currently i have there some that was causing problems, but i will complete it so that sdk and ddk can completely rely in _xx intrinsics being available or defined to define theirs, so eliminating also compiler and platform dependency in the sdks. After fixing a few, everything works, but these defs are a mess, the sdk has implementations for some available as intrinsics, others are lacking or incorrect for some platform. etc. I will be fixing that mess by defining all those based in the compiler and platform specific intrin.h, so the sdks will be much cleaner and portable. - Many occurences of inline assembly inside conditional blocks, where very often the msc part was wrong, and compiler specific directives, have been replaced by instances of the macros defined in these includes. Many in ke\i386\cpu.c but also many others spread among many files. * [ntos] DbgPrint improvements - DbgPrint support moved to ntoskrnl/dbg. - DbgPrint now uses a function pointer to the actual handler, so that it can be changed as necessary in different phases or by the kernel debuggers. The initial DbgPrint handler in ser1.c is a very simple one that writes directly to the com port, allowing early and transparent debug logging right at KiSystemStartup. When enough of the system has been initialized, the pointer is changed to the right handler. The debuggers can also change the pointer to their own handlers, improving debugger module isolation. Note that ser1 assumes that there is a com1 (@0x3f8) present. If this is not the case #define EARLY_DEBUG_PORT 0. If DBG is 0 it won't be used as well. I could add port presence detection very easily, but i don't think it necessary. Let me know otherwise. I use windbg in com2 through named pipe in vmware, and works nicely. Currently the initial mapping to ser1 is not changed later, i have yet to change the pointer when appropiate during the boot, so if the debugger is not activated all DbgPrint output is always handled by ser1, and if the debugger is activated output from kernel goes to com1 and from user to windbg, not a big problem anyway. * [sdk] sdks fixes - some defs like #define NTKERNELAPI DECLSPEC_IMPORT has been made conditional as #ifndef NTKERNELAPI #define NTKERNELAPI DECLSPEC_IMPORT #endif Obviously original ms ones were not intended to build ntoskrnl, but we do so we need to define NTKERNELAPI as empty (or dllexport) when building ntoskrnl, for sdk compatibility. - FAST_MUTEX.Gate changed to FAST_MUTEX.Event, as in ms sdks, for sdk compatibility. - KIPCR.Tib changed to KIPCR.NtTib, as in ms sdks, for sdk compatibility. - KIPCR.Self changed to KIPCR.SelfPcr, as in ms sdks. Actually, i copied the KPCR def from ms, since it coincided but was more complete with an union and better documented. Changed some argument types to match ms definitions. In every case the type is compatible, so the change is safe. Eliminated some warnings. NTSYSAPI ULONG NTAPI vDbgPrintExWithPrefix(PCCH Prefix, ULONG ComponentId, ULONG Level, PCCH Format, va_list arglist); NTSYSAPI ULONG NTAPI vDbgPrintEx(ULONG ComponentId, ULONG Level, PCCH Format, va_list arglist); ULONG _CDECL DbgPrint(PCSTR Format, ...); NTSYSAPI ULONG _CDECL DbgPrintEx(ULONG ComponentId, ULONG Level, PCSTR Format, ...); NTSYSAPI ULONG _CDECL DbgPrintReturnControlC(PCCH Format, ...); NTSYSAPI NTSTATUS NTAPI DbgQueryDebugFilterState(ULONG ComponentId, ULONG Level); NTSYSAPI NTSTATUS NTAPI DbgSetDebugFilterState(ULONG ComponentId, ULONG Level, BOOLEAN State); * [ntos] added lacking global ntoskrnl\cc\cacheman.c BOOLEAN CcPfEnablePrefetcher = 0; * [ntos] ntoskrnl\ex\work.c: Int32x32To64 with all constant arguments is silly, let the compiler do it instead of invoking a runtime multiplication. * [ntos] ntoskrnl\ke\dpc.c FIXME: KiTimerExpiration causes a crash if global optimization (MSVC9) difficult to trace, it works most times, but sometimes make a called dpc routine crash. Added _OPTIMIZE_OFF_GLOBAL and _OPTIMIZE_DFT before and after the function. _OPTIMIZE macros are defined in platf.h, appropiately in msc version and empty in the gnuc one. * [ntos] ntoskrnl\ke\freeldr.c KERNEL_DESCRIPTOR_PAGE macro bug fix // #define KERNEL_DESCRIPTOR_PAGE(x) (((ULONG_PTR)x &~ KSEG0_BASE) >> PAGE_SHIFT) #define KERNEL_DESCRIPTOR_PAGE(x) ( ( (ULONG_PTR)x > KSEG0_BASE ? ((ULONG_PTR)x-KSEG0_BASE) : (ULONG_PTR)x) >> PAGE_SHIFT) * [ntos] TSS needs alignment changed globals definition order _ALIGN(0x80) KTSS KiBootTss; _ALIGN is appropiately defined in platf.h for msc and gnuc * [ntos] mm/arm3 #line 15 in removed in all files These play havoc with msvc and ultracompare. I don't think they are necessary in any case so i removed them. If there is a good reason to have them, plz put them in #ifdef ARM block, or much better, define a macro in the platf.h for arm * [ntos] ntoskrnl\ps\win32.c PsConvertToGuiThread calls KeSwitchKernelStack, which changes the stack and ebp added _OPTIMIZE_OFF_STKF and _OPTIMIZE_DFT before and after the fn, so it works regardless of the optimizations chosen. * [rtl] GetGlobalFlags GetVersion moved to separate files so that are only linked if actually used. * [ntos] ntoskrnl\include\internal\ke_x.h KeGetPreviousMode Changed to macro without outer cast. Don't use wrong cast or inline return type, it is unnecessary and can generate unnecessary rt conversion. * [ntos] use section macros in platf.h instead of compiler specific directives defs of PLACE_IN_SECTION, INIT_FUNCTION, PAGE_LOCKED_FUNCTION, PAGE_UNLOCKED_FUNCTION removed and refereces changed to macros based in platf.h that are suitable for both gnuc and msc, unlike the previous ones that couldn't be defined for msc coz it needs the function name and is used only in definition, not in declaration. * [ntos] msc part in intrin_i.h removed cpu_c.h contains everything intrin_i had, and much more it didn't. gcc doesn't need it either if cpu_c.h is included instead, so this file should dissapear. * [ntos] PETHREAD and PEPROCESS ambiguity ddk may define PETHREAD as KTHREAD * or ETHREAD * depending on what specific includes are used. To avoid the ambiguity i replaced in some places PETHREAD for ETHREAD *, and so removing the need of previous recast hacks. The ambiguity is also in ms ddk, so i don't think we should change it, but be aware of the ambiguity and use * instead of the pointer type to avoid mistakes. [ddk] #define KERNEL_STACK_SIZE this has been put inside an #ifndef KERNEL_STACK_SIZE block we may need to increase the default stack size, i did, since i detected occasional crashes debugging boot due to insufficient stack. [ddk] seg fields in struct _CONTEXT changed to USHORT and USHORT reserved added to keep the same alignment. ms ddk also used ULONG, but it is unforntunate since it may generate unneeded rt size conversions. I can't think any way the change could break anything so i considered the change a safe improvement. [ndk] include\ndk\extypes.h casts in EX_PUSH_LOCK_ defs removed, totally unneeded and undesirable. KGDT_ include\ndk\i386\asm.h removed parentheses in KGDT_ defs, totally unnecessary, and wrong, since depeding on the assembler they can be interpreted as memory addresses instead of immediate values. as was failing to interpret them correctly! [rtl] ROUND_ macros were giving redefinition warnings, as these were implemented differently in different includes added #ifndef block, changed the implemantation, (older used multiplication what's unnefficient), and eliminated unneeded and undesirable casts. #ifndef ROUND_DOWN #define ROUND_DOWN(n, align) \ (n & ~(align-1)) #define ROUND_UP(n, align) \ ((n + (align-1)) & ~(align-1)) #endif [ntos] declaration of KeInvalidateAllCaches lacked NTAPI, necessary since it's an export. The problem manifested only if not using stdcall as compiler default. * [crt] lib\sdk\crt2 - created lib\sdk\crt2, initially a copy of crt, to avoid breaking the current crt while testing changes. This is the one being linked in the msvc ntoskrnl. Many functions have been put in separate files, to avoid linkage of unused functions. A few of them have been improved. vsprintf was taken from the rtl. - currently contains at least all the functions needed and exported by ntoskrnl, some others are missing. * [crt] lib\rtl2 - created lib\rtl2, a copy of rtl, to avoid breaking current rtl while testing changes. - minor changes and some fix. Use diff to check changes, not big deal.
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Ros-diffs
mailing list