- Don't load PnP drivers if they're disabled.

- Save pointer to PnP tree device node in device object's DeviceObjectExtension.
- Add function IopGetDeviceNode for getting device node from device object pointer.
- Rewritten IoGetDeviceProperty to use values that are in device node instead of sending Irps.

svn path=/trunk/; revision=8718
This commit is contained in:
Filip Navara 2004-03-14 17:10:48 +00:00
parent c5058d5a3c
commit b4e4cd6676
4 changed files with 95 additions and 80 deletions

View file

@ -16,7 +16,7 @@
* 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.38 2003/12/15 17:49:41 ekohl Exp $
/* $Id: io.h,v 1.39 2004/03/14 17:10:48 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -48,6 +48,13 @@ typedef struct _IO_COMPLETION_PACKET{
LIST_ENTRY ListEntry;
} IO_COMPLETION_PACKET, *PIO_COMPLETION_PACKET;
typedef struct _DEVOBJ_EXTENSION {
CSHORT Type;
USHORT Size;
PDEVICE_OBJECT DeviceObject;
ULONG Unknown[3];
struct _DEVICE_NODE *DeviceNode;
} DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
typedef struct _DEVICE_NODE
{

View file

@ -1,4 +1,4 @@
/* $Id: device.c,v 1.66 2004/03/07 11:59:10 navaraf Exp $
/* $Id: device.c,v 1.67 2004/03/14 17:10:48 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -636,6 +636,7 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject,
*/
{
PDEVICE_OBJECT CreatedDeviceObject;
PDEVOBJ_EXTENSION DeviceObjectExtension;
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
@ -740,6 +741,17 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject,
IoAttachVpb(CreatedDeviceObject);
}
DeviceObjectExtension =
ExAllocatePoolWithTag(NonPagedPool, sizeof(DEVOBJ_EXTENSION),
TAG_DEVICE_EXTENSION);
DeviceObjectExtension->Type = 0 /* ?? */;
DeviceObjectExtension->Size = sizeof(DEVOBJ_EXTENSION);
DeviceObjectExtension->DeviceObject = CreatedDeviceObject;
DeviceObjectExtension->DeviceNode = NULL;
CreatedDeviceObject->DeviceObjectExtension = DeviceObjectExtension;
*DeviceObject = CreatedDeviceObject;
return(STATUS_SUCCESS);

View file

@ -1,4 +1,4 @@
/* $Id: driver.c,v 1.35 2004/03/12 19:40:29 navaraf Exp $
/* $Id: driver.c,v 1.36 2004/03/14 17:10:48 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -802,33 +802,34 @@ NTSTATUS
IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode, BOOLEAN BootDriverOnly)
{
NTSTATUS Status;
ULONG ServiceStart;
RTL_QUERY_REGISTRY_TABLE QueryTable[2];
if (DeviceNode->ServiceName.Buffer == NULL)
{
return STATUS_UNSUCCESSFUL;
}
/*
* Get service start value
*/
RtlZeroMemory(QueryTable, sizeof(QueryTable));
QueryTable[0].Name = L"Start";
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[0].EntryContext = &ServiceStart;
Status = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES,
DeviceNode->ServiceName.Buffer, QueryTable, NULL, NULL);
if (!NT_SUCCESS(Status))
{
DPRINT("RtlQueryRegistryValues() failed (Status %x)\n", Status);
return Status;
}
if (BootDriverOnly)
{
ULONG ServiceStart;
RTL_QUERY_REGISTRY_TABLE QueryTable[2];
PLOADER_MODULE KeLoaderModules = (PLOADER_MODULE)KeLoaderBlock.ModsAddr;
/*
* Get service start value
*/
RtlZeroMemory(QueryTable, sizeof(QueryTable));
QueryTable[0].Name = L"Start";
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[0].EntryContext = &ServiceStart;
Status = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES,
DeviceNode->ServiceName.Buffer, QueryTable, NULL, NULL);
if (!NT_SUCCESS(Status))
{
DPRINT("RtlQueryRegistryValues() failed (Status %x)\n", Status);
return Status;
}
/*
* Find and initialize boot driver
*/
@ -860,6 +861,7 @@ IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode, BOOLEAN BootDriverOnly)
return STATUS_UNSUCCESSFUL;
}
} else
if (ServiceStart < 4)
{
UNICODE_STRING ImagePath;
@ -889,6 +891,8 @@ IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode, BOOLEAN BootDriverOnly)
*/
RtlFreeUnicodeString(&ImagePath);
}
else
Status = STATUS_UNSUCCESSFUL;
return Status;
}

View file

@ -1,4 +1,4 @@
/* $Id: pnpmgr.c,v 1.23 2004/03/12 19:40:29 navaraf Exp $
/* $Id: pnpmgr.c,v 1.24 2004/03/14 17:10:48 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -62,16 +62,11 @@ IoInvalidateDeviceRelations(
{
}
PPNP_BUS_INFORMATION FASTCALL
IopQueryBusInformation(
PDEVICE_NODE FASTCALL
IopGetDeviceNode(
PDEVICE_OBJECT DeviceObject)
{
IO_STATUS_BLOCK IoStatusBlock;
IO_STACK_LOCATION Stack;
return NT_SUCCESS(IopInitiatePnpIrp(DeviceObject, &IoStatusBlock,
IRP_MN_QUERY_BUS_INFORMATION, &Stack)) ?
(PPNP_BUS_INFORMATION)IoStatusBlock.Information : NULL;
return DeviceObject->DeviceObjectExtension->DeviceNode;
}
/*
@ -86,9 +81,18 @@ IoGetDeviceProperty(
OUT PVOID PropertyBuffer,
OUT PULONG ResultLength)
{
PPNP_BUS_INFORMATION BusInformation;
PDEVICE_NODE DeviceNode = IopGetDeviceNode(DeviceObject);
ULONG Length;
PVOID Data;
DPRINT("IoGetDeviceProperty called");
DPRINT("IoGetDeviceProperty called\n");
if (DeviceNode == NULL ||
DeviceNode->BusInformation == NULL ||
DeviceNode->CapabilityFlags == NULL)
{
return STATUS_INVALID_DEVICE_REQUEST;
}
/*
* Used IRPs:
@ -97,64 +101,46 @@ IoGetDeviceProperty(
*/
switch (DeviceProperty)
{
/* Complete, untested */
case DevicePropertyBusNumber:
*ResultLength = sizeof(ULONG);
if (BufferLength < sizeof(ULONG))
return STATUS_BUFFER_TOO_SMALL;
BusInformation = IopQueryBusInformation(DeviceObject);
if (BusInformation != NULL)
{
*((ULONG *)PropertyBuffer) = BusInformation->BusNumber;
ExFreePool(BusInformation);
return STATUS_UNSUCCESSFUL;
}
return STATUS_SUCCESS;
Length = sizeof(ULONG);
Data = &DeviceNode->BusInformation->BusNumber;
break;
/* Complete, untested */
case DevicePropertyBusTypeGuid:
*ResultLength = 39 * sizeof(WCHAR);
if (BufferLength < (39 * sizeof(WCHAR)))
return STATUS_BUFFER_TOO_SMALL;
BusInformation = IopQueryBusInformation(DeviceObject);
if (BusInformation != NULL)
{
swprintf((PWSTR)PropertyBuffer,
L"{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
BusInformation->BusTypeGuid.Data1,
BusInformation->BusTypeGuid.Data2,
BusInformation->BusTypeGuid.Data3,
BusInformation->BusTypeGuid.Data4[0],
BusInformation->BusTypeGuid.Data4[1],
BusInformation->BusTypeGuid.Data4[2],
BusInformation->BusTypeGuid.Data4[3],
BusInformation->BusTypeGuid.Data4[4],
BusInformation->BusTypeGuid.Data4[5],
BusInformation->BusTypeGuid.Data4[6],
BusInformation->BusTypeGuid.Data4[7]);
ExFreePool(BusInformation);
return STATUS_UNSUCCESSFUL;
}
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]);
return STATUS_SUCCESS;
/* Complete, untested */
case DevicePropertyLegacyBusType:
*ResultLength = sizeof(INTERFACE_TYPE);
if (BufferLength < sizeof(INTERFACE_TYPE))
return STATUS_BUFFER_TOO_SMALL;
BusInformation = IopQueryBusInformation(DeviceObject);
if (BusInformation != NULL)
{
RtlCopyMemory(
PropertyBuffer,
&BusInformation->LegacyBusType,
sizeof(INTERFACE_TYPE));
ExFreePool(BusInformation);
return STATUS_UNSUCCESSFUL;
}
return STATUS_SUCCESS;
Length = sizeof(INTERFACE_TYPE);
Data = &DeviceNode->BusInformation->LegacyBusType;
break;
case DevicePropertyAddress:
Length = sizeof(ULONG);
Data = &DeviceNode->CapabilityFlags->Address;
break;
case DevicePropertyUINumber:
Length = sizeof(ULONG);
Data = &DeviceNode->CapabilityFlags->UINumber;
break;
case DevicePropertyBootConfiguration:
case DevicePropertyBootConfigurationTranslated:
case DevicePropertyClassGuid:
@ -168,13 +154,17 @@ IoGetDeviceProperty(
case DevicePropertyLocationInformation:
case DevicePropertyManufacturer:
case DevicePropertyPhysicalDeviceObjectName:
case DevicePropertyUINumber:
break;
return STATUS_NOT_IMPLEMENTED;
default:
return STATUS_INVALID_PARAMETER_2;
return STATUS_INVALID_PARAMETER_2;
}
*ResultLength = Length;
if (BufferLength < Length)
return STATUS_BUFFER_TOO_SMALL;
RtlCopyMemory(PropertyBuffer, Data, Length);
return STATUS_NOT_IMPLEMENTED;
}
@ -309,6 +299,8 @@ IopCreateDeviceNode(PDEVICE_NODE ParentNode,
Node->Pdo = PhysicalDeviceObject;
PhysicalDeviceObject->DeviceObjectExtension->DeviceNode = Node;
if (ParentNode)
{
KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql);