Author: tkreuzer
Date: Thu Sep 15 11:27:27 2011
New Revision: 53710
URL:
http://svn.reactos.org/svn/reactos?rev=53710&view=rev
Log:
[FREELDR]
- Improve List_PaToVa, making the code cleaner
- Dereference LoaderBlock->Extension only after WinLdrSetProcessorContext, since its in
kernel address space
Modified:
trunk/reactos/boot/freeldr/freeldr/windows/conversion.c
trunk/reactos/boot/freeldr/freeldr/windows/winldr.c
Modified: trunk/reactos/boot/freeldr/freeldr/windows/conversion.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/windows/conversion.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/conversion.c [iso-8859-1] Thu Sep 15
11:27:27 2011
@@ -45,38 +45,32 @@
#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);
+ /* Go to the next entry */
+ EntryPa = NextPa;
+ }
- Next = NextPA->Flink;
- }
-
- //
- // Finally convert first Flink/Blink
- //
- ListEntry->Flink = PaToVa((PVOID)ListEntry->Flink);
- if (ListEntry->Blink)
- ListEntry->Blink = PaToVa((PVOID)ListEntry->Blink);
- }
+ /* 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
Modified: trunk/reactos/boot/freeldr/freeldr/windows/winldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/windows/winldr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/winldr.c [iso-8859-1] Thu Sep 15 11:27:27
2011
@@ -569,6 +569,7 @@
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,11 +632,11 @@
/* Map pages and create memory descriptors */
WinLdrSetupMemoryLayout(LoaderBlock);
+ /* Set processor context */
+ WinLdrSetProcessorContext();
+
/* Save final value of LoaderPagesSpanned */
LoaderBlock->Extension->LoaderPagesSpanned = LoaderPagesSpanned;
-
- /* Set processor context */
- WinLdrSetProcessorContext();
TRACE("Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
KiSystemStartup, LoaderBlockVA);