From bf702f35f25ec63f31eec10ab49eade5a0647159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Fri, 22 Aug 2008 17:47:13 +0000 Subject: [PATCH] Clean up code by removing now useless parts Replace 3rd arg of IopActionInitChildServices by a global variable (removes a pointer cast) IopStartDevice: no need to get top of stack, IopInitiatePnpIrp does it for us svn path=/trunk/; revision=35532 --- reactos/ntoskrnl/include/internal/io.h | 6 +- reactos/ntoskrnl/io/iomgr/driver.c | 21 ----- reactos/ntoskrnl/io/iomgr/iomgr.c | 4 +- reactos/ntoskrnl/io/pnpmgr/plugplay.c | 2 +- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 122 ++++--------------------- 5 files changed, 24 insertions(+), 131 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/io.h b/reactos/ntoskrnl/include/internal/io.h index ca656d2b8a0..65dec1a517f 100644 --- a/reactos/ntoskrnl/include/internal/io.h +++ b/reactos/ntoskrnl/include/internal/io.h @@ -553,8 +553,7 @@ IopActionConfigureChildServices( NTSTATUS IopActionInitChildServices( IN PDEVICE_NODE DeviceNode, - IN PVOID Context, - IN BOOLEAN BootDrivers + IN PVOID Context ); NTSTATUS @@ -579,8 +578,7 @@ IopQueueTargetDeviceEvent( NTSTATUS IopInitializePnpServices( - IN PDEVICE_NODE DeviceNode, - IN BOOLEAN BootDrivers); + IN PDEVICE_NODE DeviceNode); NTSTATUS NTAPI diff --git a/reactos/ntoskrnl/io/iomgr/driver.c b/reactos/ntoskrnl/io/iomgr/driver.c index d69b47eb8ac..c5a8bee7034 100644 --- a/reactos/ntoskrnl/io/iomgr/driver.c +++ b/reactos/ntoskrnl/io/iomgr/driver.c @@ -782,10 +782,6 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) LPWSTR FileExtension; PUNICODE_STRING ModuleName = &LdrEntry->BaseDllName; UNICODE_STRING ServiceName; -#if 1 // Disable for FreeLDR 2.5 - UNICODE_STRING ServiceNameWithExtension; - PLDR_DATA_TABLE_ENTRY ModuleObject; -#endif /* * Display 'Loading XXX...' message @@ -805,19 +801,6 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) FileNameWithoutPath++; } - /* - * Load the module. - */ -#if 1 // Remove for FreeLDR 2.5. - RtlCreateUnicodeString(&ServiceNameWithExtension, FileNameWithoutPath); - Status = LdrProcessDriverModule(LdrEntry, &ServiceNameWithExtension, &ModuleObject); - if (!NT_SUCCESS(Status)) - { - CPRINT("Driver '%wZ' load failed, status (%x)\n", ModuleName, Status); - return Status; - } -#endif - /* * Strip the file extension from ServiceName */ @@ -844,7 +827,6 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY LdrEntry) /* * Initialize the driver */ - DeviceNode->Flags |= DN_DRIVER_LOADED; Status = IopInitializeDriverModule(DeviceNode, LdrEntry, &DeviceNode->ServiceName, FALSE, &DriverObject); @@ -1729,9 +1711,6 @@ IopLoadUnloadDriver(PLOAD_UNLOAD_PARAMS LoadParams) /* Store its DriverSection, so that it could be unloaded */ DriverObject->DriverSection = ModuleObject; - - /* We have a driver for this DeviceNode */ - DeviceNode->Flags |= DN_DRIVER_LOADED; } IopInitializeDevice(DeviceNode, DriverObject); diff --git a/reactos/ntoskrnl/io/iomgr/iomgr.c b/reactos/ntoskrnl/io/iomgr/iomgr.c index f9cf68a94b4..d53ef808e74 100644 --- a/reactos/ntoskrnl/io/iomgr/iomgr.c +++ b/reactos/ntoskrnl/io/iomgr/iomgr.c @@ -14,6 +14,7 @@ #include ULONG IopTraceLevel = 0; +BOOLEAN PnpSystemInit = FALSE; // should go into a proper header VOID @@ -535,9 +536,10 @@ IoInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock) #endif /* Load services for devices found by PnP manager */ - IopInitializePnpServices(IopRootDeviceNode, FALSE); + IopInitializePnpServices(IopRootDeviceNode); /* Load system start drivers */ + PnpSystemInit = TRUE; IopInitializeSystemDrivers(); /* Destroy the group driver list */ diff --git a/reactos/ntoskrnl/io/pnpmgr/plugplay.c b/reactos/ntoskrnl/io/pnpmgr/plugplay.c index c0370787d25..e7bdf2ffd7c 100644 --- a/reactos/ntoskrnl/io/pnpmgr/plugplay.c +++ b/reactos/ntoskrnl/io/pnpmgr/plugplay.c @@ -576,7 +576,7 @@ IopResetDevice(PPLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData) Status = IopActionConfigureChildServices(DeviceNode, DeviceNode->Parent); if (NT_SUCCESS(Status)) - Status = IopActionInitChildServices(DeviceNode, DeviceNode->Parent, FALSE); + Status = IopActionInitChildServices(DeviceNode, DeviceNode->Parent); ObDereferenceObject(DeviceObject); diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index ae63ab0c0e0..e6005c00b6b 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -24,6 +24,7 @@ KGUARDED_MUTEX PpDeviceReferenceTableLock; RTL_AVL_TABLE PpDeviceReferenceTable; extern ULONG ExpInitializationPhase; +extern BOOLEAN PnpSystemInit; /* DATA **********************************************************************/ @@ -139,16 +140,13 @@ IopStartDevice( IO_STATUS_BLOCK IoStatusBlock; IO_STACK_LOCATION Stack; ULONG RequiredLength; - PDEVICE_OBJECT Fdo; NTSTATUS Status; - Fdo = IoGetAttachedDeviceReference(DeviceNode->PhysicalDeviceObject); - IopDeviceNodeSetFlag(DeviceNode, DNF_ASSIGNING_RESOURCES); DPRINT("Sending IRP_MN_FILTER_RESOURCE_REQUIREMENTS to device stack\n"); Stack.Parameters.FilterResourceRequirements.IoResourceRequirementList = DeviceNode->ResourceRequirements; Status = IopInitiatePnpIrp( - Fdo, + DeviceNode->PhysicalDeviceObject, &IoStatusBlock, IRP_MN_FILTER_RESOURCE_REQUIREMENTS, &Stack); @@ -190,7 +188,7 @@ IopStartDevice( KeEnterCriticalRegion(); Status = IopInitiatePnpIrp( - Fdo, + DeviceNode->PhysicalDeviceObject, &IoStatusBlock, IRP_MN_START_DEVICE, &Stack); @@ -213,10 +211,8 @@ IopStartDevice( } } - ObDereferenceObject(Fdo); - if (NT_SUCCESS(Status)) - DeviceNode->Flags |= DN_STARTED; + IopDeviceNodeSetFlag(DeviceNode, DNF_STARTED); return Status; } @@ -1784,7 +1780,6 @@ IopActionConfigureChildServices(PDEVICE_NODE DeviceNode, * device is started */ DPRINT1("%wZ is using NULL driver\n", &DeviceNode->InstancePath); IopDeviceNodeSetFlag(DeviceNode, DNF_STARTED); - DeviceNode->Flags |= DN_STARTED; } return STATUS_SUCCESS; } @@ -1805,8 +1800,6 @@ IopActionConfigureChildServices(PDEVICE_NODE DeviceNode, * Pointer to device node. * Context * Pointer to parent node to initialize child node services for. - * BootDrivers - * Load only driver marked as boot start. * * Remarks * If the driver image for a service is not loaded and initialized @@ -1819,14 +1812,13 @@ IopActionConfigureChildServices(PDEVICE_NODE DeviceNode, NTSTATUS IopActionInitChildServices(PDEVICE_NODE DeviceNode, - PVOID Context, - BOOLEAN BootDrivers) + PVOID Context) { PDEVICE_NODE ParentDeviceNode; NTSTATUS Status; + BOOLEAN BootDrivers = !PnpSystemInit; - DPRINT("IopActionInitChildServices(%p, %p, %d)\n", DeviceNode, Context, - BootDrivers); + DPRINT("IopActionInitChildServices(%p, %p)\n", DeviceNode, Context); ParentDeviceNode = (PDEVICE_NODE)Context; @@ -1900,8 +1892,6 @@ IopActionInitChildServices(PDEVICE_NODE DeviceNode, /* Driver is loaded and initialized at this point */ if (NT_SUCCESS(Status)) { - /* We have a driver for this DeviceNode */ - DeviceNode->Flags |= DN_DRIVER_LOADED; /* Attach lower level filter drivers. */ IopAttachFilterDrivers(DeviceNode, TRUE); /* Initialize the function driver for the device node */ @@ -1945,34 +1935,6 @@ IopActionInitChildServices(PDEVICE_NODE DeviceNode, return STATUS_SUCCESS; } -/* - * IopActionInitAllServices - * - * Initialize the service for all (direct) child nodes of a parent node. This - * function just calls IopActionInitChildServices with BootDrivers = FALSE. - */ - -NTSTATUS -IopActionInitAllServices(PDEVICE_NODE DeviceNode, - PVOID Context) -{ - return IopActionInitChildServices(DeviceNode, Context, FALSE); -} - -/* - * IopActionInitBootServices - * - * Initialize the boot start services for all (direct) child nodes of a - * parent node. This function just calls IopActionInitChildServices with - * BootDrivers = TRUE. - */ -NTSTATUS -IopActionInitBootServices(PDEVICE_NODE DeviceNode, - PVOID Context) -{ - return IopActionInitChildServices(DeviceNode, Context, TRUE); -} - /* * IopInitializePnpServices * @@ -1982,37 +1944,21 @@ IopActionInitBootServices(PDEVICE_NODE DeviceNode, * DeviceNode * Top device node to start initializing services. * - * BootDrivers - * When set to TRUE, only drivers marked as boot start will - * be loaded. Otherwise, all drivers will be loaded. - * * Return Value * Status */ NTSTATUS -IopInitializePnpServices(IN PDEVICE_NODE DeviceNode, - IN BOOLEAN BootDrivers) +IopInitializePnpServices(IN PDEVICE_NODE DeviceNode) { DEVICETREE_TRAVERSE_CONTEXT Context; - DPRINT("IopInitializePnpServices(%p, %d)\n", DeviceNode, BootDrivers); + DPRINT("IopInitializePnpServices(%p)\n", DeviceNode); - if (BootDrivers) - { - IopInitDeviceTreeTraverseContext( - &Context, - DeviceNode, - IopActionInitBootServices, - DeviceNode); - } - else - { - IopInitDeviceTreeTraverseContext( - &Context, - DeviceNode, - IopActionInitAllServices, - DeviceNode); - } + IopInitDeviceTreeTraverseContext( + &Context, + DeviceNode, + IopActionInitChildServices, + DeviceNode); return IopTraverseDeviceTree(&Context); } @@ -3051,12 +2997,11 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, if (!NT_SUCCESS(Status)) { - DPRINT1("Problem: Status=0x%08x, ResultLength = %d\n", Status, *ResultLength); ExFreePool(ValueInformation); if (Status == STATUS_BUFFER_OVERFLOW) return STATUS_BUFFER_TOO_SMALL; - else - return Status; + DPRINT1("Problem: Status=0x%08x, ResultLength = %d\n", Status, *ResultLength); + return Status; } /* FIXME: Verify the value (NULL-terminated, correct format). */ @@ -3339,10 +3284,6 @@ IoSynchronousInvalidateDeviceRelations( IO_STATUS_BLOCK IoStatusBlock; PDEVICE_NODE ChildDeviceNode; IO_STACK_LOCATION Stack; - BOOLEAN BootDrivers; - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING LinkName = RTL_CONSTANT_STRING(L"\\SystemRoot"); - HANDLE Handle; NTSTATUS Status; ULONG i; @@ -3437,36 +3378,9 @@ IoSynchronousInvalidateDeviceRelations( } /* - * Get the state of the system boot. If the \\SystemRoot link isn't - * created yet, we will assume that it's possible to load only boot - * drivers. + * Initialize services for discovered children. */ - InitializeObjectAttributes( - &ObjectAttributes, - &LinkName, - 0, - NULL, - NULL); - Status = ZwOpenFile( - &Handle, - FILE_ALL_ACCESS, - &ObjectAttributes, - &IoStatusBlock, - 0, - 0); - if (NT_SUCCESS(Status)) - { - BootDrivers = FALSE; - ZwClose(Handle); - } - else - BootDrivers = TRUE; - - /* - * Initialize services for discovered children. Only boot drivers will - * be loaded from boot driver! - */ - Status = IopInitializePnpServices(DeviceNode, BootDrivers); + Status = IopInitializePnpServices(DeviceNode); if (!NT_SUCCESS(Status)) { DPRINT("IopInitializePnpServices() failed with status 0x%08lx\n", Status);