Author: tkreuzer
Date: Tue Jan 14 21:21:29 2014
New Revision: 61628
URL:
http://svn.reactos.org/svn/reactos?rev=61628&view=rev
Log:
[BATTC] Check if MiniportInfo->Pdo is NULL before passing it to
IoRegisterDeviceInterface
[CMBATT] Fix broken CmBattGetAcpiInterfaces
[COMPBATT] Fix "typo" in CompBattAddDevice that caused memory corruption
Modified:
trunk/reactos/drivers/battery/battc/battc.c
trunk/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c
trunk/reactos/drivers/bus/acpi/compbatt/comppnp.c
trunk/reactos/drivers/storage/ide/pciidex/pdo.c
Modified: trunk/reactos/drivers/battery/battc/battc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/battery/battc/batt…
==============================================================================
--- trunk/reactos/drivers/battery/battc/battc.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/battery/battc/battc.c [iso-8859-1] Tue Jan 14 21:21:29 2014
@@ -151,18 +151,26 @@
ExInitializeFastMutex(&BattClass->Mutex);
- Status = IoRegisterDeviceInterface(MiniportInfo->Pdo,
- &GUID_DEVICE_BATTERY,
- NULL,
- &BattClass->InterfaceName);
- if (NT_SUCCESS(Status))
- {
- DPRINT("Initialized battery interface: %wZ\n",
&BattClass->InterfaceName);
- IoSetDeviceInterfaceState(&BattClass->InterfaceName, TRUE);
- }
- else
- {
- DPRINT1("IoRegisterDeviceInterface failed (0x%x)\n", Status);
+ if (MiniportInfo->Pdo != NULL)
+ {
+ Status = IoRegisterDeviceInterface(MiniportInfo->Pdo,
+ &GUID_DEVICE_BATTERY,
+ NULL,
+ &BattClass->InterfaceName);
+ if (NT_SUCCESS(Status))
+ {
+ DPRINT("Initialized battery interface: %wZ\n",
&BattClass->InterfaceName);
+ Status = IoSetDeviceInterfaceState(&BattClass->InterfaceName, TRUE);
+ if (Status == STATUS_OBJECT_NAME_EXISTS)
+ {
+ DPRINT1("Got STATUS_OBJECT_NAME_EXISTS for
SetDeviceInterfaceState\n");
+ Status = STATUS_SUCCESS;
+ }
+ }
+ else
+ {
+ DPRINT1("IoRegisterDeviceInterface failed (0x%x)\n", Status);
+ }
}
*ClassData = BattClass;
Modified: trunk/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/cmbatt/cm…
==============================================================================
--- trunk/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c [iso-8859-1] Tue Jan 14 21:21:29 2014
@@ -23,7 +23,7 @@
NTSTATUS Status;
PCMBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
if (CmBattDebug & 0x20) DbgPrint("CmBattWaitWakeLoop: Entered.\n");
-
+
/* Check for success */
if ((NT_SUCCESS(IoStatusBlock->Status)) &&
(DeviceExtension->WaitWakeEnable))
{
@@ -48,7 +48,7 @@
DeviceExtension->PowerIrp = NULL;
}
}
-
+
NTSTATUS
NTAPI
CmBattIoCompletion(IN PDEVICE_OBJECT DeviceObject,
@@ -87,6 +87,7 @@
/* Build the query */
IoStackLocation = IoGetNextIrpStackLocation(Irp);
+ IoStackLocation->MajorFunction = IRP_MJ_PNP;
IoStackLocation->MinorFunction = IRP_MN_QUERY_INTERFACE;
IoStackLocation->Parameters.QueryInterface.InterfaceType =
&GUID_ACPI_INTERFACE_STANDARD;
IoStackLocation->Parameters.QueryInterface.Size =
sizeof(ACPI_INTERFACE_STANDARD);
@@ -100,16 +101,15 @@
/* Initialize our wait event */
KeInitializeEvent(&Event, SynchronizationEvent, 0);
-
+
/* Set the completion routine */
- IoCopyCurrentIrpStackLocationToNext(Irp);
IoSetCompletionRoutine(Irp,
(PVOID)CmBattIoCompletion,
&Event,
TRUE,
TRUE,
TRUE);
-
+
/* Now call ACPI */
Status = IoCallDriver(DeviceObject, Irp);
if (Status == STATUS_PENDING)
@@ -122,10 +122,10 @@
NULL);
Status = Irp->IoStatus.Status;
}
-
+
/* Free the IRP */
IoFreeIrp(Irp);
-
+
/* Return status */
if (!(NT_SUCCESS(Status)) && (CmBattDebug & 0xC))
DbgPrint("CmBattGetAcpiInterfaces: Could not get ACPI driver interfaces,
status = %x\n", Status);
@@ -157,7 +157,7 @@
DeviceExtension,
DeviceExtension->FdoType,
DeviceExtension->DeviceId);
-
+
/* Make sure it's safe to go ahead */
IoReleaseRemoveLockAndWait(&DeviceExtension->RemoveLock, 0);
@@ -168,7 +168,7 @@
IoCancelIrp(DeviceExtension->PowerIrp);
DeviceExtension->PowerIrp = NULL;
}
-
+
/* Check what type of FDO is being removed */
Context = DeviceExtension->AcpiInterface.Context;
if (DeviceExtension->FdoType == CmBattBattery)
@@ -187,7 +187,7 @@
CmBattWmiDeRegistration(DeviceExtension);
AcAdapterPdo = NULL;
}
-
+
/* Detach and delete */
IoDetachDevice(DeviceExtension->AttachedDevice);
IoDeleteDevice(DeviceExtension->DeviceObject);
@@ -209,30 +209,30 @@
DeviceExtension = DeviceObject->DeviceExtension;
switch (IoStackLocation->MinorFunction)
{
- case IRP_MN_WAIT_WAKE:
+ case IRP_MN_WAIT_WAKE:
if (CmBattDebug & 0x10)
DbgPrint("CmBattPowerDispatch: IRP_MN_WAIT_WAKE\n");
break;
-
+
case IRP_MN_POWER_SEQUENCE:
if (CmBattDebug & 0x10)
DbgPrint("CmBattPowerDispatch: IRP_MN_POWER_SEQUENCE\n");
break;
-
+
case IRP_MN_QUERY_POWER:
if (CmBattDebug & 0x10)
DbgPrint("CmBattPowerDispatch: IRP_MN_WAIT_WAKE\n");
break;
-
+
case IRP_MN_SET_POWER:
if (CmBattDebug & 0x10)
DbgPrint("CmBattPowerDispatch: IRP_MN_SET_POWER type: %d, State: %d
\n",
IoStackLocation->Parameters.Power.Type,
IoStackLocation->Parameters.Power.State);
break;
-
+
default:
-
+
if (CmBattDebug & 1)
DbgPrint("CmBattPowerDispatch: minor %d\n",
IoStackLocation->MinorFunction);
break;
@@ -252,7 +252,7 @@
Status = Irp->IoStatus.Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
-
+
/* Return status */
return Status;
}
@@ -271,12 +271,12 @@
/* Get stack location and device extension */
IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
DeviceExtension = DeviceObject->DeviceExtension;
-
+
/* Set default error */
Status = STATUS_NOT_SUPPORTED;
/* Try to acquire the lock before doing anything */
- Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, 0);
+ Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, Irp);
if (!NT_SUCCESS(Status))
{
/* Complete the request */
@@ -287,9 +287,9 @@
/* What's the operation? */
switch (IoStackLocation->MinorFunction)
- {
+ {
case IRP_MN_QUERY_PNP_DEVICE_STATE:
-
+
/* Initialize our wait event */
KeInitializeEvent(&Event, SynchronizationEvent, 0);
@@ -322,28 +322,28 @@
IoCompleteRequest(Irp, IO_NO_INCREMENT);
IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp);
return Status;
-
+
case IRP_MN_SURPRISE_REMOVAL:
if (CmBattDebug & 0x20)
DbgPrint("CmBattPnpDispatch: IRP_MN_SURPRISE_REMOVAL\n");
-
+
/* Lock the device extension and set the handle count to invalid */
ExAcquireFastMutex(&DeviceExtension->FastMutex);
DeviceExtension->HandleCount = -1;
ExReleaseFastMutex(&DeviceExtension->FastMutex);
Status = STATUS_SUCCESS;
break;
-
+
case IRP_MN_START_DEVICE:
if (CmBattDebug & 0x20)
DbgPrint("CmBattPnpDispatch: IRP_MN_START_DEVICE\n");
-
+
/* Mark the extension as started */
if (DeviceExtension->FdoType == CmBattBattery) DeviceExtension->Started
= TRUE;
Status = STATUS_SUCCESS;
break;
-
- case IRP_MN_STOP_DEVICE:
+
+ case IRP_MN_STOP_DEVICE:
if (CmBattDebug & 0x20)
DbgPrint("CmBattPnpDispatch: IRP_MN_STOP_DEVICE\n");
@@ -351,7 +351,7 @@
if (DeviceExtension->FdoType == CmBattBattery) DeviceExtension->Started
= FALSE;
Status = STATUS_SUCCESS;
break;
-
+
case IRP_MN_QUERY_REMOVE_DEVICE:
if (CmBattDebug & 0x20)
DbgPrint("CmBattPnpDispatch: IRP_MN_QUERY_REMOVE_DEVICE\n");
@@ -376,23 +376,23 @@
/* Fail because there's still open handles */
Status = STATUS_UNSUCCESSFUL;
}
-
+
/* Release the lock and return */
ExReleaseFastMutex(&DeviceExtension->FastMutex);
break;
-
+
case IRP_MN_REMOVE_DEVICE:
if (CmBattDebug & 0x20)
DbgPrint("CmBattPnpDispatch: IRP_MN_REMOVE_DEVICE\n");
-
+
/* Call the remove code */
Status = CmBattRemoveDevice(DeviceObject, Irp);
break;
-
+
case IRP_MN_CANCEL_REMOVE_DEVICE:
if (CmBattDebug & 0x20)
DbgPrint("CmBattPnpDispatch: IRP_MN_CANCEL_REMOVE_DEVICE\n");
-
+
/* Lock the extension and get the handle count */
ExAcquireFastMutex(&DeviceExtension->FastMutex);
if (DeviceExtension->HandleCount == -1)
@@ -403,33 +403,33 @@
else if (CmBattDebug & 2)
{
/* Nop, but warn about it */
- DbgPrint("CmBattPnpDispatch: Received CANCEL_REMOVE when OpenCount
== %x\n",
+ DbgPrint("CmBattPnpDispatch: Received CANCEL_REMOVE when OpenCount
== %x\n",
DeviceExtension->HandleCount);
}
-
+
/* Return success in all cases, and release the lock */
Status = STATUS_SUCCESS;
ExReleaseFastMutex(&DeviceExtension->FastMutex);
break;
-
+
case IRP_MN_QUERY_STOP_DEVICE:
if (CmBattDebug & 0x20)
DbgPrint("CmBattPnpDispatch: IRP_MN_QUERY_STOP_DEVICE\n");
-
- /* There's no real support for this */
+
+ /* There's no real support for this */
Status = STATUS_NOT_IMPLEMENTED;
break;
case IRP_MN_CANCEL_STOP_DEVICE:
if (CmBattDebug & 0x20)
DbgPrint("CmBattPnpDispatch: IRP_MN_CANCEL_STOP_DEVICE\n");
-
- /* There's no real support for this */
+
+ /* There's no real support for this */
Status = STATUS_NOT_IMPLEMENTED;
break;
-
+
case IRP_MN_QUERY_CAPABILITIES:
-
+
/* Initialize our wait event */
KeInitializeEvent(&Event, SynchronizationEvent, 0);
@@ -496,14 +496,14 @@
IoStackLocation->MinorFunction);
break;
}
-
- /* Release the remove lock */
+
+ /* Release the remove lock */
IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp);
/* Set IRP status if we have one */
if (Status != STATUS_NOT_SUPPORTED) Irp->IoStatus.Status = Status;
- /* Did someone pick it up? */
+ /* Did someone pick it up? */
if ((NT_SUCCESS(Status)) || (Status == STATUS_NOT_SUPPORTED))
{
/* Still unsupported, try ACPI */
@@ -539,7 +539,7 @@
ULONG ResultLength;
PAGED_CODE();
if (CmBattDebug & 0x220) DbgPrint("CmBattCreateFdo: Entered\n");
-
+
/* Get unique ID */
Status = CmBattGetUniqueId(DeviceObject, &UniqueId);
if (!NT_SUCCESS(Status))
@@ -549,7 +549,7 @@
if (CmBattDebug & 2)
DbgPrint("CmBattCreateFdo: Error %x from _UID, assuming unit #0\n",
Status);
}
-
+
/* Create the FDO */
Status = IoCreateDevice(DriverObject,
DeviceExtensionSize,
@@ -565,7 +565,7 @@
DbgPrint("CmBattCreateFdo: error (0x%x) creating device object\n",
Status);
return Status;
}
-
+
/* Set FDO flags */
FdoDeviceObject->Flags |= (DO_POWER_PAGABLE | DO_BUFFERED_IO);
FdoDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
@@ -576,7 +576,7 @@
FdoExtension->DeviceObject = FdoDeviceObject;
FdoExtension->FdoDeviceObject = FdoDeviceObject;
FdoExtension->PdoDeviceObject = DeviceObject;
-
+
/* Attach to ACPI */
FdoExtension->AttachedDevice = IoAttachDeviceToDeviceStack(FdoDeviceObject,
DeviceObject);
@@ -588,7 +588,7 @@
DbgPrint("CmBattCreateFdo: IoAttachDeviceToDeviceStack
failed.\n");
return STATUS_UNSUCCESSFUL;
}
-
+
/* Get ACPI interface for EVAL */
Status = CmBattGetAcpiInterfaces(FdoExtension->AttachedDevice,
&FdoExtension->AcpiInterface);
@@ -604,14 +604,14 @@
/* Setup the rest of the extension */
ExInitializeFastMutex(&FdoExtension->FastMutex);
- IoInitializeRemoveLock(&FdoExtension->RemoveLock, 0, 0, 0);
+ IoInitializeRemoveLock(&FdoExtension->RemoveLock, 'RbmC', 0, 0);
FdoExtension->HandleCount = 0;
FdoExtension->WaitWakeEnable = FALSE;
FdoExtension->DeviceId = UniqueId;
FdoExtension->DeviceName = NULL;
FdoExtension->DelayNotification = FALSE;
FdoExtension->ArFlag = 0;
-
+
/* Open the device key */
Status = IoOpenDeviceRegistryKey(DeviceObject,
PLUGPLAY_REGKEY_DEVICE,
@@ -630,9 +630,9 @@
if (NT_SUCCESS(Status))
{
/* Set value */
- FdoExtension->WaitWakeEnable = *(PULONG)PartialInfo->Data;
+ FdoExtension->WaitWakeEnable = ((*(PULONG)PartialInfo->Data) != 0);
}
-
+
/* Close the handle */
ZwClose(KeyHandle);
}
@@ -652,7 +652,7 @@
BATTERY_MINIPORT_INFO MiniportInfo;
NTSTATUS Status;
PDEVICE_OBJECT FdoDeviceObject;
- PCMBATT_DEVICE_EXTENSION FdoExtension;
+ PCMBATT_DEVICE_EXTENSION FdoExtension;
PAGED_CODE();
if (CmBattDebug & 0x220)
DbgPrint("CmBattAddBattery: pdo %x\n", DeviceObject);
@@ -680,7 +680,7 @@
FdoExtension->InterruptTime = KeQueryInterruptTime();
FdoExtension->TripPointSet = CmBattSetTripPpoint(FdoExtension, 0) !=
STATUS_OBJECT_NAME_NOT_FOUND;
-
+
/* Setup the battery miniport information structure */
RtlZeroMemory(&MiniportInfo, sizeof(MiniportInfo));
MiniportInfo.Pdo = DeviceObject;
@@ -694,7 +694,7 @@
MiniportInfo.SetStatusNotify = (PVOID)CmBattSetStatusNotify;
MiniportInfo.DisableStatusNotify = (PVOID)CmBattDisableStatusNotify;
MiniportInfo.DeviceName = FdoExtension->DeviceName;
-
+
/* Register with the class driver */
Status = BatteryClassInitializeDevice(&MiniportInfo,
&FdoExtension->ClassData);
if (!NT_SUCCESS(Status))
@@ -714,7 +714,7 @@
DbgPrint("CmBattAddBattery: Could not register as a WMI provider, status
= %Lx\n", Status);
return Status;
}
-
+
/* Register ACPI */
Status =
FdoExtension->AcpiInterface.RegisterForDeviceNotifications(FdoExtension->AcpiInterface.Context,
(PVOID)CmBattNotifyHandler,
@@ -728,7 +728,7 @@
if (CmBattDebug & 0xC)
DbgPrint("CmBattAddBattery: Could not register for battery notify,
status = %Lx\n", Status);
}
-
+
/* Return status */
return Status;
}
@@ -757,7 +757,7 @@
/* Set this as the AC adapter's PDO */
AcAdapterPdo = PdoDeviceObject;
}
-
+
/* Create the FDO for the adapter */
Status = CmBattCreateFdo(DriverObject,
PdoDeviceObject,
@@ -770,7 +770,7 @@
DbgPrint("CmBattAddAcAdapter: error (0x%x) creating Fdo\n",
Status);
return Status;
}
-
+
/* Set the type and do WMI registration */
DeviceExtension = FdoDeviceObject->DeviceExtension;
DeviceExtension->FdoType = CmBattAcAdapter;
@@ -781,7 +781,7 @@
if (CmBattDebug & 0xC)
DbgPrint("CmBattAddBattery: Could not register as a WMI provider, status
= %Lx\n", Status);
}
-
+
/* Register with ACPI */
Status =
DeviceExtension->AcpiInterface.RegisterForDeviceNotifications(DeviceExtension->AcpiInterface.Context,
(PVOID)CmBattNotifyHandler,
@@ -809,7 +809,7 @@
PAGED_CODE();
if (CmBattDebug & 0x220)
DbgPrint("CmBattAddDevice: Entered with pdo %x\n", PdoDeviceObject);
-
+
/* Make sure we have a PDO */
if (!PdoDeviceObject)
{
@@ -817,7 +817,7 @@
if (CmBattDebug & 0x24) DbgPrint("CmBattAddDevice: Asked to do
detection\n");
return STATUS_NO_MORE_ENTRIES;
}
-
+
/* Open the driver key */
Status = IoOpenDeviceRegistryKey(PdoDeviceObject,
PLUGPLAY_REGKEY_DRIVER,
@@ -846,7 +846,7 @@
DbgPrint("CmBattAddDevice: Could not read the power type identifier:
%x\n", Status);
return Status;
}
-
+
/* Check what kind of power source this is */
PowerSourceType = *(PULONG)PartialInfo->Data;
if (PowerSourceType == 1)
@@ -866,7 +866,7 @@
DbgPrint("CmBattAddDevice: Invalid POWER_SOURCE_TYPE == %d \n",
PowerSourceType);
return STATUS_UNSUCCESSFUL;
}
-
+
/* Return whatever the FDO creation routine did */
return Status;
}
Modified: trunk/reactos/drivers/bus/acpi/compbatt/comppnp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/compbatt/…
==============================================================================
--- trunk/reactos/drivers/bus/acpi/compbatt/comppnp.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/acpi/compbatt/comppnp.c [iso-8859-1] Tue Jan 14 21:21:29
2014
@@ -11,7 +11,7 @@
#include "compbatt.h"
/* FUNCTIONS ******************************************************************/
-
+
NTSTATUS
NTAPI
CompBattPowerDispatch(IN PDEVICE_OBJECT DeviceObject,
@@ -19,10 +19,10 @@
{
PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
if (CompBattDebug & 1) DbgPrint("CompBatt: PowerDispatch received power
IRP.\n");
-
+
/* Start the next IRP */
PoStartNextPowerIrp(Irp);
-
+
/* Call the next driver in the stack */
IoSkipCurrentIrpStackLocation(Irp);
return PoCallDriver(DeviceExtension->AttachedDevice, Irp);
@@ -52,18 +52,18 @@
IoAcquireRemoveLock(&BatteryData->RemoveLock, 0);
ExReleaseFastMutex(&DeviceExtension->Lock);
IoReleaseRemoveLockAndWait(&BatteryData->RemoveLock, 0);
-
+
/* Remove the entry from the list */
ExAcquireFastMutex(&DeviceExtension->Lock);
RemoveEntryList(&BatteryData->BatteryLink);
ExReleaseFastMutex(&DeviceExtension->Lock);
return BatteryData;
}
-
+
/* Next */
NextEntry = NextEntry->Flink;
}
-
+
/* Done */
ExReleaseFastMutex(&DeviceExtension->Lock);
if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING
RemoveBatteryFromList\n");
@@ -80,7 +80,7 @@
BOOLEAN Found = FALSE;
if (CompBattDebug & 1)
DbgPrint("CompBatt: ENTERING IsBatteryAlreadyOnList\n");
-
+
/* Loop the battery list */
ExAcquireFastMutex(&DeviceExtension->Lock);
ListHead = &DeviceExtension->BatteryList;
@@ -99,7 +99,7 @@
/* Next */
NextEntry = NextEntry->Flink;
}
-
+
/* Release the lock and return search status */
ExReleaseFastMutex(&DeviceExtension->Lock);
if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING
IsBatteryAlreadyOnList\n");
@@ -119,7 +119,7 @@
PAGED_CODE();
if (CompBattDebug & 1)
DbgPrint("CompBatt: ENTERING AddNewBattery \"%w\" \n",
BatteryName->Buffer);
-
+
/* Is this a new battery? */
if (!IsBatteryAlreadyOnList(BatteryName, DeviceExtension))
{
@@ -136,7 +136,7 @@
BatteryData->BatteryName.MaximumLength = BatteryName->Length;
BatteryData->BatteryName.Buffer = (PWCHAR)(BatteryData + 1);
RtlCopyUnicodeString(&BatteryData->BatteryName, BatteryName);
-
+
/* Get the device object */
Status = CompBattGetDeviceObjectPointer(BatteryName,
FILE_ALL_ACCESS,
@@ -147,14 +147,14 @@
/* Reference the DO and drop the FO */
ObReferenceObject(BatteryData->DeviceObject);
ObDereferenceObject(FileObject);
-
- /* Allocate the battery IRP */
+
+ /* Allocate the battery IRP */
Irp = IoAllocateIrp(BatteryData->DeviceObject->StackSize + 1, 0);
if (Irp)
{
/* Save it */
BatteryData->Irp = Irp;
-
+
/* Setup the stack location */
IoStackLocation = IoGetNextIrpStackLocation(Irp);
IoStackLocation->Parameters.Others.Argument1 = DeviceExtension;
@@ -176,7 +176,7 @@
ExInitializeWorkItem(&BatteryData->WorkItem,
(PVOID)CompBattMonitorIrpCompleteWorker,
BatteryData);
-
+
/* Setup the IRP work entry */
CompBattMonitorIrpComplete(BatteryData->DeviceObject, Irp, 0);
Status = STATUS_SUCCESS;
@@ -193,10 +193,10 @@
else if (CompBattDebug & 8)
{
/* Fail */
- DbgPrint("CompBattAddNewBattery: Failed to get device Object. status
= %lx\n",
+ DbgPrint("CompBattAddNewBattery: Failed to get device Object. status
= %lx\n",
Status);
}
-
+
/* Free the battery data */
ExFreePool(BatteryData);
}
@@ -229,7 +229,7 @@
/* Dereference and free it */
ObDereferenceObject(BatteryData->DeviceObject);
ExFreePool(BatteryData);
-
+
/* Notify class driver */
DeviceExtension->Flags = 0;
BatteryClassStatusNotify(DeviceExtension->ClassData);
@@ -248,7 +248,7 @@
PWCHAR LinkList;
UNICODE_STRING LinkString;
if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING GetBatteries\n");
-
+
/* Get all battery links */
Status = IoGetDeviceInterfaces(&GUID_DEVICE_BATTERY, NULL, 0, &LinkList);
p = LinkList;
@@ -260,12 +260,12 @@
/* Create the string */
RtlInitUnicodeString(&LinkString, p);
if (!LinkString.Length) break;
-
+
/* Add this battery and move on */
Status = CompBattAddNewBattery(&LinkString, DeviceExtension);
p += (LinkString.Length / sizeof(WCHAR)) + sizeof(UNICODE_NULL);
}
-
+
/* Parsing complete, clean up buffer */
ExFreePool(LinkList);
}
@@ -274,7 +274,7 @@
/* Fail */
DbgPrint("CompBatt: Couldn't get list of batteries\n");
}
-
+
/* Done */
if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING GetBatteries\n");
return Status;
@@ -325,12 +325,12 @@
UNICODE_STRING SymbolicLinkName;
BATTERY_MINIPORT_INFO MiniportInfo;
if (CompBattDebug & 2) DbgPrint("CompBatt: Got an AddDevice - %x\n",
PdoDeviceObject);
-
+
/* Create the device */
RtlInitUnicodeString(&DeviceName, L"\\Device\\CompositeBattery");
Status = IoCreateDevice(DriverObject,
sizeof(COMPBATT_DEVICE_EXTENSION),
- &DeviceName,
+ &DeviceName,
FILE_DEVICE_BATTERY,
FILE_DEVICE_SECURE_OPEN,
FALSE,
@@ -340,11 +340,11 @@
/* Setup symbolic link for Win32 access */
RtlInitUnicodeString(&SymbolicLinkName,
L"\\DosDevices\\CompositeBattery");
IoCreateSymbolicLink(&SymbolicLinkName, &DeviceName);
-
+
/* Initialize the device extension */
DeviceExtension = DeviceObject->DeviceExtension;
- RtlZeroMemory(DeviceExtension, 0x1B0u);
-
+ RtlZeroMemory(DeviceExtension, sizeof(COMPBATT_DEVICE_EXTENSION));
+
/* Attach to device stack and set DO pointers */
DeviceExtension->AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject,
PdoDeviceObject);
@@ -355,7 +355,7 @@
if (CompBattDebug & 8)
DbgPrint("CompBattAddDevice: Could not attach to LowerDevice.\n");
IoDeleteDevice(DeviceObject);
- return STATUS_UNSUCCESSFUL;
+ return STATUS_UNSUCCESSFUL;
}
/* Set device object flags */
@@ -367,7 +367,7 @@
InitializeListHead(&DeviceExtension->BatteryList);
DeviceExtension->Flags = 0;
DeviceExtension->NextTag = 1;
-
+
/* Setup the miniport data */
RtlZeroMemory(&MiniportInfo, sizeof(MiniportInfo));
MiniportInfo.MajorVersion = BATTERY_CLASS_MAJOR_VERSION;
@@ -381,7 +381,7 @@
MiniportInfo.SetStatusNotify = (BCLASS_SET_STATUS_NOTIFY)CompBattSetStatusNotify;
MiniportInfo.DisableStatusNotify =
(BCLASS_DISABLE_STATUS_NOTIFY)CompBattDisableStatusNotify;
MiniportInfo.Pdo = NULL;
-
+
/* Register with the class driver */
Status = BatteryClassInitializeDevice(&MiniportInfo,
&DeviceExtension->ClassData);
@@ -413,7 +413,7 @@
switch (IoStackLocation->MinorFunction)
{
case IRP_MN_START_DEVICE:
-
+
/* Device is starting, register for new batteries and pick up current ones
*/
Status = IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange,
0,
@@ -438,32 +438,32 @@
}
break;
case IRP_MN_CANCEL_STOP_DEVICE:
-
+
/* Explicitly say ok */
Status = STATUS_SUCCESS;
break;
-
+
case IRP_MN_CANCEL_REMOVE_DEVICE:
/* Explicitly say ok */
Status = STATUS_SUCCESS;
break;
-
+
case IRP_MN_SURPRISE_REMOVAL:
-
+
/* Explicitly say ok */
Status = STATUS_SUCCESS;
break;
-
+
case IRP_MN_QUERY_PNP_DEVICE_STATE:
-
+
/* Add this in */
Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
Status = STATUS_SUCCESS;
break;
-
+
default:
-
+
/* Not supported */
Status = STATUS_INVALID_DEVICE_REQUEST;
break;
@@ -472,7 +472,7 @@
/* Set IRP status if we have one */
if (Status != STATUS_NOT_SUPPORTED) Irp->IoStatus.Status = Status;
- /* Did someone pick it up? */
+ /* Did someone pick it up? */
if ((NT_SUCCESS(Status)) || (Status == STATUS_NOT_SUPPORTED))
{
/* Still unsupported, try ACPI */
Modified: trunk/reactos/drivers/storage/ide/pciidex/pdo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/ide/pciide…
==============================================================================
--- trunk/reactos/drivers/storage/ide/pciidex/pdo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/storage/ide/pciidex/pdo.c [iso-8859-1] Tue Jan 14 21:21:29 2014
@@ -351,6 +351,63 @@
*pDeviceRelations = DeviceRelations;
return STATUS_SUCCESS;
+}
+
+//GUID_PCIIDE_INTERRUPT_INTERFACE
+//GUID_PCIIDE_REQUEST_PROPER_RESOURCES
+
+DEFINE_GUID(GUID_PCIIDE_SYNC_ACCESS_INTERFACE, 0x681190EB, 0xE4EA, 0x11D0, 0xAB, 0x82,
0x00, 0xA0, 0xC9, 0x06, 0x96, 0x2F);
+DEFINE_GUID(GUID_PCIIDE_XFER_MODE_INTERFACE, 0x681190EC, 0xE4EA, 0x11D0, 0xAB, 0x82,
0x00, 0xA0, 0xC9, 0x06, 0x96, 0x2F);
+
+
+
+NTSTATUS
+PciIdeXPdoPnpQueryInterface(
+ PIRP Irp)
+{
+#if 0
+ PIO_STACK_LOCATION IrpStack = IoGetCurrentIrpStackLocation(Irp);
+ PACPI_INTERFACE_STANDARD AcpiInterface;
+
+ if (IrpStack->Parameters.QueryInterface.Version != 1)
+ {
+ DPRINT1("Invalid version number: %d\n",
+ IrpStack->Parameters.QueryInterface.Version);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ if (IsEqualGUID(IrpStack->Parameters.QueryInterface.InterfaceType,
+ &GUID_PCIIDE_XFER_MODE_INTERFACE))
+ {
+ DPRINT1("GUID_PCIIDE_XFER_MODE_INTERFACE\n");
+
+ if (IrpStack->Parameters.QueryInterface.Size <
sizeof(ACPI_INTERFACE_STANDARD))
+ {
+ DPRINT1("Buffer too small! (%d)\n",
IrpStack->Parameters.QueryInterface.Size);
+ return STATUS_BUFFER_TOO_SMALL;
+ }
+
+ AcpiInterface =
(PACPI_INTERFACE_STANDARD)IrpStack->Parameters.QueryInterface.Interface;
+
+ AcpiInterface->InterfaceReference = AcpiInterfaceReference;
+ AcpiInterface->InterfaceDereference = AcpiInterfaceDereference;
+ AcpiInterface->GpeConnectVector = AcpiInterfaceConnectVector;
+ AcpiInterface->GpeDisconnectVector = AcpiInterfaceDisconnectVector;
+ AcpiInterface->GpeEnableEvent = AcpiInterfaceEnableEvent;
+ AcpiInterface->GpeDisableEvent = AcpiInterfaceDisableEvent;
+ AcpiInterface->GpeClearStatus = AcpiInterfaceClearStatus;
+ AcpiInterface->RegisterForDeviceNotifications =
AcpiInterfaceNotificationsRegister;
+ AcpiInterface->UnregisterForDeviceNotifications =
AcpiInterfaceNotificationsUnregister;
+
+ return STATUS_SUCCESS;
+ }
+ else
+ {
+ DPRINT1("Invalid GUID\n");
+ return STATUS_NOT_SUPPORTED;
+ }
+#endif
+ return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS NTAPI
@@ -519,6 +576,11 @@
}
break;
}
+ case IRP_MN_QUERY_INTERFACE:
+ {
+ Status = PciIdeXPdoPnpQueryInterface(Irp);
+ break;
+ }
default:
{
/* We can't forward request to the lower driver, because