Skip to content

Commit bed8b2a

Browse files
committed
[FREELDR][NDK][X64] Remove KIP0PCRADDRESS definition and mapping
It is not used by either ReactOS or Windows.
1 parent 4e5e72f commit bed8b2a

File tree

3 files changed

+10
-32
lines changed

3 files changed

+10
-32
lines changed

boot/freeldr/freeldr/include/arch/amd64/amd64.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
#pragma once
2323
#endif
2424

25-
// This is needed because headers define wrong one for ReactOS
26-
#undef KIP0PCRADDRESS
27-
#define KIP0PCRADDRESS 0xFFFFF78000001000ULL /* FIXME!!! */
28-
2925
#define VA_MASK 0x0000FFFFFFFFFFFFUL
3026

3127
#define PtrToPfn(p) \

boot/freeldr/freeldr/ntldr/arch/amd64/winldr.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ PHARDWARE_PTE PxeBase;
2424
//PHARDWARE_PTE HalPageTable;
2525

2626
PVOID GdtIdt;
27-
ULONG_PTR PcrBasePage;
27+
PFN_NUMBER SharedUserDataPfn;
2828
ULONG_PTR TssBasePage;
2929

3030
/* FUNCTIONS **************************************************************/
@@ -246,15 +246,8 @@ WinLdrMapSpecialPages(VOID)
246246
{
247247
PHARDWARE_PTE PpeBase, PdeBase;
248248

249-
/* Map the PCR page */
250-
if (!MempMapSinglePage(KIP0PCRADDRESS, PcrBasePage * PAGE_SIZE))
251-
{
252-
ERR("Could not map PCR @ %lx\n", PcrBasePage);
253-
return FALSE;
254-
}
255-
256249
/* Map KI_USER_SHARED_DATA */
257-
if (!MempMapSinglePage(KI_USER_SHARED_DATA, (PcrBasePage+1) * PAGE_SIZE))
250+
if (!MempMapSinglePage(KI_USER_SHARED_DATA, SharedUserDataPfn * PAGE_SIZE))
258251
{
259252
ERR("Could not map KI_USER_SHARED_DATA\n");
260253
return FALSE;
@@ -380,22 +373,22 @@ WinLdrSetProcessorContext(
380373

381374
void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
382375
{
383-
ULONG_PTR Pcr = 0;
376+
PVOID SharedUserDataAddress = NULL;
384377
ULONG_PTR Tss = 0;
385378
ULONG BlockSize, NumPages;
386379

387380
LoaderBlock->u.I386.CommonDataArea = (PVOID)DbgPrint; // HACK
388381
LoaderBlock->u.I386.MachineType = MACHINE_TYPE_ISA;
389382

390-
/* Allocate 2 pages for PCR */
391-
Pcr = (ULONG_PTR)MmAllocateMemoryWithType(2 * MM_PAGE_SIZE, LoaderStartupPcrPage);
392-
PcrBasePage = Pcr >> MM_PAGE_SHIFT;
393-
if (Pcr == 0)
383+
/* Allocate 1 page for SharedUserData */
384+
SharedUserDataAddress = MmAllocateMemoryWithType(MM_PAGE_SIZE, LoaderStartupPcrPage);
385+
SharedUserDataPfn = (ULONG_PTR)SharedUserDataAddress >> MM_PAGE_SHIFT;
386+
if (SharedUserDataAddress == NULL)
394387
{
395-
UiMessageBox("Can't allocate PCR.");
388+
UiMessageBox("Can't allocate SharedUserData page.");
396389
return;
397390
}
398-
RtlZeroMemory((PVOID)Pcr, 2 * MM_PAGE_SIZE);
391+
RtlZeroMemory(SharedUserDataAddress, MM_PAGE_SIZE);
399392

400393
/* Allocate TSS */
401394
BlockSize = (sizeof(KTSS) + MM_PAGE_SIZE) & ~(MM_PAGE_SIZE - 1);
@@ -422,7 +415,7 @@ void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
422415
// FIXME: bugcheck
423416
}
424417

425-
/* Map stuff like PCR, KI_USER_SHARED_DATA and Apic */
418+
/* Map KI_USER_SHARED_DATA, Apic and HAL space */
426419
WinLdrMapSpecialPages();
427420
}
428421

sdk/include/ndk/amd64/ketypes.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,6 @@ Header Name:
8080
#define KF_FPU_LEAKAGE_BIT 41 // From ksamd64.inc (0x29 -> 0x20000000000)
8181
#define KF_CAT_BIT 44 // From ksamd64.inc (0x2C -> 0x100000000000)
8282

83-
//
84-
// KPCR Access for non-IA64 builds
85-
//
86-
//#define K0IPCR ((ULONG_PTR)(KIP0PCRADDRESS))
87-
//#define PCR ((volatile KPCR * const)K0IPCR)
88-
#define PCR ((volatile KPCR * const)__readgsqword(FIELD_OFFSET(KPCR, Self)))
89-
//#if defined(CONFIG_SMP) || defined(NT_BUILD)
90-
//#undef KeGetPcr
91-
//#define KeGetPcr() ((volatile KPCR * const)__readfsdword(0x1C))
92-
//#endif
93-
9483
//
9584
// Double fault stack size
9685
//

0 commit comments

Comments
 (0)