Author: fireball Date: Tue Dec 11 00:01:45 2007 New Revision: 31133
URL: http://svn.reactos.org/svn/reactos?rev=31133&view=rev Log: - Improve the FreeLDR->NTLDR conversion layer by now converting the ARC Hardware Tree. - Apply relocation-style fixups to convert from FreeLDR to Kernel Addresses, since a contiguous buffer was used in FreeLDR, which means we only need to add a delta to each FreeLDR pointer to get the Kernel pointer. - Don't assert if we receive an ARC tree, since we now do! Instead, pretty-print it to the debug log. - Remove some registry debug spew.
Modified: trunk/reactos/ntoskrnl/config/cm.h trunk/reactos/ntoskrnl/config/cmconfig.c trunk/reactos/ntoskrnl/config/cmdata.c trunk/reactos/ntoskrnl/config/cmsysini.c trunk/reactos/ntoskrnl/ke/freeldr.c
Modified: trunk/reactos/ntoskrnl/config/cm.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cm.h?rev=31... ============================================================================== --- trunk/reactos/ntoskrnl/config/cm.h (original) +++ trunk/reactos/ntoskrnl/config/cm.h Tue Dec 11 00:01:45 2007 @@ -456,6 +456,16 @@ } CM_PARSE_CONTEXT, *PCM_PARSE_CONTEXT;
// +// MultiFunction Adapter Recognizer Structure +// +typedef struct _CMP_MF_TYPE +{ + PWCHAR Identifier; + USHORT InterfaceType; + USHORT Count; +} CMP_MF_TYPE, *PCMP_MF_TYPE; + +// // System Control Vector // typedef struct _CM_SYSTEM_CONTROL_VECTOR @@ -1387,6 +1397,10 @@ extern ULONG CmpConfigurationAreaSize; extern PCM_FULL_RESOURCE_DESCRIPTOR CmpConfigurationData; extern UNICODE_STRING CmTypeName[]; +extern UNICODE_STRING CmClassName[]; +extern CMP_MF_TYPE CmpMultifunctionTypes[]; +extern USHORT CmpUnknownBusCount; +extern ULONG CmpTypeCount[MaximumType + 1]; extern HIVE_LIST_ENTRY CmpMachineHiveList[]; extern UNICODE_STRING CmSymbolicLinkValueName; extern UNICODE_STRING CmpSystemStartOptions;
Modified: trunk/reactos/ntoskrnl/config/cmconfig.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmconfig.c?... ============================================================================== --- trunk/reactos/ntoskrnl/config/cmconfig.c (original) +++ trunk/reactos/ntoskrnl/config/cmconfig.c Tue Dec 11 00:01:45 2007 @@ -87,10 +87,10 @@
/* Fail if the key couldn't be created, and make sure it's a new key */ if (!NT_SUCCESS(Status)) return Status; - ASSERT(Disposition == REG_CREATED_NEW_KEY); - } - - /* Sstup the compnent information key */ + //ASSERT(Disposition == REG_CREATED_NEW_KEY); + } + + /* Setup the component information key */ RtlInitUnicodeString(&ValueName, L"Component Information"); Status = NtSetValueKey(KeyHandle, &ValueName, @@ -116,6 +116,7 @@ Status = RtlAnsiStringToUnicodeString(&ValueData, &TempString, TRUE); + RtlCreateUnicodeString(&ValueData, (PWCHAR)Component->Identifier); if (NT_SUCCESS(Status)) { /* Save the identifier in the registry */ @@ -192,6 +193,157 @@
/* Return status */ return Status; +} + +int t, tabLevel; + +VOID +NTAPI +CmpDumpHardwareTree(IN PCONFIGURATION_COMPONENT_DATA CurrentEntry, + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber) +{ + PCONFIGURATION_COMPONENT Component; + USHORT DeviceIndexTable[MaximumType + 1] = {0}; + ULONG Interface = InterfaceType, Bus = BusNumber, i; + PCHAR InterfaceStrings[MaximumInterfaceType + 1] = + { + "Internal", + "Isa", + "Eisa", + "MicroChannel", + "TurboChannel", + "PCIBus", + "VMEBus", + "NuBus", + "PCMCIABus", + "CBus", + "MPIBus", + "MPSABus", + "ProcessorInternal", + "InternalPowerBus", + "PNPISABus", + "PNPBus", + "Unknown" + }; + + while (CurrentEntry) + { + for (t = 0; t < tabLevel; t++) DbgPrint("\t"); + DbgPrint("Dumping node @ 0x%p\n", CurrentEntry); + for (t = 0; t < tabLevel; t++) DbgPrint("\t"); + DbgPrint("Parent @ 0x%p Sibling @ 0x%p Child @ 0x%p\n", + CurrentEntry->Parent, CurrentEntry->Sibling, CurrentEntry->Child); + + /* Check if this is an adapter */ + Component = &CurrentEntry->ComponentEntry; + if ((Component->Class == AdapterClass) && + (CurrentEntry->Parent->ComponentEntry.Class == SystemClass)) + { + /* Check what kind of adapter it is */ + switch (Component->Type) + { + /* EISA */ + case EisaAdapter: + + /* Fixup information */ + Interface = Eisa; + Bus = CmpTypeCount[EisaAdapter]++; + break; + + /* Turbo-channel */ + case TcAdapter: + + /* Fixup information */ + Interface = TurboChannel; + Bus = CmpTypeCount[TurboChannel]++; + break; + + /* ISA, PCI, etc busses */ + case MultiFunctionAdapter: + + /* Check if we have an identifier */ + if (Component->Identifier) + { + /* Loop each multi-function adapter type */ + for (i = 0; CmpMultifunctionTypes[i].Identifier; i++) + { + /* Check for a name match */ + if (!_wcsicmp(CmpMultifunctionTypes[i].Identifier, + (PWCHAR)Component->Identifier)) + { + /* Match found */ + break; + } + } + + /* Fix up information */ + Interface = CmpMultifunctionTypes[i].InterfaceType; + Bus = CmpMultifunctionTypes[i].Count++; + } + break; + + /* SCSI Bus */ + case ScsiAdapter: + + /* Fix up */ + Interface = Internal; + Bus = CmpTypeCount[ScsiAdapter]++; + break; + + /* Unknown */ + default: + Interface = -1; + Bus = CmpUnknownBusCount++; + break; + } + } + + /* Convert from NT to ARC class */ + if (Component->Class == SystemClass) Component->Type = ArcSystem; + + /* Dump information on the component */ + for (t = 0; t < tabLevel; t++) DbgPrint("\t"); + DbgPrint("Component Type: %wZ\n", &CmTypeName[Component->Type]); + for (t = 0; t < tabLevel; t++) DbgPrint("\t"); + DbgPrint("Class: %wZ\n", &CmClassName[Component->Class]); + if (Component->Class != SystemClass) + { + for (t = 0; t < tabLevel; t++) DbgPrint("\t"); + DbgPrint("Device Index: %lx\n", DeviceIndexTable[Component->Type]++); + } + for (t = 0; t < tabLevel; t++) DbgPrint("\t"); + DbgPrint("Component Information:\n"); + for (t = 0; t < tabLevel; t++) DbgPrint("\t"); + DbgPrint("\tFlags: %lx\n", Component->Flags); + for (t = 0; t < tabLevel; t++) DbgPrint("\t"); + DbgPrint("\tVersion: %lx\n", Component->Version); + for (t = 0; t < tabLevel; t++) DbgPrint("\t"); + DbgPrint("\tAffinity: %lx\n", Component->AffinityMask); + if (Component->IdentifierLength) + { + for (t = 0; t < tabLevel; t++) DbgPrint("\t"); + DbgPrint("Identifier: %S\n", Component->Identifier); + } + for (t = 0; t < tabLevel; t++) DbgPrint("\t"); + DbgPrint("Configuration Data: %p\n", CurrentEntry->ConfigurationData); + for (t = 0; t < tabLevel; t++) DbgPrint("\t"); + DbgPrint("Interface Type: %s Bus Number: %d\n\n", + InterfaceStrings[Interface], + Bus); + + /* Check for children */ + if (CurrentEntry->Child) + { + /* Recurse child */ + tabLevel++; + CmpDumpHardwareTree(CurrentEntry->Child, Interface, Bus); + tabLevel--; + } + + /* Get to the next entry */ + CurrentEntry = CurrentEntry->Sibling; + } }
NTSTATUS @@ -258,7 +410,10 @@ /* Check if we got anything from NTLDR */ if (LoaderBlock->ConfigurationRoot) { - ASSERTMSG("NTLDR ARC Hardware Tree Not Supported!\n", FALSE); + /* Dump the hardware tree */ + DPRINT1("ARC Hardware Tree Received @ 0x%p. Dumping HW Info:\n\n", + LoaderBlock->ConfigurationRoot); + CmpDumpHardwareTree(LoaderBlock->ConfigurationRoot, -1, -1); } else { @@ -272,3 +427,4 @@ return Status; }
+
Modified: trunk/reactos/ntoskrnl/config/cmdata.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmdata.c?re... ============================================================================== --- trunk/reactos/ntoskrnl/config/cmdata.c (original) +++ trunk/reactos/ntoskrnl/config/cmdata.c Tue Dec 11 00:01:45 2007 @@ -60,7 +60,22 @@ BOOLEAN CmpMiniNTBoot; ULONG CmpBootType;
+USHORT CmpUnknownBusCount; +ULONG CmpTypeCount[MaximumType + 1]; + HANDLE CmpRegistryRootHandle; + +UNICODE_STRING CmClassName[MaximumClass + 1] = +{ + RTL_CONSTANT_STRING(L"System"), + RTL_CONSTANT_STRING(L"Processor"), + RTL_CONSTANT_STRING(L"Cache"), + RTL_CONSTANT_STRING(L"Adapter"), + RTL_CONSTANT_STRING(L"Controller"), + RTL_CONSTANT_STRING(L"Peripheral"), + RTL_CONSTANT_STRING(L"MemoryClass"), + RTL_CONSTANT_STRING(L"Undefined") +};
UNICODE_STRING CmTypeName[MaximumType + 1] = { @@ -108,6 +123,19 @@ RTL_CONSTANT_STRING(L"Undefined") };
+CMP_MF_TYPE CmpMultifunctionTypes[] = +{ + {L"ISA", Isa, 0}, + {L"MCA", MicroChannel, 0}, + {L"PCI", PCIBus, 0}, + {L"VME", VMEBus, 0}, + {L"PCMCIA", PCMCIABus, 0}, + {L"CBUS", CBus, 0}, + {L"MPIPI", MPIBus, 0}, + {L"MPSA", MPSABus, 0}, + {NULL, Internal, 0} +}; + CM_SYSTEM_CONTROL_VECTOR CmControlVector[] = { {
Modified: trunk/reactos/ntoskrnl/config/cmsysini.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c?... ============================================================================== --- trunk/reactos/ntoskrnl/config/cmsysini.c (original) +++ trunk/reactos/ntoskrnl/config/cmsysini.c Tue Dec 11 00:01:45 2007 @@ -1054,8 +1054,7 @@ /* Get the hive index, make sure it makes sense */ i = (ULONG)StartContext; ASSERT(CmpMachineHiveList[i].Name != NULL); - DPRINT1("[HiveLoad] Parallel Thread: %d\n", i); - + /* We were started */ CmpMachineHiveList[i].ThreadStarted = TRUE;
@@ -1097,7 +1096,6 @@ CmpMachineHiveList[i].Allocate = TRUE;
/* Load the hive file */ - DPRINT1("[HiveLoad]: Load from file %wZ\n", &FileName); Status = CmpInitHiveFromFile(&FileName, CmpMachineHiveList[i].HHiveFlags, &CmHive, @@ -1122,12 +1120,10 @@ } else { + /* We already have a hive, is it volatile? */ CmHive = CmpMachineHiveList[i].CmHive; - /* We already have a hive, is it volatile? */ if (!(CmHive->Hive.HiveFlags & HIVE_VOLATILE)) { - DPRINT1("[HiveLoad]: Open from file %wZ\n", &FileName); - /* It's now, open the hive file and log */ Status = CmpOpenHiveFiles(&FileName, L".LOG", @@ -1305,7 +1301,6 @@ }
/* Now link the hive to its master */ - DPRINT1("[HiveLoad]: Link %wZ\n", &RegName); Status = CmpLinkHiveToMaster(&RegName, NULL, CmpMachineHiveList[i].CmHive2,
Modified: trunk/reactos/ntoskrnl/ke/freeldr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/freeldr.c?rev=3... ============================================================================== --- trunk/reactos/ntoskrnl/ke/freeldr.c (original) +++ trunk/reactos/ntoskrnl/ke/freeldr.c Tue Dec 11 00:01:45 2007 @@ -36,7 +36,7 @@ ULONG BldrCurrentMd; ULONG BldrCurrentMod;
-/* NT Loader Data. Eats up about 80KB! */ +/* NT Loader Data. Eats up about 100KB! */ LOADER_PARAMETER_BLOCK BldrLoaderBlock; // 0x0000 LOADER_PARAMETER_EXTENSION BldrExtensionBlock; // 0x0060 CHAR BldrCommandLine[256]; // 0x00DC @@ -53,7 +53,7 @@ ARC_DISK_INFORMATION BldrArcDiskInfo; // 0x12134 CHAR BldrArcNames[32][256]; // 0x1213C ARC_DISK_SIGNATURE BldrDiskInfo[32]; // 0x1413C - // 0x1443C +CHAR BldrArcHwBuffer[16 * 1024]; // 0x1843C
/* BIOS Memory Map */ BIOS_MEMORY_DESCRIPTOR BiosMemoryDescriptors[16] = {{0}}; @@ -862,6 +862,34 @@
VOID NTAPI +KiRosFixupComponentTree(IN PCONFIGURATION_COMPONENT_DATA p, + IN ULONG i) +{ + PCONFIGURATION_COMPONENT pp; + + /* Loop each entry */ + while (p) + { + /* Grab the component entry */ + pp = &p->ComponentEntry; + + /* Fixup the pointers */ + if (pp->Identifier) pp->Identifier = (PVOID)((ULONG_PTR)pp->Identifier + i); + if (p->ConfigurationData) p->ConfigurationData = (PVOID)((ULONG_PTR)p->ConfigurationData + i); + if (p->Parent) p->Parent = (PVOID)((ULONG_PTR)p->Parent + i); + if (p->Sibling) p->Sibling = (PVOID)((ULONG_PTR)p->Sibling + i); + if (p->Child) p->Child = (PVOID)((ULONG_PTR)p->Child + i); + + /* Check if we have a child */ + if (p->Child) KiRosFixupComponentTree(p->Child, i); + + /* Get to the next entry */ + p = p->Sibling; + } +} + +VOID +NTAPI KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock, IN PLOADER_PARAMETER_BLOCK *NtLoaderBlock) { @@ -1185,6 +1213,15 @@ InsertTailList(&LoaderBlock->ArcDiskInformation->DiskSignatureListHead, &ArcDiskInfo->ListEntry); } + + /* Copy the ARC Hardware Tree */ + RtlCopyMemory(BldrArcHwBuffer, (PVOID)RosLoaderBlock->ArchExtra, 16 * 1024); + LoaderBlock->ConfigurationRoot = (PVOID)BldrArcHwBuffer; + + /* Apply fixups */ + KiRosFixupComponentTree(LoaderBlock->ConfigurationRoot, + (ULONG_PTR)BldrArcHwBuffer - + RosLoaderBlock->ArchExtra); }
VOID