--- trunk/reactos/ntoskrnl/io/iomgr.c 2005-06-04 21:35:07 UTC (rev 15795)
+++ trunk/reactos/ntoskrnl/io/iomgr.c 2005-06-04 22:55:58 UTC (rev 15796)
@@ -40,7 +40,7 @@
NPAGED_LOOKASIDE_LIST IoSmallIrpLookaside;
/* INIT FUNCTIONS ************************************************************/
-
+
VOID
INIT_FUNCTION
IoInitCancelHandling(VOID)
@@ -64,11 +64,11 @@
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 @@
LargeIrpSize,
IO_LARGEIRP,
0);
-
+
/* Initialize the Lookaside List for Small IRPs */
ExInitializeNPagedLookasideList(&IoSmallIrpLookaside,
NULL,
@@ -95,14 +95,14 @@
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 @@
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 @@
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 @@
}
Prcb->PPLookasideList[LookasideCompletionList].P = &CurrentList->L;
}
-
+
DPRINT("Done allocation\n");
}
@@ -187,7 +187,7 @@
IopInitDriverImplementation();
DPRINT("Creating Device Object Type\n");
-
+
/* Initialize the Driver object type */
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
RtlInitUnicodeString(&Name, L"Device");
@@ -198,16 +198,16 @@
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 @@
*/
PnpInit();
}
-
+
VOID
INIT_FUNCTION
IoInit2(BOOLEAN BootLog)
@@ -325,6 +325,8 @@
MODULE_OBJECT ModuleObject;
NTSTATUS Status;
+ PnpInit2();
+
IoCreateDriverList();
KeInitializeSpinLock (&IoStatisticsLock);
--- trunk/reactos/ntoskrnl/io/pnpmgr.c 2005-06-04 21:35:07 UTC (rev 15795)
+++ trunk/reactos/ntoskrnl/io/pnpmgr.c 2005-06-04 22:55:58 UTC (rev 15796)
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
NumberOfResources--;
}
}
-
+
}
-
+
DeviceNode->ResourceList->List[0].PartialResourceList.Count = NumberOfResources;
DeviceNode->ResourceListTranslated->List[0].PartialResourceList.Count = NumberOfResources;
-
+
return STATUS_SUCCESS;
ByeBye:
@@ -1818,7 +1850,8 @@
DeviceNode,
IopActionInitBootServices,
DeviceNode);
- } else
+ }
+ else
{
IopInitDeviceTreeTraverseContext(
&Context,
@@ -1981,6 +2014,35 @@
}
+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 @@
}
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 @@
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 */