Author: ion
Date: Fri Mar 2 09:01:07 2007
New Revision: 25941
URL:
http://svn.reactos.org/svn/reactos?rev=25941&view=rev
Log:
- Create PDE/PTE entries for KUSER_SHARED_DATA in FreeLDR, so that MmInit1 isn't
needed to access it.
- This allows us to access SharedUserData much earlier in the kernel, as well as in kdcom,
which means the Windows/TinyKRNL version should now work without modification.
Modified:
trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c
trunk/reactos/boot/freeldr/freeldr/arch/i386/mb.S
trunk/reactos/boot/freeldr/freeldr/include/reactos.h
trunk/reactos/ntoskrnl/ke/i386/kiinit.c
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c Fri Mar 2 09:01:07 2007
@@ -40,9 +40,10 @@
extern PAGE_DIRECTORY_X86 startup_pagedirectory;
extern PAGE_DIRECTORY_X86 lowmem_pagetable;
extern PAGE_DIRECTORY_X86 kernel_pagetable;
-extern ULONG_PTR hyperspace_pagetable;
+extern PAGE_DIRECTORY_X86 hyperspace_pagetable;
extern PAGE_DIRECTORY_X86 apic_pagetable;
extern PAGE_DIRECTORY_X86 kpcr_pagetable;
+extern PAGE_DIRECTORY_X86 kuser_pagetable;
PVOID
NTAPI
@@ -183,6 +184,11 @@
PageDir->Pde[KpcrPageTableIndex].Valid = 1;
PageDir->Pde[KpcrPageTableIndex].Write = 1;
PageDir->Pde[KpcrPageTableIndex].PageFrameNumber = PaPtrToPfn(kpcr_pagetable);
+
+ /* Set up the KUSER PDE */
+ PageDir->Pde[KuserPageTableIndex].Valid = 1;
+ PageDir->Pde[KuserPageTableIndex].Write = 1;
+ PageDir->Pde[KuserPageTableIndex].PageFrameNumber = PaPtrToPfn(kuser_pagetable);
/* Set up Low Memory PTEs */
PageDir = (PPAGE_DIRECTORY_X86)&lowmem_pagetable;
@@ -221,6 +227,17 @@
PageDir->Pde[0].Valid = 1;
PageDir->Pde[0].Write = 1;
PageDir->Pde[0].PageFrameNumber = 1;
+
+ /* Setup KUSER PTEs */
+ PageDir = (PPAGE_DIRECTORY_X86)&kuser_pagetable;
+ for (i = 0; i < 1024; i++)
+ {
+ /* SEetup each entry */
+ PageDir->Pde[i].Valid = 1;
+ PageDir->Pde[i].Write = 1;
+ PageDir->Pde[i].Owner = 1;
+ PageDir->Pde[i].PageFrameNumber = PaToPfn(KI_USER_SHARED_DATA + i *
PAGE_SIZE);
+ }
}
PLOADER_MODULE
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/mb.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/mb.S (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/mb.S Fri Mar 2 09:01:07 2007
@@ -37,15 +37,8 @@
.globl _hyperspace_pagetable
.globl _apic_pagetable
.globl _kpcr_pagetable
+ .globl _kuser_pagetable
- .globl _startup_pagedirectorytable_pae
- .globl _startup_pagedirectory_pae
- .globl _lowmem_pagetable_pae
- .globl _kernel_pagetable_pae
- .globl _hyperspace_pagetable_pae
- .globl _apic_pagetable_pae
- .globl _kpcr_pagetable_pae
-
.globl _PageDirectoryEnd
//
@@ -80,24 +73,7 @@
_kpcr_pagetable:
.fill 4096, 1, 0
-_startup_pagedirectory_pae:
- .fill 4 * 4096, 1, 0
+_kuser_pagetable:
+ .fill 4096, 1, 0
-_lowmem_pagetable_pae:
- .fill 2 * 4096, 1, 0
-
-_kernel_pagetable_pae:
- .fill 3*4096, 1, 0
-
-_hyperspace_pagetable_pae:
- .fill 2*4096, 1, 0
-
-_apic_pagetable_pae:
- .fill 2*4096, 1, 0
-
-_kpcr_pagetable_pae:
- .fill 4*4096, 1, 0
-
-_startup_pagedirectorytable_pae:
- .fill 4096, 1, 0
_PageDirectoryEnd:
Modified: trunk/reactos/boot/freeldr/freeldr/include/reactos.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/reactos.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/reactos.h Fri Mar 2 09:01:07 2007
@@ -53,6 +53,7 @@
#define HyperspacePageTableIndex (HYPERSPACE_BASE >> 22)
#define KpcrPageTableIndex (KPCR_BASE >> 22)
#define ApicPageTableIndex (APIC_BASE >> 22)
+#define KuserPageTableIndex (KI_USER_SHARED_DATA >> 22)
#define KernelEntryPoint (KernelEntry - KERNEL_BASE_PHYS) + KernelBase
Modified: trunk/reactos/ntoskrnl/ke/i386/kiinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/kiinit.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/kiinit.c (original)
+++ trunk/reactos/ntoskrnl/ke/i386/kiinit.c Fri Mar 2 09:01:07 2007
@@ -381,7 +381,6 @@
ULONG FeatureBits;
LARGE_INTEGER PageDirectory;
PVOID DpcStack;
- ULONG NXSupportPolicy;
ULONG Vendor[3];
/* Detect and set the CPU Type */
@@ -403,19 +402,19 @@
FeatureBits = KiGetFeatureBits();
/* Set the default NX policy (opt-in) */
- NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;
+ SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;
/* Check if NPX is always on */
if (strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=ALWAYSON"))
{
/* Set it always on */
- NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSON;
+ SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSON;
FeatureBits |= KF_NX_ENABLED;
}
else if (strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=OPTOUT"))
{
/* Set it in opt-out mode */
- NXSupportPolicy = NX_SUPPORT_POLICY_OPTOUT;
+ SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTOUT;
FeatureBits |= KF_NX_ENABLED;
}
else if ((strstr(KeLoaderBlock->LoadOptions, "NOEXECUTE=OPTIN")) ||
@@ -428,7 +427,7 @@
(strstr(KeLoaderBlock->LoadOptions, "EXECUTE")))
{
/* Set disabled mode */
- NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSOFF;
+ SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSOFF;
FeatureBits |= KF_NX_DISABLED;
}
@@ -533,9 +532,6 @@
0,
4096);
- /* Set the NX Support policy */
- SharedUserData->NXSupportPolicy = (UCHAR)NXSupportPolicy;
-
/* Set basic CPU Features that user mode can read */
SharedUserData->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] =
(KeFeatureBits & KF_MMX) ? TRUE: FALSE;