- Refactor creation of component data under the HARDWARE\DESCRIPTION node to use separate routines in a new ARC file, so that registry routines are factored out of the process. This allows 1) Better portability with PPC branch (which will need to do the same kind of hardware work) 2) Ability to eventually get rid of the registry calls and build a true ARC hardware device tree instead (which the kernel will have to parse during boot). The idea is to remove registry writing support from freeldr (because the code is old and freeldr shouldn't be touching the registry anyway). Patch by Alex.

svn path=/trunk/; revision=31113
This commit is contained in:
Aleksey Bragin 2007-12-09 20:17:56 +00:00
parent a0da7760d4
commit 0e2f7faae4
7 changed files with 397 additions and 735 deletions

View file

@ -233,41 +233,12 @@ HalpCalibrateStallExecution(VOID)
delay_count /= (MILLISEC / 2); /* Calculate delay_count for 1ms */ delay_count /= (MILLISEC / 2); /* Calculate delay_count for 1ms */
} }
VOID
SetComponentInformation(FRLDRHKEY ComponentKey,
ULONG Flags,
ULONG Key,
ULONG Affinity)
{
CM_COMPONENT_INFORMATION CompInfo;
LONG Error;
CompInfo.Flags = Flags;
CompInfo.Version = 0;
CompInfo.Key = Key;
CompInfo.Affinity = Affinity;
/* Set 'Component Information' value */
Error = RegSetValue(ComponentKey,
L"Component Information",
REG_BINARY,
(PCHAR)&CompInfo,
sizeof(CM_COMPONENT_INFORMATION));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
}
}
static VOID static VOID
DetectPnpBios(FRLDRHKEY SystemKey, ULONG *BusNumber) DetectPnpBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{ {
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor; PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PNP_BIOS_DEVICE_NODE DeviceNode; PCM_PNP_BIOS_DEVICE_NODE DeviceNode;
PCM_PNP_BIOS_INSTALLATION_CHECK InstData; PCM_PNP_BIOS_INSTALLATION_CHECK InstData;
WCHAR Buffer[80];
FRLDRHKEY BusKey; FRLDRHKEY BusKey;
ULONG x; ULONG x;
ULONG NodeSize = 0; ULONG NodeSize = 0;
@ -278,7 +249,6 @@ DetectPnpBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
ULONG PnpBufferSize; ULONG PnpBufferSize;
ULONG Size; ULONG Size;
char *Ptr; char *Ptr;
LONG Error;
InstData = (PCM_PNP_BIOS_INSTALLATION_CHECK)PnpBiosSupported(); InstData = (PCM_PNP_BIOS_INSTALLATION_CHECK)PnpBiosSupported();
if (InstData == NULL || strncmp((CHAR*)InstData->Signature, "$PnP", 4)) if (InstData == NULL || strncmp((CHAR*)InstData->Signature, "$PnP", 4))
@ -304,38 +274,18 @@ DetectPnpBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
DbgPrint((DPRINT_HWDETECT, "MaxNodeSize %u NodeCount %u\n", NodeSize, NodeCount)); DbgPrint((DPRINT_HWDETECT, "MaxNodeSize %u NodeCount %u\n", NodeSize, NodeCount));
DbgPrint((DPRINT_HWDETECT, "Estimated buffer size %u\n", NodeSize * NodeCount)); DbgPrint((DPRINT_HWDETECT, "Estimated buffer size %u\n", NodeSize * NodeCount));
/* Create new bus key */ /* Create component key */
swprintf(Buffer, FldrCreateComponentKey(SystemKey, L"MultifunctionAdapter", *BusNumber, &BusKey);
L"MultifunctionAdapter\\%u", *BusNumber);
Error = RegCreateKey(SystemKey,
Buffer,
&BusKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
return;
}
/* Increment bus number */
(*BusNumber)++; (*BusNumber)++;
/* Set 'Component Information' value similar to my NT4 box */ /* Set the component information */
SetComponentInformation(BusKey, FldrSetComponentInformation(BusKey,
0x0, 0x0,
0x0, 0x0,
0xFFFFFFFF); 0xFFFFFFFF);
/* Set 'Identifier' value */ /* Set the identifier */
Error = RegSetValue(BusKey, FldrSetIdentifier(BusKey, L"PNP BIOS");
L"Identifier",
REG_SZ,
(PCHAR)L"PNP BIOS",
9 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
return;
}
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Size = sizeof(CM_FULL_RESOURCE_DESCRIPTOR) + (NodeSize * NodeCount); Size = sizeof(CM_FULL_RESOURCE_DESCRIPTOR) + (NodeSize * NodeCount);
@ -405,19 +355,8 @@ DetectPnpBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
DbgPrint((DPRINT_HWDETECT, "Real buffer size: %u\n", PnpBufferSize)); DbgPrint((DPRINT_HWDETECT, "Real buffer size: %u\n", PnpBufferSize));
DbgPrint((DPRINT_HWDETECT, "Resource size: %u\n", Size)); DbgPrint((DPRINT_HWDETECT, "Resource size: %u\n", Size));
/* Set 'Configuration Data' value */ FldrSetConfigurationData(BusKey, FullResourceDescriptor, Size);
Error = RegSetValue(BusKey,
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor); MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
}
} }
@ -431,7 +370,6 @@ SetHarddiskConfigurationData(FRLDRHKEY DiskKey,
EXTENDED_GEOMETRY ExtGeometry; EXTENDED_GEOMETRY ExtGeometry;
GEOMETRY Geometry; GEOMETRY Geometry;
ULONG Size; ULONG Size;
LONG Error;
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Size = sizeof(CM_FULL_RESOURCE_DESCRIPTOR) + Size = sizeof(CM_FULL_RESOURCE_DESCRIPTOR) +
@ -490,18 +428,8 @@ SetHarddiskConfigurationData(FRLDRHKEY DiskKey,
DiskGeometry->SectorsPerTrack, DiskGeometry->SectorsPerTrack,
DiskGeometry->BytesPerSector)); DiskGeometry->BytesPerSector));
Error = RegSetValue(DiskKey, FldrSetConfigurationData(DiskKey, FullResourceDescriptor, Size);
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor); MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
}
} }
@ -516,7 +444,6 @@ SetHarddiskIdentifier(FRLDRHKEY DiskKey,
ULONG Signature; ULONG Signature;
WCHAR Identifier[20]; WCHAR Identifier[20];
CHAR ArcName[256]; CHAR ArcName[256];
LONG Error;
/* Read the MBR */ /* Read the MBR */
if (!MachDiskReadLogicalSectors(DriveNumber, 0ULL, 1, (PVOID)DISKREADBUFFER)) if (!MachDiskReadLogicalSectors(DriveNumber, 0ULL, 1, (PVOID)DISKREADBUFFER))
@ -573,17 +500,7 @@ SetHarddiskIdentifier(FRLDRHKEY DiskKey,
DbgPrint((DPRINT_HWDETECT, "Identifier: %S\n", Identifier)); DbgPrint((DPRINT_HWDETECT, "Identifier: %S\n", Identifier));
/* Set identifier */ /* Set identifier */
Error = RegSetValue(DiskKey, FldrSetIdentifier(DiskKey, Identifier);
L"Identifier",
REG_SZ,
(PCHAR)Identifier,
sizeof(Identifier));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Identifier) failed (Error %u)\n",
(int)Error));
}
} }
@ -594,12 +511,10 @@ DetectBiosDisks(FRLDRHKEY SystemKey,
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor; PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_INT13_DRIVE_PARAMETER Int13Drives; PCM_INT13_DRIVE_PARAMETER Int13Drives;
GEOMETRY Geometry; GEOMETRY Geometry;
WCHAR Buffer[80];
FRLDRHKEY DiskKey; FRLDRHKEY DiskKey;
ULONG DiskCount; ULONG DiskCount;
ULONG Size; ULONG Size;
ULONG i; ULONG i;
LONG Error;
BOOLEAN Changed; BOOLEAN Changed;
/* Count the number of visible drives */ /* Count the number of visible drives */
@ -680,37 +595,17 @@ DetectBiosDisks(FRLDRHKEY SystemKey,
} }
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Error = RegSetValue(SystemKey, FldrSetConfigurationData(SystemKey, FullResourceDescriptor, Size);
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor); MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
return;
}
/* Create and fill subkey for each harddisk */ /* Create and fill subkey for each harddisk */
for (i = 0; i < DiskCount; i++) for (i = 0; i < DiskCount; i++)
{ {
/* Create disk key */ /* Create disk key */
swprintf (Buffer, FldrCreateComponentKey(BusKey,
L"DiskController\\0\\DiskPeripheral\\%u", L"DiskController\\0\\DiskPeripheral",
i); i,
Error = RegCreateKey(BusKey,
Buffer,
&DiskKey); &DiskKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "Failed to create drive key\n"));
continue;
}
DbgPrint((DPRINT_HWDETECT, "Created key: %S\n", Buffer));
/* Set disk values */ /* Set disk values */
SetHarddiskConfigurationData(DiskKey, 0x80 + i); SetHarddiskConfigurationData(DiskKey, 0x80 + i);
@ -764,11 +659,9 @@ DetectBiosFloppyPeripheral(FRLDRHKEY ControllerKey)
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor; PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor; PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
PCM_FLOPPY_DEVICE_DATA FloppyData; PCM_FLOPPY_DEVICE_DATA FloppyData;
WCHAR KeyName[32];
WCHAR Identifier[20]; WCHAR Identifier[20];
FRLDRHKEY PeripheralKey; FRLDRHKEY PeripheralKey;
ULONG Size; ULONG Size;
LONG Error;
ULONG FloppyNumber; ULONG FloppyNumber;
UCHAR FloppyType; UCHAR FloppyType;
ULONG MaxDensity[6] = {0, 360, 1200, 720, 1440, 2880}; ULONG MaxDensity[6] = {0, 360, 1200, 720, 1440, 2880};
@ -785,21 +678,13 @@ DetectBiosFloppyPeripheral(FRLDRHKEY ControllerKey)
Ptr = GetInt1eTable(); Ptr = GetInt1eTable();
swprintf(KeyName, L"FloppyDiskPeripheral\\%u", FloppyNumber); FldrCreateComponentKey(ControllerKey,
L"FloppyDiskPeripheral",
Error = RegCreateKey(ControllerKey, FloppyNumber,
KeyName,
&PeripheralKey); &PeripheralKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "Failed to create peripheral key\n"));
return;
}
DbgPrint((DPRINT_HWDETECT, "Created key: %S\n", KeyName));
/* Set 'ComponentInformation' value */ /* Set 'ComponentInformation' value */
SetComponentInformation(PeripheralKey, FldrSetComponentInformation(PeripheralKey,
0x0, 0x0,
FloppyNumber, FloppyNumber,
0xFFFFFFFF); 0xFFFFFFFF);
@ -838,33 +723,12 @@ DetectBiosFloppyPeripheral(FRLDRHKEY ControllerKey)
FloppyData->DataTransferRate = 0; FloppyData->DataTransferRate = 0;
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Error = RegSetValue(PeripheralKey, FldrSetConfigurationData(PeripheralKey, FullResourceDescriptor, Size);
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor); MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
return;
}
/* Set 'Identifier' value */ /* Set 'Identifier' value */
swprintf(Identifier, L"FLOPPY%u", FloppyNumber + 1); swprintf(Identifier, L"FLOPPY%u", FloppyNumber + 1);
Error = RegSetValue(PeripheralKey, FldrSetIdentifier(PeripheralKey, Identifier);
L"Identifier",
REG_SZ,
(PCHAR)Identifier,
(wcslen(Identifier) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue() failed (Error %u)\n",
(int)Error));
}
} }
} }
@ -877,7 +741,6 @@ DetectBiosFloppyController(FRLDRHKEY SystemKey,
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor; PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
FRLDRHKEY ControllerKey; FRLDRHKEY ControllerKey;
ULONG Size; ULONG Size;
LONG Error;
ULONG FloppyCount; ULONG FloppyCount;
FloppyCount = GetFloppyCount(); FloppyCount = GetFloppyCount();
@ -888,20 +751,15 @@ DetectBiosFloppyController(FRLDRHKEY SystemKey,
if (FloppyCount == 0) if (FloppyCount == 0)
return; return;
Error = RegCreateKey(BusKey, FldrCreateComponentKey(SystemKey,
L"DiskController\\0", L"DiskController",
0,
&ControllerKey); &ControllerKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "Failed to create controller key\n"));
return;
}
DbgPrint((DPRINT_HWDETECT, "Created key: DiskController\\0\n")); DbgPrint((DPRINT_HWDETECT, "Created key: DiskController\\0\n"));
/* Set 'ComponentInformation' value */ /* Set 'ComponentInformation' value */
SetComponentInformation(ControllerKey, FldrSetComponentInformation(ControllerKey,
0x64, Output | Input | Removable,
0, 0,
0xFFFFFFFF); 0xFFFFFFFF);
@ -950,19 +808,8 @@ DetectBiosFloppyController(FRLDRHKEY SystemKey,
PartialDescriptor->u.Dma.Port = 0; PartialDescriptor->u.Dma.Port = 0;
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey, FldrSetConfigurationData(ControllerKey, FullResourceDescriptor, Size);
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor); MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
return;
}
DetectBiosFloppyPeripheral(ControllerKey); DetectBiosFloppyPeripheral(ControllerKey);
} }
@ -1153,7 +1000,6 @@ DetectSerialPointerPeripheral(FRLDRHKEY ControllerKey,
ULONG i; ULONG i;
ULONG j; ULONG j;
ULONG k; ULONG k;
LONG Error;
DbgPrint((DPRINT_HWDETECT, DbgPrint((DPRINT_HWDETECT,
"DetectSerialPointerPeripheral()\n")); "DetectSerialPointerPeripheral()\n"));
@ -1281,21 +1127,16 @@ DetectSerialPointerPeripheral(FRLDRHKEY ControllerKey,
} }
/* Create 'PointerPeripheral' key */ /* Create 'PointerPeripheral' key */
Error = RegCreateKey(ControllerKey, FldrCreateComponentKey(ControllerKey,
L"PointerPeripheral\\0", L"PointerPeripheral",
0,
&PeripheralKey); &PeripheralKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"Failed to create peripheral key\n"));
return;
}
DbgPrint((DPRINT_HWDETECT, DbgPrint((DPRINT_HWDETECT,
"Created key: PointerPeripheral\\0\n")); "Created key: PointerPeripheral\\0\n"));
/* Set 'ComponentInformation' value */ /* Set 'ComponentInformation' value */
SetComponentInformation(PeripheralKey, FldrSetComponentInformation(PeripheralKey,
0x20, Input,
0, 0,
0xFFFFFFFF); 0xFFFFFFFF);
@ -1307,31 +1148,13 @@ DetectSerialPointerPeripheral(FRLDRHKEY ControllerKey,
FullResourceDescriptor.PartialResourceList.Revision = 1; FullResourceDescriptor.PartialResourceList.Revision = 1;
FullResourceDescriptor.PartialResourceList.Count = 0; FullResourceDescriptor.PartialResourceList.Count = 0;
Error = RegSetValue(PeripheralKey, FldrSetConfigurationData(PeripheralKey,
L"Configuration Data", &FullResourceDescriptor,
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)&FullResourceDescriptor,
sizeof(CM_FULL_RESOURCE_DESCRIPTOR) - sizeof(CM_FULL_RESOURCE_DESCRIPTOR) -
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
}
/* Set 'Identifier' value */ /* Set 'Identifier' value */
Error = RegSetValue(PeripheralKey, FldrSetIdentifier(PeripheralKey, Identifier);
L"Identifier",
REG_SZ,
(PCHAR)Identifier,
(wcslen(Identifier) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue() failed (Error %u)\n",
(int)Error));
}
} }
} }
@ -1349,7 +1172,6 @@ DetectSerialPorts(FRLDRHKEY BusKey)
ULONG ControllerNumber = 0; ULONG ControllerNumber = 0;
FRLDRHKEY ControllerKey; FRLDRHKEY ControllerKey;
ULONG i; ULONG i;
LONG Error;
ULONG Size; ULONG Size;
DbgPrint((DPRINT_HWDETECT, "DetectSerialPorts()\n")); DbgPrint((DPRINT_HWDETECT, "DetectSerialPorts()\n"));
@ -1368,23 +1190,14 @@ DetectSerialPorts(FRLDRHKEY BusKey)
Base)); Base));
/* Create controller key */ /* Create controller key */
swprintf(Buffer, FldrCreateComponentKey(BusKey,
L"SerialController\\%u", L"SerialController",
ControllerNumber); ControllerNumber,
Error = RegCreateKey(BusKey,
Buffer,
&ControllerKey); &ControllerKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "Failed to create controller key\n"));
continue;
}
DbgPrint((DPRINT_HWDETECT, "Created key: %S\n", Buffer));
/* Set 'ComponentInformation' value */ /* Set 'ComponentInformation' value */
SetComponentInformation(ControllerKey, FldrSetComponentInformation(ControllerKey,
0x78, Output | Input | ConsoleIn | ConsoleOut,
ControllerNumber, ControllerNumber,
0xFFFFFFFF); 0xFFFFFFFF);
@ -1438,35 +1251,12 @@ DetectSerialPorts(FRLDRHKEY BusKey)
SerialDeviceData->BaudClock = 1843200; /* UART Clock frequency (Hertz) */ SerialDeviceData->BaudClock = 1843200; /* UART Clock frequency (Hertz) */
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey, FldrSetConfigurationData(ControllerKey, FullResourceDescriptor, Size);
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor); MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
}
/* Set 'Identifier' value */ /* Set 'Identifier' value */
swprintf(Buffer, swprintf(Buffer, L"COM%u", i + 1);
L"COM%u", FldrSetIdentifier(ControllerKey, Buffer);
i + 1);
Error = RegSetValue(ControllerKey,
L"Identifier",
REG_SZ,
(PCHAR)Buffer,
(wcslen(Buffer) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue() failed (Error %u)\n",
(int)Error));
continue;
}
DbgPrint((DPRINT_HWDETECT, DbgPrint((DPRINT_HWDETECT,
"Created value: Identifier %s\n", "Created value: Identifier %s\n",
Buffer)); Buffer));
@ -1494,7 +1284,6 @@ DetectParallelPorts(FRLDRHKEY BusKey)
ULONG Base; ULONG Base;
ULONG ControllerNumber; ULONG ControllerNumber;
ULONG i; ULONG i;
LONG Error;
ULONG Size; ULONG Size;
DbgPrint((DPRINT_HWDETECT, "DetectParallelPorts() called\n")); DbgPrint((DPRINT_HWDETECT, "DetectParallelPorts() called\n"));
@ -1513,23 +1302,14 @@ DetectParallelPorts(FRLDRHKEY BusKey)
Base)); Base));
/* Create controller key */ /* Create controller key */
swprintf(Buffer, FldrCreateComponentKey(BusKey,
L"ParallelController\\%u", L"ParallelController",
ControllerNumber); ControllerNumber,
Error = RegCreateKey(BusKey,
Buffer,
&ControllerKey); &ControllerKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "Failed to create controller key\n"));
continue;
}
DbgPrint((DPRINT_HWDETECT, "Created key: %S\n", Buffer));
/* Set 'ComponentInformation' value */ /* Set 'ComponentInformation' value */
SetComponentInformation(ControllerKey, FldrSetComponentInformation(ControllerKey,
0x40, Output,
ControllerNumber, ControllerNumber,
0xFFFFFFFF); 0xFFFFFFFF);
@ -1576,35 +1356,12 @@ DetectParallelPorts(FRLDRHKEY BusKey)
} }
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey, FldrSetConfigurationData(ControllerKey, FullResourceDescriptor, Size);
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor); MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
}
/* Set 'Identifier' value */ /* Set 'Identifier' value */
swprintf(Buffer, swprintf(Buffer, L"PARALLEL%u", i + 1);
L"PARALLEL%u", FldrSetIdentifier(ControllerKey, Buffer);
i + 1);
Error = RegSetValue(ControllerKey,
L"Identifier",
REG_SZ,
(PCHAR)Buffer,
(wcslen(Buffer) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue() failed (Error %u)\n",
(int)Error));
continue;
}
DbgPrint((DPRINT_HWDETECT, DbgPrint((DPRINT_HWDETECT,
"Created value: Identifier %s\n", "Created value: Identifier %s\n",
Buffer)); Buffer));
@ -1695,25 +1452,20 @@ DetectKeyboardPeripheral(FRLDRHKEY ControllerKey)
PCM_KEYBOARD_DEVICE_DATA KeyboardData; PCM_KEYBOARD_DEVICE_DATA KeyboardData;
FRLDRHKEY PeripheralKey; FRLDRHKEY PeripheralKey;
ULONG Size; ULONG Size;
LONG Error;
/* HACK: don't call DetectKeyboardDevice() as it fails in Qemu 0.8.2 */ /* HACK: don't call DetectKeyboardDevice() as it fails in Qemu 0.8.2 */
if (TRUE || DetectKeyboardDevice()) if (TRUE || DetectKeyboardDevice())
{ {
/* Create controller key */ /* Create controller key */
Error = RegCreateKey(ControllerKey, FldrCreateComponentKey(ControllerKey,
L"KeyboardPeripheral\\0", L"KeyboardPeripheral",
0,
&PeripheralKey); &PeripheralKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "Failed to create peripheral key\n"));
return;
}
DbgPrint((DPRINT_HWDETECT, "Created key: KeyboardPeripheral\\0\n")); DbgPrint((DPRINT_HWDETECT, "Created key: KeyboardPeripheral\\0\n"));
/* Set 'ComponentInformation' value */ /* Set 'ComponentInformation' value */
SetComponentInformation(ControllerKey, FldrSetComponentInformation(ControllerKey,
0x28, Input | ConsoleIn,
0, 0,
0xFFFFFFFF); 0xFFFFFFFF);
@ -1749,31 +1501,11 @@ DetectKeyboardPeripheral(FRLDRHKEY ControllerKey)
KeyboardData->KeyboardFlags = 0x20; KeyboardData->KeyboardFlags = 0x20;
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Error = RegSetValue(PeripheralKey, FldrSetConfigurationData(PeripheralKey, FullResourceDescriptor, Size);
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor); MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
}
/* Set 'Identifier' value */ /* Set 'Identifier' value */
Error = RegSetValue(PeripheralKey, FldrSetIdentifier(PeripheralKey, L"PCAT_ENHANCED");
L"Identifier",
REG_SZ,
(PCHAR)L"PCAT_ENHANCED",
14 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue() failed (Error %u)\n",
(int)Error));
}
} }
} }
@ -1785,22 +1517,17 @@ DetectKeyboardController(FRLDRHKEY BusKey)
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor; PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
FRLDRHKEY ControllerKey; FRLDRHKEY ControllerKey;
ULONG Size; ULONG Size;
LONG Error;
/* Create controller key */ /* Create controller key */
Error = RegCreateKey(BusKey, FldrCreateComponentKey(BusKey,
L"KeyboardController\\0", L"KeyboardController",
0,
&ControllerKey); &ControllerKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "Failed to create controller key\n"));
return;
}
DbgPrint((DPRINT_HWDETECT, "Created key: KeyboardController\\0\n")); DbgPrint((DPRINT_HWDETECT, "Created key: KeyboardController\\0\n"));
/* Set 'ComponentInformation' value */ /* Set 'ComponentInformation' value */
SetComponentInformation(ControllerKey, FldrSetComponentInformation(ControllerKey,
0x28, Input | ConsoleIn,
0, 0,
0xFFFFFFFF); 0xFFFFFFFF);
@ -1851,19 +1578,8 @@ DetectKeyboardController(FRLDRHKEY BusKey)
PartialDescriptor->u.Port.Length = 1; PartialDescriptor->u.Port.Length = 1;
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey, FldrSetConfigurationData(ControllerKey, FullResourceDescriptor, Size);
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor); MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
return;
}
DetectKeyboardPeripheral(ControllerKey); DetectKeyboardPeripheral(ControllerKey);
} }
@ -1984,26 +1700,21 @@ DetectPS2Mouse(FRLDRHKEY BusKey)
CM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor; CM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
FRLDRHKEY ControllerKey; FRLDRHKEY ControllerKey;
FRLDRHKEY PeripheralKey; FRLDRHKEY PeripheralKey;
LONG Error;
if (DetectPS2AuxPort()) if (DetectPS2AuxPort())
{ {
DbgPrint((DPRINT_HWDETECT, "Detected PS2 port\n")); DbgPrint((DPRINT_HWDETECT, "Detected PS2 port\n"));
/* Create controller key */ /* Create controller key */
Error = RegCreateKey(BusKey, FldrCreateComponentKey(BusKey,
L"PointerController\\0", L"PointerController",
0,
&ControllerKey); &ControllerKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "Failed to create controller key\n"));
return;
}
DbgPrint((DPRINT_HWDETECT, "Created key: PointerController\\0\n")); DbgPrint((DPRINT_HWDETECT, "Created key: PointerController\\0\n"));
/* Set 'ComponentInformation' value */ /* Set 'ComponentInformation' value */
SetComponentInformation(ControllerKey, FldrSetComponentInformation(ControllerKey,
0x20, Input,
0, 0,
0xFFFFFFFF); 0xFFFFFFFF);
@ -2025,38 +1736,24 @@ DetectPS2Mouse(FRLDRHKEY BusKey)
FullResourceDescriptor.PartialResourceList.PartialDescriptors[0].u.Interrupt.Affinity = 0xFFFFFFFF; FullResourceDescriptor.PartialResourceList.PartialDescriptors[0].u.Interrupt.Affinity = 0xFFFFFFFF;
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey, FldrSetConfigurationData(ControllerKey,
L"Configuration Data", &FullResourceDescriptor,
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)&FullResourceDescriptor,
sizeof(CM_FULL_RESOURCE_DESCRIPTOR)); sizeof(CM_FULL_RESOURCE_DESCRIPTOR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
return;
}
if (DetectPS2AuxDevice()) if (DetectPS2AuxDevice())
{ {
DbgPrint((DPRINT_HWDETECT, "Detected PS2 mouse\n")); DbgPrint((DPRINT_HWDETECT, "Detected PS2 mouse\n"));
/* Create peripheral key */ /* Create peripheral key */
Error = RegCreateKey(ControllerKey, FldrCreateComponentKey(ControllerKey,
L"PointerPeripheral\\0", L"PointerController",
0,
&PeripheralKey); &PeripheralKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "Failed to create peripheral key\n"));
return;
}
DbgPrint((DPRINT_HWDETECT, "Created key: PointerPeripheral\\0\n")); DbgPrint((DPRINT_HWDETECT, "Created key: PointerPeripheral\\0\n"));
/* Set 'ComponentInformation' value */ /* Set 'ComponentInformation' value */
SetComponentInformation(PeripheralKey, FldrSetComponentInformation(PeripheralKey,
0x20, Input,
0, 0,
0xFFFFFFFF); 0xFFFFFFFF);
@ -2069,33 +1766,13 @@ DetectPS2Mouse(FRLDRHKEY BusKey)
FullResourceDescriptor.PartialResourceList.Count = 0; FullResourceDescriptor.PartialResourceList.Count = 0;
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Error = RegSetValue(PeripheralKey, FldrSetConfigurationData(PeripheralKey,
L"Configuration Data", &FullResourceDescriptor,
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)&FullResourceDescriptor,
sizeof(CM_FULL_RESOURCE_DESCRIPTOR) - sizeof(CM_FULL_RESOURCE_DESCRIPTOR) -
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
return;
}
/* Set 'Identifier' value */ /* Set 'Identifier' value */
Error = RegSetValue(PeripheralKey, FldrSetIdentifier(PeripheralKey, L"MICROSOFT PS2 MOUSE");
L"Identifier",
REG_SZ,
(PCHAR)L"MICROSOFT PS2 MOUSE",
20 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue() failed (Error %u)\n",
(int)Error));
return;
}
} }
} }
} }
@ -2107,20 +1784,15 @@ DetectDisplayController(FRLDRHKEY BusKey)
WCHAR Buffer[80]; WCHAR Buffer[80];
FRLDRHKEY ControllerKey; FRLDRHKEY ControllerKey;
USHORT VesaVersion; USHORT VesaVersion;
LONG Error;
Error = RegCreateKey(BusKey, FldrCreateComponentKey(BusKey,
L"DisplayController\\0", L"DisplayController",
0,
&ControllerKey); &ControllerKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "Failed to create controller key\n"));
return;
}
DbgPrint((DPRINT_HWDETECT, "Created key: DisplayController\\0\n")); DbgPrint((DPRINT_HWDETECT, "Created key: DisplayController\\0\n"));
/* Set 'ComponentInformation' value */ /* Set 'ComponentInformation' value */
SetComponentInformation(ControllerKey, FldrSetComponentInformation(ControllerKey,
0x00, 0x00,
0, 0,
0xFFFFFFFF); 0xFFFFFFFF);
@ -2153,18 +1825,7 @@ DetectDisplayController(FRLDRHKEY BusKey)
} }
/* Set 'Identifier' value */ /* Set 'Identifier' value */
Error = RegSetValue(ControllerKey, FldrSetIdentifier(ControllerKey, Buffer);
L"Identifier",
REG_SZ,
(PCHAR)Buffer,
(wcslen(Buffer) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue() failed (Error %u)\n",
(int)Error));
return;
}
/* FIXME: Add display peripheral (monitor) data */ /* FIXME: Add display peripheral (monitor) data */
} }
@ -2174,25 +1835,17 @@ static VOID
DetectIsaBios(FRLDRHKEY SystemKey, ULONG *BusNumber) DetectIsaBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{ {
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor; PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
WCHAR Buffer[80];
FRLDRHKEY BusKey; FRLDRHKEY BusKey;
ULONG Size; ULONG Size;
LONG Error;
/* Create new bus key */ /* Create new bus key */
swprintf(Buffer, FldrCreateComponentKey(SystemKey,
L"MultifunctionAdapter\\%u", *BusNumber); L"MultifunctionAdapter",
Error = RegCreateKey(SystemKey, *BusNumber,
Buffer,
&BusKey); &BusKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
return;
}
/* Set 'Component Information' value similar to my NT4 box */ /* Set 'Component Information' value similar to my NT4 box */
SetComponentInformation(BusKey, FldrSetComponentInformation(BusKey,
0x0, 0x0,
0x0, 0x0,
0xFFFFFFFF); 0xFFFFFFFF);
@ -2201,16 +1854,7 @@ DetectIsaBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
(*BusNumber)++; (*BusNumber)++;
/* Set 'Identifier' value */ /* Set 'Identifier' value */
Error = RegSetValue(BusKey, FldrSetIdentifier(BusKey, L"ISA");
L"Identifier",
REG_SZ,
(PCHAR)L"ISA",
4 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
return;
}
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Size = sizeof(CM_FULL_RESOURCE_DESCRIPTOR) - Size = sizeof(CM_FULL_RESOURCE_DESCRIPTOR) -
@ -2232,19 +1876,8 @@ DetectIsaBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
FullResourceDescriptor->PartialResourceList.Count = 0; FullResourceDescriptor->PartialResourceList.Count = 0;
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Error = RegSetValue(BusKey, FldrSetConfigurationData(BusKey, FullResourceDescriptor, Size);
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor); MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
return;
}
/* Detect ISA/BIOS devices */ /* Detect ISA/BIOS devices */
DetectBiosDisks(SystemKey, BusKey); DetectBiosDisks(SystemKey, BusKey);
@ -2270,19 +1903,11 @@ PcHwDetect(VOID)
{ {
FRLDRHKEY SystemKey; FRLDRHKEY SystemKey;
ULONG BusNumber = 0; ULONG BusNumber = 0;
LONG Error;
DbgPrint((DPRINT_HWDETECT, "DetectHardware()\n")); DbgPrint((DPRINT_HWDETECT, "DetectHardware()\n"));
/* Create the 'System' key */ /* Create the 'System' key */
Error = RegCreateKey(NULL, FldrCreateSystemKey(&SystemKey);
L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
&SystemKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
return;
}
/* Detect buses */ /* Detect buses */
DetectPciBios(SystemKey, &BusNumber); DetectPciBios(SystemKey, &BusNumber);

View file

@ -51,28 +51,21 @@ FindAcpiBios(VOID)
VOID VOID
DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber) DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{ {
WCHAR Buffer[80];
FRLDRHKEY BiosKey; FRLDRHKEY BiosKey;
LONG Error;
if (FindAcpiBios()) if (FindAcpiBios())
{ {
AcpiPresent = TRUE; AcpiPresent = TRUE;
/* Create new bus key */ /* Create new bus key */
swprintf(Buffer, FldrCreateComponentKey(SystemKey,
L"MultifunctionAdapter\\%u", *BusNumber); L"MultifunctionAdapter",
Error = RegCreateKey(SystemKey, *BusNumber,
Buffer,
&BiosKey); &BiosKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
return;
}
#if 0 #if 0
/* Set 'Component Information' */ /* Set 'Component Information' */
SetComponentInformation(BiosKey, FldrSetComponentInformation(BiosKey,
0x0, 0x0,
0x0, 0x0,
0xFFFFFFFF); 0xFFFFFFFF);
@ -82,18 +75,10 @@ DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
(*BusNumber)++; (*BusNumber)++;
/* Set 'Identifier' value */ /* Set 'Identifier' value */
Error = RegSetValue(BiosKey, FldrSetIdentifier(BiosKey, L"ACPI BIOS");
L"Identifier",
REG_SZ,
(PCHAR)L"ACPI BIOS",
10 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
return;
} }
} /* FIXME: Add congiguration data */
} }
/* EOF */ /* EOF */

View file

@ -56,27 +56,19 @@ FindApmBios(VOID)
VOID VOID
DetectApmBios(FRLDRHKEY SystemKey, ULONG *BusNumber) DetectApmBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{ {
WCHAR Buffer[80];
FRLDRHKEY BiosKey; FRLDRHKEY BiosKey;
LONG Error;
if (FindApmBios()) if (FindApmBios())
{ {
/* Create new bus key */ /* Create new bus key */
swprintf(Buffer, FldrCreateComponentKey(SystemKey,
L"MultifunctionAdapter\\%u", *BusNumber); L"MultifunctionAdapter",
Error = RegCreateKey(SystemKey, *BusNumber,
Buffer,
&BiosKey); &BiosKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
return;
}
#if 0 #if 0
/* Set 'Component Information' */ /* Set 'Component Information' */
SetComponentInformation(BiosKey, FldrSetComponentInformation(BiosKey,
0x0, 0x0,
0x0, 0x0,
0xFFFFFFFF); 0xFFFFFFFF);
@ -86,17 +78,7 @@ DetectApmBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
(*BusNumber)++; (*BusNumber)++;
/* Set 'Identifier' value */ /* Set 'Identifier' value */
Error = RegSetValue(BiosKey, FldrSetIdentifier(BiosKey, L"APM");
L"Identifier",
REG_SZ,
(PCHAR)L"APM",
4 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
return;
}
} }
/* FIXME: Add congiguration data */ /* FIXME: Add congiguration data */

View file

@ -147,39 +147,25 @@ DetectPciIrqRoutingTable(FRLDRHKEY BusKey)
PPCI_IRQ_ROUTING_TABLE Table; PPCI_IRQ_ROUTING_TABLE Table;
FRLDRHKEY TableKey; FRLDRHKEY TableKey;
ULONG Size; ULONG Size;
LONG Error;
Table = GetPciIrqRoutingTable(); Table = GetPciIrqRoutingTable();
if (Table != NULL) if (Table != NULL)
{ {
DbgPrint((DPRINT_HWDETECT, "Table size: %u\n", Table->Size)); DbgPrint((DPRINT_HWDETECT, "Table size: %u\n", Table->Size));
Error = RegCreateKey(BusKey, FldrCreateComponentKey(BusKey,
L"RealModeIrqRoutingTable\\0", L"RealModeIrqRoutingTable",
0,
&TableKey); &TableKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
return;
}
/* Set 'Component Information' */ /* Set 'Component Information' */
SetComponentInformation(TableKey, FldrSetComponentInformation(TableKey,
0x0, 0x0,
0x0, 0x0,
0xFFFFFFFF); 0xFFFFFFFF);
/* Set 'Identifier' value */ /* Set 'Identifier' value */
Error = RegSetValue(TableKey, FldrSetIdentifier(TableKey, L"PCI Real-mode IRQ Routing Table");
L"Identifier",
REG_SZ,
(PCHAR)L"PCI Real-mode IRQ Routing Table",
32 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
return;
}
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Size = FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList.PartialDescriptors) + Size = FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList.PartialDescriptors) +
@ -216,19 +202,8 @@ DetectPciIrqRoutingTable(FRLDRHKEY BusKey)
Table->Size); Table->Size);
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Error = RegSetValue(TableKey, FldrSetConfigurationData(TableKey, FullResourceDescriptor, Size);
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor); MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
return;
}
} }
} }
@ -238,10 +213,8 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{ {
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor; PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
CM_PCI_BUS_DATA BusData; CM_PCI_BUS_DATA BusData;
WCHAR Buffer[80];
FRLDRHKEY BiosKey; FRLDRHKEY BiosKey;
ULONG Size; ULONG Size;
LONG Error;
#if 0 #if 0
FRLDRHKEY BusKey; FRLDRHKEY BusKey;
ULONG i; ULONG i;
@ -252,19 +225,13 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
if (FindPciBios(&BusData)) if (FindPciBios(&BusData))
{ {
/* Create new bus key */ /* Create new bus key */
swprintf(Buffer, FldrCreateComponentKey(SystemKey,
L"MultifunctionAdapter\\%u", *BusNumber); L"MultifunctionAdapter",
Error = RegCreateKey(SystemKey, *BusNumber,
Buffer,
&BiosKey); &BiosKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
return;
}
/* Set 'Component Information' */ /* Set 'Component Information' */
SetComponentInformation(BiosKey, FldrSetComponentInformation(BiosKey,
0x0, 0x0,
0x0, 0x0,
0xFFFFFFFF); 0xFFFFFFFF);
@ -273,16 +240,7 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
(*BusNumber)++; (*BusNumber)++;
/* Set 'Identifier' value */ /* Set 'Identifier' value */
Error = RegSetValue(BiosKey, FldrSetIdentifier(BiosKey, L"PCI BIOS");
L"Identifier",
REG_SZ,
(PCHAR)L"PCI BIOS",
9 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
return;
}
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Size = sizeof(CM_FULL_RESOURCE_DESCRIPTOR); Size = sizeof(CM_FULL_RESOURCE_DESCRIPTOR);
@ -307,19 +265,8 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
FullResourceDescriptor->PartialResourceList.PartialDescriptors[0].u.BusNumber.Length = 1; FullResourceDescriptor->PartialResourceList.PartialDescriptors[0].u.BusNumber.Length = 1;
/* Set 'Configuration Data' value */ /* Set 'Configuration Data' value */
Error = RegSetValue(BiosKey, FldrSetConfigurationData(BiosKey, FullResourceDescriptor, Size);
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor); MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
(int)Error));
return;
}
DetectPciIrqRoutingTable(BiosKey); DetectPciIrqRoutingTable(BiosKey);
@ -333,20 +280,13 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
/* Report PCI buses */ /* Report PCI buses */
for (i = 0; i < (ULONG)BusData.BusCount; i++) for (i = 0; i < (ULONG)BusData.BusCount; i++)
{ {
swprintf(Buffer, FldrCreateComponentKey(SystemKey,
L"MultifunctionAdapter\\%u", *BusNumber); L"MultifunctionAdapter",
Error = RegCreateKey(SystemKey, *BusNumber,
Buffer, &BiosKey);
&BusKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
printf("RegCreateKey() failed (Error %u)\n", (int)Error);
return;
}
/* Set 'Component Information' */ /* Set 'Component Information' */
SetComponentInformation(BusKey, FldrSetComponentInformation(BusKey,
0x0, 0x0,
0x0, 0x0,
0xFFFFFFFF); 0xFFFFFFFF);
@ -354,21 +294,10 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
/* Increment bus number */ /* Increment bus number */
(*BusNumber)++; (*BusNumber)++;
/* Set 'Identifier' value */ /* Set 'Identifier' value */
Error = RegSetValue(BusKey, FldrSetIdentifier(BiosKey, szPci);
L"Identifier",
REG_SZ,
(PCSTR)szPci,
sizeof(szPci));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
return;
}
} }
#endif #endif
} }
} }

View file

@ -46,6 +46,7 @@
<directory name="reactos"> <directory name="reactos">
<file>registry.c</file> <file>registry.c</file>
<file>arcname.c</file> <file>arcname.c</file>
<file>archwsup.c</file>
<file>binhive.c</file> <file>binhive.c</file>
<file>reactos.c</file> <file>reactos.c</file>
</directory> </directory>

View file

@ -25,34 +25,52 @@
#include "../../reactos/registry.h" #include "../../reactos/registry.h"
#endif #endif
/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags */
#define CM_RESOURCE_PORT_MEMORY 0x0000
#define CM_RESOURCE_PORT_IO 0x0001
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
#define CM_RESOURCE_INTERRUPT_LATCHED 0x0001
typedef struct _CM_COMPONENT_INFORMATION
{
ULONG Flags;
ULONG Version;
ULONG Key;
ULONG Affinity;
} __attribute__((packed)) CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION;
/* CM_COMPONENT_INFORMATION.Flags */
#define Failed 0x00000001
//#define ReadOnly 0x00000002
#define Removable 0x00000004
#define ConsoleIn 0x00000008
#define ConsoleOut 0x00000010
#define Input 0x00000020
#define Output 0x00000040
#define CONFIG_CMD(bus, dev_fn, where) \ #define CONFIG_CMD(bus, dev_fn, where) \
(0x80000000 | (((ULONG)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3)) (0x80000000 | (((ULONG)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3))
//
// ARC Component Configuration Routines
//
VOID
NTAPI
FldrSetComponentInformation(
IN FRLDRHKEY ComponentKey,
IN IDENTIFIER_FLAG Flags,
IN ULONG Key,
IN ULONG Affinity
);
VOID
NTAPI
FldrSetIdentifier(
IN FRLDRHKEY ComponentKey,
IN PWCHAR Identifier
);
VOID
NTAPI
FldrCreateSystemKey(
OUT FRLDRHKEY *SystemKey
);
VOID
NTAPI
FldrCreateComponentKey(
IN FRLDRHKEY SystemKey,
IN PWCHAR BusName,
IN ULONG BusNumber,
OUT FRLDRHKEY *ComponentKey
);
VOID
NTAPI
FldrSetConfigurationData(
IN FRLDRHKEY ComponentKey,
IN PVOID ConfigurationData,
IN ULONG Size
);
/* PROTOTYPES ***************************************************************/ /* PROTOTYPES ***************************************************************/
/* hardware.c */ /* hardware.c */
@ -61,11 +79,6 @@ VOID StallExecutionProcessor(ULONG Microseconds);
VOID HalpCalibrateStallExecution(VOID); VOID HalpCalibrateStallExecution(VOID);
VOID SetComponentInformation(FRLDRHKEY ComponentKey,
ULONG Flags,
ULONG Key,
ULONG Affinity);
/* hwacpi.c */ /* hwacpi.c */
VOID DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber); VOID DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber);

View file

@ -0,0 +1,127 @@
/*
* PROJECT: ReactOS Boot Loader (FreeLDR)
* LICENSE: GPL - See COPYING in the top level directory
* FILE: boot/freeldr/freeldr/reactos/archwsup.c
* PURPOSE: Routines for ARC Hardware Tree and Configuration Data
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES *******************************************************************/
#include <freeldr.h>
#define NDEBUG
#include <debug.h>
/* FUNCTIONS ******************************************************************/
VOID
NTAPI
FldrSetComponentInformation(IN FRLDRHKEY ComponentKey,
IN IDENTIFIER_FLAG Flags,
IN ULONG Key,
IN ULONG Affinity)
{
CONFIGURATION_COMPONENT ConfigurationComponent;
LONG Error;
/* Build the component information */
ConfigurationComponent.Flags = Flags;
ConfigurationComponent.Version = 0;
ConfigurationComponent.Revision = 0;
ConfigurationComponent.Key = Key;
ConfigurationComponent.AffinityMask = Affinity;
/* Set the value */
Error = RegSetValue(ComponentKey,
L"Component Information",
REG_BINARY,
(PVOID)&ConfigurationComponent.Flags,
FIELD_OFFSET(CONFIGURATION_COMPONENT, ConfigurationDataLength) -
FIELD_OFFSET(CONFIGURATION_COMPONENT, Flags));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", Error));
}
}
VOID
NTAPI
FldrSetIdentifier(IN FRLDRHKEY ComponentKey,
IN PWCHAR Identifier)
{
LONG Error;
ULONG IdentifierLength = (wcslen(Identifier) + 1) * sizeof(WCHAR);
/* Set the key */
Error = RegSetValue(ComponentKey,
L"Identifier",
REG_SZ,
(PCHAR)Identifier,
IdentifierLength);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", Error));
return;
}
}
VOID
NTAPI
FldrCreateSystemKey(OUT FRLDRHKEY *SystemKey)
{
LONG Error;
/* Create the key */
Error = RegCreateKey(NULL,
L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
SystemKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", Error));
return;
}
}
VOID
NTAPI
FldrCreateComponentKey(IN FRLDRHKEY SystemKey,
IN PWCHAR BusName,
IN ULONG BusNumber,
OUT FRLDRHKEY *ComponentKey)
{
LONG Error;
WCHAR Buffer[80];
/* Build the key name */
swprintf(Buffer, L"%s\\%u", BusName, BusNumber);
/* Create the key */
Error = RegCreateKey(SystemKey, Buffer, ComponentKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", Error));
return;
}
}
VOID
NTAPI
FldrSetConfigurationData(IN FRLDRHKEY ComponentKey,
IN PVOID ConfigurationData,
IN ULONG Size)
{
LONG Error;
/* Set 'Configuration Data' value */
Error = RegSetValue(ComponentKey,
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
ConfigurationData,
Size);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
"RegSetValue(Configuration Data) failed (Error %u)\n",
Error));
}
}