mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
- Create device instance key for root device node.
- Add DeviceReference value for each non-root device node. svn path=/trunk/; revision=15796
This commit is contained in:
parent
607f793fc0
commit
355593bafa
3 changed files with 118 additions and 37 deletions
|
@ -16,8 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id$
|
||||
*
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: include/internal/io.h
|
||||
|
@ -340,6 +339,9 @@ extern ULONGLONG IoOtherTransferCount;
|
|||
VOID
|
||||
PnpInit(VOID);
|
||||
|
||||
VOID
|
||||
PnpInit2(VOID);
|
||||
|
||||
VOID
|
||||
IopInitDriverImplementation(VOID);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ NPAGED_LOOKASIDE_LIST IoLargeIrpLookaside;
|
|||
NPAGED_LOOKASIDE_LIST IoSmallIrpLookaside;
|
||||
|
||||
/* INIT FUNCTIONS ************************************************************/
|
||||
|
||||
|
||||
VOID
|
||||
INIT_FUNCTION
|
||||
IoInitCancelHandling(VOID)
|
||||
|
@ -64,11 +64,11 @@ IopInitLookasideLists(VOID)
|
|||
ULONG i;
|
||||
PKPRCB Prcb;
|
||||
PNPAGED_LOOKASIDE_LIST CurrentList = NULL;
|
||||
|
||||
|
||||
/* Calculate the sizes */
|
||||
LargeIrpSize = sizeof(IRP) + (8 * sizeof(IO_STACK_LOCATION));
|
||||
SmallIrpSize = sizeof(IRP) + sizeof(IO_STACK_LOCATION);
|
||||
|
||||
|
||||
/* Initialize the Lookaside List for Large IRPs */
|
||||
ExInitializeNPagedLookasideList(&IoLargeIrpLookaside,
|
||||
NULL,
|
||||
|
@ -77,7 +77,7 @@ IopInitLookasideLists(VOID)
|
|||
LargeIrpSize,
|
||||
IO_LARGEIRP,
|
||||
0);
|
||||
|
||||
|
||||
/* Initialize the Lookaside List for Small IRPs */
|
||||
ExInitializeNPagedLookasideList(&IoSmallIrpLookaside,
|
||||
NULL,
|
||||
|
@ -95,14 +95,14 @@ IopInitLookasideLists(VOID)
|
|||
sizeof(IO_COMPLETION_PACKET),
|
||||
IOC_TAG1,
|
||||
0);
|
||||
|
||||
|
||||
/* Now allocate the per-processor lists */
|
||||
for (i = 0; i < KeNumberProcessors; i++)
|
||||
{
|
||||
/* Get the PRCB for this CPU */
|
||||
Prcb = ((PKPCR)(KPCR_BASE + i * PAGE_SIZE))->Prcb;
|
||||
DPRINT("Setting up lookaside for CPU: %x, PRCB: %p\n", i, Prcb);
|
||||
|
||||
|
||||
/* Set the Large IRP List */
|
||||
Prcb->PPLookasideList[LookasideLargeIrpList].L = &IoLargeIrpLookaside.L;
|
||||
CurrentList = ExAllocatePoolWithTag(NonPagedPool,
|
||||
|
@ -124,7 +124,7 @@ IopInitLookasideLists(VOID)
|
|||
CurrentList = &IoLargeIrpLookaside;
|
||||
}
|
||||
Prcb->PPLookasideList[LookasideLargeIrpList].P = &CurrentList->L;
|
||||
|
||||
|
||||
/* Set the Small IRP List */
|
||||
Prcb->PPLookasideList[LookasideSmallIrpList].L = &IoSmallIrpLookaside.L;
|
||||
CurrentList = ExAllocatePoolWithTag(NonPagedPool,
|
||||
|
@ -146,7 +146,7 @@ IopInitLookasideLists(VOID)
|
|||
CurrentList = &IoSmallIrpLookaside;
|
||||
}
|
||||
Prcb->PPLookasideList[LookasideSmallIrpList].P = &CurrentList->L;
|
||||
|
||||
|
||||
/* Set the I/O Completion List */
|
||||
Prcb->PPLookasideList[LookasideCompletionList].L = &IoCompletionPacketLookaside.L;
|
||||
CurrentList = ExAllocatePoolWithTag(NonPagedPool,
|
||||
|
@ -169,7 +169,7 @@ IopInitLookasideLists(VOID)
|
|||
}
|
||||
Prcb->PPLookasideList[LookasideCompletionList].P = &CurrentList->L;
|
||||
}
|
||||
|
||||
|
||||
DPRINT("Done allocation\n");
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ IoInit (VOID)
|
|||
IopInitDriverImplementation();
|
||||
|
||||
DPRINT("Creating Device Object Type\n");
|
||||
|
||||
|
||||
/* Initialize the Driver object type */
|
||||
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
|
||||
RtlInitUnicodeString(&Name, L"Device");
|
||||
|
@ -198,16 +198,16 @@ IoInit (VOID)
|
|||
ObjectTypeInitializer.UseDefaultObject = TRUE;
|
||||
ObjectTypeInitializer.GenericMapping = IopFileMapping;
|
||||
ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoDeviceObjectType);
|
||||
|
||||
|
||||
/* Do the Adapter Type */
|
||||
RtlInitUnicodeString(&Name, L"Adapter");
|
||||
ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoAdapterObjectType);
|
||||
|
||||
|
||||
/* Do the Controller Type */
|
||||
RtlInitUnicodeString(&Name, L"Controller");
|
||||
ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(CONTROLLER_OBJECT);
|
||||
ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoControllerObjectType);
|
||||
|
||||
ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoControllerObjectType);
|
||||
|
||||
/* Initialize the File object type */
|
||||
RtlInitUnicodeString(&Name, L"File");
|
||||
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
|
||||
|
@ -315,7 +315,7 @@ IoInit (VOID)
|
|||
*/
|
||||
PnpInit();
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
INIT_FUNCTION
|
||||
IoInit2(BOOLEAN BootLog)
|
||||
|
@ -325,6 +325,8 @@ IoInit2(BOOLEAN BootLog)
|
|||
MODULE_OBJECT ModuleObject;
|
||||
NTSTATUS Status;
|
||||
|
||||
PnpInit2();
|
||||
|
||||
IoCreateDriverList();
|
||||
|
||||
KeInitializeSpinLock (&IoStatisticsLock);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/* $Id$
|
||||
*
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/io/pnpmgr.c
|
||||
|
@ -893,6 +892,39 @@ IopSetDeviceInstanceData(HANDLE InstanceKey,
|
|||
ZwClose(LogConfKey);
|
||||
}
|
||||
|
||||
if (DeviceNode->PhysicalDeviceObject != NULL)
|
||||
{
|
||||
/* Create the 'Control' key */
|
||||
RtlInitUnicodeString(&KeyName,
|
||||
L"Control");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE | OBJ_OPENIF,
|
||||
InstanceKey,
|
||||
NULL);
|
||||
Status = ZwCreateKey(&LogConfKey,
|
||||
KEY_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_VOLATILE,
|
||||
NULL);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
ULONG Reference = (ULONG)DeviceNode->PhysicalDeviceObject;
|
||||
RtlInitUnicodeString(&KeyName,
|
||||
L"DeviceReference");
|
||||
Status = ZwSetValueKey(LogConfKey,
|
||||
&KeyName,
|
||||
0,
|
||||
REG_DWORD,
|
||||
&Reference,
|
||||
sizeof(PVOID));
|
||||
|
||||
ZwClose(LogConfKey);
|
||||
}
|
||||
}
|
||||
|
||||
DPRINT("IopSetDeviceInstanceData() done\n");
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
|
@ -909,17 +941,17 @@ IopAssignDeviceResources(
|
|||
ULONG NumberOfResources = 0;
|
||||
ULONG i;
|
||||
NTSTATUS Status;
|
||||
|
||||
|
||||
/* Fill DeviceNode->ResourceList and DeviceNode->ResourceListTranslated;
|
||||
* by using DeviceNode->ResourceRequirements */
|
||||
|
||||
|
||||
if (!DeviceNode->ResourceRequirements
|
||||
|| DeviceNode->ResourceRequirements->AlternativeLists == 0)
|
||||
{
|
||||
DeviceNode->ResourceList = DeviceNode->ResourceListTranslated = NULL;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* FIXME: that's here that PnP arbiter should go */
|
||||
/* Actually, simply use resource list #0 as assigned resource list */
|
||||
ResourceList = &DeviceNode->ResourceRequirements->List[0];
|
||||
|
@ -928,45 +960,45 @@ IopAssignDeviceResources(
|
|||
Status = STATUS_REVISION_MISMATCH;
|
||||
goto ByeBye;
|
||||
}
|
||||
|
||||
DeviceNode->ResourceList = ExAllocatePool(PagedPool,
|
||||
|
||||
DeviceNode->ResourceList = ExAllocatePool(PagedPool,
|
||||
sizeof(CM_RESOURCE_LIST) + ResourceList->Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
|
||||
if (!DeviceNode->ResourceList)
|
||||
{
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto ByeBye;
|
||||
}
|
||||
|
||||
DeviceNode->ResourceListTranslated = ExAllocatePool(PagedPool,
|
||||
|
||||
DeviceNode->ResourceListTranslated = ExAllocatePool(PagedPool,
|
||||
sizeof(CM_RESOURCE_LIST) + ResourceList->Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
|
||||
if (!DeviceNode->ResourceListTranslated)
|
||||
{
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto ByeBye;
|
||||
}
|
||||
|
||||
|
||||
DeviceNode->ResourceList->Count = 1;
|
||||
DeviceNode->ResourceList->List[0].InterfaceType = DeviceNode->ResourceRequirements->InterfaceType;
|
||||
DeviceNode->ResourceList->List[0].BusNumber = DeviceNode->ResourceRequirements->BusNumber;
|
||||
DeviceNode->ResourceList->List[0].PartialResourceList.Version = 1;
|
||||
DeviceNode->ResourceList->List[0].PartialResourceList.Revision = 1;
|
||||
|
||||
|
||||
DeviceNode->ResourceListTranslated->Count = 1;
|
||||
DeviceNode->ResourceListTranslated->List[0].InterfaceType = DeviceNode->ResourceRequirements->InterfaceType;
|
||||
DeviceNode->ResourceListTranslated->List[0].BusNumber = DeviceNode->ResourceRequirements->BusNumber;
|
||||
DeviceNode->ResourceListTranslated->List[0].PartialResourceList.Version = 1;
|
||||
DeviceNode->ResourceListTranslated->List[0].PartialResourceList.Revision = 1;
|
||||
|
||||
|
||||
for (i = 0; i < ResourceList->Count; i++)
|
||||
{
|
||||
ResourceDescriptor = &ResourceList->Descriptors[i];
|
||||
|
||||
|
||||
if (ResourceDescriptor->Option == 0 || ResourceDescriptor->Option == IO_RESOURCE_PREFERRED)
|
||||
{
|
||||
DescriptorRaw = &DeviceNode->ResourceList->List[0].PartialResourceList.PartialDescriptors[NumberOfResources];
|
||||
DescriptorTranslated = &DeviceNode->ResourceListTranslated->List[0].PartialResourceList.PartialDescriptors[NumberOfResources];
|
||||
NumberOfResources++;
|
||||
|
||||
|
||||
/* Copy ResourceDescriptor to DescriptorRaw and DescriptorTranslated */
|
||||
DescriptorRaw->Type = DescriptorTranslated->Type = ResourceDescriptor->Type;
|
||||
DescriptorRaw->ShareDisposition = DescriptorTranslated->ShareDisposition = ResourceDescriptor->ShareDisposition;
|
||||
|
@ -1001,7 +1033,7 @@ IopAssignDeviceResources(
|
|||
DescriptorRaw->u.Interrupt.Vector = 9;
|
||||
else
|
||||
DescriptorRaw->u.Interrupt.Vector = ResourceDescriptor->u.Interrupt.MinimumVector;
|
||||
|
||||
|
||||
DescriptorTranslated->u.Interrupt.Vector = HalGetInterruptVector(
|
||||
DeviceNode->ResourceRequirements->InterfaceType,
|
||||
DeviceNode->ResourceRequirements->BusNumber,
|
||||
|
@ -1069,12 +1101,12 @@ IopAssignDeviceResources(
|
|||
NumberOfResources--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
DeviceNode->ResourceList->List[0].PartialResourceList.Count = NumberOfResources;
|
||||
DeviceNode->ResourceListTranslated->List[0].PartialResourceList.Count = NumberOfResources;
|
||||
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
ByeBye:
|
||||
|
@ -1818,7 +1850,8 @@ IopInitializePnpServices(
|
|||
DeviceNode,
|
||||
IopActionInitBootServices,
|
||||
DeviceNode);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
IopInitDeviceTreeTraverseContext(
|
||||
&Context,
|
||||
|
@ -1981,6 +2014,35 @@ IopInvalidateDeviceRelations(
|
|||
}
|
||||
|
||||
|
||||
static NTSTATUS INIT_FUNCTION
|
||||
IopSetRootDeviceInstanceData(PDEVICE_NODE DeviceNode)
|
||||
{
|
||||
PWSTR KeyBuffer;
|
||||
HANDLE InstanceKey = NULL;
|
||||
NTSTATUS Status;
|
||||
|
||||
/* Create registry key for the instance id, if it doesn't exist yet */
|
||||
KeyBuffer = ExAllocatePool(PagedPool,
|
||||
(49 * sizeof(WCHAR)) + DeviceNode->InstancePath.Length);
|
||||
wcscpy(KeyBuffer, L"\\Registry\\Machine\\System\\CurrentControlSet\\Enum\\");
|
||||
wcscat(KeyBuffer, DeviceNode->InstancePath.Buffer);
|
||||
Status = IopCreateDeviceKeyPath(KeyBuffer,
|
||||
&InstanceKey);
|
||||
ExFreePool(KeyBuffer);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Failed to create the instance key! (Status %lx)\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* FIXME: Set 'ConfigFlags' value */
|
||||
|
||||
ZwClose(InstanceKey);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
VOID INIT_FUNCTION
|
||||
PnpInit(VOID)
|
||||
{
|
||||
|
@ -2026,7 +2088,7 @@ PnpInit(VOID)
|
|||
}
|
||||
|
||||
if (!IopCreateUnicodeString(&IopRootDeviceNode->InstancePath,
|
||||
L"HTREE\\Root\\0",
|
||||
L"HTREE\\ROOT\\0",
|
||||
PagedPool))
|
||||
{
|
||||
CPRINT("Failed to create the instance path!\n");
|
||||
|
@ -2044,4 +2106,19 @@ PnpInit(VOID)
|
|||
IopRootDeviceNode->PhysicalDeviceObject);
|
||||
}
|
||||
|
||||
|
||||
VOID INIT_FUNCTION
|
||||
PnpInit2(VOID)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
/* Set root device instance data */
|
||||
Status = IopSetRootDeviceInstanceData(IopRootDeviceNode);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
CPRINT("Failed to set instance data\n");
|
||||
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Reference in a new issue