mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:42:58 +00:00
- Combine PnpInit1/2 since they were called one after the other.
- Load RAW driver while loading boot drivers. - Cleanup IoInitSystem a bit more. svn path=/trunk/; revision=24563
This commit is contained in:
parent
fd5116b50c
commit
1b96a22c6c
3 changed files with 120 additions and 134 deletions
|
@ -918,7 +918,6 @@ IopInitializeBuiltinDriver(
|
||||||
* Return Value
|
* Return Value
|
||||||
* None
|
* None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
FASTCALL
|
FASTCALL
|
||||||
IopInitializeBootDrivers(VOID)
|
IopInitializeBootDrivers(VOID)
|
||||||
|
@ -926,6 +925,50 @@ IopInitializeBootDrivers(VOID)
|
||||||
PLIST_ENTRY ListHead, NextEntry;
|
PLIST_ENTRY ListHead, NextEntry;
|
||||||
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
||||||
UNICODE_STRING NtosSymName = RTL_CONSTANT_STRING(L"ntoskrnl.sym");
|
UNICODE_STRING NtosSymName = RTL_CONSTANT_STRING(L"ntoskrnl.sym");
|
||||||
|
PDEVICE_NODE DeviceNode;
|
||||||
|
PDRIVER_OBJECT DriverObject;
|
||||||
|
LDR_DATA_TABLE_ENTRY ModuleObject;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Use IopRootDeviceNode for now */
|
||||||
|
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
|
||||||
|
if (!NT_SUCCESS(Status)) return;
|
||||||
|
|
||||||
|
/* Setup the module object for the RAW FS Driver */
|
||||||
|
ModuleObject.DllBase = NULL;
|
||||||
|
ModuleObject.SizeOfImage = 0;
|
||||||
|
ModuleObject.EntryPoint = RawFsDriverEntry;
|
||||||
|
|
||||||
|
/* Initialize it */
|
||||||
|
Status = IopInitializeDriverModule(DeviceNode,
|
||||||
|
&ModuleObject,
|
||||||
|
&DeviceNode->ServiceName,
|
||||||
|
TRUE,
|
||||||
|
&DriverObject);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Fail */
|
||||||
|
IopFreeDeviceNode(DeviceNode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now initialize the associated device */
|
||||||
|
Status = IopInitializeDevice(DeviceNode, DriverObject);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Fail */
|
||||||
|
IopFreeDeviceNode(DeviceNode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Start it up */
|
||||||
|
Status = IopStartDevice(DeviceNode);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Fail */
|
||||||
|
IopFreeDeviceNode(DeviceNode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Hack for NTOSKRNL.SYM */
|
/* Hack for NTOSKRNL.SYM */
|
||||||
KDB_SYMBOLFILE_HOOK(&NtosSymName);
|
KDB_SYMBOLFILE_HOOK(&NtosSymName);
|
||||||
|
|
|
@ -442,9 +442,6 @@ NTAPI
|
||||||
IoInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
IoInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
{
|
{
|
||||||
LARGE_INTEGER ExpireTime;
|
LARGE_INTEGER ExpireTime;
|
||||||
PDEVICE_NODE DeviceNode;
|
|
||||||
PDRIVER_OBJECT DriverObject;
|
|
||||||
LDR_DATA_TABLE_ENTRY ModuleObject;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
CHAR Buffer[256];
|
CHAR Buffer[256];
|
||||||
ANSI_STRING NtBootPath, RootString;
|
ANSI_STRING NtBootPath, RootString;
|
||||||
|
@ -497,66 +494,17 @@ IoInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
/* Create Object Directories */
|
/* Create Object Directories */
|
||||||
if (!IopCreateRootDirectories()) return FALSE;
|
if (!IopCreateRootDirectories()) return FALSE;
|
||||||
|
|
||||||
/*
|
/* Initialize PnP manager */
|
||||||
* Initialize PnP manager
|
|
||||||
*/
|
|
||||||
PnpInit();
|
PnpInit();
|
||||||
|
|
||||||
PnpInit2();
|
/* Initialize PnP root relations */
|
||||||
|
|
||||||
IoCreateDriverList();
|
|
||||||
|
|
||||||
KeInitializeSpinLock (&IoStatisticsLock);
|
|
||||||
|
|
||||||
/* Initialize raw filesystem driver */
|
|
||||||
|
|
||||||
/* Use IopRootDeviceNode for now */
|
|
||||||
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
CPRINT("IopCreateDeviceNode() failed with status (%x)\n", Status);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ModuleObject.DllBase = NULL;
|
|
||||||
ModuleObject.SizeOfImage = 0;
|
|
||||||
ModuleObject.EntryPoint = RawFsDriverEntry;
|
|
||||||
|
|
||||||
Status = IopInitializeDriverModule(DeviceNode,
|
|
||||||
&ModuleObject,
|
|
||||||
&DeviceNode->ServiceName,
|
|
||||||
TRUE,
|
|
||||||
&DriverObject);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
IopFreeDeviceNode(DeviceNode);
|
|
||||||
CPRINT("IopInitializeDriver() failed with status (%x)\n", Status);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = IopInitializeDevice(DeviceNode, DriverObject);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
IopFreeDeviceNode(DeviceNode);
|
|
||||||
CPRINT("IopInitializeDevice() failed with status (%x)\n", Status);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = IopStartDevice(DeviceNode);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
IopFreeDeviceNode(DeviceNode);
|
|
||||||
CPRINT("IopInitializeDevice() failed with status (%x)\n", Status);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize PnP root releations
|
|
||||||
*/
|
|
||||||
IoSynchronousInvalidateDeviceRelations(IopRootDeviceNode->
|
IoSynchronousInvalidateDeviceRelations(IopRootDeviceNode->
|
||||||
PhysicalDeviceObject,
|
PhysicalDeviceObject,
|
||||||
BusRelations);
|
BusRelations);
|
||||||
|
|
||||||
|
/* Create the group driver list */
|
||||||
|
IoCreateDriverList();
|
||||||
|
|
||||||
/* Load boot start drivers */
|
/* Load boot start drivers */
|
||||||
IopInitializeBootDrivers();
|
IopInitializeBootDrivers();
|
||||||
|
|
||||||
|
|
|
@ -2610,73 +2610,6 @@ cleanup:
|
||||||
ExFreePool(Data);
|
ExFreePool(Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID INIT_FUNCTION
|
|
||||||
PnpInit(VOID)
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT Pdo;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
DPRINT("PnpInit()\n");
|
|
||||||
|
|
||||||
KeInitializeSpinLock(&IopDeviceTreeLock);
|
|
||||||
|
|
||||||
/* Initialize the Bus Type GUID List */
|
|
||||||
IopBusTypeGuidList = ExAllocatePool(PagedPool, sizeof(IO_BUS_TYPE_GUID_LIST));
|
|
||||||
RtlZeroMemory(IopBusTypeGuidList, sizeof(IO_BUS_TYPE_GUID_LIST));
|
|
||||||
ExInitializeFastMutex(&IopBusTypeGuidList->Lock);
|
|
||||||
|
|
||||||
/* Initialize PnP-Event notification support */
|
|
||||||
Status = IopInitPlugPlayEvents();
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
CPRINT("IopInitPlugPlayEvents() failed\n");
|
|
||||||
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create root device node
|
|
||||||
*/
|
|
||||||
|
|
||||||
Status = IopCreateDriverObject(&IopRootDriverObject, NULL, 0, FALSE, NULL, 0);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
CPRINT("IoCreateDriverObject() failed\n");
|
|
||||||
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = IoCreateDevice(IopRootDriverObject, 0, NULL, FILE_DEVICE_CONTROLLER,
|
|
||||||
0, FALSE, &Pdo);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
CPRINT("IoCreateDevice() failed\n");
|
|
||||||
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = IopCreateDeviceNode(NULL, Pdo, &IopRootDeviceNode);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
CPRINT("Insufficient resources\n");
|
|
||||||
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!RtlCreateUnicodeString(&IopRootDeviceNode->InstancePath,
|
|
||||||
L"HTREE\\ROOT\\0"))
|
|
||||||
{
|
|
||||||
CPRINT("Failed to create the instance path!\n");
|
|
||||||
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, STATUS_NO_MEMORY, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Report the device to the user-mode pnp manager */
|
|
||||||
IopQueueTargetDeviceEvent(&GUID_DEVICE_ARRIVAL,
|
|
||||||
&IopRootDeviceNode->InstancePath);
|
|
||||||
|
|
||||||
IopRootDeviceNode->PhysicalDeviceObject->Flags |= DO_BUS_ENUMERATED_DEVICE;
|
|
||||||
PnpRootDriverEntry(IopRootDriverObject, NULL);
|
|
||||||
IopRootDriverObject->DriverExtension->AddDevice(
|
|
||||||
IopRootDriverObject,
|
|
||||||
IopRootDeviceNode->PhysicalDeviceObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS INIT_FUNCTION
|
static NTSTATUS INIT_FUNCTION
|
||||||
IopEnumerateDetectedDevices(
|
IopEnumerateDetectedDevices(
|
||||||
IN HANDLE hBaseKey,
|
IN HANDLE hBaseKey,
|
||||||
|
@ -3297,10 +3230,71 @@ IopUpdateRootKey(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID INIT_FUNCTION
|
VOID INIT_FUNCTION
|
||||||
PnpInit2(VOID)
|
PnpInit(VOID)
|
||||||
{
|
{
|
||||||
|
PDEVICE_OBJECT Pdo;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("PnpInit()\n");
|
||||||
|
|
||||||
|
KeInitializeSpinLock(&IopDeviceTreeLock);
|
||||||
|
|
||||||
|
/* Initialize the Bus Type GUID List */
|
||||||
|
IopBusTypeGuidList = ExAllocatePool(PagedPool, sizeof(IO_BUS_TYPE_GUID_LIST));
|
||||||
|
RtlZeroMemory(IopBusTypeGuidList, sizeof(IO_BUS_TYPE_GUID_LIST));
|
||||||
|
ExInitializeFastMutex(&IopBusTypeGuidList->Lock);
|
||||||
|
|
||||||
|
/* Initialize PnP-Event notification support */
|
||||||
|
Status = IopInitPlugPlayEvents();
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
CPRINT("IopInitPlugPlayEvents() failed\n");
|
||||||
|
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create root device node
|
||||||
|
*/
|
||||||
|
|
||||||
|
Status = IopCreateDriverObject(&IopRootDriverObject, NULL, 0, FALSE, NULL, 0);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
CPRINT("IoCreateDriverObject() failed\n");
|
||||||
|
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = IoCreateDevice(IopRootDriverObject, 0, NULL, FILE_DEVICE_CONTROLLER,
|
||||||
|
0, FALSE, &Pdo);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
CPRINT("IoCreateDevice() failed\n");
|
||||||
|
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = IopCreateDeviceNode(NULL, Pdo, &IopRootDeviceNode);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
CPRINT("Insufficient resources\n");
|
||||||
|
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RtlCreateUnicodeString(&IopRootDeviceNode->InstancePath,
|
||||||
|
L"HTREE\\ROOT\\0"))
|
||||||
|
{
|
||||||
|
CPRINT("Failed to create the instance path!\n");
|
||||||
|
KEBUGCHECKEX(PHASE1_INITIALIZATION_FAILED, STATUS_NO_MEMORY, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Report the device to the user-mode pnp manager */
|
||||||
|
IopQueueTargetDeviceEvent(&GUID_DEVICE_ARRIVAL,
|
||||||
|
&IopRootDeviceNode->InstancePath);
|
||||||
|
|
||||||
|
IopRootDeviceNode->PhysicalDeviceObject->Flags |= DO_BUS_ENUMERATED_DEVICE;
|
||||||
|
PnpRootDriverEntry(IopRootDriverObject, NULL);
|
||||||
|
IopRootDriverObject->DriverExtension->AddDevice(
|
||||||
|
IopRootDriverObject,
|
||||||
|
IopRootDeviceNode->PhysicalDeviceObject);
|
||||||
|
|
||||||
/* Move information about devices detected by Freeloader to SYSTEM\CurrentControlSet\Root\ */
|
/* Move information about devices detected by Freeloader to SYSTEM\CurrentControlSet\Root\ */
|
||||||
Status = IopUpdateRootKey();
|
Status = IopUpdateRootKey();
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -3310,4 +3304,5 @@ PnpInit2(VOID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue