* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: io.h,v 1.45 2004/10/22 10:55:35 ekohl Exp $
+/* $Id: io.h,v 1.46 2004/10/23 14:46:04 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
typedef struct _DEVICE_NODE
{
+ /* A tree structure. */
struct _DEVICE_NODE *Parent;
struct _DEVICE_NODE *PrevSibling;
struct _DEVICE_NODE *NextSibling;
struct _DEVICE_NODE *Child;
- PDEVICE_OBJECT Pdo;
- UNICODE_STRING InstancePath;
- UNICODE_STRING ServiceName;
- //TargetDeviceNotifyList?
- PDEVICE_CAPABILITIES CapabilityFlags;
+ /* The level of deepness in the tree. */
+ UINT Level;
+ /* */
+// PPO_DEVICE_NOTIFY Notify;
+ /* State machine. */
+// PNP_DEVNODE_STATE State;
+// PNP_DEVNODE_STATE PreviousState;
+// PNP_DEVNODE_STATE StateHistory[20];
+ UINT StateHistoryEntry;
+ /* ? */
+ INT CompletionStatus;
+ /* ? */
+ PIRP PendingIrp;
+ /* See DNF_* flags below (WinDBG documentation has WRONG values) */
ULONG Flags;
+ /* See DNUF_* flags below */
ULONG UserFlags;
- ULONG DisableableDepends;
+ /* See CM_PROB_* values are defined in cfg.h */
ULONG Problem;
- PCM_RESOURCE_LIST CmResourceList;
- PCM_RESOURCE_LIST BootResourceList;
- PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList;
+ /* Pointer to the PDO corresponding to the device node. */
+ PDEVICE_OBJECT PhysicalDeviceObject;
+ /* Resource list as assigned by the PnP arbiter. See IRP_MN_START_DEVICE
+ and ARBITER_INTERFACE (not documented in DDK, but present in headers). */
+ PCM_RESOURCE_LIST ResourceList;
+ /* Resource list as assigned by the PnP arbiter (translated version). */
+ PCM_RESOURCE_LIST ResourceListTranslated;
+ /* Instance path relative to the Enum key in registry. */
+ UNICODE_STRING InstancePath;
+ /* Name of the driver service. */
+ UNICODE_STRING ServiceName;
+ /* ? */
+ PDEVICE_OBJECT DuplicatePDO;
+ /* See IRP_MN_QUERY_RESOURCE_REQUIREMENTS. */
+ PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements;
+ /* Information about bus for bus drivers. */
+ INTERFACE_TYPE InterfaceType;
+ ULONG BusNumber;
+ /* Information about underlying bus for child devices. */
+ INTERFACE_TYPE ChildInterfaceType;
+ ULONG ChildBusNumber;
+ USHORT ChildBusTypeIndex;
+ /* ? */
+ UCHAR RemovalPolicy;
+ UCHAR HardwareRemovalPolicy;
+ LIST_ENTRY TargetDeviceNotify;
+ LIST_ENTRY DeviceArbiterList;
+ LIST_ENTRY DeviceTranslatorList;
+ USHORT NoTranslatorMask;
+ USHORT QueryTranslatorMask;
+ USHORT NoArbiterMask;
+ USHORT QueryArbiterMask;
+ ULONG OverUsed1;
+ ULONG OverUsed2;
+ /* See IRP_MN_QUERY_RESOURCES. */
+ PCM_RESOURCE_LIST BootResources;
+ /* See the bitfields in DEVICE_CAPABILITIES structure. */
+ ULONG CapabilityFlags;
+ struct
+ {
+ ULONG DockStatus;
+ LIST_ENTRY ListEntry;
+ WCHAR *SerialNumber;
+ } DockInfo;
+ ULONG DisableableDepends;
+ LIST_ENTRY PendedSetInterfaceState;
+ LIST_ENTRY LegacyBusListEntry;
+ ULONG DriverUnloadRetryCount;
+
/* Not NT's */
- PPNP_BUS_INFORMATION BusInformation;
+ GUID BusTypeGuid;
+ ULONG Address;
} DEVICE_NODE, *PDEVICE_NODE;
/* For Flags field */
-/* $Id: pnpmgr.c,v 1.44 2004/10/22 20:44:48 navaraf Exp $
+/* $Id: pnpmgr.c,v 1.45 2004/10/23 14:48:16 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
switch (DeviceProperty)
{
case DevicePropertyBusNumber:
- if (DeviceNode->BusInformation == NULL)
- return STATUS_INVALID_DEVICE_REQUEST;
Length = sizeof(ULONG);
- Data = &DeviceNode->BusInformation->BusNumber;
+ Data = &DeviceNode->BusNumber;
break;
/* Complete, untested */
case DevicePropertyBusTypeGuid:
- if (DeviceNode->BusInformation == NULL)
- return STATUS_INVALID_DEVICE_REQUEST;
*ResultLength = 39 * sizeof(WCHAR);
if (BufferLength < (39 * sizeof(WCHAR)))
return STATUS_BUFFER_TOO_SMALL;
swprintf((PWSTR)PropertyBuffer,
L"{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
- DeviceNode->BusInformation->BusTypeGuid.Data1,
- DeviceNode->BusInformation->BusTypeGuid.Data2,
- DeviceNode->BusInformation->BusTypeGuid.Data3,
- DeviceNode->BusInformation->BusTypeGuid.Data4[0],
- DeviceNode->BusInformation->BusTypeGuid.Data4[1],
- DeviceNode->BusInformation->BusTypeGuid.Data4[2],
- DeviceNode->BusInformation->BusTypeGuid.Data4[3],
- DeviceNode->BusInformation->BusTypeGuid.Data4[4],
- DeviceNode->BusInformation->BusTypeGuid.Data4[5],
- DeviceNode->BusInformation->BusTypeGuid.Data4[6],
- DeviceNode->BusInformation->BusTypeGuid.Data4[7]);
+ DeviceNode->BusTypeGuid.Data1,
+ DeviceNode->BusTypeGuid.Data2,
+ DeviceNode->BusTypeGuid.Data3,
+ DeviceNode->BusTypeGuid.Data4[0],
+ DeviceNode->BusTypeGuid.Data4[1],
+ DeviceNode->BusTypeGuid.Data4[2],
+ DeviceNode->BusTypeGuid.Data4[3],
+ DeviceNode->BusTypeGuid.Data4[4],
+ DeviceNode->BusTypeGuid.Data4[5],
+ DeviceNode->BusTypeGuid.Data4[6],
+ DeviceNode->BusTypeGuid.Data4[7]);
return STATUS_SUCCESS;
case DevicePropertyLegacyBusType:
- if (DeviceNode->BusInformation == NULL)
- return STATUS_INVALID_DEVICE_REQUEST;
Length = sizeof(INTERFACE_TYPE);
- Data = &DeviceNode->BusInformation->LegacyBusType;
+ Data = &DeviceNode->InterfaceType;
break;
case DevicePropertyAddress:
- if (DeviceNode->CapabilityFlags == NULL)
- return STATUS_INVALID_DEVICE_REQUEST;
Length = sizeof(ULONG);
- Data = &DeviceNode->CapabilityFlags->Address;
+ Data = &DeviceNode->Address;
break;
- case DevicePropertyUINumber:
- if (DeviceNode->CapabilityFlags == NULL)
- return STATUS_INVALID_DEVICE_REQUEST;
- Length = sizeof(ULONG);
- Data = &DeviceNode->CapabilityFlags->UINumber;
- break;
+// case DevicePropertyUINumber:
+// if (DeviceNode->CapabilityFlags == NULL)
+// return STATUS_INVALID_DEVICE_REQUEST;
+// Length = sizeof(ULONG);
+// Data = &DeviceNode->CapabilityFlags->UINumber;
+// break;
case DevicePropertyClassName:
case DevicePropertyClassGuid:
case DevicePropertyCompatibleIDs:
case DevicePropertyDeviceDescription:
case DevicePropertyLocationInformation:
+ case DevicePropertyUINumber:
{
LPWSTR RegistryPropertyName, KeyNameBuffer;
UNICODE_STRING KeyName, ValueName;
RegistryPropertyName = L"DeviceDesc"; break;
case DevicePropertyLocationInformation:
RegistryPropertyName = L"LocationInformation"; break;
+ case DevicePropertyUINumber:
+ RegistryPropertyName = L"UINumber"; break;
default:
RegistryPropertyName = NULL; break;
}
case DevicePropertyBootConfiguration:
Length = 0;
- if (DeviceNode->BootResourceList->Count != 0)
+ if (DeviceNode->BootResources->Count != 0)
{
Length = sizeof(CM_RESOURCE_LIST) +
- ((DeviceNode->BootResourceList->Count - 1) * sizeof(CM_FULL_RESOURCE_DESCRIPTOR));
+ ((DeviceNode->BootResources->Count - 1) * sizeof(CM_FULL_RESOURCE_DESCRIPTOR));
}
- Data = &DeviceNode->BootResourceList;
+ Data = &DeviceNode->BootResources;
break;
/* FIXME: use a translated boot configuration instead */
case DevicePropertyBootConfigurationTranslated:
Length = 0;
- if (DeviceNode->BootResourceList->Count != 0)
+ if (DeviceNode->BootResources->Count != 0)
{
Length = sizeof(CM_RESOURCE_LIST) +
- ((DeviceNode->BootResourceList->Count - 1) * sizeof(CM_FULL_RESOURCE_DESCRIPTOR));
+ ((DeviceNode->BootResources->Count - 1) * sizeof(CM_FULL_RESOURCE_DESCRIPTOR));
}
- Data = &DeviceNode->BootResourceList;
+ Data = &DeviceNode->BootResources;
break;
case DevicePropertyEnumeratorName:
if (PopSystemPowerDeviceNode)
{
KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql);
- *DeviceObject = PopSystemPowerDeviceNode->Pdo;
+ *DeviceObject = PopSystemPowerDeviceNode->PhysicalDeviceObject;
KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql);
return STATUS_SUCCESS;
IopDeviceNodeSetFlag(Node, DNF_LEGACY_DRIVER);
}
- Node->Pdo = PhysicalDeviceObject;
+ Node->PhysicalDeviceObject = PhysicalDeviceObject;
PhysicalDeviceObject->DeviceObjectExtension->DeviceNode = Node;
KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql);
- ASSERT(DeviceNode->Pdo);
+ ASSERT(DeviceNode->PhysicalDeviceObject);
- ObDereferenceObject(DeviceNode->Pdo);
+ ObDereferenceObject(DeviceNode->PhysicalDeviceObject);
/* Unlink from parent if it exists */
RtlFreeUnicodeString(&DeviceNode->ServiceName);
- if (DeviceNode->CapabilityFlags)
+ if (DeviceNode->ResourceList)
{
- ExFreePool(DeviceNode->CapabilityFlags);
+ ExFreePool(DeviceNode->ResourceList);
}
- if (DeviceNode->CmResourceList)
+ if (DeviceNode->ResourceListTranslated)
{
- ExFreePool(DeviceNode->CmResourceList);
+ ExFreePool(DeviceNode->ResourceListTranslated);
}
- if (DeviceNode->BootResourceList)
+ if (DeviceNode->ResourceRequirements)
{
- ExFreePool(DeviceNode->BootResourceList);
+ ExFreePool(DeviceNode->ResourceRequirements);
}
- if (DeviceNode->ResourceRequirementsList)
+ if (DeviceNode->BootResources)
{
- ExFreePool(DeviceNode->ResourceRequirementsList);
- }
-
- if (DeviceNode->BusInformation)
- {
- ExFreePool(DeviceNode->BusInformation);
+ ExFreePool(DeviceNode->BootResources);
}
ExFreePool(DeviceNode);
}
-NTSTATUS
-IopQueryCapabilities(
- PDEVICE_OBJECT Pdo,
- PDEVICE_CAPABILITIES *Capabilities)
-{
- IO_STATUS_BLOCK IoStatusBlock;
- PDEVICE_CAPABILITIES Caps;
- IO_STACK_LOCATION Stack;
- NTSTATUS Status;
-
- DPRINT("Sending IRP_MN_QUERY_CAPABILITIES to device stack\n");
-
- *Capabilities = NULL;
-
- Caps = ExAllocatePool(PagedPool, sizeof(DEVICE_CAPABILITIES));
- if (!Caps)
- {
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- RtlZeroMemory(Caps, sizeof(DEVICE_CAPABILITIES));
- Caps->Size = sizeof(DEVICE_CAPABILITIES);
- Caps->Version = 1;
- Caps->Address = -1;
- Caps->UINumber = -1;
-
- Stack.Parameters.DeviceCapabilities.Capabilities = Caps;
-
- Status = IopInitiatePnpIrp(
- Pdo,
- &IoStatusBlock,
- IRP_MN_QUERY_CAPABILITIES,
- &Stack);
- if (NT_SUCCESS(Status))
- {
- *Capabilities = Caps;
- }
- else
- {
- DPRINT("IopInitiatePnpIrp() failed (Status %x)\n", Status);
- }
-
- return Status;
-}
-
-
NTSTATUS
IopTraverseDeviceTreeNode(
PDEVICETREE_TRAVERSE_CONTEXT Context)
if (NT_SUCCESS(Status))
{
/* Set 'BootConfig' value */
- if (DeviceNode->BootResourceList != NULL)
+ if (DeviceNode->BootResources != NULL)
{
- ResCount = DeviceNode->BootResourceList->Count;
+ ResCount = DeviceNode->BootResources->Count;
if (ResCount != 0)
{
ListSize = sizeof(CM_RESOURCE_LIST) +
&KeyName,
0,
REG_RESOURCE_LIST,
- &DeviceNode->BootResourceList,
+ &DeviceNode->BootResources,
ListSize);
}
}
/* Set 'BasicConfigVector' value */
- if (DeviceNode->ResourceRequirementsList != NULL &&
- DeviceNode->ResourceRequirementsList->ListSize != 0)
+ if (DeviceNode->ResourceRequirements != NULL &&
+ DeviceNode->ResourceRequirements->ListSize != 0)
{
RtlInitUnicodeString(&KeyName,
L"BasicConfigVector");
&KeyName,
0,
REG_RESOURCE_REQUIREMENTS_LIST,
- &DeviceNode->ResourceRequirementsList,
- DeviceNode->ResourceRequirementsList->ListSize);
+ &DeviceNode->ResourceRequirements,
+ DeviceNode->ResourceRequirements->ListSize);
}
NtClose(LogConfKey);
USHORT TotalLength;
HANDLE InstanceKey = NULL;
UNICODE_STRING ValueName;
+ DEVICE_CAPABILITIES DeviceCapabilities;
DPRINT("IopActionInterrogateDeviceStack(%p, %p)\n", DeviceNode, Context);
- DPRINT("PDO %x\n", DeviceNode->Pdo);
+ DPRINT("PDO %x\n", DeviceNode->PhysicalDeviceObject);
ParentDeviceNode = (PDEVICE_NODE)Context;
Stack.Parameters.QueryId.IdType = BusQueryDeviceID;
Status = IopInitiatePnpIrp(
- DeviceNode->Pdo,
+ DeviceNode->PhysicalDeviceObject,
&IoStatusBlock,
IRP_MN_QUERY_ID,
&Stack);
Stack.Parameters.QueryId.IdType = BusQueryInstanceID;
Status = IopInitiatePnpIrp(
- DeviceNode->Pdo,
+ DeviceNode->PhysicalDeviceObject,
&IoStatusBlock,
IRP_MN_QUERY_ID,
&Stack);
DPRINT("IopInitiatePnpIrp() failed (Status %x)\n", Status);
}
- Status = IopQueryCapabilities(DeviceNode->Pdo, &DeviceNode->CapabilityFlags);
+ RtlZeroMemory(&DeviceCapabilities, sizeof(DEVICE_CAPABILITIES));
+ DeviceCapabilities.Size = sizeof(DEVICE_CAPABILITIES);
+ DeviceCapabilities.Version = 1;
+ DeviceCapabilities.Address = -1;
+ DeviceCapabilities.UINumber = -1;
+
+ Stack.Parameters.DeviceCapabilities.Capabilities = &DeviceCapabilities;
+ Status = IopInitiatePnpIrp(
+ DeviceNode->PhysicalDeviceObject,
+ &IoStatusBlock,
+ IRP_MN_QUERY_CAPABILITIES,
+ &Stack);
if (NT_SUCCESS(Status))
{
}
else
{
+ DPRINT("IopInitiatePnpIrp() failed (Status %x)\n", Status);
}
- if (DeviceNode->CapabilityFlags != NULL &&
- !DeviceNode->CapabilityFlags->UniqueID)
+ DeviceNode->CapabilityFlags = *(PULONG)((ULONG_PTR)&DeviceCapabilities + 4);
+ DeviceNode->Address = DeviceCapabilities.Address;
+
+ if (!DeviceCapabilities.UniqueID)
{
DPRINT("Instance ID is not unique\n");
/* FIXME: Add information from parent bus driver to InstancePath */
}
- if (DeviceNode->CapabilityFlags != NULL)
{
/* Set 'Capabilities' value */
RtlInitUnicodeString(&ValueName,
&ValueName,
0,
REG_DWORD,
- (PVOID)((ULONG_PTR)&DeviceNode->CapabilityFlags + 4),
+ (PVOID)&DeviceNode->CapabilityFlags,
sizeof(ULONG));
/* Set 'UINumber' value */
- if (DeviceNode->CapabilityFlags->UINumber != (ULONG)-1)
+ if (DeviceCapabilities.UINumber != (ULONG)-1)
{
RtlInitUnicodeString(&ValueName,
L"UINumber");
&ValueName,
0,
REG_DWORD,
- &DeviceNode->CapabilityFlags->UINumber,
+ &DeviceCapabilities.UINumber,
sizeof(ULONG));
}
}
Stack.Parameters.QueryId.IdType = BusQueryHardwareIDs;
Status = IopInitiatePnpIrp(
- DeviceNode->Pdo,
+ DeviceNode->PhysicalDeviceObject,
&IoStatusBlock,
IRP_MN_QUERY_ID,
&Stack);
Stack.Parameters.QueryId.IdType = BusQueryCompatibleIDs;
Status = IopInitiatePnpIrp(
- DeviceNode->Pdo,
+ DeviceNode->PhysicalDeviceObject,
&IoStatusBlock,
IRP_MN_QUERY_ID,
&Stack);
Stack.Parameters.QueryDeviceText.DeviceTextType = DeviceTextDescription;
Stack.Parameters.QueryDeviceText.LocaleId = 0; /* FIXME */
Status = IopInitiatePnpIrp(
- DeviceNode->Pdo,
+ DeviceNode->PhysicalDeviceObject,
&IoStatusBlock,
IRP_MN_QUERY_DEVICE_TEXT,
&Stack);
Stack.Parameters.QueryDeviceText.DeviceTextType = DeviceTextLocationInformation;
Stack.Parameters.QueryDeviceText.LocaleId = 0; // FIXME
Status = IopInitiatePnpIrp(
- DeviceNode->Pdo,
+ DeviceNode->PhysicalDeviceObject,
&IoStatusBlock,
IRP_MN_QUERY_DEVICE_TEXT,
&Stack);
DPRINT("Sending IRP_MN_QUERY_BUS_INFORMATION to device stack\n");
Status = IopInitiatePnpIrp(
- DeviceNode->Pdo,
+ DeviceNode->PhysicalDeviceObject,
&IoStatusBlock,
IRP_MN_QUERY_BUS_INFORMATION,
NULL);
if (NT_SUCCESS(Status))
{
- DeviceNode->BusInformation =
+ PPNP_BUS_INFORMATION BusInformation =
(PPNP_BUS_INFORMATION)IoStatusBlock.Information;
+
+ DeviceNode->BusNumber = BusInformation->BusNumber;
+ DeviceNode->InterfaceType = BusInformation->LegacyBusType;
+ memcpy(&DeviceNode->BusTypeGuid,
+ &BusInformation->BusTypeGuid,
+ sizeof(GUID));
+ ExFreePool(BusInformation);
}
else
{
DPRINT("IopInitiatePnpIrp() failed (Status %x)\n", Status);
- DeviceNode->BusInformation = NULL;
+
+ DeviceNode->BusNumber = -1;
+ DeviceNode->InterfaceType = -1;
+ memset(&DeviceNode->BusTypeGuid,
+ 0,
+ sizeof(GUID));
}
DPRINT("Sending IRP_MN_QUERY_RESOURCES to device stack\n");
Status = IopInitiatePnpIrp(
- DeviceNode->Pdo,
+ DeviceNode->PhysicalDeviceObject,
&IoStatusBlock,
IRP_MN_QUERY_RESOURCES,
NULL);
if (NT_SUCCESS(Status))
{
- DeviceNode->BootResourceList =
+ DeviceNode->BootResources =
(PCM_RESOURCE_LIST)IoStatusBlock.Information;
DeviceNode->Flags |= DNF_HAS_BOOT_CONFIG;
}
else
{
DPRINT("IopInitiatePnpIrp() failed (Status %x)\n", Status);
- DeviceNode->BootResourceList = NULL;
+ DeviceNode->BootResources = NULL;
}
DPRINT("Sending IRP_MN_QUERY_RESOURCE_REQUIREMENTS to device stack\n");
Status = IopInitiatePnpIrp(
- DeviceNode->Pdo,
+ DeviceNode->PhysicalDeviceObject,
&IoStatusBlock,
IRP_MN_QUERY_RESOURCE_REQUIREMENTS,
NULL);
if (NT_SUCCESS(Status))
{
- DeviceNode->ResourceRequirementsList =
+ DeviceNode->ResourceRequirements =
(PIO_RESOURCE_REQUIREMENTS_LIST)IoStatusBlock.Information;
}
else
{
DPRINT("IopInitiatePnpIrp() failed (Status %x)\n", Status);
- DeviceNode->ResourceRequirementsList = NULL;
+ DeviceNode->ResourceRequirements = NULL;
}
Stack.Parameters.QueryDeviceRelations.Type = Type/*BusRelations*/;
Status = IopInitiatePnpIrp(
- DeviceNode->Pdo,
+ DeviceNode->PhysicalDeviceObject,
&IoStatusBlock,
IRP_MN_QUERY_DEVICE_RELATIONS,
&Stack);
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
- IopRootDeviceNode->Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE;
+ IopRootDeviceNode->PhysicalDeviceObject->Flags |= DO_BUS_ENUMERATED_DEVICE;
PnpRootDriverEntry(IopRootDriverObject, NULL);
IopRootDriverObject->DriverExtension->AddDevice(
IopRootDriverObject,
- IopRootDeviceNode->Pdo);
+ IopRootDeviceNode->PhysicalDeviceObject);
}
/* EOF */