return status;
}
-VOID
+NTSTATUS
FdoAddPhysicalDeviceObject(
IN PXENVIF_FDO Fdo,
IN PXENVIF_PDO Pdo
{
PDEVICE_OBJECT DeviceObject;
PXENVIF_DX Dx;
+ NTSTATUS status;
DeviceObject = PdoGetDeviceObject(Pdo);
Dx = (PXENVIF_DX)DeviceObject->DeviceExtension;
ASSERT3U(Dx->Type, ==, PHYSICAL_DEVICE_OBJECT);
+ if (__FdoGetDevicePowerState(Fdo) == PowerDeviceD3)
+ goto done;
+
+ status = PdoResume(Pdo);
+ if (!NT_SUCCESS(status))
+ goto fail1;
+
+done:
InsertTailList(&Fdo->Dx->ListEntry, &Dx->ListEntry);
ASSERT3U(Fdo->References, !=, 0);
Fdo->References++;
- if (__FdoGetDevicePowerState(Fdo) == PowerDeviceD0)
- PdoResume(Pdo);
+ return STATUS_SUCCESS;
+
+fail1:
+ Error("fail1 (%08x)\n", status);
+
+ return status;
}
VOID
Dx = (PXENVIF_DX)DeviceObject->DeviceExtension;
ASSERT3U(Dx->Type, ==, PHYSICAL_DEVICE_OBJECT);
- if (__FdoGetDevicePowerState(Fdo) == PowerDeviceD0)
- PdoSuspend(Pdo);
+ if (__FdoGetDevicePowerState(Fdo) == PowerDeviceD3)
+ goto done;
+ PdoSuspend(Pdo);
+
+done:
RemoveEntryList(&Dx->ListEntry);
ASSERT3U(Fdo->References, !=, 0);
--Fdo->References;
ASSERT3U(Dx->Type, ==, PHYSICAL_DEVICE_OBJECT);
- PdoResume(Pdo);
+ status = PdoResume(Pdo);
+ ASSERT(NT_SUCCESS(status));
}
__FdoReleaseMutex(Fdo);
if (!NT_SUCCESS(status))
goto fail13;
+ Dx->Fdo = Fdo;
+
InitializeMutex(&Fdo->Mutex);
InitializeListHead(&Dx->ListEntry);
Fdo->References = 1;
FunctionDeviceObject,
__FdoGetName(Fdo));
- Dx->Fdo = Fdo;
FunctionDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
-
return STATUS_SUCCESS;
fail13:
FunctionDeviceObject,
__FdoGetName(Fdo));
- Dx->Fdo = NULL;
-
RtlZeroMemory(&Fdo->Mutex, sizeof (MUTEX));
+ Dx->Fdo = NULL;
+
RtlZeroMemory(&Fdo->GnttabInterface,
sizeof (XENBUS_GNTTAB_INTERFACE));
return status;
}
-VOID
+NTSTATUS
PdoResume(
- IN PXENVIF_PDO Pdo
+ IN PXENVIF_PDO Pdo
)
{
- Trace("====>\n");
-
- FrontendResume(__PdoGetFrontend(Pdo));
-
- Trace("<====\n");
+ return FrontendResume(__PdoGetFrontend(Pdo));
}
VOID
IN PXENVIF_PDO Pdo
)
{
- Trace("====>\n");
-
FrontendSuspend(__PdoGetFrontend(Pdo));
-
- Trace("<====\n");
}
NTSTATUS
FdoGetSuspendInterface(Fdo,&Pdo->SuspendInterface);
+ Dx->Pdo = Pdo;
+
+ KeInitializeSpinLock(&Pdo->EjectLock);
+
+ status = FdoAddPhysicalDeviceObject(Fdo, Pdo);
+ if (!NT_SUCCESS(status))
+ goto fail11;
+
for (Index = 0; Index < Pdo->Count; Index++) {
Info("%p (%s %08X)\n",
PhysicalDeviceObject,
Pdo->Revision[Index]);
}
- Dx->Pdo = Pdo;
PhysicalDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
+ return STATUS_SUCCESS;
- KeInitializeSpinLock(&Pdo->EjectLock);
+fail11:
+ Error("fail11\n");
- FdoAddPhysicalDeviceObject(Fdo, Pdo);
+ (VOID) __PdoClearEjectRequested(Pdo);
+ RtlZeroMemory(&Pdo->EjectLock, sizeof (KSPIN_LOCK));
- return STATUS_SUCCESS;
+ Dx->Pdo = NULL;
+
+ RtlZeroMemory(&Pdo->SuspendInterface,
+ sizeof (XENBUS_SUSPEND_INTERFACE));
+
+ FrontendTeardown(__PdoGetFrontend(Pdo));
+ Pdo->Frontend = NULL;
fail10:
Error("fail10\n");
FdoRemovePhysicalDeviceObject(Fdo, Pdo);
+ (VOID) __PdoClearEjectRequested(Pdo);
+ RtlZeroMemory(&Pdo->EjectLock, sizeof (KSPIN_LOCK));
+
Dx->Pdo = NULL;
RtlZeroMemory(&Pdo->SuspendInterface,
sizeof (XENBUS_SUSPEND_INTERFACE));
- VifTeardown(Pdo->VifContext);
- Pdo->VifContext = NULL;
-
FrontendTeardown(__PdoGetFrontend(Pdo));
Pdo->Frontend = NULL;
+ VifTeardown(Pdo->VifContext);
+ Pdo->VifContext = NULL;
+
BusTeardown(&Pdo->BusInterface);
for (Index = 0; Index < Pdo->Count; Index++)