4 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
5 * Copyright (C) 2006 Aleksey Bragin <aleksey@reactos.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include <ndk/ldrtypes.h>
28 void WinLdrSetupForNt(PLOADER_PARAMETER_BLOCK LoaderBlock
,
33 //FIXME: Do a better way to retrieve Arc disk information
34 extern ULONG reactos_disk_count
;
35 extern ARC_DISK_SIGNATURE reactos_arc_disk_info
[];
36 extern char reactos_arc_strings
[32][256];
38 extern BOOLEAN UseRealHeap
;
39 extern ULONG LoaderPagesSpanned
;
40 extern BOOLEAN AcpiPresent
;
42 extern HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
;
43 extern BOOLEAN WinLdrTerminalConnected
;
44 extern void WinLdrSetupEms(IN PCHAR BootOptions
);
47 WinLdrCheckForLoadedDll(IN OUT PLOADER_PARAMETER_BLOCK WinLdrBlock
,
49 OUT PLDR_DATA_TABLE_ENTRY
*LoadedEntry
);
52 VOID
DumpMemoryAllocMap(VOID
);
53 VOID
WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock
);
54 VOID
WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock
);
55 VOID
WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock
);
60 AllocateAndInitLPB(PLOADER_PARAMETER_BLOCK
*OutLoaderBlock
)
62 PLOADER_PARAMETER_BLOCK LoaderBlock
;
64 /* Allocate and zero-init the LPB */
65 LoaderBlock
= MmHeapAlloc(sizeof(LOADER_PARAMETER_BLOCK
));
66 RtlZeroMemory(LoaderBlock
, sizeof(LOADER_PARAMETER_BLOCK
));
68 /* Init three critical lists, used right away */
69 InitializeListHead(&LoaderBlock
->LoadOrderListHead
);
70 InitializeListHead(&LoaderBlock
->MemoryDescriptorListHead
);
71 InitializeListHead(&LoaderBlock
->BootDriverListHead
);
73 /* Alloc space for NLS (it will be converted to VA in WinLdrLoadNLS) */
74 LoaderBlock
->NlsData
= MmHeapAlloc(sizeof(NLS_DATA_BLOCK
));
75 if (LoaderBlock
->NlsData
== NULL
)
77 UiMessageBox("Failed to allocate memory for NLS table data!");
80 RtlZeroMemory(LoaderBlock
->NlsData
, sizeof(NLS_DATA_BLOCK
));
82 *OutLoaderBlock
= LoaderBlock
;
87 WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock
,
93 /* Examples of correct options and paths */
94 //CHAR Options[] = "/DEBUGPORT=COM1 /BAUDRATE=115200";
95 //CHAR Options[] = "/NODEBUG";
96 //CHAR SystemRoot[] = "\\WINNT\\";
97 //CHAR ArcBoot[] = "multi(0)disk(0)rdisk(0)partition(1)";
99 CHAR HalPath
[] = "\\";
102 ULONG i
, PathSeparator
;
103 PLOADER_PARAMETER_EXTENSION Extension
;
105 /* Construct SystemRoot and ArcBoot from SystemPath */
106 PathSeparator
= strstr(BootPath
, "\\") - BootPath
;
107 strncpy(ArcBoot
, BootPath
, PathSeparator
);
108 ArcBoot
[PathSeparator
] = 0;
110 DPRINTM(DPRINT_WINDOWS
, "ArcBoot: %s\n", ArcBoot
);
111 DPRINTM(DPRINT_WINDOWS
, "SystemRoot: %s\n", SystemRoot
);
112 DPRINTM(DPRINT_WINDOWS
, "Options: %s\n", Options
);
114 /* Fill Arc BootDevice */
115 LoaderBlock
->ArcBootDeviceName
= MmHeapAlloc(strlen(ArcBoot
)+1);
116 strcpy(LoaderBlock
->ArcBootDeviceName
, ArcBoot
);
117 LoaderBlock
->ArcBootDeviceName
= PaToVa(LoaderBlock
->ArcBootDeviceName
);
119 /* Fill Arc HalDevice, it matches ArcBoot path */
120 LoaderBlock
->ArcHalDeviceName
= MmHeapAlloc(strlen(ArcBoot
)+1);
121 strcpy(LoaderBlock
->ArcHalDeviceName
, ArcBoot
);
122 LoaderBlock
->ArcHalDeviceName
= PaToVa(LoaderBlock
->ArcHalDeviceName
);
124 /* Fill SystemRoot */
125 LoaderBlock
->NtBootPathName
= MmHeapAlloc(strlen(SystemRoot
)+1);
126 strcpy(LoaderBlock
->NtBootPathName
, SystemRoot
);
127 LoaderBlock
->NtBootPathName
= PaToVa(LoaderBlock
->NtBootPathName
);
129 /* Fill NtHalPathName */
130 LoaderBlock
->NtHalPathName
= MmHeapAlloc(strlen(HalPath
)+1);
131 strcpy(LoaderBlock
->NtHalPathName
, HalPath
);
132 LoaderBlock
->NtHalPathName
= PaToVa(LoaderBlock
->NtHalPathName
);
134 /* Fill load options */
135 LoaderBlock
->LoadOptions
= MmHeapAlloc(strlen(Options
)+1);
136 strcpy(LoaderBlock
->LoadOptions
, Options
);
137 LoaderBlock
->LoadOptions
= PaToVa(LoaderBlock
->LoadOptions
);
140 LoaderBlock
->ArcDiskInformation
= (PARC_DISK_INFORMATION
)MmHeapAlloc(sizeof(ARC_DISK_INFORMATION
));
141 InitializeListHead(&LoaderBlock
->ArcDiskInformation
->DiskSignatureListHead
);
143 /* Convert ARC disk information from freeldr to a correct format */
144 for (i
= 0; i
< reactos_disk_count
; i
++)
146 PARC_DISK_SIGNATURE ArcDiskInfo
;
148 /* Get the ARC structure */
149 ArcDiskInfo
= (PARC_DISK_SIGNATURE
)MmHeapAlloc(sizeof(ARC_DISK_SIGNATURE
));
150 RtlZeroMemory(ArcDiskInfo
, sizeof(ARC_DISK_SIGNATURE
));
152 /* Copy the data over */
153 ArcDiskInfo
->Signature
= reactos_arc_disk_info
[i
].Signature
;
154 ArcDiskInfo
->CheckSum
= reactos_arc_disk_info
[i
].CheckSum
;
156 /* Copy the ARC Name */
157 ArcDiskInfo
->ArcName
= (PCHAR
)MmHeapAlloc(sizeof(CHAR
)*256);
158 strcpy(ArcDiskInfo
->ArcName
, reactos_arc_disk_info
[i
].ArcName
);
159 ArcDiskInfo
->ArcName
= (PCHAR
)PaToVa(ArcDiskInfo
->ArcName
);
161 /* Mark partition table as valid */
162 ArcDiskInfo
->ValidPartitionTable
= TRUE
;
164 /* Insert into the list */
165 InsertTailList(&LoaderBlock
->ArcDiskInformation
->DiskSignatureListHead
,
166 &ArcDiskInfo
->ListEntry
);
169 /* Convert all list's to Virtual address */
171 /* Convert the ArcDisks list to virtual address */
172 List_PaToVa(&LoaderBlock
->ArcDiskInformation
->DiskSignatureListHead
);
173 LoaderBlock
->ArcDiskInformation
= PaToVa(LoaderBlock
->ArcDiskInformation
);
175 /* Convert configuration entries to VA */
176 ConvertConfigToVA(LoaderBlock
->ConfigurationRoot
);
177 LoaderBlock
->ConfigurationRoot
= PaToVa(LoaderBlock
->ConfigurationRoot
);
179 /* Convert all DTE into virtual addresses */
180 List_PaToVa(&LoaderBlock
->LoadOrderListHead
);
182 /* this one will be converted right before switching to
183 virtual paging mode */
184 //List_PaToVa(&LoaderBlock->MemoryDescriptorListHead);
186 /* Convert list of boot drivers */
187 List_PaToVa(&LoaderBlock
->BootDriverListHead
);
189 /* Initialize Extension now */
190 Extension
= MmHeapAlloc(sizeof(LOADER_PARAMETER_EXTENSION
));
191 if (Extension
== NULL
)
193 UiMessageBox("Failed to allocate LPB Extension!");
196 RtlZeroMemory(Extension
, sizeof(LOADER_PARAMETER_EXTENSION
));
198 /* Fill LPB extension */
199 Extension
->Size
= sizeof(LOADER_PARAMETER_EXTENSION
);
200 Extension
->MajorVersion
= (VersionToBoot
& 0xFF00) >> 8;
201 Extension
->MinorVersion
= VersionToBoot
& 0xFF;
202 Extension
->Profile
.Status
= 2;
204 /* Check if ACPI is present */
207 /* See KiRosFrldrLpbToNtLpb for details */
208 Extension
->AcpiTable
= (PVOID
)1;
212 /* Set headless block pointer */
213 if (WinLdrTerminalConnected
)
215 Extension
->HeadlessLoaderBlock
= MmHeapAlloc(sizeof(HEADLESS_LOADER_BLOCK
));
216 if (Extension
->HeadlessLoaderBlock
== NULL
)
218 UiMessageBox("Failed to allocate HLB Extension!");
223 Extension
->HeadlessLoaderBlock
,
224 &LoaderRedirectionInformation
,
225 sizeof(HEADLESS_LOADER_BLOCK
));
226 Extension
->HeadlessLoaderBlock
= PaToVa(Extension
->HeadlessLoaderBlock
);
229 /* Load drivers database */
230 strcpy(MiscFiles
, BootPath
);
231 strcat(MiscFiles
, "AppPatch\\drvmain.sdb");
232 Extension
->DrvDBImage
= PaToVa(WinLdrLoadModule(MiscFiles
,
233 &Extension
->DrvDBSize
, LoaderRegistryData
));
235 /* Convert extension and setup block pointers */
236 LoaderBlock
->Extension
= PaToVa(Extension
);
238 if (LoaderBlock
->SetupLdrBlock
)
239 LoaderBlock
->SetupLdrBlock
= PaToVa(LoaderBlock
->SetupLdrBlock
);
244 WinLdrLoadDeviceDriver(PLOADER_PARAMETER_BLOCK LoaderBlock
,
246 PUNICODE_STRING FilePath
,
248 PLDR_DATA_TABLE_ENTRY
*DriverDTE
)
251 CHAR DriverPath
[1024];
257 // Separate the path to file name and directory path
258 _snprintf(DriverPath
, sizeof(DriverPath
), "%wZ", FilePath
);
259 DriverNamePos
= strrchr(DriverPath
, '\\');
260 if (DriverNamePos
!= NULL
)
263 strcpy(DllName
, DriverNamePos
+1);
265 // Cut out the name from the path
266 *(DriverNamePos
+1) = 0;
270 // There is no directory in the path
271 strcpy(DllName
, DriverPath
);
275 DPRINTM(DPRINT_WINDOWS
, "DriverPath: %s, DllName: %s, LPB %p\n", DriverPath
, DllName
, LoaderBlock
);
278 // Check if driver is already loaded
279 Status
= WinLdrCheckForLoadedDll(LoaderBlock
, DllName
, DriverDTE
);
282 // We've got the pointer to its DTE, just return success
286 // It's not loaded, we have to load it
287 strcpy(FullPath
, "\\ArcName\\");
288 _snprintf(FullPath
+strlen("\\ArcName\\"), sizeof(FullPath
), "%s%wZ", BootPath
, FilePath
);
289 Status
= WinLdrLoadImage(FullPath
+strlen("\\ArcName\\"), LoaderBootDriver
, &DriverBase
);
293 // Allocate a DTE for it
294 Status
= WinLdrAllocateDataTableEntry(LoaderBlock
, DllName
, FullPath
, DriverBase
, DriverDTE
);
297 DPRINTM(DPRINT_WINDOWS
, "WinLdrAllocateDataTableEntry() failed\n");
301 // Modify any flags, if needed
302 (*DriverDTE
)->Flags
|= Flags
;
304 // Look for any dependencies it may have, and load them too
305 sprintf(FullPath
,"%s%s", BootPath
, DriverPath
);
306 Status
= WinLdrScanImportDescriptorTable(LoaderBlock
, FullPath
, *DriverDTE
);
309 DPRINTM(DPRINT_WINDOWS
, "WinLdrScanImportDescriptorTable() failed for %s\n",
318 WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock
,
322 PBOOT_DRIVER_LIST_ENTRY BootDriver
;
325 // Walk through the boot drivers list
326 NextBd
= LoaderBlock
->BootDriverListHead
.Flink
;
328 while (NextBd
!= &LoaderBlock
->BootDriverListHead
)
330 BootDriver
= CONTAINING_RECORD(NextBd
, BOOT_DRIVER_LIST_ENTRY
, Link
);
332 DPRINTM(DPRINT_WINDOWS
, "BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver
->FilePath
,
333 BootDriver
->LdrEntry
, &BootDriver
->RegistryPath
);
335 // Paths are relative (FIXME: Are they always relative?)
338 Status
= WinLdrLoadDeviceDriver(LoaderBlock
, BootPath
, &BootDriver
->FilePath
,
339 0, &BootDriver
->LdrEntry
);
341 // If loading failed - cry loudly
342 //FIXME: Maybe remove it from the list and try to continue?
345 UiMessageBox("Can't load boot driver!");
349 // Convert the RegistryPath and DTE addresses to VA since we are not going to use it anymore
350 BootDriver
->RegistryPath
.Buffer
= PaToVa(BootDriver
->RegistryPath
.Buffer
);
351 BootDriver
->FilePath
.Buffer
= PaToVa(BootDriver
->FilePath
.Buffer
);
352 BootDriver
->LdrEntry
= PaToVa(BootDriver
->LdrEntry
);
354 NextBd
= BootDriver
->Link
.Flink
;
360 PVOID
WinLdrLoadModule(PCSTR ModuleName
, ULONG
*Size
,
361 TYPE_OF_MEMORY MemoryType
)
365 FILEINFORMATION FileInfo
;
370 //CHAR ProgressString[256];
372 /* Inform user we are loading files */
373 //sprintf(ProgressString, "Loading %s...", FileName);
374 //UiDrawProgressBarCenter(1, 100, ProgressString);
376 DPRINTM(DPRINT_WINDOWS
, "Loading module %s\n", ModuleName
);
379 /* Open the image file */
380 Status
= ArcOpen((PCHAR
)ModuleName
, OpenReadOnly
, &FileId
);
381 if (Status
!= ESUCCESS
)
383 /* In case of errors, we just return, without complaining to the user */
387 /* Get this file's size */
388 Status
= ArcGetFileInformation(FileId
, &FileInfo
);
389 if (Status
!= ESUCCESS
)
394 FileSize
= FileInfo
.EndingAddress
.LowPart
;
397 /* Allocate memory */
398 PhysicalBase
= MmAllocateMemoryWithType(FileSize
, MemoryType
);
399 if (PhysicalBase
== NULL
)
405 /* Load whole file */
406 Status
= ArcRead(FileId
, PhysicalBase
, FileSize
, &BytesRead
);
408 if (Status
!= ESUCCESS
)
413 DPRINTM(DPRINT_WINDOWS
, "Loaded %s at 0x%x with size 0x%x\n", ModuleName
, PhysicalBase
, FileSize
);
420 WinLdrDetectVersion()
427 L
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server",
429 if (rc
!= ERROR_SUCCESS
)
431 // Key doesn't exist; assume NT 4.0
432 return _WIN32_WINNT_NT4
;
435 // We may here want to read the value of ProductVersion
436 return _WIN32_WINNT_WS03
;
441 LoadAndBootWindows(PCSTR OperatingSystemName
,
443 USHORT OperatingSystemVersion
)
446 char FullPath
[MAX_PATH
], SystemRoot
[MAX_PATH
], BootPath
[MAX_PATH
];
447 CHAR FileName
[MAX_PATH
];
448 CHAR BootOptions
[256];
451 PVOID NtosBase
= NULL
, HalBase
= NULL
, KdComBase
= NULL
;
454 PLOADER_PARAMETER_BLOCK LoaderBlock
, LoaderBlockVA
;
455 KERNEL_ENTRY_POINT KiSystemStartup
;
456 PLDR_DATA_TABLE_ENTRY KernelDTE
, HalDTE
, KdComDTE
= NULL
;
462 // Open the operating system section
463 // specified in the .ini file
464 HasSection
= IniOpenSection(OperatingSystemName
, &SectionId
);
467 UiDrawStatusText("Detecting Hardware...");
468 UiDrawProgressBarCenter(1, 100, "Loading NT...");
470 /* Read the system path is set in the .ini file */
471 if (!HasSection
|| !IniReadSettingByName(SectionId
, "SystemPath", FullPath
, sizeof(FullPath
)))
473 strcpy(FullPath
, OperatingSystemName
);
476 /* Special case for LiveCD */
477 if (!_strnicmp(FullPath
, "LiveCD", strlen("LiveCD")))
479 strcpy(BootPath
, FullPath
+ strlen("LiveCD"));
480 MachDiskGetBootPath(FullPath
, sizeof(FullPath
));
481 strcat(FullPath
, BootPath
);
484 /* Convert FullPath to SystemRoot */
485 PathSeparator
= strstr(FullPath
, "\\");
486 strcpy(SystemRoot
, PathSeparator
);
487 strcat(SystemRoot
, "\\");
489 /* Read booting options */
490 if (!HasSection
|| !IniReadSettingByName(SectionId
, "Options", BootOptions
, sizeof(BootOptions
)))
492 /* Get options after the title */
493 const CHAR
*p
= SettingsValue
;
494 while (*p
== ' ' || *p
== '"')
496 while (*p
!= '\0' && *p
!= '"')
498 strcpy(BootOptions
, p
);
499 DPRINTM(DPRINT_WINDOWS
,"BootOptions: '%s'\n", BootOptions
);
502 /* Append boot-time options */
503 AppendBootTimeOptions(BootOptions
);
506 // Check if a ramdisk file was given
508 File
= strstr(BootOptions
, "/RDPATH=");
512 // Copy the file name and everything else after it
514 strcpy(FileName
, File
+ 8);
519 *strstr(FileName
, " ") = ANSI_NULL
;
524 RamDiskLoadVirtualFile(FileName
);
527 /* Let user know we started loading */
528 UiDrawStatusText("Loading...");
530 /* append a backslash */
531 strcpy(BootPath
, FullPath
);
532 if ((strlen(BootPath
)==0) ||
533 BootPath
[strlen(BootPath
)] != '\\')
534 strcat(BootPath
, "\\");
536 DPRINTM(DPRINT_WINDOWS
,"BootPath: '%s'\n", BootPath
);
538 /* Allocate and minimalistic-initialize LPB */
539 AllocateAndInitLPB(&LoaderBlock
);
542 /* Setup redirection support */
543 WinLdrSetupEms(BootOptions
);
545 /* Detect hardware */
547 LoaderBlock
->ConfigurationRoot
= MachHwDetect();
550 Status
= WinLdrInitSystemHive(LoaderBlock
, BootPath
);
551 DPRINTM(DPRINT_WINDOWS
, "SYSTEM hive loaded with status %d\n", Status
);
553 if (OperatingSystemVersion
== 0)
554 OperatingSystemVersion
= WinLdrDetectVersion();
556 strcpy(FileName
, "\\ArcName\\");
559 strcpy(FileName
+strlen("\\ArcName\\"), BootPath
);
560 strcat(FileName
, "SYSTEM32\\NTOSKRNL.EXE");
561 Status
= WinLdrLoadImage(FileName
+strlen("\\ArcName\\"), LoaderSystemCode
, &NtosBase
);
562 DPRINTM(DPRINT_WINDOWS
, "Ntos loaded with status %d at %p\n", Status
, NtosBase
);
563 WinLdrAllocateDataTableEntry(LoaderBlock
, "ntoskrnl.exe",
564 FileName
, NtosBase
, &KernelDTE
);
567 strcpy(FileName
+strlen("\\ArcName\\"), BootPath
);
568 strcat(FileName
, "SYSTEM32\\HAL.DLL");
569 Status
= WinLdrLoadImage(FileName
+strlen("\\ArcName\\"), LoaderHalCode
, &HalBase
);
570 DPRINTM(DPRINT_WINDOWS
, "HAL loaded with status %d at %p\n", Status
, HalBase
);
571 WinLdrAllocateDataTableEntry(LoaderBlock
, "hal.dll",
572 FileName
, HalBase
, &HalDTE
);
574 /* Load kernel-debugger support dll */
575 if (OperatingSystemVersion
> _WIN32_WINNT_WIN2K
)
577 strcpy(FileName
+strlen("\\ArcName\\"), BootPath
);
578 strcat(FileName
, "SYSTEM32\\KDCOM.DLL");
579 Status
= WinLdrLoadImage(FileName
+strlen("\\ArcName\\"), LoaderBootDriver
, &KdComBase
);
580 DPRINTM(DPRINT_WINDOWS
, "KdCom loaded with status %d at %p\n", Status
, KdComBase
);
581 WinLdrAllocateDataTableEntry(LoaderBlock
, "kdcom.dll",
582 FileName
, KdComBase
, &KdComDTE
);
585 /* Load all referenced DLLs for kernel, HAL and kdcom.dll */
586 strcpy(FileName
, BootPath
);
587 strcat(FileName
, "SYSTEM32\\");
588 WinLdrScanImportDescriptorTable(LoaderBlock
, FileName
, KernelDTE
);
589 WinLdrScanImportDescriptorTable(LoaderBlock
, FileName
, HalDTE
);
591 WinLdrScanImportDescriptorTable(LoaderBlock
, FileName
, KdComDTE
);
593 /* Load NLS data, OEM font, and prepare boot drivers list */
594 Status
= WinLdrScanSystemHive(LoaderBlock
, BootPath
);
595 DPRINTM(DPRINT_WINDOWS
, "SYSTEM hive scanned with status %d\n", Status
);
597 /* Load boot drivers */
598 Status
= WinLdrLoadBootDrivers(LoaderBlock
, BootPath
);
599 DPRINTM(DPRINT_WINDOWS
, "Boot drivers loaded with status %d\n", Status
);
601 /* Alloc PCR, TSS, do magic things with the GDT/IDT */
602 WinLdrSetupForNt(LoaderBlock
, &GdtIdt
, &PcrBasePage
, &TssBasePage
);
604 /* Initialize Phase 1 - no drivers loading anymore */
605 WinLdrInitializePhase1(LoaderBlock
, BootOptions
, SystemRoot
, BootPath
, OperatingSystemVersion
);
607 /* Save entry-point pointer and Loader block VAs */
608 KiSystemStartup
= (KERNEL_ENTRY_POINT
)KernelDTE
->EntryPoint
;
609 LoaderBlockVA
= PaToVa(LoaderBlock
);
611 /* "Stop all motors", change videomode */
612 if (OperatingSystemVersion
< _WIN32_WINNT_WIN2K
)
613 MachPrepareForReactOS(TRUE
);
615 MachPrepareForReactOS(FALSE
);
618 //DumpMemoryAllocMap();
620 /* Turn on paging mode of CPU*/
621 WinLdrTurnOnPaging(LoaderBlock
, PcrBasePage
, TssBasePage
, GdtIdt
);
623 /* Save final value of LoaderPagesSpanned */
624 LoaderBlockVA
->Extension
->LoaderPagesSpanned
= LoaderPagesSpanned
;
626 DPRINTM(DPRINT_WINDOWS
, "Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
627 KiSystemStartup
, LoaderBlockVA
);
629 WinLdrpDumpMemoryDescriptors(LoaderBlockVA
);
630 WinLdrpDumpBootDriver(LoaderBlockVA
);
631 WinLdrpDumpArcDisks(LoaderBlockVA
);
633 //FIXME: If I substitute this debugging checkpoint, GCC will "optimize away" the code below
635 /*asm(".intel_syntax noprefix\n");
638 asm(".att_syntax\n");*/
641 (*KiSystemStartup
)(LoaderBlockVA
);
647 WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock
)
650 PMEMORY_ALLOCATION_DESCRIPTOR MemoryDescriptor
;
652 NextMd
= LoaderBlock
->MemoryDescriptorListHead
.Flink
;
654 while (NextMd
!= &LoaderBlock
->MemoryDescriptorListHead
)
656 MemoryDescriptor
= CONTAINING_RECORD(NextMd
, MEMORY_ALLOCATION_DESCRIPTOR
, ListEntry
);
658 DPRINTM(DPRINT_WINDOWS
, "BP %08X PC %04X MT %d\n", MemoryDescriptor
->BasePage
,
659 MemoryDescriptor
->PageCount
, MemoryDescriptor
->MemoryType
);
661 NextMd
= MemoryDescriptor
->ListEntry
.Flink
;
666 WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock
)
669 PBOOT_DRIVER_LIST_ENTRY BootDriver
;
671 NextBd
= LoaderBlock
->BootDriverListHead
.Flink
;
673 while (NextBd
!= &LoaderBlock
->BootDriverListHead
)
675 BootDriver
= CONTAINING_RECORD(NextBd
, BOOT_DRIVER_LIST_ENTRY
, Link
);
677 DPRINTM(DPRINT_WINDOWS
, "BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver
->FilePath
,
678 BootDriver
->LdrEntry
, &BootDriver
->RegistryPath
);
680 NextBd
= BootDriver
->Link
.Flink
;
685 WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock
)
688 PARC_DISK_SIGNATURE ArcDisk
;
690 NextBd
= LoaderBlock
->ArcDiskInformation
->DiskSignatureListHead
.Flink
;
692 while (NextBd
!= &LoaderBlock
->ArcDiskInformation
->DiskSignatureListHead
)
694 ArcDisk
= CONTAINING_RECORD(NextBd
, ARC_DISK_SIGNATURE
, ListEntry
);
696 DPRINTM(DPRINT_WINDOWS
, "ArcDisk %s checksum: 0x%X, signature: 0x%X\n",
697 ArcDisk
->ArcName
, ArcDisk
->CheckSum
, ArcDisk
->Signature
);
699 NextBd
= ArcDisk
->ListEntry
.Flink
;