diff --git a/reactos/boot/freeldr/freeldr/windows/conversion.c b/reactos/boot/freeldr/freeldr/windows/conversion.c index ff2aa0965d5..5c5452a5033 100644 --- a/reactos/boot/freeldr/freeldr/windows/conversion.c +++ b/reactos/boot/freeldr/freeldr/windows/conversion.c @@ -45,38 +45,32 @@ PaToVa(PVOID Pa) #endif VOID -List_PaToVa(LIST_ENTRY *ListEntry) +List_PaToVa(PLIST_ENTRY ListHeadPa) { - LIST_ENTRY *ListHead = ListEntry; - LIST_ENTRY *Next = ListEntry->Flink; - LIST_ENTRY *NextPA; + PLIST_ENTRY EntryPa, NextPa; - //Print(L"\n\nList_Entry: %X, First Next: %X\n", ListEntry, Next); - // - // Walk through the whole list - // - if (Next != NULL) + /* List must be properly initialized */ + ASSERT(ListHeadPa->Flink != 0); + ASSERT(ListHeadPa->Blink != 0); + + /* Loop the list in physical address space */ + EntryPa = ListHeadPa->Flink; + while (EntryPa != ListHeadPa) { - while (Next != PaToVa(ListHead)) - { - NextPA = VaToPa(Next); - //Print(L"Current: %X, Flink: %X, Blink: %X\n", Next, NextPA->Flink, NextPA->Blink); + /* Save the physical address of the next entry */ + NextPa = EntryPa->Flink; - NextPA->Flink = PaToVa((PVOID)NextPA->Flink); - NextPA->Blink = PaToVa((PVOID)NextPA->Blink); + /* Convert the addresses of this entry */ + EntryPa->Flink = PaToVa(EntryPa->Flink); + EntryPa->Blink = PaToVa(EntryPa->Blink); - //Print(L"After converting Flink: %X, Blink: %X\n", NextPA->Flink, NextPA->Blink); - - Next = NextPA->Flink; - } - - // - // Finally convert first Flink/Blink - // - ListEntry->Flink = PaToVa((PVOID)ListEntry->Flink); - if (ListEntry->Blink) - ListEntry->Blink = PaToVa((PVOID)ListEntry->Blink); + /* Go to the next entry */ + EntryPa = NextPa; } + + /* Finally convert the list head */ + ListHeadPa->Flink = PaToVa(ListHeadPa->Flink); + ListHeadPa->Blink = PaToVa(ListHeadPa->Blink); } // This function converts only Child->Child, and calls itself for each Sibling diff --git a/reactos/boot/freeldr/freeldr/windows/winldr.c b/reactos/boot/freeldr/freeldr/windows/winldr.c index fe91c6395e0..a955524ef14 100644 --- a/reactos/boot/freeldr/freeldr/windows/winldr.c +++ b/reactos/boot/freeldr/freeldr/windows/winldr.c @@ -569,6 +569,7 @@ LoadAndBootWindowsCommon( PLDR_DATA_TABLE_ENTRY KernelDTE, HalDTE, KdComDTE = NULL; KERNEL_ENTRY_POINT KiSystemStartup; LPCSTR SystemRoot; + TRACE("LoadAndBootWindowsCommon()\n"); /* Convert BootPath to SystemRoot */ SystemRoot = strstr(BootPath, "\\"); @@ -631,12 +632,12 @@ LoadAndBootWindowsCommon( /* Map pages and create memory descriptors */ WinLdrSetupMemoryLayout(LoaderBlock); - /* Save final value of LoaderPagesSpanned */ - LoaderBlock->Extension->LoaderPagesSpanned = LoaderPagesSpanned; - /* Set processor context */ WinLdrSetProcessorContext(); + /* Save final value of LoaderPagesSpanned */ + LoaderBlock->Extension->LoaderPagesSpanned = LoaderPagesSpanned; + TRACE("Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n", KiSystemStartup, LoaderBlockVA);