Author: sir_richard
Date: Tue Jun 29 20:21:45 2010
New Revision: 47908
URL:
http://svn.reactos.org/svn/reactos?rev=47908&view=rev
Log:
[PCIX]: Fix 17 different bugs in the new PCI driver. ACPI and PCI IRQ Routing table
detection now works, ACPI table mapping doesn't crash anymore, PciGetRegistryValue
doens't always fail, some DPRINTs fixed, added missing "continues",
"breaks", and early-"returns". Fixed missing, or extra "!"s.
If you're going to try being clever with do while FALSE loops, get 'em right!
The driver now works up to the point where eVb has last committed his code.
Modified:
trunk/reactos/drivers/bus/pcix/init.c
trunk/reactos/drivers/bus/pcix/pci.h
trunk/reactos/drivers/bus/pcix/utils.c
Modified: trunk/reactos/drivers/bus/pcix/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/init.c?re…
==============================================================================
--- trunk/reactos/drivers/bus/pcix/init.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/pcix/init.c [iso-8859-1] Tue Jun 29 20:21:45 2010
@@ -37,7 +37,7 @@
HANDLE KeyHandle, SubKey;
ULONG NumberOfBytes, i, Length;
PKEY_FULL_INFORMATION FullInfo;
- PKEY_VALUE_BASIC_INFORMATION KeyInfo;
+ PKEY_BASIC_INFORMATION KeyInfo;
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
PACPI_BIOS_MULTI_NODE NodeData;
UNICODE_STRING ValueName;
@@ -98,15 +98,19 @@
PCI_POOL_TAG);
if (!ValueInfo) break;
- /* Query each sub-key */
- Status = ZwEnumerateKey(KeyHandle,
- 0,
- KeyValueBasicInformation,
- KeyInfo,
- Length,
- &NumberOfBytes);
- for (i = 0; Status != STATUS_NO_MORE_ENTRIES; i++)
- {
+ /* Loop each sub-key */
+ i = 0;
+ while (TRUE)
+ {
+ /* Query each sub-key */
+ Status = ZwEnumerateKey(KeyHandle,
+ i++,
+ KeyBasicInformation,
+ KeyInfo,
+ Length,
+ &NumberOfBytes);
+ if (Status == STATUS_NO_MORE_ENTRIES) break;
+
/* Null-terminate the keyname, because the kernel does not */
KeyInfo->Name[KeyInfo->NameLength / sizeof(WCHAR)] = UNICODE_NULL;
@@ -127,29 +131,29 @@
sizeof(KEY_VALUE_PARTIAL_INFORMATION) +
sizeof(L"ACPI BIOS"),
&NumberOfBytes);
- if (NT_SUCCESS(Status))
- {
- /* Check if this is the PCI BIOS subkey */
- if (!wcsncmp((PWCHAR)ValueInfo->Data,
- L"ACPI BIOS",
- ValueInfo->DataLength))
- {
- /* It is, proceed to query the PCI IRQ routing table */
- Status = PciGetRegistryValue(L"Configuration Data",
- KeyInfo->Name,
- KeyHandle,
- REG_FULL_RESOURCE_DESCRIPTOR,
- (PVOID*)&Package,
- &NumberOfBytes);
- ZwClose(SubKey);
- break;
- }
- }
-
- /* Close the subkey and try the next one */
- ZwClose(SubKey);
- }
- }
+ if (NT_SUCCESS(Status))
+ {
+ /* Check if this is the PCI BIOS subkey */
+ if (!wcsncmp((PWCHAR)ValueInfo->Data,
+ L"ACPI BIOS",
+ ValueInfo->DataLength))
+ {
+ /* It is, proceed to query the PCI IRQ routing table */
+ Status = PciGetRegistryValue(L"Configuration Data",
+ KeyInfo->Name,
+ KeyHandle,
+ REG_FULL_RESOURCE_DESCRIPTOR,
+ (PVOID*)&Package,
+ &NumberOfBytes);
+ ZwClose(SubKey);
+ break;
+ }
+ }
+
+ /* Close the subkey and try the next one */
+ ZwClose(SubKey);
+ }
+ }
/* Check if we got here because the routing table was found */
if (!NT_SUCCESS(Status))
@@ -176,6 +180,7 @@
/* Copy the data */
RtlCopyMemory(*AcpiMultiNode, NodeData, Length);
+ Status = STATUS_SUCCESS;
} while (FALSE);
/* Close any opened keys, free temporary allocations, and return status */
@@ -202,7 +207,7 @@
/* Try to find the RSDT or XSDT */
Status = PciAcpiFindRsdt(&AcpiMultiNode);
- if (NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status))
{
/* No ACPI on the machine */
DPRINT1("AcpiFindRsdt() Failed!\n");
@@ -231,7 +236,6 @@
if (!Rsdt) return NULL;
/* Validate the table's signature */
- DPRINT1("ACPI RSDT/XSDT at 0x%p\n", Rsdt);
if ((Rsdt->Header.Signature != RSDT_SIGNATURE) &&
(Rsdt->Header.Signature != XSDT_SIGNATURE))
{
@@ -269,7 +273,7 @@
if (Rsdt->Header.Signature != XSDT_SIGNATURE)
{
/* Read the 32-bit physical address */
- PhysicalAddress.LowPart = Rsdt->Tables[CurrentEntry];
+ PhysicalAddress.QuadPart = Rsdt->Tables[CurrentEntry];
}
else
{
@@ -313,7 +317,7 @@
HANDLE KeyHandle, SubKey;
ULONG NumberOfBytes, i, Length;
PKEY_FULL_INFORMATION FullInfo;
- PKEY_VALUE_BASIC_INFORMATION KeyInfo;
+ PKEY_BASIC_INFORMATION KeyInfo;
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
UNICODE_STRING ValueName;
struct
@@ -364,24 +368,28 @@
Status = STATUS_INSUFFICIENT_RESOURCES;
Length = FullInfo->MaxNameLen + 26;
KeyInfo = ExAllocatePoolWithTag(PagedPool, Length, PCI_POOL_TAG);
- if ( !KeyInfo ) break;
+ if (!KeyInfo) break;
/* Allocate the value information and name we expect to find */
ValueInfo = ExAllocatePoolWithTag(PagedPool,
sizeof(KEY_VALUE_PARTIAL_INFORMATION) +
sizeof(L"PCI BIOS"),
PCI_POOL_TAG);
- if ( !ValueInfo ) break;
-
- /* Query each sub-key */
- Status = ZwEnumerateKey(KeyHandle,
- 0,
- KeyValueBasicInformation,
- KeyInfo,
- Length,
- &NumberOfBytes);
- for (i = 0; Status != STATUS_NO_MORE_ENTRIES; i++)
- {
+ if (!ValueInfo) break;
+
+ /* Loop each sub-key */
+ i = 0;
+ while (TRUE)
+ {
+ /* Query each sub-key */
+ Status = ZwEnumerateKey(KeyHandle,
+ i++,
+ KeyBasicInformation,
+ KeyInfo,
+ Length,
+ &NumberOfBytes);
+ if (Status == STATUS_NO_MORE_ENTRIES) break;
+
/* Null-terminate the keyname, because the kernel does not */
KeyInfo->Name[KeyInfo->NameLength / sizeof(WCHAR)] = UNICODE_NULL;
@@ -576,7 +584,9 @@
(NameLength != PCI_HACK_ENTRY_SUBSYS_SIZE) &&
(NameLength != PCI_HACK_ENTRY_FULL_SIZE))
{
+ /* It's an invalid entry, skip it */
DPRINT1("Skipping hack entry with invalid length name\n");
+ continue;
}
/* Initialize the entry */
@@ -634,11 +644,11 @@
DPRINT1("Adding Hack entry for Vendor:0x%04x Device:0x%04x ",
Entry->VendorID, Entry->DeviceID);
if (Entry->Flags & PCI_HACK_HAS_SUBSYSTEM_INFO)
- DPRINT1("SybSys:0x%04x SubVendor:0x%04x ",
- Entry->SubSystemID, Entry->SubVendorID);
+ DbgPrint("SybSys:0x%04x SubVendor:0x%04x ",
+ Entry->SubSystemID, Entry->SubVendorID);
if (Entry->Flags & PCI_HACK_HAS_REVISION_INFO)
- DPRINT1("Revision:0x%02x", Entry->RevisionID);
- DPRINT1(" = 0x%I64x\n", Entry->HackFlags);
+ DbgPrint("Revision:0x%02x", Entry->RevisionID);
+ DbgPrint(" = 0x%I64x\n", Entry->HackFlags);
}
/* Bail out in case of failure */
@@ -843,6 +853,7 @@
/* Check if the system has an ACPI Hardware Watchdog Timer */
WdTable = PciGetAcpiTable(WDRT_SIGNATURE);
+ Status = STATUS_SUCCESS;
} while (FALSE);
/* Close all opened keys, return driver status to PnP Manager */
Modified: trunk/reactos/drivers/bus/pcix/pci.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/pci.h?rev…
==============================================================================
--- trunk/reactos/drivers/bus/pcix/pci.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/pcix/pci.h [iso-8859-1] Tue Jun 29 20:21:45 2010
@@ -38,10 +38,10 @@
//
// PCI Hack Entry Name Lengths
//
-#define PCI_HACK_ENTRY_SIZE sizeof(L"VVVVdddd") //
16
-#define PCI_HACK_ENTRY_REV_SIZE sizeof(L"VVVVddddRR") //
20
-#define PCI_HACK_ENTRY_SUBSYS_SIZE sizeof(L"VVVVddddssssIIII") //
32
-#define PCI_HACK_ENTRY_FULL_SIZE sizeof(L"VVVVddddssssIIIIRR") //
36
+#define PCI_HACK_ENTRY_SIZE sizeof(L"VVVVdddd") -
sizeof(UNICODE_NULL)
+#define PCI_HACK_ENTRY_REV_SIZE sizeof(L"VVVVddddRR") -
sizeof(UNICODE_NULL)
+#define PCI_HACK_ENTRY_SUBSYS_SIZE sizeof(L"VVVVddddssssIIII") -
sizeof(UNICODE_NULL)
+#define PCI_HACK_ENTRY_FULL_SIZE sizeof(L"VVVVddddssssIIIIRR") -
sizeof(UNICODE_NULL)
//
// PCI Hack Entry Flags
Modified: trunk/reactos/drivers/bus/pcix/utils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/utils.c?r…
==============================================================================
--- trunk/reactos/drivers/bus/pcix/utils.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/pcix/utils.c [iso-8859-1] Tue Jun 29 20:21:45 2010
@@ -260,6 +260,7 @@
/* Copy the data into the buffer and return its length to the caller */
RtlCopyMemory(*OutputBuffer, PartialInfo->Data, NeededLength);
if (OutputLength) *OutputLength = NeededLength;
+ Status = STATUS_SUCCESS;
} while (0);
/* Close any opened keys and free temporary allocations */
@@ -325,7 +326,6 @@
if (!NT_SUCCESS(Status)) break;
/* Success, ranges added done */
- return STATUS_SUCCESS;
};
RtlFreeRangeList(&PciIsaBitExclusionList);